Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Patch loading issue with double ended Oryx data #215

Merged
merged 7 commits into from
Apr 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 1 addition & 5 deletions .bumpversion.cfg
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[bumpversion]
current_version = 3.0.0
current_version = 3.0.1
commit = True
tag = True

Expand All @@ -11,10 +11,6 @@ replace = {new_version}.
search = version = release = "{current_version}"
replace = version = release = "{new_version}"

[bumpversion:file:src/dtscalibration/__init__.py]
search = __version__ = "{current_version}"
replace = __version__ = "{new_version}"

[bumpversion:file:CITATION.cff]
search = "v{current_version}"
replace = "v{new_version}"
7 changes: 7 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,13 @@
Changelog
=========

3.0.1 (2024-04-13)
---

Fixed

* Oryx v4 double ended could have the backward measurements incorrectly cut off during loading.

3.0.0 (2023-11-05)
---

Expand Down
2 changes: 1 addition & 1 deletion CITATION.cff
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,5 @@ doi: "10.5281/zenodo.1410097"
license: "BSD-3-Clause"
repository-code: "https://github.com/dtscalibration/python-dts-calibration"
title: "Python distributed temperature sensing calibration"
version: "v3.0.0"
version: "v3.0.1"
url: "https://python-dts-calibration.readthedocs.io"
2 changes: 1 addition & 1 deletion README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ Overview
:alt: PyPI Package latest release
:target: https://pypi.python.org/pypi/dtscalibration

.. |commits-since| image:: https://img.shields.io/github/commits-since/dtscalibration/python-dts-calibration/v3.0.0.svg
.. |commits-since| image:: https://img.shields.io/github/commits-since/dtscalibration/python-dts-calibration/v3.0.1.svg
:alt: Commits since latest release
:target: https://github.com/dtscalibration/python-dts-calibration/compare/v1.1.1...main

Expand Down
2 changes: 1 addition & 1 deletion docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
year = str(date.today().year)
author = "Bas des Tombe and Bart Schilperoort"
copyright = f"{year}, {author}"
version = release = "3.0.0"
version = release = "3.0.1"

pygments_style = "trac"
templates_path = [".", sphinx_autosummary_accessors.templates_path]
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ select = [ # It would be nice to have the commented out checks working.

]
extend-select = [
"D401", # First line should be in imperative mood
#"D401", # First line should be in imperative mood
"D400", # First line should end in a period.
"D404", # First word of the docstring should not be "This"
"TID252", # No relative imports (not pep8 compliant)
Expand Down
6 changes: 6 additions & 0 deletions src/dtscalibration/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import importlib.metadata
import warnings

from dtscalibration.dts_accessor import DtsAccessor # noqa: F401
from dtscalibration.dts_accessor_utils import get_netcdf_encoding
Expand All @@ -23,3 +24,8 @@
"shift_double_ended",
"suggest_cable_shift_double_ended",
]

warnings.filterwarnings(
"ignore",
message="Converting non-nanosecond precision timedelta values to nanosecond",
)
2 changes: 1 addition & 1 deletion src/dtscalibration/dts_accessor.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
"""This module provides an xarray accessor for DTS calibration."""
"""The xarray accessor for DTS calibration."""

import dask.array as da
import numpy as np
Expand Down
18 changes: 8 additions & 10 deletions src/dtscalibration/dts_accessor_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -845,17 +845,15 @@ def merge_double_ended_times(
elif direction == "bw" and direction_next == "fw":
pass

elif direction == "fw" and direction_next == "fw":
if verbose:
print(
f"Missing backward measurement beween {ds_fw.time.values[ind]} and {ds_fw.time.values[ind_next]}"
)
elif direction == "fw" and direction_next == "fw" and verbose:
print(
f"Missing backward measurement beween {ds_fw.time.values[ind]} and {ds_fw.time.values[ind_next]}"
)

elif direction == "bw" and direction_next == "bw":
if verbose:
print(
f"Missing forward measurement beween {ds_bw.time.values[ind]} and {ds_bw.time.values[ind_next]}"
)
elif direction == "bw" and direction_next == "bw" and verbose:
print(
f"Missing forward measurement beween {ds_bw.time.values[ind]} and {ds_bw.time.values[ind_next]}"
)

# throw out is dt differs from its neighbors
if verify_timedeltas:
Expand Down
16 changes: 12 additions & 4 deletions src/dtscalibration/io/sensornet.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,11 +109,13 @@ def read_sensornet_files(
or fnmatch.fnmatch(ddf_version, "Sentinel DTS v5*")
):
flip_reverse_measurements = True
elif fnmatch.fnmatch(ddf_version, "ORYX F/W v4*"):
flip_reverse_measurements = False
else:
flip_reverse_measurements = False
warnings.warn(
f"Sensornet .dff version {ddf_version}"
" has not been tested.\nPlease open an issue on github"
f"\n Sensornet .dff version {ddf_version}"
" has not been tested.\n Please open an issue on github"
" and provide an example file"
)

Expand Down Expand Up @@ -398,8 +400,14 @@ def read_sensornet_files_routine_v3(
[0, fiber_bw_1_index - fiber_n_indices - fiber_n_indices_internal]
)

REV_ST = REV_ST[fiber_bw_start_index:fiber_bw_end_index]
REV_AST = REV_AST[fiber_bw_start_index:fiber_bw_end_index]
if (fiber_end_index - fiber_start_index) == (
fiber_bw_end_index - fiber_bw_start_index
):
REV_ST = REV_ST[fiber_bw_start_index:fiber_bw_end_index]
REV_AST = REV_AST[fiber_bw_start_index:fiber_bw_end_index]
else:
REV_ST = REV_ST[fiber_start_index:fiber_end_index]
REV_AST = REV_AST[fiber_start_index:fiber_end_index]

else:
# Use the fiber indices from the forward channel
Expand Down
16 changes: 9 additions & 7 deletions tests/test_datastore.py
Original file line number Diff line number Diff line change
Expand Up @@ -528,15 +528,17 @@ def test_resample_datastore():
ds = read_silixa_files(directory=filepath, timezone_netcdf="UTC", file_ext="*.xml")
assert ds.time.size == 3

ds_resampled = Dataset(ds.resample(time="47S").mean())
ds_resampled = ds.resample(time="47s").mean()

assert ds_resampled.time.size == 2
assert ds_resampled.st.dims == ("x", "time"), (
"The dimension have to "
"be manually transposed "
"after resampling. To "
"guarantee the order"
)

## No control over dim order from resample with accessor
# assert ds_resampled.st.dims == ("x", "time"), (
# "The dimension have to "
# "be manually transposed "
# "after resampling. To "
# "guarantee the order"
# )


def test_timeseries_keys():
Expand Down
Loading