seismiclocations class

class csi.seismiclocations(name, utmzone=None, ellps='WGS84', lon0=None, lat0=None)

A class that handles a simple earthquake catalog

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’)

BuildHistogramsAlongFaultTrace(fault, filename, normed=True, width=10.0, bins=50, plot=False, planemode='verticalfault', Range=(-5.0, 5.0), reference=None)

Builds a histogram of the earthquake distribution along the fault trace.

Args:
  • fault : instance of fault with {xf} and {yf} attributes

  • filename: Name of output file

Kwargs:
  • normed: Norm the histogram

  • width: Width of the averaging cell (distance along strike)

  • bins : number of bins

  • plot : True/False

  • planemode: ‘verticalfault’ or ‘bestfit’. verticalfault will assume the fault is vertical. bestfit will fit a dip angle within the cloud of events (can produce weird results sometimes).

  • Range : Range for histogram computation

  • reference: Tuple of float to set the reference of the domain

Returns:
  • None. Everything is stored in output files

Cmt2Dislocation(size=1, mu=30000000000.0, choseplane='nochoice', moment_from_tensor=False, verbose=True)

Builds a list of single square patch faults from the cmt solutions. If no condition is given, it returns the first value.

Kwargs:
  • size : Size of one side of the fault patch (km) of (width, length) in km

  • mu : Shear modulus (Pa).

  • choseplane : Choice of the focal plane to use (can be ‘smallestdip’, ‘highestdip’, ‘nochoice’)

  • moment_from_tensor: Computes the scalar moment from the cmt.

  • verbose : talk to me

Returns:
  • None. Attribute {faults} is a list of faults with a single patch corresponding to the chosen fault plane

MapHistogram(binwidth=1.0, plot=False, normed=True)

Builds a 2D histogram of the earthquakes locations.

Kwargs:
  • binwidth : width of the bins used for histogram.

  • plot : True/False

  • normed : Normed the histgram

Returns:
  • None. Histogram is stored in the {histogram} attribute

Mo2mag()

Compute the magnitude from the moment.

Returns:
  • None. Result is in the {mag} attribute

ProjectOnFaultTrace(fault, discretized=True, filename=None)

Projects the location of the earthquake along the fault trace. This routine is not a 3D one, it just deals with the surface trace of the fault.

Args:
  • fault: Fault object that has a surface trace ({xf} and {yf} attributes)

Kwargs:
  • discretized: If True, then it uses the discretized fault, not the trace. Never tested with False.

  • filename: Store in a text file

Returns:
  • None. Everything is stored in the dictionary {Projected}

computeGR(plot=False, bins=20)

Plots the Gutemberg-Richter distribution.

Kwargs:
  • plot : make a figure

  • bins : how many bins to use

Returns:
  • None

coord2prof(xc, yc, length, azimuth, width)

Routine returning the profile

Args:
  • xc : X pos of center

  • yc : Y pos of center

  • length : length of the profile.

  • azimuth : azimuth of the profile.

  • width : width of the profile.

Returns:
  • dis : Distance from the center

  • mag : Magnitude

  • depth : Depth

  • norm : distance perpendicular to profile

  • boxll : lon lat coordinates of the profile box used

  • xe1, ye1 : coordinates (UTM) of the profile endpoint

  • xe2, ye2 : coordinates (UTM) of the profile endpoint

delete2Close2Trace(faults, distance=1.0)

Deletes the earthquakes that are too close from the fault trace.

Args:
  • faults : list of instances of faults. These need to have {xf} and {yf} attributes

Kwargs:
  • distance : threshold distance.

Returns:
  • None. Direclty modifies the list of earthquakes

distance2fault(faults, distance=5.0)

Selects the earthquakes that are located less than distance away from the fault plane.

Args:
  • faults : List of faults

Kwargs:
  • distance : Threshold

Returns:
  • None. Selected events are kept. Others are deleted.

distance2trace(faults, distance=5.0)

Selects the earthquakes that are located less than ‘distance’ km away from a given surface fault trace.

Args:
  • faults : list of instances of faults. These need to have {xf} and {yf} attributes

Kwargs:
  • distance : threshold distance.

Returns:
  • None. Selected earthquakes are kept. Others are deleted.

fitBvalue(b=None)

Fits a B-value to a Gutemberg-Righter distribution. option: if b is provided, then the fit is forced to have a slope b.

Note:

This method has not been implemented

getClosestFaultPatch(fault)

Returns a list of index for all the earthquakes containing the index of the closest fault patch.

Args:
  • fault : an instance of a fault class

Returns:
  • ipatch, a list of the index of the closest patch for each event

getCmts()

Returns the cmt in one line

Return:
  • List of sextuples

getEarthquakesOnPatches(fault, epsilon=0.01)

Project each earthquake on a fault patch. Should work with any fault patch type.

Args:
  • fault : instance of a fault class

Kwargs:
  • epsilon : float comparison tolerance number

Returns:
  • InPatch, a list of events in each patch

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

Project the seismic locations 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. Profiles are stored in the attribute {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:
  • None

lonlat2xy()

Pass the position into the utm coordinate system.

Returns:
  • None

mag2Mo()

Computes the moment from the magnitude. Result in N.m

Returns:
  • None. Result is in the {Mo} attribute

mergeCatalog(catalog)

Merges another catalog into this one.

Args:
  • catalog: Seismic location object.

Returns:
  • None

momentEvolution(plot=False, outfile=None)

Computes the evolution of the moment with time.

Kwargs:
  • plot : True/False

  • outfile: output file

Returns:
  • None

plot(faults=None, figure=None, norm=None, data='mag', show=True, Map=True, Fault=True, drawCoastlines=True, resolution='auto', expand=0.2, linewidth=0.3, figsize=None, markersize=10, cmap='jet', alpha=1.0, box=None, titleyoffset=1.1, zorder=1, shadedtopo=None, landcolor='lightgrey', seacolor=None, 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 objects.

  • figure : number of the figure.

  • norm : colorbar limits

  • data : ‘mag’, ‘time’, ‘depth’ or an array

  • markersize : Size of the dots is magnitude and markersize is the divider

  • show : bool. Show on screen?

  • drawCoastlines : bool. default is True

  • expand : default expand around the limits covered by the data

  • linewidth : Width of dots edges

  • plotType : ‘decim’, ‘scatter’ or ‘flat’

  • figsize : tuple of figure sizes

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

Returns:
  • None

read_CMTSolutions(infile)

Reads data and moment tensors from an ascii file listing CMT solutions format. Go check the GCMT webpage for format description

Args:
  • infile: Input file.

Returns:
  • None

read_ascii(infile, header=0)

Reads data from an ascii file.

time (isoformat)

lon

lat

depth

magnitude

yyy-mm-ddThh:mm:ss.ss

float

float

float

float

Args:
  • infile : input file

Kwargs:
  • header : length of the header

Returns:
  • None

read_csi(infile, header=0)

Reads data from a file written by csi.seismiclocation.write2file

lon

lat

depth

magnitude

time (isoformat)

float

float

float

float

yyy-mm-ddThh:mm:ss.ss

Args:
  • infile : input file

Kwargs:
  • header : length of the header

Returns:
  • None

read_from_AyitiSeisme_csv(filename)

Read a catalog from the AyitiSeisme CSV files

Args:
  • filename : Input file name

Returns:
  • None

read_from_Hauksson(filename, header=0)

Read the Seismic catalog from the SCSN networks (Template from E. Hauksson, Caltech). File format is as follows

year

month

day

hour

minute

seconds

lat

lon

depth

magnitude

int

int

int

int

int

float

float

float

float

float

Args:
  • filename : Name of the input file.

Kwargs:
  • header : Size of the header.

Returns:
  • None

read_from_NCSN(filename, header=65)

Read the Seismic catalog from the NCSN networks. Magnitude is in a column determined from the header. The rest reads as

year

month

day

hour

minute

lat

lon

depth

int

int

int

int

int

float

float

float

Args:
  • filename : Name of the input file.

Kwargs:
  • header : Size of the header.

Returns:
  • None

read_from_Rietbrock(filename, header=1)

Read the Seismic catalog from the NCSN networks (Template from F. Waldhauser).

id

year

month

day

hour

minute

seconds

degre lat

minute lat

degree lon

minute lon

depth

magnitude

int

int

int

int

int

float

float

float

float

float

float

float

Args:
  • filename : Name of the input file.

Kwargs:
  • header : Size of the header.

Returns:
  • None

read_from_SCSN(filename, header=65)

Read the Seismic catalog from the SCSN networks (Template from F. Waldhauser).

year

month

day

hour

minute

lat

lon

depth

magnitude

int

int

int

int

int

float

float

float

float

Args:
  • filename : Name of the input file.

Kwargs:
  • header : Size of the header.

Returns:
  • None

selectbox(minlon, maxlon, minlat, maxlat, depth=100000.0, mindep=0.0)

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

Args:
  • minlon : Minimum longitude.

  • maxlon : Maximum longitude.

  • minlat : Minimum latitude.

  • maxlat : Maximum latitude.

Kwargs:
  • depth : Maximum depth

  • mindepth : Minimum depth

Returns:
  • None. Direclty kicks out earthquakes that are not in the box

selectmagnitude(minimum, maximum=10)

Selects the earthquakes between two magnitudes.

Args:
  • minimum : Minimum earthquake magnitude wanted.

Kwargs:
  • maximum : Maximum earthquake magnitude wanted.

Returns:
  • None. Directly kicks out earthquakes that are not within the wanted magnitude range

selecttime(start=[2001, 1, 1], end=[2101, 1, 1])

Selects the earthquake in between two dates. Dates can be datetime.datetime or lists.

Args:
  • start : Beginning of the period [yyyy, mm, dd]

  • end : End of the period [yyyy, mm, dd]

Returns:
  • None. Direclty kicks out earthquakes that are not within start-end period

sortInTime()

Sorts the earthquakes in Time

Returns:
  • None. Directly modifies the object

write2file(filename, add_column=None)

Write the earthquakes to a file.

Args:
  • filename : Name of the output file.

Kwargs:
  • add_column : array or list of length equal to the number of events

Returns:
  • None

writeProfile2File(name, filename, fault=None)

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

Args:
  • name : name of the profile you want to write

  • filename : Name of the output file

Kwargs:
  • fault : Add fault for intersection

Returns:
  • None

writeSelectedMagRange(filename, minMag=5.0, maxMag=10.0)

Write to a file the earthquakes with a magnitude larger than minMag and smaller than maxMag.

Args:
  • filename : Name of the output file

Kwargs:
  • minMag : minimum Magnitude.

  • maxMag : maximum Magnitude.

Returns:
  • None

xy2lonlat()

Pass the position from utm to lonlat.

Returns:
  • None