imagedownsampling class

class csi.imagedownsampling(name, image, faults=None, verbose=True)

A class to downsample images

Args:
  • name : Name of the downsampler.

  • image : InSAR or opticorr data set to be downsampled.

Kwargs:
  • faults : List of faults.

  • verbose : Talk to me

Returns:
  • None

blockSize(block)

Returns block size. R.Grandin, April 2015

Args:
  • block : Block instance of the imagedownsampling class.

Returns:
  • None

buildDownsampledCd(mu, lam, function='exp')

Builds the covariance matrix by weihgting following the downsampling scheme

Args:
  • mu : Autocovariance

  • lam : Characteristic distance

Kwargs:
  • function : ‘exp’ (\(C = \mu^2 e^{\frac{-d}{\lambda}}\)) or ‘gauss’ (\(C = \mu^2 e^{\frac{-d^2}{2\lambda^2}}\))

Returns:
  • None

computeGradientCurvature(smooth=None)

Computes the gradient for all the blocks.

Kwargs:
  • smooth : Smoothes the Gradient and the Curvature using a Gaussian filter. {smooth} is the kernel size (in km) of the filter.

Returns:
  • None

computeResolution(slipdirection, damping, vertical=False)

Computes the resolution matrix in the data space.

Args:
  • slipdirection : Directions to include when computing the resolution operator.

  • damping : Damping coefficient (damping is made through an identity matrix).

Kwargs:
  • vertical : Use vertical GFs?

Returns:
  • None

cutblockinfour(block)

From a block, returns 4 equal blocks.

Args:
  • block : block as defined in initialstate.

Returns:
  • 4 lists of block corners

cutblockinthree(block)

Used to create a smoother downsampled grid. From a single block, returns three blocks. Not used for now. T.L. Shreve, January 2018

Args:
  • block : block as defined in initialstate.

Returns:
  • 3 lists of block corners

dataBased(threshold, plot=False, verboseLevel='minimum', quantity='curvature', smooth=None, itmax=100)

Iteratively downsamples the dataset until value compute inside each block is lower than the threshold. Threshold is based on the gradient or curvature of the phase field inside the block. The algorithm is based on the varres downsampler. Please check at http://earthdef.caltech.edu

Args:
  • threshold : Gradient threshold

Kwargs:
  • plot : True/False

  • verboseLevel : Talk to me

  • quantity : curvature or gradient

  • smooth : Smooth the {quantity} spatial with a filter of kernel size of {smooth} km

  • itmax : Maximum number of iterations

Returns:
  • None

distToFault(block)

Returns distance from block to fault. The distance is here defined as the minimum distance from any of the four block corners to the fault. (R.Grandin, April 2015)

Args:
  • block : Block instance of the imagedownsampling class.

Returns:
  • None

distanceBased(chardist=15, expodist=1, plot=False, norm=None)

Downsamples the dataset depending on the distance from the fault R.Grandin, April 2015

Kwargs:
  • chardist : Characteristic distance of downsampling.

  • expodist : Exponent of the distance-based downsampling criterion.

  • plot : True/False

  • Norm : colorlimits for plotting

Returns:
  • None

downsample(plot=False, norm=None)

From the saved list of blocks, computes the downsampled data set and the informations that come along.

Kwargs:
  • plot : True/False

  • Norm : colorlimits for plotting

Returns:
  • None

downsampleFromRspFile(prefix, tolerance=0.5, plot=False)

From the downsampling scheme saved in a .rsp file, downsamples the image.

Args:
  • prefix : Prefix of the rsp file.

Kwargs:
  • tolerance : Minimum surface covered in a patch to be kept.

  • plot : Plot the downsampled data (True/False)

Returns:
  • None

downsampleFromSampler(sampler, plot=False)

From the downsampling scheme in a previous sampler, downsamples the image.

Args:
  • sampler : Sampler which has a blocks instance.

Kwargs:
  • plot : Plot the downsampled data (True/False)

Returns:
  • None

getblockarea(block)

Returns the total area of a block.

Args:
  • block : Block as defined in initialstate.

Returns:
  • float

getblockcenter(block)

Returns the center of a block.

Args:
  • block : Block as defined in initialstate.

Returns:
  • None

initialstate(startingsize, minimumsize, tolerance=0.5, plot=False)

Does the first cut onto the data.

Args:
  • startingsize : Size of the first regular downsampling (it’ll be the effective maximum size of windows)

  • minimumsize : Minimum Size of the blocks.

Kwargs:
  • tolerance : Between 0 and 1. If 1, all the pixels must have a value so that the box is kept. If 0, no pixels are needed… Default is 0.5

  • plot : True/False

Returns:
  • None

plotDownsampled(norm=None, show=True)

Plots the downsampling as it is at this step.

Kwargs:
  • figure : Figure ID.

  • ref : utm or lonlat

  • Norm : [colormin, colormax]

  • data2plot : used if datatype is opticorr: can be north or east.

  • savefig : True/False

  • show : display True/False

Returns:
  • None

readDownsamplingScheme(prefix)

Reads a downsampling scheme from a rsp file and set it as self.blocks

Args:
  • prefix : Prefix of a .rsp file written by writeDownsampled2File.

Returns:
  • None

reject_pixels_fault(distance, fault)

Removes pixels that are too close to the fault in the downsampled image.

Args:
  • distance : Distance between pixels and fault (scalar)

  • fault : fault object

Returns:
  • None

resolutionBased(threshold, damping, slipdirection='s', plot=False, verboseLevel='minimum', vertical=False)

Iteratively downsamples the dataset until value compute inside each block is lower than the threshold.

Args:
  • threshold : Threshold.

  • damping : Damping coefficient (damping is made through an identity matrix).

Kwargs:
  • slipdirection : Which direction to accout for to build the slip Green’s functions (s, d or t)

  • plot : False/True

  • verboseLevel : talk to me

  • vertical : Use vertical green’s functions.

Returns:
  • None

setBlocks(blocks)

Takes a list of blocks and set it in self.

Args:
  • blocks : List of blocks (xy coordinates)

Returns:
  • None

setDownsamplingScheme(sampler)

From an imagedownsampling object, sets the downsampling scheme.

Args:
  • sampler : imagedownsampling instance

Returns:
  • None

trashblock(j)

Deletes one block.

Args:
  • j : index of a block

Returns:
  • None

trashblocks(jj)

Deletes the blocks corresponding to indexes in the list jj.

Args:
  • jj : index of a block

Returns:
  • None

writeDownsampled2File(prefix, rsp=False)

Writes the downsampled image data to a file. The file will be called prefix.txt. If rsp is True, then it writes a file called prefix.rsp containing the boxes of the downsampling. If prefix has white spaces, those are replaced by “_”.

Args:
  • prefix : Prefix of the output file

Kwargs:
  • rsp : Write the rsp file?

Returns:
  • None