gps class

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

A class that handles a network of gps displacements

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)

addstation(station, lon, lat, vel, err, synth=None, los=None)

Add a station to a network.

Args:
  • station : name of the station

  • lon : Longitude

  • lat : Latitude

  • vel : velocity (3 numbers)

  • err : uncertainty (3 numbers)

Kwargs:
  • synth : Synthetics (3 numbers)

  • los : Line-of-sight projection (1 number)

Returns:
  • None

buildCd(direction='en')

Builds a diagonal data covariance matrix using the formal uncertainties in the GPS data.

Kwargs:
  • direction : Direction to take into account. Can be any combination of e, n and u.

Returns:
  • None

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

Takes the slip model in each of the faults and builds the synthetic displacement using the Green’s functions.

Args:
  • faults : list of faults to include.

Kwargs:
  • direction : list of directions to use. Can be any combination of ‘s’, ‘d’ and ‘t’.

  • vertical : True/False

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

  • custom : if some custom green’s function was used, include it.

Returns:
  • None

combineNetworks(gpsdata, newNetworkName='Combined Network', mergeType=None)

Combine networks into a new network.

Args:
  • gpsdata : List of gps instances.

Kwargs:
  • newNetworkName : Name of the returned network

  • mergeTypeStyle of merging

    None: duplicates stations sum: if two identical stations, sum the displacements

Returns:
  • None

compute2Dstrain(fault, write2file=False, verbose=False)

Computes the 2D strain tensor stored in the fault given as an argument.

Args:
  • fault : Instance of a fault class

Kwargs:
  • write2file : Write to a file

  • verbose : talk to me

Returns:
  • None

computeBestHelmert(components=2, data='data')

Fits a full Helmert transform to the network

Kwargs:
  • components : Take the 2 horizontal (default) or 3 enu

  • data : Can be ‘data’, ‘synth’, ‘res’, or ‘transofmration’

Returns:
  • None

computeCustom(fault)

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

Args:
  • fault : A fault instance.

computeHelmertTransform(fault, verbose=False)

Removes the Helmert Transform stored in the fault given as argument.

Args:
  • fault : Instance of a fault class

Kwargs:
  • verbose: talk to me

Returns:
  • None

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

Computes the transformation that is stored with a particular fault. Stores it in transformation.

Args:
  • fault : An instance of a fault class

Kwargs:
  • verbose : talk to me

  • custom : Do we have custom green’s functions

Returns:
  • None

compute_rotation(elon, elat, omega)

Removes a rotation from the lon, lat and velocity of a rotation pole.

Args:
  • elon : Longitude of the rotation pole

  • elat : Latitude of the rotation pole

  • omega : Amplitude of the rotation (in rad/yr).

Returns:
  • None

createNetwork(lonc, latc, expand, nstation, prefix='S')

Builds a GPS network with randomly dropped stations within the box. Box is specified by the center (lonc, latc) and its half-size in degrees (expand). {nstation} gives the number of stations randomly chosen.

Args:
  • lonc : Longitude of the center of the box

  • latc : Latitude of the center of the box

  • expand : Half-size in degrees of the box

  • nstation : Number of stations in the box

  • prefix : Station name prefix (number of the station is added)

deletestation(station)

Removes a station from the network

Args:
  • station : Name of the station

Returns:
  • None

distance2fault(faults)

Computes the distance between the GPS stations and a list of faults.

Args:
  • faults : list of faults

Return:
  • d : distance

extractTimeSeriesOffsets(date1, date2, destination='data')

Puts the offset from the time series between date1 and date2 into an instance of self.

Args:
  • date1 : datetime object.

  • date2 : datetime object.

Kwargs:
  • destination : if ‘data’, results are in vel_enu, if ‘synth’, results are in synth

get2DstrainEst(strain=True, rotation=True, translation=True, computeNormFact=True)

Returns the matrix to estimate the full 2d strain tensor. Positive is clockwise for the rotation. Only works with 2D.

When building the estimator:
  • First column is translation along the x-axis

  • Second column is translation along the y-axis

  • Third column is the Epsilon_xx component

  • Fourth column is the Epsilon_xy component

  • Fifth column is the Epsilon_yy component

  • Sixth column is the Rotation term

Kwargs:
  • strain: True/False

  • rotation: True/False

  • translation: True/False

  • computeNorFact: Recompute normalizatin factor.

Returns:
  • 2D array

getHelmertMatrix(components=2, meanbase=None, center=None)

Returns a Helmert matrix for a gps data set.

Kwargs:
  • components: How many components (can be 2 or 3)

  • meanbase: float for baseline length normalization

  • center: tuple of float for the center o the network

Returns:
  • 2d array

getMisfit()

Computes the summed misfit of the residuals

Returns:

getNetworkAtDate(date, verbose=True)

Returns a GPS object which displacements are the values at the desired date.

Args:
  • date : datetime.datetime instance

Return:
  • gps : a GPS instance

getNumberOfTransformParameters(transformation)

Returns the number of transform parameters for the given transformation. Strain is only computed as an aerial strain (2D). If verticals are included, it just estimates a vertical translation for the network.

Args:
  • transformation : String. Can be ‘strain’, ‘full’, ‘strainnorotation’, ‘strainnotranslation’, ‘strainonly’

Returns:
  • Integer

getRMS(vertical=False)

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

Returns:
  • dataRMS, synthRMS: 2 floats

getSubNetwork(name, stations)

Given a list of station names, returns the corresponding gps object.

Args:
  • name : Name of the returned gps object

  • stations : List of station names.

Returns:
  • gps : Instance of the gps class

getTransformEstimator(transformation, computeNormFact=True)

Returns the estimator for the transform.

Args:
  • transformation : String. Can be ‘strain’, ‘full’, ‘strainnorotation’, ‘strainnotranslation’, ‘strainonly’, ‘translation’ or ‘translationrotation’

Kwargs:
  • computeNormFact: compute and store the normalizing factor

Returns:
  • 2d array

getVariance()

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

Returns:
  • dataVariance, synthVariance: 2 floats

geterr(station)

Gets the errors enu for the station.

Args:
  • station : name of the station.

Returns:
  • vector : 3D vector of uncertainties

getprofile(name, loncenter, latcenter, length, azimuth, width, data='data')

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.

Kwargs:
  • data : Do the profile through the ‘data’ or the ‘synth’etics.

Returns:
  • None: Profiles are stored in self.profiles

getstation(station)

Gets informations for a station.

Args:
  • station : name of the station

Returns:
  • lon, lat, vel, err, synth, los

getvelo(station, data='data')

Gets the velocities enu for the station.

Args:
  • station : name of the station.

Kwargs:
  • data : which velocity do you want (‘data’ or ‘synth’)

Returns:
  • vel : 3D vector

importNetwork(gpsdata, iftwo='keep')

Adds stations from gpsdata to the current network. If station is already in here, there is several options:

  • if iftwo == ‘keep’: Keep both measures

  • if iftwo == gpsdata.name: Keep the incomcing measure

  • if iftwo == self.name: Keep the current one

Args:
  • gpsdata : A gps instance

Kwargs:
  • iftwo : same station policy

Returns:
  • None

initializeTimeSeries(start=None, end=None, stationfile=False, sqlfile=None, time=None, interval=1, verbose=False, los=False, factor=1.0)

Initializes a time series for all the stations.

Kwargs:
  • start : Starting date

  • end : Ending date

  • interval : in days (default=1).

  • stationfile : Read the time series from the station file

  • sqlfile : Red the time series from a sqlfile

  • time : time would be taken from this array

  • verbose : talk to me

  • los : Los vector

  • factor : scaling factor

Returns:
  • None

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:
  • distance : float

keep_stations(stations)

Keeps only the stations on the arg list.

Args:
  • stations : list of stations to keep.

Returns:
  • None

lonlat2xy()

Pass the position of the stations into the utm coordinate system.

makeDelaunay(plot=False)

Builds a Delaunay triangulation of the GPS network.

Kwargs:
  • plot : True/False(default).

Returns:
  • None

plot(faults=None, figure=135, name=False, legendscale=10.0, scale=None, legendunit='', figsize=None, plot_los=False, drawCoastlines=True, expand=0.2, show=True, error=True, title=True, colorbar=True, cbaxis=[0.1, 0.2, 0.1, 0.02], cborientation='horizontal', cblabel='', landcolor='lightgrey', seacolor=None, shadedtopo=None, Map=True, Fault=True, zorder=None, vertical=False, verticalsize=[30], verticalnorm=None, box=None, width=0.005, headwidth=3, headlength=5, headaxislength=4.5, minshaft=1, minlength=1, data=['data'], color=['k'], titleyoffset=1.1, alpha=1.0)

Plot the network

Kwargs:
  • faults : list of instances of faults

  • data : list of data to plot (can be ‘data’, ‘synth’, ‘res’ or ‘transformation’)

  • vertical : plot verticals (True/False)

  • verticalsize : size of the dots for vertical plots (list as long as data)

  • color : lits of color specifications as long as data

  • name : plot the name of the stations

  • legendscale : size of the legend (default is 10)

  • scale : scale of the arrows

  • ref : can be ‘utm’ or ‘lonlat’

  • drawCoastlines: True/False

  • expand : Expand the map (in degrees)

  • show : plot to screen

  • figure : number of the figure.

  • faults : List of fault objects to plot the surface trace of a fault object (see verticalfault.py).

  • plot_los : Plot the los projected gps as scatter points

  • box : Lon/lat box [lonmin, lonmax, latmin, latmax]

Returns:
  • None

plotprofile(name, legendscale=10.0, fault=None, data=['parallel', 'normal', 'vertical'], show=True, figsize=None, colorbar=False, cbaxis=[0.1, 0.2, 0.1, 0.02], cborientation='horizontal', cblabel='')

Plot profile.

Args:
  • name : Name of the profile.

Kwargs:
  • legendscale : Length of the legend arrow.

  • fault : Add a fault on the plot

  • data : list of type of data to use

  • show : Show me

Returns:
  • None

project2InSAR(los=None, incidence=None, heading=None)

Projects the GPS data into the InSAR Line-Of-Sight provided.

Args:
  • los : list of three components of the line-of-sight vector.

  • incidence : incidence angle (single float)

  • heading : heading (single float)

Returns:
  • None

readStat(station_file, loc_format='LL')

Read simple station ascii file and populate station attributes

If loc_format=’XY’, then the file should be as

STNAME

X_COORD

Y_COORD

If loc_format=’LL’, then the file should be as

STNAME

LON

LAT

Args:
  • station_file: station filename including station coordinates

Kwargs:
  • loc_format: station file format (default= ‘LL’)

Returns:
  • None

read_from_ICM(velfile, factor=1.0, header=1)

Reading velocities from an ICM (F. Ortega’s format) file. Maybe obsolete now.

Args:
  • velfile : Input file

Kwargs:
  • factor : multiplication factor for velocities

  • header : length of the file header

Returns:
  • None

read_from_en(velfile, factor=1.0, minerr=1.0, header=0, error='std')

Reading velocities from a en file formatted as:

StationName

Lon

Lat

e_vel

n_vel

e_err

n_err

Args:
  • velfile : File containing the velocities.

Kwargs:
  • factor : multiplication factor for velocities

  • minerr : if err=0, then err=minerr.

  • header : length of the file header

  • error : if ‘variance’, then np.sqrt(err) is taken. Default is ‘std’

Returns:
  • None

read_from_enu(velfile, factor=1.0, minerr=1.0, header=0, checkNaNs=True)

Reading velocities from a enu file formatted as

StationName

Lon

Lat

e_vel

n_vel

u_vel

e_err

n_err

u_err

Args:
  • velfile : Input file

Kwargs:
  • factor : multiplication factor for velocities

  • minerr : if err=0, then err=minerr.

  • header : length of the header

  • checkNaNs : If True, kicks out stations with NaNs

Returns:
  • None

read_from_midas(velfile, stationfile, factor=1.0, minerr=1.0, header=0, checkNaNs=True)

Reading velocities from a file produced by the midas tool. Details are available here: http://geodesy.unr.edu/

Args:
  • velfile : Input file

  • stationfile : File of the list of stations

Kwargs:
  • factor : multiplication factor for velocities

  • minerr : if err=0, then err=minerr.

  • header : length of the header

  • checkNaNs : If True, kicks out stations with NaNs

Returns:
  • None

read_from_sopac(velfile, coordfile, factor=1.0, minerr=1.0)

Reading velocities from Sopac file and converting to mm/yr. Format is as sopac was providing it in 2013.

Args:
  • velfile : File containing the velocities.

  • coordfile : File containing the coordinates.

Kwargs:
  • factor : Scaling factor

  • minerr : If err is lower than minerr, err is set to minerr

Returns:
  • None

read_from_unavco(velfile, factor=1.0, minerr=1.0, header=37)

Reading velocities from a unavco file. This follows the unavco format as it was in 2013.

Args:
  • velfile : Input file

Kwargs:
  • factor : multiplication factor for velocities

  • header : length of the file header

  • minerr : If the error is lower than minerr, set it to minerr

Returns:
  • None

reference(station, refSynth=False)

References the velocities to a single station.

Args:
  • station : name of the station or list of station names.

  • refSynth : Apply referencing to synthetics as well (default=False)

Returns:
  • None

reference2network(network, components=2)

Removes a Helmert transform that best references the velocity field from self to that of network.

Args:
  • network : gps instance

  • components: Number of components to use

Returns:
  • None

reject_stations(station)

Reject the stations named in stations.

Args:
  • station : name or list of names of station.

Returns:
  • None

reject_stations_awayfault(dis, faults)

Rejects the pixels that are {dis} km away from the faults

Args:
  • dis : Threshold distance.

  • faults : list of fault objects.

Returns:
  • None

reject_stations_fault(dis, faults)

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

Args:
  • dis : Threshold distance.

  • faults : list of fault objects.

Returns:
  • None

remove2Dstrain(fault)

Computess the 2D strain and removes it.

Args:
  • fault : Instance of a fault class

Returns:
  • None

removeBestHelmert(components=2, data='data')

Fits a Helmert transform to the network and removes it.

Kwargs:
  • components : Take the 2 horizontal (default) or 3 enu

  • data : Can be ‘data’, ‘synth’, ‘res’, or ‘transofmration’

Returns:
  • None

removeHelmertTransform(fault)

Computes the Helmert and removes it.

Args:
  • fault : Instance of a fault class

Returns:
  • None

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

Removes the synthetics from a slip model.

Args:
  • faults : list of faults to include.

Kwargs:
  • direction : list of directions to use. Can be any combination of ‘s’, ‘d’ and ‘t’.

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

  • custom : if some custom green’s function was used, include it.

Returns:
  • None

removeTransformation(fault, custom=False)

Removes the transformation that is stored in a fault.

remove_euler_rotation(eradius=6378137.0, stations=None, verbose=True)

Removes the best fit Euler rotation from the network.

Kwargs:
  • eradius : Radius of the earth (should not change that much :-)).

  • stations : List of stations on which rotation is estimated. If None, uses all the stations.

  • verbose : talk to me

Returns:
  • None

scale(factor)

Scales the gps velocities by a factor.

Args:
  • factor : multiplication factor (float)

Returns:
  • None

scale_errors(scale)

Scales the errors (in-place multiplication)

Args:
  • scale : float

Returns:
  • None

select_stations(minlon, maxlon, minlat, maxlat)

Select the stations 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’. These can be a matrix or None.

Kwargs:
  • vertical : Do we set the vertical GFs? default is True

Returns:
  • None

setStat(sta_name, x, y, loc_format='LL', initVel=False)

Set station names and locations attributes

Args:
  • sta_name: station names

  • x: x coordinate (longitude or UTM)

  • y: y coordinate (latitude or UTM)

Kwargs:
  • loc_format: location format (‘LL’ for lon/lat or ‘XY’ for UTM)

  • initVel: initialize a vel_enu attribute with zeros

Returns:
  • None

setStatFromFile(filename, initVel=False, header=0)

Set station names and locations attributes. File should be formatted as

Station Name

lon

lat

TAGA

POUT

14.5

23.2

Args:
  • filename : name of the station list

Kwargs:
  • initVel : Intialize a vel_enu vector or not

  • header : Length of the file header

Returns:
  • None

setvelo(station, vel, data='data')

Sets the velocity enu for a station.

Args:
  • station : name of the station

  • vel : 3 comp list or np.array

Kwargs:
  • dataCan be ‘data’, ‘synth’ or any

    attribute of the size of vel_enu

Returns:
  • None

simulateTimeSeriesFromCMT(sismo, scale=1.0, verbose=True, elasticstructure='okada', sourceSpacing=0.1)

Takes a seismolocation object with CMT informations and computes the time series from these.

Args:
  • sismo : seismiclocation object (needs to have CMTinfo object and the corresponding faults list of dislocations).

Kwargs:
  • scale : Scales the results (default is 1.).

  • verbose : talk to me

  • elasticstructure : can be okada or edks

  • sourceSpacing : spacing of sources in case edks is chosen

Returns:
  • None

simulateTimeSeriesFromCMTWithRandomPerturbation(sismo, N, xstd=10.0, ystd=10.0, depthstd=10.0, Moperc=30.0, scale=1.0, verbose=True, plot='jhasgc', elasticstructure='okada', relative_location_is_ok=False)

Runs N simulations of time series from CMT. xtsd, ystd, depthstd are the standard deviation of the Gaussian used to perturbe the location The moment will be perturbed by a fraction of the moment (Moperc). if relative_location_is_ok is True, then all the mechanisms are moved by a common translation.

Args:
  • sismo : seismiclocation object

  • N : Number of perturbed models

Kwargs:
  • xstd : std dev in longitude (km)

  • ystd : std dev in latitude (km)

  • depthstd : std dev in depth (km)

  • Moperc : maximum perturbation of the seismic moment (%)

  • scale : Scaling factor

  • verbose : talk to me

  • plot : name of the station to plot

  • elasticstructure : okada or edks

  • relative_location_is_ok : a common perturbation for all mechanisms

Returns:
  • None

write2GMTfile(namefile=None, data='data', outDir='./', vertOrHoriz='horiz')

Writes GPS data to the GMT psvelo format file, converting units from m to cm Args:

  • namefile : Name of the output file.

  • data : data, synth, strain, transformation.

  • vertOrHoriz : write vertical or horizontal data to file (Default horiz)

write2file(namefile=None, data='data', outDir='./')

Write the data to a file. If namefile is None, then the output file will be in the form outDir/self.name.dat

Kwargs:
  • namefile : Name of the output file.

  • data : data, synth, strain, transformation.

  • outDir : Output directory

Returns:
  • None

writeEDKSdata()

This routine prepares the data file as input for EDKS.

writeProfile2File(name, filename, fault=None)

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

Args:
  • name : Name of the profile to write out

  • filename : Name of the output file

Kwargs:
  • fault : Add the location of a fault (uses the fault trace)

Returns:
  • None

writeTimeSeries(verbose=False, outdir='./', steplike=False)

Writes the time series of displacement in text files. Filenames are entirely determined from the name of the station example: STAT.dat, COPO.dat, ISME.dat …

Kwargs:
  • verbose : talk to me

  • outdir : output directory

  • steplike : write 2 dots per day

Returns:
  • None

xy2lonlat()

Convert all stations x, y to lon lat using the utm transform.