opticorr class

class csi.opticorr(name, utmzone=None, ellps='WGS84', verbose=True, lon0=None, lat0=None)

A class that handles optical correlation results

Args:
  • name : Name of the dataset.

Kwargs:
  • utmzone : UTM zone (optional, default=None)

  • lon0 : Longitude of the center of the UTM zone

  • lat0 : Latitude of the center of the UTM zone

  • ellps : ellipsoid (optional, default=’WGS84’)

  • verbose : Speak to me (default=True)

ModelResolutionDownsampling(faults, threshold, damping, startingsize=10.0, minimumsize=0.5, tolerance=0.1, plot=False)

Downsampling algorythm based on Lohman & Simons, 2005, G3.

Args:
  • faults : List of faults, these need to have a buildGFs routine (ex: for RectangularPatches, it will be Okada).

  • threshold : Resolution threshold, if above threshold, keep dividing.

  • damping : Damping parameter. Damping is enforced through the addition of a identity matrix.

Kwargs:
  • startingsize : Starting size of the downsampling boxes.

  • minimumsize : Minimum size for the downsampling blocks

  • tolerance : tolerance in the block size in km

  • plot : show me

Returns:
  • None

buildsynth(faults, direction='sd', poly=None, vertical=False, custom=False, computeNormFact=True)

Computes the synthetic data using the faults and the associated slip distributions.

Args:
  • faults : List of faults.

Kwargs:
  • direction : Direction of slip to use.

  • vertical : use verticals

  • include_poly : if a polynomial function has been estimated, include it.

  • custom : if True, uses the fault.custom and fault.G[data.name][‘custom’] to correct

  • computeNormFact : if False, uses TransformNormalizingFactor set with self.setTransformNormalizingFactor

Returns:
  • None

computeCustom(fault)

Computes the displacements associated with the custom green’s functions.

Args:
  • fault : Fault object with custom green’s functions

Returns:
  • None. Stores the prediction in self.custompred

computePoly(fault, computeNormFact=True)

Computes the orbital bias estimated in fault

Args:
  • fault : Fault object that has a polysol structure.

Kwargs:
  • computeNormFact: if True, recompute the normalization.

Returns:
  • None

computeTransformNormalizingFactor()

Compute orbit normalizing factors and store them in insar object.

Returns:
  • None

getMisfit()

Computes the Sum of the data and if synthetics are computed, the RMS of the residuals

Returns:
  • 2 floats

getPolyEstimator(ptype, computeNormFact=True)

Returns the Estimator for the polynomial form to estimate in the optical correlation data.

Args:
  • ptype : Style of polynomial

ptype

what it means

1

apply a constant offset to the data (1 parameter)

3

apply offset and linear function of x and y (3 parameters)

4

apply offset, linear function and cross term (4 parameters)

Watch out: If vertical is True, you should only estimate polynomials for the horizontals.

Kwargs:
  • computeNormFact : bool. If False, uses parameters in self.TransformNormalizingFactor

Returns:
  • 2d array

getRMS()

Computes the RMS of the data and if synthetics are computed, the RMS of the residuals

getTransformEstimator(trans, computeNormFact=True)

Returns the Estimator for the transformation to estimate in the InSAR data.

Args:
  • transTransformation type
    • 1: constant offset to the data

    • 3: constant and linear function of x and y

    • 4: constant, linear term and cross term.

    • ‘strain’: estimates an aerial strain tensor

Kwargs:
  • computeNormFact : Recompute the normalization factor

Returns:
  • None

getVariance()

Computes the Variance of the data and if synthetics are computed, the RMS of the residuals

Returns:
  • 2 floats

getprofile(name, loncenter, latcenter, length, azimuth, width)

Project the GPS velocities onto a profile. Works on the lat/lon coordinates system.

Args:
  • name : Name of the profile.

  • loncenter : Profile origin along longitude.

  • latcenter : Profile origin along latitude.

  • length : Length of profile.

  • azimuth : Azimuth in degrees.

  • width : Width of the profile.

Returns:
  • None. Stores profile in self.profiles

intersectProfileFault(name, fault)

Gets the distance between the fault/profile intersection and the profile center.

Args:
  • name : name of the profile.

  • fault : fault object from verticalfault.

Returns:
  • Float

plot(faults=None, figure=None, gps=None, decim=False, norm=None, Map=True, Fault=True, data='data', show=True, drawCoastlines=True, expand=0.2, colorbar=True, cbaxis=[0.1, 0.2, 0.1, 0.02], cborientation='horizontal', cblabel='')

Plot the data set, together with a fault, if asked.

Kwargs:
  • faults : list of fault object.

  • figure : number of the figure.

  • gps : superpose a GPS dataset.

  • decim : plot the data following the decimation process of varres.

  • data : plot either ‘dataEast’, ‘dataNorth’, ‘synthNorth’, ‘synthEast’, ‘resEast’, ‘resNorth’, ‘data’, ‘synth’ or ‘res’

  • norm : tuple of float for the min and max of the colorbar

  • show : Show me

  • drawCoastlines : True or False

  • expand : How to expand the map around the data in degrees.

Returns:
  • None

plotprofile(name, legendscale=5.0, fault=None)

Plot profile.

Args:
  • name : Name of the profile.

Kwargs:
  • legendscale: Length of the legend arrow.

  • fault : instance of a fault class

Returns:
  • None

read_from_binary(east, north, lon, lat, err_east=None, err_north=None, factor=1.0, step=0.0, dtype=<class 'numpy.float32'>, remove_nan=True)

Read from a set of binary files or from a set of arrays.

Args:
  • east : array or filename of the east displacement

  • north : array or filename of the north displacement

  • lon : array or filename of the longitude

  • lat : array or filename of the latitude

Kwargs:
  • err_east : uncertainties on the east displacement (file or array)

  • err_north : uncertainties on the north displacememt (file or array)

  • factor : multiplication factor

  • step : offset

  • dtype : type of binary file

  • remove_nan: Remove nans or not

Returns:
  • None

read_from_envi(filename, component='EW', remove_nan=True)

Reads displacement map from an ENVI file.

Args:
  • filename : Name of the input file

Kwargs:
  • component : ‘EW’ or ‘NS’

  • remove_nan: Remove Nans or not

Returns:
  • None

read_from_grd(filename, factor=1.0, step=0.0, flip=False, keepnans=False, variableName='z')

Reads velocity map from a grd file.

Args:
  • filename : Name of the input file. As we are reading two files, the files are filename_east.grd and filename_north.grd

Kwargs:
  • factor : scale by a factor

  • step : add a value.

  • flip : Flip image upside down (some netcdf files require this)

  • keepnans : Keeps NaNs or not

  • variableName : Name of the variable in the netcdf file

Returns:
  • None

read_from_varres(filename, factor=1.0, step=0.0, header=2, cov=False)

Read the Optical Corr east-north offsets from the VarRes output. This is what comes from the decimation process in imagedownsampling

Args:
  • filename : Name of the input file. Two files are opened filename.txt and filename.rsp.

Kwargs:
  • factor : Factor to multiply the east-north offsets.

  • step : Add a value to the velocity.

  • header : Size of the header.

  • cov : Read an additional covariance file (binary np.float32, Nd*Nd elements).

Returns:
  • None

read_from_xyz(filename, factor=1.0, step=0.0, header=0)

Reads the maps from a xyz file formatted as

lon

lat

east

north

east_err

north_err

Args:
  • filename : name of the input file.

Kwargs:
  • factor : scale by a factor.

  • step : add a value.

  • header : length of the file header

Returns:
  • None

read_with_reader(readerFunc, filePrefix, factor=1.0, cov=False)

Read data from a .txt file using a user provided reading function. Assume the user knows what they are doing and are returning the correct values.

Args:
  • readerFunc : A method that knows how to read a file and returns lon, lat, east, north, east_err and north_err (1d arrays)

Kwargs:
  • filePrefix : filename before .txt

  • factor : scaling factor

  • cov : read a covariance from a binary file

reject_pixel(u)

Reject pixels.

Args:
  • u : Index of the pixel to reject.

Returns:
  • None

reject_pixels_fault(dis, faults)

Rejects the pixels that are dis km close to the fault.

Args:
  • dis : Threshold distance. If the distance is negative, rejects the pixels that are more than -1.0*distance away from the fault.

  • faults : list of fault objects.

Returns:
  • None

removePoly(fault, verbose=False, custom=False, computeNormFact=True)

Removes a polynomial from the parameters that are in a fault.

Args:
  • fault : instance of fault that has a polysol structure

Kwargs:
  • verbose : Talk to me

  • custom : Is there custom GFs?

  • computeNormFact : If True, recomputes Normalization factor

Returns:
  • None. Directly corrects the data

removeRamp(order=3, maskPoly=None)

Note: No Idea who started implementing this, but it is clearly not finished…

Pre-remove a ramp from the data that fall outside of mask. If no mask is provided, we use all the points to fit a mask.

Kwargs:
  • order : Polynomial order

  • maskPoly : path to make a mask

Returns:
  • None

removeSynth(faults, direction='sd', poly=None, vertical=False, custom=False, computeNormFact=True)

Removes the synthetics using the faults and the slip distributions that are in there.

Args:
  • faults : List of faults.

Kwargs:
  • direction : Direction of slip to use.

  • vertical : use verticals

  • include_poly : if a polynomial function has been estimated, include it.

  • custom : if True, uses the fault.custom and fault.G[data.name][‘custom’] to correct

  • computeNormFact : if False, uses TransformNormalizingFactor set with self.setTransformNormalizingFactor

removeTransformation(fault, verbose=False, custom=False)

Wrapper of removePoly to ensure consistency between data sets.

Args:
  • fault : a fault instance

Kwargs:
  • verbose : talk to us

  • custom : Remove custom GFs

Returns:
  • None

select_pixels(minlon, maxlon, minlat, maxlat)

Select the pixels in a box defined by min and max, lat and lon.

Args:
  • minlon : Minimum longitude.

  • maxlon : Maximum longitude.

  • minlat : Minimum latitude.

  • maxlat : Maximum latitude.

Returns:
  • None

setGFsInFault(fault, G, vertical=True)

From a dictionary of Green’s functions, sets these correctly into the fault object fault for future computation.

Args:
  • fault : Instance of Fault

  • G : Dictionary with 3 entries ‘strikeslip’, ‘dipslip’ and ‘tensile’

Kwargs:
  • vertical : Do we use vertical predictions? Default is True

Returns:
  • None

setTransformNormalizingFactor(x0, y0, normX, normY)

Set orbit normalizing factors in insar object.

Args:
  • x0 : Normalization reference x-axis

  • y0 : Normalization reference y-axis

  • normX : Normalizing length along x-axis

  • normY : Normalizing length along y-axis

Returns:
  • None

splitFromShapefile(shapefile, remove_nan=True)

Uses the paths defined in a Shapefile to select and return particular domains of self.

Args:
  • shapefile : Input file (shapefile format).

Kwargs:
  • remove_nan: Remove nans

Returns:
  • None

write2binary(prefix, dtype=<class 'float'>)

Writes the records in a binary file.

Output filenames:
  • {prefix}_north.dat : North displacement

  • {prefix}_east.dat : East displacement

  • {prefix}_lon.dat : Longitude

  • {prefix}_lat.dat : Latitude

Args:
  • prefix : prefix of the output file

Kwargs:
  • dtype : data type in the binary file

Returns:
  • None

write2grd(fname, oversample=1, data='data', interp=100, cmd='surface', useGMT=False)

Uses surface to write the output to a grd file.

Args:
  • fname : Filename

Kwargs:
  • oversample: Oversampling factor.

  • data : can be ‘data’, ‘synth’ or ‘res’.

  • interp : Number of points along lon and lat (can be a list).

  • cmd : command used for the conversion( i.e., surface or xyz2gmt)

  • useGMT : use GMT or scipy

Returns:
  • None

writeDecim2file(filename, data='dataNorth', outDir='./')

Writes the decimation scheme to a file plottable by GMT psxy command.

Args:
  • filename : Name of the output file (ascii file)

Kwargs:
  • data : Add the value with a -Z option for each rectangle. Can be ‘dataNorth’, ‘dataEast’, synthNorth, synthEast, data or synth

  • outDir : Output directory

Returns:
  • None

writeEDKSdata()

* Obsolete *

writeProfile2File(name, filename, fault=None)

Writes the profile named ‘name’ to the ascii file filename.

Args:
  • name : name of the profile

  • filename : output file name

Kwargs:
  • fault : instance of a fault class

Returns:
  • None