WINデータクラス
Classes to handle WIN data.
-v0.3.0-a1 - created 2024/09/14 - enhanced: from_obspy 2024/09/14 - add WIN.select 2024/09/20 - add some properties to WIN1ch and WIN 2024/09/20 - add WIN.setitem, add, len, WIN1ch.add 2024/09/20 - add WIN.write 2024/09/21 - bug fix: WIN.plot 2024/09/21 handling of starttime and endtime
Params
dataclass
Class to handle parameters of WIN data.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
station |
str
|
Station code. |
None
|
component |
str
|
Component code. |
None
|
fs |
float
|
Sampling frequency. |
None
|
calib |
float
|
Calibration factor to convert bit to physical value. |
1
|
unit |
str
|
Unit of the data. |
None
|
apply_calib: bool = False
class-attribute
instance-attribute
calib: float = 1
class-attribute
instance-attribute
chtable: pd.Series = None
class-attribute
instance-attribute
component: str = None
class-attribute
instance-attribute
dt
property
fmax: float = None
class-attribute
instance-attribute
fmin: float = None
class-attribute
instance-attribute
fs: float = None
class-attribute
instance-attribute
station: str = None
class-attribute
instance-attribute
unit: str = None
class-attribute
instance-attribute
__init__(station=None, component=None, fs=None, calib=1, apply_calib=False, unit=None, fmin=None, fmax=None, chtable=None)
__repr__()
WIN
dataclass
Class to hold multiple WIN data. It is preferable that each sampling frequency is constant.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
data |
It holds channel number as index and WIN1ch class as data. |
required | |
chtable |
Series
|
Loaded channel table. Use read_chtable(fp) to load channel table. |
None
|
chtable: pd.Series = None
class-attribute
instance-attribute
chtablefp: str = None
class-attribute
instance-attribute
data = None
class-attribute
instance-attribute
fp: list[str] = None
class-attribute
instance-attribute
__add__(other)
__getitem__(key)
__init__(fp=None, chtablefp=None, chtable=None)
__len__()
__radd__(other)
__repr__()
__setitem__(key, value)
__to_bit__(sample_size=None, boundary='cut')
Convert to WIN binary format. Return DataFrame of bitarray for each 1s vs ch.
calib()
Apply calibration factor to data.
decalib()
Remove calibration factor from data.
from_obspy(st)
staticmethod
Convert Obspy Stream class to WIN class.
plot(title='', lw=0.5, c='k', **kwargs)
read(fp, sort=True, ch=None, targettime=None, beforesec=None, aftersec=None, filenameformat=None)
Read WIN files.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
fp |
list[str]
|
File path of WIN data. |
required |
sort |
bool
|
If True, sort the returned data by channel number. |
True
|
ch |
list[str]
|
List of channel number to exclusively read. |
None
|
targettime |
datetime
|
Target time to read data. |
None
|
beforesec |
int
|
Time before the target time to read. |
None
|
aftersec |
int
|
Time after the target time to read. |
None
|
filenameformat |
str
|
Format of the file name. |
None
|
read_chtable(fp, encoding='utf-8', apply_calib=False)
Read channel table file.
select(station=None, component=None)
Select data based on station and component. Supports wildcards using regular expressions.
to_obspy()
Convert to Obspy Stream class.
trim(starttime=None, endtime=None)
Trim data based on time.
write(savename=None, savedir=None, sample_size=None, boundary='cut')
Write WIN file.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
dst |
Destination path. Directory or file path. If Directory is given, file name will be automatically generated. |
required |
WIN1ch
dataclass
Class to handle WIN data of 1 channel. It is preferable the sampling frequency is constant.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
ch |
Channel name. |
required | |
data |
Data of the channel. |
required | |
time |
Time of the data. Should has same size as data. |
required | |
params |
Parameters of the data. |
required |
ch: str = None
class-attribute
instance-attribute
data: np.ndarray = None
class-attribute
instance-attribute
endtime
property
params = Params()
class-attribute
instance-attribute
starttime
property
time: np.ndarray = None
class-attribute
instance-attribute
timelength
property
__add__(other)
__getitem__(key)
__init__()
__len__()
__radd__(other)
__repr__()
__str__()
__to_bit__(sample_size=None, boundary='cut')
calib()
Apply calibration factor to data.
copy()
Return a copy of the data.
cumsum()
Calculate integration of data.
decalib()
Remove calibration factor from data.
demean()
Remove mean from data.
detrend()
Remove trend from data.
from_obspy(tr)
staticmethod
get_fs()
A function to get sampling frequency from time axis and hold it in self.params.fs. If sampling frequency is not constant, it will return None.
gradient()
Calculate gradient of data.
plot(title='', lw=0.5, c='k', **kwargs)
to_obspy()
Convert to Obspy Trace class.
trim(starttime=None, endtime=None, contain_end=True)
Trim data based on time.
write(fp, **kwargs)
Write WIN file.
from_obspy(obspy_data, chtable=None, encoding='utf-8', apply_calib=False)
Generate WIN or WIN1ch class from Obspy Stream or Trace class.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
obspy_data |
Obspy Stream or Trace class. |
required |
read(fp, chtable=None, encoding='utf-8', apply_calib=False, **kwargs)
Read WIN file(s). If there is a channel table file whose name is fp+".ch", the channel table is automatically read. If channel table is given, it will be loaded and applied to the data.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
fp |
list[str]
|
File path of WIN data. |
required |
chtable |
str
|
File path of channel table, by default None |
None
|
encoding |
str
|
Encoding of the channel table, by default "utf-8" |
'utf-8'
|
apply_calib |
bool
|
If True, apply calibration factor to output data, by default False |
False
|
Returns:
Name | Type | Description |
---|---|---|
win |
WIN or WIN1ch
|
WIN or WIN1ch class. |