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

Nexrad split cut removal #271

Merged
merged 16 commits into from
Feb 19, 2025
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
1 change: 1 addition & 0 deletions docs/history.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
* ENH: Add message type 1 decoding to nexrad level 2 reader ({issue}`256`) ({pull}`267`) by [@kmuehlbauer](https://github.com/kmuehlbauer).
* ENH: Introduce file locks for nexrad level2 and iris backend ({issue}`207`) ({pull}`268`) by [@kmuehlbauer](https://github.com/kmuehlbauer).


## 0.8.0 (2024-11-04)

This is the first version which uses datatree directly from xarray. Thus, xarray is pinned to version >= 2024.10.0.
Expand Down
1 change: 0 additions & 1 deletion xradar/io/backends/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,6 @@ def _get_required_root_dataset(ls_ds, optional=True):

# merging both the created and the variables within each dataset
root = xr.merge([root, _vars], compat="override")

attrs = root.attrs.keys()
remove_attrs = set(attrs) ^ set(required_global_attrs)
if optional:
Expand Down
29 changes: 13 additions & 16 deletions xradar/io/backends/nexrad_level2.py
Original file line number Diff line number Diff line change
Expand Up @@ -1694,8 +1694,6 @@
"""
from xarray.core.treenode import NodePath

comment = None

if isinstance(sweep, str):
sweep = NodePath(sweep).name
sweeps = [sweep]
Expand All @@ -1712,18 +1710,19 @@
)
else:
with NEXRADLevel2File(filename_or_obj, loaddata=False) as nex:
nsweeps = nex.msg_5["number_elevation_cuts"]
n_sweeps = len(nex.msg_31_data_header)
# check for zero (old files)
if nsweeps == 0:
nsweeps = n_sweeps
comment = "No message 5 information available"
# Check if duplicated sweeps ("split cut mode")
elif nsweeps > n_sweeps:
nsweeps = n_sweeps
comment = "Split Cut Mode scanning strategy"

sweeps = [f"sweep_{i}" for i in range(nsweeps)]
# Expected number of elevation cuts from the VCP definition
exp_sweeps = nex.msg_5["number_elevation_cuts"]
# Actual number of sweeps recorded in the file
act_sweeps = len(nex.msg_31_data_header)
# Check for AVSET mode: If AVSET was active, the actual number of sweeps (act_sweeps)
# will be fewer than the expected number (exp_sweeps), as higher elevations were skipped.
# More info https://www.test.roc.noaa.gov/radar-techniques/avset.php
# https://www.test.roc.noaa.gov/public-documents/engineering-branch/new-technology/misc/avset/AVSET_AMS_RADAR_CONF_Final.pdf
if exp_sweeps > act_sweeps:
# Adjust nsweeps to the actual number of recorded sweeps
exp_sweeps = act_sweeps

Check warning on line 1723 in xradar/io/backends/nexrad_level2.py

View check run for this annotation

Codecov / codecov/patch

xradar/io/backends/nexrad_level2.py#L1723

Added line #L1723 was not covered by tests

sweeps = [f"sweep_{i}" for i in range(act_sweeps)]

sweep_dict = open_sweeps_as_dict(
filename_or_obj=filename_or_obj,
Expand All @@ -1745,8 +1744,6 @@
)
ls_ds: list[xr.Dataset] = [sweep_dict[sweep] for sweep in sweep_dict.keys()]
ls_ds.insert(0, xr.Dataset())
if comment is not None:
ls_ds[0].attrs["comment"] = comment
dtree: dict = {
"/": _assign_root(ls_ds),
"/radar_parameters": _get_subgroup(ls_ds, radar_parameters_subgroup),
Expand Down