HinetPy.win32 模块

Process seismic waveform data in win32 format.

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

提取数据并以SAC格式保存。

This function calls the win2sac_32 command, available in the Hi-net win32tools package, to convert data files from win32 format to SAC fomrat. It can also extract the channel information as SAC polezero files.

Note that the win2sac_32 command always remove the instrument sensitivity from waveform data, and multiply the data by 1.0e9. Thus, the extracted SAC files are not in digital counts, but velocity in nm/s, or acceleration in nm/s/s. Due to the same reason, the extracted SAC polezero files does not keep the sensitivity in the “CONSTANT” of SAC polezero files.

参数:
  • data (str) – 要处理的win32文件。

  • ctable (str) – 通道表文件。

  • suffix (str) – 输出SAC文件的后缀。默认值为 SAC

  • outdir (str) – 输出目录。默认输出到当前目录。

  • pmax (int) – Maximum number of data points for one channel. Defaults to 8640000. If one channel has more than 8640000 data points (i.e., longer than one day for a 100 Hz sampling rate), you MUST increase pmax.

  • filter_by_id (list or str) – Filter channels by ID. It can be a list of IDs or a wildcard.

  • filter_by_name (list or str) – Filter channels by name. It can be a list of names or a wildcard.

  • filter_by_component (list or str) – Filter channels by component. It can be a list of component names or a wildcard.

  • with_sacpz (bool) – Aslo extract SAC PZ files. By default, the suffix is .SAC_PZ and the channel sensitivity is not kept in the “CONSTANT”.

  • processes (None or int) – Number of processes to speed up data extraction parallelly. None means using all CPUs.

  • deprecated: (..) – 0.7.0: Parameter with_pz is deprecated. Use with_sacpz instead.

示例

Extract all channels with default settings:

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

Extract all channels with a specified suffix and output directory:

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

只提取指定通道:

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

Extract instrumental responses in SAC polezero format from a channel table.

警告

The function only works for Hi-net instrumental responses.

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

参数:
  • ctable (str) – 通道表文件。

  • suffix (str) – SAC零极点文件后缀,默认为 SAC_PZ

  • outdir (str) – 输出目录。默认输出到当前目录。

  • keep_sensitivity (bool) – The win2sac_32 program automatically removes sensitivity from waveform data during the win32-to-SAC format conversion. So the generated polezero file should omit the sensitivity.

  • filter_by_id (list or str) – Filter channels by ID. It can be a list of IDs or a wildcard.

  • filter_by_name (list or str) – Filter channels by name. It can be a list of names or a wildcard.

  • filter_by_component (list or str) – Filter channels by component. It can be a list of component names or a wildcard.

  • processes (None or int) – Number of processes to speed up data extraction parallelly. None means using all CPUs.

示例

Extract all channels with default settings:

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

Extract all channels with a specified suffix and output directory:

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

只提取指定通道:

>>> extract_sacpz(
...     "0101_20100101.ch", filter_by_name="N.NA*", filter_by_component="[NE]"
... )
HinetPy.win32.extract_pz(ctable, **kwargs)

Extract instrumental responses in SAC polezero format from a channel table.

自 0.7.0 版本弃用: extract_pz() is deprecated. Use extract_sacpz() instead.

HinetPy.win32.read_ctable(ctable)

Read a channel table file.

参数:

ctable (str) – Channle table file.

返回:

List of Channel.

返回类型:

list

HinetPy.win32.merge(data, total_data, force_sort=False)

Merge multiple win32 files into one large win32 file.

The function calls the catwin32 command, available in the Hi-net win32tools package, to merge multiple win32 files into one large win32 file.

By default, the catwin32 command simply concatenates all files in the order they are passed. So the files must be sorted by their start time before being passed. If your files are named by starttime like 201304040203.cnt, you can use data=sorted(glob.glob("20130404*.cnt")) to pass the sorted list of files. Otherwise, you have to use force_sort=True, forcing catwin32 to sort all files by starttime before merging. However, the sorting process is very time consuming. Do NOT set force_sort=True unless necessary.

参数:
  • data (list or str) – Win32 files to be merged. It can be a list of file names or a wildcard.

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

  • force_sort (bool) – Sort all win32 files by starttime before merging.

示例

For win32 files that are named by starttime (e.g. 201304040203.cnt), sorting win32 files using Python’s built-in sorted() function is preferred:

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

If win32 files are randomly named, you should use force_sort=True to force catwin32 to sort all data by time before merging.

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

You can also use wildcard to specify the win32 files to be merged. The function will sort the matched files for you automatically.

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