Skip to content

Commit

Permalink
Merge branch 'main' into Update-to-recent-xarray-and-pandas
Browse files Browse the repository at this point in the history
  • Loading branch information
bdestombe authored Jul 27, 2023
2 parents 10534ae + a6b374d commit 4a4971b
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions src/dtscalibration/datastore_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -246,17 +246,21 @@ def merge_double_ended_times(ds_fw, ds_bw, verify_timedeltas=True, verbose=True)

# throw out is dt differs from its neighbors
if verify_timedeltas:
dt = (ds_bw.isel(time=iuse_chbw).time.values - ds_fw.isel(time=iuse_chfw).time.values) /\
np.array(1000000000, dtype='timedelta64[ns]')
dt = (
(ds_bw.isel(time=iuse_chbw).time.values - ds_fw.isel(time=iuse_chfw).time.values) /
np.timedelta64(1, "s"))
leaveout = np.zeros_like(dt, dtype=bool)
leaveout[1:-1] = np.isclose(dt[:-2], dt[2:], atol=1.5, rtol=0.) * ~np.isclose(dt[:-2], dt[1:-1], atol=1.5, rtol=0.)
iuse_chfw2 = np.array(iuse_chfw)[~leaveout]
iuse_chbw2 = np.array(iuse_chbw)[~leaveout]

if verbose:
for itfw, itbw in zip(np.array(iuse_chfw)[leaveout], np.array(iuse_chbw)[leaveout]):
print(f"FW: {ds_fw.isel(time=itfw).time.values} and BW: {ds_bw.isel(time=itbw).time.values} do not "
f"belong together as their timedelta is larger than their neighboring timedeltas. Thrown out.")
print(
"The following measurements do not belong together, as the time difference\n"
"between the\forward and backward measurements is more than 1.5 seconds\n"
"larger than the neighboring measurements.\n"
f"FW: {ds_fw.isel(time=itfw).time.values} and BW: {ds_bw.isel(time=itbw).time.values}")

else:
iuse_chfw2 = iuse_chfw
Expand Down

0 comments on commit 4a4971b

Please sign in to comment.