Skip to content

Commit

Permalink
add fix from widescale tests for issue #233
Browse files Browse the repository at this point in the history
  • Loading branch information
kkappler committed Sep 15, 2023
1 parent 60bb3b9 commit d8b0c62
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions aurora/pipelines/run_summary.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,27 @@ def add_duration(self, df=None):
df["duration"] = durations
return

def check_runs_are_valid(self, drop=False, **kwargs):
""" kwargs can tell us what sorts of conditions to check, for example all_zero, there are nan, etc."""
check_for_all_zero_runs = True
for i_row, row in self.df.iterrows():
print(f"Checking row for zeros {row}")
m = mth5.mth5.MTH5()
m.open_mth5(row.mth5_path)
run_obj = m.get_run(row.station_id, row.run_id, row.survey)
runts = run_obj.to_runts()
if runts.dataset.to_array().data.__abs__().sum() == 0:
print("CRITICAL: Detected a run with all zero values")
self.df["valid"].at[i_row] = False

Check warning on line 125 in aurora/pipelines/run_summary.py

View check run for this annotation

Codecov / codecov/patch

aurora/pipelines/run_summary.py#L116-L125

Added lines #L116 - L125 were not covered by tests
# load each run, and take the median of the sum of the absolute values
if drop:
self.drop_invalid_rows()
return

Check warning on line 129 in aurora/pipelines/run_summary.py

View check run for this annotation

Codecov / codecov/patch

aurora/pipelines/run_summary.py#L127-L129

Added lines #L127 - L129 were not covered by tests

def drop_invalid_rows(self):
self.df = self.df[self.df.valid]
self.df.reset_index(drop=True, inplace=True)

Check warning on line 133 in aurora/pipelines/run_summary.py

View check run for this annotation

Codecov / codecov/patch

aurora/pipelines/run_summary.py#L132-L133

Added lines #L132 - L133 were not covered by tests

# BELOW FUNCTION CAN BE COPIED FROM METHOD IN KernelDataset()
# def drop_runs_shorter_than(self, duration, units="s"):
# if units != "s":
Expand Down Expand Up @@ -227,6 +248,7 @@ def channel_summary_to_run_summary(
data_dict["input_channels"] = input_channels
data_dict["output_channels"] = output_channels
data_dict["channel_scale_factors"] = channel_scale_factors
data_dict["valid"] = True

run_summary_df = pd.DataFrame(data=data_dict)
if sortby:
Expand Down

0 comments on commit d8b0c62

Please sign in to comment.