Skip to content

Commit

Permalink
merge some changes from earthscope_tests branch
Browse files Browse the repository at this point in the history
  • Loading branch information
kkappler committed Aug 6, 2023
1 parent 266899d commit 031ee61
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 1 deletion.
47 changes: 47 additions & 0 deletions aurora/sandbox/mth5_helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,53 @@
from mth5.clients import FDSN
from mth5.utils.helpers import initialize_mth5

def enrich_channel_summary(mth5_object, df, keyword):
"""
Parameters
----------
mth5_object: mth5.mth5.MTH5
df: pd.DataFrame
A channel summary dataframe
keyword: str
supported keywords are ["num_filters",]
"num_filters" computes the number of filters associated with each row (channel-run) and adds that "num_filters" column of df
Returns
-------
df: pd.DataFrame
The channel summary df with the new column
"""
df[keyword] = -1
if keyword=="num_filters":
for i_row, row in df.iterrows():
channel = mth5_object.get_channel(row.station, row.run, row.component, row.survey)
num_filters = len(channel.channel_response_filter.filters_list)
df[keyword].iat[i_row] = num_filters
return df

def augmented_channel_summary(mth5_object, df=None):#, **kwargs):
"""
Consider supportig kwargs, such as a list of keyords that tell what columns to add
For now, we only want to add n_filters
Parameters
----------
df: channel summary dataframe
Returns
-------
"""
if not df:
df = mth5_object.channel_summary.to_dataframe()
df["n_filters"] = -1
for i_row, row in df.iterrows():
channel = mth5_object.get_channel(row.station, row.run, row.component, row.survey)
n_filters = len(channel.channel_response_filter.filters_list)
df.n_filters.iat[i_row] = n_filters
return df


def build_request_df(network_id, station_id, channels=None, start=None, end=None):
"""
Expand Down
2 changes: 1 addition & 1 deletion tests/cas04/02b_process_cas04_mth5.py
Original file line number Diff line number Diff line change
Expand Up @@ -356,7 +356,7 @@ def old_main():
#process_run_list("CAS04", ["b", "c", "d"]) # , reprocess=False)
#process_with_remote(h5_paths, "CAS04", "CAV07")
#process_with_remote(h5_paths, "CAS04", "NVR11", band_setup_file=BANDS_DEFAULT_FILE)
#process_with_remote(h5_paths, "CAS04", "REV06")
process_with_remote(h5_paths, "CAS04", "REV06")

#for RR in ["CAV07", "NVR11", "REV06"]:
for RR in ["REV06",]:
Expand Down

0 comments on commit 031ee61

Please sign in to comment.