HinetPy.win32 module

Processing data in win32 format.

class HinetPy.win32.Channel(id=None, name=None, component=None, latitude=None, longitude=None, unit=None, gain=None, damping=None, period=None, preamplification=None, lsb_value=None)

Class for channel.

Initialize a channel.

Parameters
  • id (str) – Channel ID.

  • name (str) – Station Name.

  • component (str) – Channel component name (U|N|E).

  • latitude (float) – Station latitude.

  • longitude (float) – Station longitude.

  • unit (str) – Unit of data (m, m/s, m/s/s, rad).

  • gain (float) – Sensor sensitivity.

  • damping (float) – Damping constant of the sensor.

  • period (float) – Natural period of the seismometer.

  • preamplification – Preamplification.

  • lsb_value – LSB value.

HinetPy.win32.extract_sac(data, ctable, suffix='SAC', outdir='.', pmax=8640000, filter_by_id=None, filter_by_name=None, filter_by_component=None, with_pz=False, processes=0)

Extract data as SAC format files.

Parameters
  • data (str) – win32 file to be processed.

  • ctable (str) – Channel table file.

  • suffix (str) – Suffix of output SAC files. Defaults to SAC.

  • outdir (str) – Output directory. Defaults to current directory.

  • pmax (int) – Maximum number of data points. Defaults to 8640000. If the input data is longer than one day, you have to to increase pmax.

  • filter_by_id (list of str or wildcard) – Filter channels by ID.

  • filter_by_name (list of str or wildcard) – Filter channels by name.

  • filter_by_component (list of str or wildcard) – Filter channels by component.

  • with_pz (bool) – Extract PZ files at the same time. PZ file has default suffix .SAC_PZ.

  • processes (int) – Number of parallel processes to speed up data extraction. Use all processes by default.

Note

win2sac removes sensitivity from waveform, then multiply by 1.0e9. Thus the extracted SAC files are velocity in nm/s, or acceleration in nm/s/s.

Examples

>>> extract_sac("0101_201001010000_5.cnt", "0101_20100101.ch")

Extract all channel with specified SAC suffix and output directory:

>>> extract_sac(
...     "0101_201001010000_5.cnt",
...     "0101_20100101.ch",
...     suffix="",
...     outdir="20100101000",
... )

Extract only specified channels:

>>> extract_sac(
...     "0101_201001010000_5.cnt",
...     "0101_20100101.ch",
...     filter_by_name="N.NA*",
...     filter_by_component="[NE]",
... )
HinetPy.win32.extract_pz(ctable, suffix='SAC_PZ', outdir='.', keep_sensitivity=False, filter_by_chid=None, filter_by_name=None, filter_by_component=None)

Extract instrumental response in SAC PZ format from channel table.

Warning

Only works for instrumental responses of Hi-net network.

RESP files of F-net network can be downloaded from F-net website.

Parameters
  • ctable (str) – Channel table file.

  • suffix (str) – Suffix of SAC PZ files. Defaults to SAC_PZ.

  • outdir (str) – Output directory. Defaults to current directory.

  • keep_sensivity (bool) – win2sac automatically removes sensivity from waveform data during win32 format to SAC format conversion. So the generated polezero file should omit the sensitivity.

  • filter_by_id (list of str or wildcard) – Filter channels by ID.

  • filter_by_name (list of str or wildcard) – Filter channels by name.

  • filter_by_component (list of str or wildcard) – Filter channels by component.

Examples

>>> extract_pz("0101_20100101.ch")

Extract all channel with specified suffix and output directory:

>>> extract_pz("0101_20100101.ch", suffix="", outdir="20100101000")

Extract only specified channels:

>>> extract_pz(
...     "0101_20100101.ch", filter_by_name="N.NA*", filter_by_component="[NE]"
... )
HinetPy.win32.merge(datas, total_data, force_sort=False)

Merge several win32 files to one win32 file.

Parameters
  • datas (list of str or wildcard) – Win32 files to be merged.

  • total_data (str) – Filename of ouput win32 file.

  • force_sort (bool) – Sort all win32 files by date.

Examples

If win32 files are named by starttime (e.g. 201304040203.cnt), sorting win32 files in list by name/time is prefered:

>>> datas = sorted(glob.glob("20130404*.cnt"))
>>> merge(datas, "outdir/final.cnt")

If win32 files are named randomly, you should set force_sort to True to force catwin32 to sort all data by time. However, it’s time consuming. Do NOT use it unless necessary:

>>> datas = ["001.cnt", "002.cnt", "003.cnt"]
>>> merge(datas, "final.cnt", force_sort=True)

You can also use wildcard to specify the win32 files to be merged.

>>> merge("20130404*.cnt", "final.cnt")