earthscopestraintools.mseed_tools module
- earthscopestraintools.mseed_tools.download_mseed(net: str, sta: str, loc: str, cha: str, start: str, end: str, print_url: bool = False)
Load miniseed data from fdsnws-dataselect into obspy Stream object.
- Parameters:
net (str) – FDSN 2 character network code, accepts wildcards
sta (str) – FDSN 4 character station code, accepts wildcards
loc (str) – FDSN 2 character location code, accepts wildcards
cha (str) – FDSN 3 character channel code, accepts wildcards
start (str) – start time of query as ISO formatted string
end (str) – end time of query as ISO formatted string
print_url (bool, optional) – show dataselect url, defaults to False
- Returns:
data as Stream object
- Return type:
obspy.Core.Stream
- earthscopestraintools.mseed_tools.fdsn2bottlename(channel)
convert FDSN channel code into bottlename
- Parameters:
channel (str) – FDSN channel
- Returns:
bottlename
- Return type:
str
- earthscopestraintools.mseed_tools.load_mseed_file_to_df(filename: str)
read miniseed file from local disk into pandas dataframe, with time as the index and each channel as a column. Uses obspy as an intermediate step.
- Parameters:
filename (str) – miniseed filename
- Returns:
data loaded into pandas dataframe
- Return type:
pd.DataFrame
- earthscopestraintools.mseed_tools.load_mseed_to_df(net: str, sta: str, loc: str, cha: str, start: str, end: str, save_as: str | None = None, print_url: bool = False, print_traces: bool = True)
Load miniseed data from fdsnws-dataselect a pandas dataframe, with time as the index and each channel as a column. Uses obspy as an intermediate step. Enforces completeness by building an index of all timestamps in date range and filling gaps with nans.
- Parameters:
net (str) – FDSN 2 character network code, accepts wildcards
sta (str) – FDSN 4 character station code, accepts wildcards
loc (str) – FDSN 2 character location code, accepts wildcards
cha (str) – FDSN 3 character channel code, accepts wildcards
start (str) – start time of query as ISO formatted string
end (str) – end time of query as ISO formatted string
save_as (str, optional) – filename to save miniseed data, defaults to None
print_url (bool, optional) – show dataselect url, defaults to False
print_traces (bool, optional) – show traces loaded into obspy, defaults to True
- Returns:
data loaded into pandas dataframe
- Return type:
pd.DataFrame
- earthscopestraintools.mseed_tools.mseed2pandas(st: Stream, print_traces=True)
Restructure data from obspy.Core.Stream to pandas.DataFrame with time as the index and each channel as a column.
- Parameters:
st (obspy.Core.Stream) – Stream object containing one or more Traces
print_traces (bool, optional) – show traces loaded into obspy, defaults to True
- Returns:
data loaded into pandas dataframe
- Return type:
pandas.DataFrame
- earthscopestraintools.mseed_tools.save_mseed_file(net: str, sta: str, loc: str, cha: str, start: str, end: str, filename: str)
Load miniseed data from fdsnws-dataselect into obspy, and save as miniseed.
- Parameters:
net (str) – FDSN 2 character network code, accepts wildcards
sta (str) – FDSN 4 character station code, accepts wildcards
loc (str) – FDSN 2 character location code, accepts wildcards
cha (str) – FDSN 3 character channel code, accepts wildcards
start (str) – start time of query as ISO formatted string
end (str) – end time of query as ISO formatted string
filename (str) – filename to save miniseed data
- earthscopestraintools.mseed_tools.ts_from_mseed(network: str, station: str, location: str, channel: str, start: str, end: str, name: str | None = None, period: float | None = None, series: str = 'raw', units: str = 'unknown', fill_value: int = 999999, to_nan: bool = True, scale_factor: float | None = None)
Load miniseed data from fdsnws-dataselect into Timeseries object.
- Parameters:
network (str) – FDSN 2 character network code, accepts wildcards
station (str) – FDSN 4 character station code, accepts wildcards
location (str) – FDSN 2 character location code, accepts wildcards
channel (str) – FDSN 3 character channel code, accepts wildcards
start (str) – start time of query as ISO formatted string
end (str) – end time of query as ISO formatted string
name (str, optional) – name of timeseries, including station name. useful for showing stats. , defaults to None
period (float, optional) – sample period of data, defaults to None
series (str, optional) – description of timeseries, ie ‘raw’, ‘microstrain’, ‘atmp_c’, ‘tide_c’, ‘offset_c’, ‘trend_c’, defaults to “raw”
units (str, optional) – units of timeseries, defaults to “counts” or “unknown”
fill_value (int, optional) – gap fill value to replace if to_nan is set to True, defaults to 999999
to_nan (bool, optional) – option to convert gap fill values to numpy.nan, defaults to True
scale_factor (float, optional) – scale factor to apply to miniseed data, defaults to None
- Returns:
Timeseries object containing data loaded from miniseed
- Return type: