pygmi.seis.iodefs

Contents

pygmi.seis.iodefs#

Import and export of seismology data.

Classes#

ImportSeisan

GUI to import SEISAN and SeisComP data.

ImportGenericFPS

GUI to import Generic Fault Plane Solution data.

ExportSeisan

GUI to export SEISAN data.

ExportCSV

GUI export seismic data to CSV.

ExportSummary

GUI to export a seismic data summary.

FilterSeisan

GUI to filter seismic data events.

Functions#

sform(strform, val, tmp, col1[, col2, nval])

Format strings.

str2float(inp)

Convert a number float, or returns NaN.

str2int(inp)

Convert a number to integer, or returns NaN.

importmacro(ifile)

Import macro format.

importnordic(ifile[, showlog])

Import Nordic and Nordic2 data.

importseiscomp(ifile[, showlog, prefmag])

Import SeisComp data.

importxlsx(ifile[, showlog])

Import Excel summary.

read_record_type_1(i)

Read record type 1.

read_record_type_2(i)

Read record type 2.

read_record_type_3(i)

Read record type 3.

read_record_type_4(i)

Read record type 4.

read_record_type_phase(i)

Read record type phase (nordic2 type 4).

read_record_type_5(i)

Read record type 5.

read_record_type_6(i)

Read record type 6.

read_record_type_e(i)

Read record type E.

read_record_type_f(i)

Read record type F.

read_record_type_h(i)

Read record type H.

read_record_type_i(i)

Read record type I.

read_record_type_m(i)

Read record type M.

merge_m(rec1, rec2)

Merge M records.

read_record_type_p(i)

Read record type P.

mercalli(mag)

Return Mercalli index.

detect_file_encoding(ifile)

Detect file encoding.

Module Contents#

pygmi.seis.iodefs.sform(strform, val, tmp, col1, col2=None, nval=-999)#

Format strings.

Formats strings according with a mod for values containing the value -999 or None. In that case it will output spaces instead. In the case of strings being output, they are truncated to fit the format statement. This routine also puts the new strings in the correct columns

Parameters:
  • strform (str) – This string must be of the form {0:4.1f}, where 4.1f can be changed.

  • val (float | str) – Input value

  • tmp (str) – Input string

  • col1 (int) – Start column (1 is first column)

  • col2 (int | None) – End column. The default is None.

  • nval (float) – Null value which gets substituted by spaces. The default is -999.

Returns:

Output formatted string.

Return type:

str

pygmi.seis.iodefs.str2float(inp)#

Convert a number float, or returns NaN.

Parameters:

inp (str) – String with a float in it

Returns:

Float or np.nan

Return type:

float

pygmi.seis.iodefs.str2int(inp)#

Convert a number to integer, or returns NaN.

Parameters:

inp (str) – String with an integer in it

Returns:

Integer or np.nan

Return type:

int

class pygmi.seis.iodefs.ImportSeisan(parent=None)#

Bases: pygmi.misc.BasicModule

GUI to import SEISAN and SeisComP data.

Parameters:

parent – Reference to the parent routine. The default is None.

settings(nodialog=False)#

Entry point into item.

Parameters:

nodialog (bool) – Run settings without a dialog. The default is False.

Returns:

True if successful, False otherwise.

Return type:

bool

saveproj()#

Save project data from class.

pygmi.seis.iodefs.importmacro(ifile)#

Import macro format.

  1. Line Location, GMT time, Local time. Format a30,i4,1x,2i2,1x,2i2,1x,i2, ‘GMT’,1x,i4,1x,2i2,1x,2i2,1x,i2,1x,’Local time’

  2. Line Comments

  3. Line Observations: Latitude, Longitude,intensity, code for scale, postal code or similar, location,Format 2f10.4,f5.1,1x,a3,1x,a10,2x,a. Note the postal code is an ascii string and left justified (a10).

Parameters:

ifile (str) – Input macro file.

Returns:

List of locations with intensities.

Return type:

GeoDataFrame

pygmi.seis.iodefs.importnordic(ifile, showlog=print)#

Import Nordic and Nordic2 data.

Parameters:
  • ifile (str) – Input file to import.

  • showlog (collections.abc.Callable[..., None]) – Display information. The default is print.

Returns:

SEISAN Data.

Return type:

list

pygmi.seis.iodefs.importseiscomp(ifile, showlog=print, prefmag='MLv')#

Import SeisComp data.

Parameters:
  • ifile (str) – Input file to import.

  • showlog (collections.abc.Callable[..., None]) – Display information. The default is print.

  • prefmag (str) – The preferred magnitude. The default is ‘MLv’.

Returns:

SEISAN Data.

Return type:

list

pygmi.seis.iodefs.importxlsx(ifile, showlog=print)#

Import Excel summary.

Parameters:
  • ifile (str) – Input file to import.

  • showlog (collections.abc.Callable[..., None]) – Display information. The default is print.

Returns:

SEISAN Data.

Return type:

list

pygmi.seis.iodefs.read_record_type_1(i)#

Read record type 1.

Parameters:

i (str) – String to read from.

Returns:

SEISAN 1 record.

Return type:

sdt.seisan_1

pygmi.seis.iodefs.read_record_type_2(i)#

Read record type 2.

Parameters:

i (str) – String to read from.

Returns:

SEISAN 2 record.

Return type:

sdt.seisan_2

pygmi.seis.iodefs.read_record_type_3(i)#

Read record type 3.

Parameters:

i (str) – String to read from.

Returns:

SEISAN 3 record.

Return type:

sdt.seisan_3

pygmi.seis.iodefs.read_record_type_4(i)#

Read record type 4.

Parameters:

i (str) – String to read from.

Returns:

SEISAN 4 record.

Return type:

sdt.seisan_4

pygmi.seis.iodefs.read_record_type_phase(i)#

Read record type phase (nordic2 type 4).

Parameters:

i (str) – String to read from.

Returns:

SEISAN 4 record.

Return type:

sdt.seisan_4

pygmi.seis.iodefs.read_record_type_5(i)#

Read record type 5.

Parameters:

i (str) – String to read from.

Returns:

SEISAN 5 record.

Return type:

sdt.seisan_5

pygmi.seis.iodefs.read_record_type_6(i)#

Read record type 6.

Parameters:

i (str) – String to read from.

Returns:

SEISAN 6 record.

Return type:

sdt.seisan_6

pygmi.seis.iodefs.read_record_type_e(i)#

Read record type E.

Parameters:

i (str) – String to read from.

Returns:

SEISAN E record.

Return type:

sdt.seisan_E

pygmi.seis.iodefs.read_record_type_f(i)#

Read record type F.

Parameters:

i (str) – String to read from.

Returns:

Dictionary with a SEISAN F record.

Return type:

dict

pygmi.seis.iodefs.read_record_type_h(i)#

Read record type H.

Parameters:

i (str) – String to read from.

Returns:

SEISAN H record.

Return type:

sdt.seisan_H

pygmi.seis.iodefs.read_record_type_i(i)#

Read record type I.

Parameters:

i (str) – String to read from.

Returns:

SEISAN I record.

Return type:

sdt.seisan_I

pygmi.seis.iodefs.read_record_type_m(i)#

Read record type M.

Parameters:

i (str) – String to read from.

Returns:

SEISAN M record.

Return type:

sdt.seisan_M

pygmi.seis.iodefs.merge_m(rec1, rec2)#

Merge M records.

Parameters:
Returns:

SEISAN M record.

Return type:

sdt.seisan_M

pygmi.seis.iodefs.read_record_type_p(i)#

Read record type P.

Parameters:

i (str) – String to read from.

Returns:

SEISAN P record.

Return type:

sdt.seisan_P

class pygmi.seis.iodefs.ImportGenericFPS(parent=None)#

Bases: pygmi.misc.BasicModule

GUI to import Generic Fault Plane Solution data.

This is stored in a csv file.

Parameters:

parent – Reference to the parent routine. The default is None.

settings(nodialog=False)#

Entry point into item.

Parameters:

nodialog (bool) – Run settings without a dialog. The default is False.

Returns:

True if successful, False otherwise.

Return type:

bool

saveproj()#

Save project data from class.

class pygmi.seis.iodefs.ExportSeisan(parent=None)#

Bases: pygmi.misc.ContextModule

GUI to export SEISAN data.

Parameters:

parent – Reference to the parent routine. The default is None.

run(filename=None)#

Entry point into the routine, used to run context menu item.

Parameters:

filename (str | None) – File name, by default None

write_record_type_1(data)#

Write record type 1.

Parameters:

data (dict) – Dictionary of record types.

write_record_type_2(data)#

Write record type 2.

Parameters:

data (dict) – Dictionary of record types.

write_record_type_3(data)#

Write record type 3.

This changes depending on the preceding line.

Parameters:

data (dict) – Dictionary of record types.

write_record_type_4(data)#

Write record type 4.

Parameters:

data (dict) – Dictionary of record types.

write_record_type_phase(data)#

Write record type 4.

Parameters:

data (dict) – Dictionary of record types.

write_record_type_5(data)#

Write record type 5.

Parameters:

data (dict) – Dictionary of record types.

write_record_type_6(data)#

Write record type 6.

Parameters:

data (dict) – Dictionary of record types.

write_record_type_7()#

Write record type 7.

write_record_type_e(data)#

Write record type E.

Parameters:

data (dict) – Dictionary of record types.

write_record_type_f(data)#

Write record type F.

Parameters:

data (dict) – Dictionary of record types.

write_record_type_h(data)#

Write record type H.

Parameters:

data (dict) – Dictionary of record types.

write_record_type_i(data)#

Write record type I.

Parameters:

data (dict) – Dictionary of record types.

write_record_type_m(data)#

Write record type M.

Parameters:

data (dict) – Dictionary of record types.

write_record_type_p(data)#

Write record type P.

Parameters:

data (dict) – Dictionary of record types.

class pygmi.seis.iodefs.ExportCSV(parent=None)#

Bases: pygmi.misc.ContextModule

GUI export seismic data to CSV.

Parameters:

parent – Reference to the parent routine. The default is None.

run()#

Entry point into the routine, used to run context menu item.

write_record_type_1(data)#

Write record type 1.

Parameters:

data (dict) – Dictionary of record types.

Returns:

Output string.

Return type:

str

write_record_type_2(data)#

Write record type 2.

Parameters:

data (dict) – Dictionary of record types.

Returns:

Output string.

Return type:

str

write_record_type_3(tmp)#

Write record type 3.

This changes depending on the preceding line.

Parameters:

tmp (str) – Data string.

Returns:

Output string.

Return type:

str

write_record_type_4(data)#

Write record type 4.

Parameters:

data (dict) – Dictionary of record types.

Returns:

List of output string.

Return type:

list of str

write_record_type_5(data)#

Write record type 5.

Parameters:

data (dict) – Dictionary of record types.

Returns:

Output string.

Return type:

str

write_record_type_6(data)#

Write record type 6.

Parameters:

data (dict) – Dictionary of record types.

Returns:

Output string.

Return type:

str

write_record_type_7()#

Write record type 7.

Returns:

tmp – Output string.

Return type:

str

write_record_type_e(data)#

Write record type E.

Parameters:

data (dict) – Dictionary of record types.

Returns:

Output string.

Return type:

str

write_record_type_f(data)#

Write record type F.

Parameters:

data (dict) – Dictionary of record types.

Returns:

Output string.

Return type:

str

write_record_type_h(data)#

Write record type H.

Parameters:

data (dict) – Dictionary of record types.

Returns:

Output string.

Return type:

str

write_record_type_i(data)#

Write record type I.

Parameters:

data (dict) – Dictionary of record types.

Returns:

Output string.

Return type:

str

write_record_type_m(data)#

Write record type M.

Parameters:

data (dict) – Dictionary of record types.

Returns:

Output string.

Return type:

str

write_record_type_p(data)#

Write record type P.

Parameters:

data (dict) – Dictionary of record types.

Returns:

Output string.

Return type:

str

class pygmi.seis.iodefs.ExportSummary(parent=None)#

Bases: pygmi.misc.ContextModule

GUI to export a seismic data summary.

Parameters:

parent – Reference to the parent routine. The default is None.

run()#

Entry point into the routine, used to run context menu item.

pygmi.seis.iodefs.mercalli(mag)#

Return Mercalli index.

Parameters:

mag (float) – Local magnitude.

Returns:

Mercalli index

Return type:

str

class pygmi.seis.iodefs.FilterSeisan(parent=None)#

Bases: pygmi.misc.BasicModule

GUI to filter seismic data events.

This filters data using thresholds.

Parameters:

parent – Reference to the parent routine. The default is None.

setupui()#

Set up UI.

data_init()#

Initialise Data.

Entry point into routine. This entry point exists for the case where data must be initialised before entering at the standard ‘settings’ sub module.

Returns:

True if successful, False otherwise.

Return type:

bool

dind_click(state)#

Check checkboxes.

Parameters:

state (int) – State of checkbox.

rectype_init(txt)#

Change combo.

Parameters:

txt (str) – Text.

recdesc_init(txt)#

Change Description.

Parameters:

txt (str) – Text.

get_limits()#

Get limits for SEISAN data.

settings(nodialog=False)#

Entry point into item.

Parameters:

nodialog (bool) – Run settings without a dialog. The default is False.

Returns:

True if successful, False otherwise.

Return type:

bool

saveproj()#

Save project data from class.

acceptall()#

Accept option.

Updates self.outdata, which is used as input to other modules.

pygmi.seis.iodefs.detect_file_encoding(ifile)#

Detect file encoding.

Parameters:

ifile – Input file name.

Returns:

Encoding result.

Return type:

str