@@ -1694,8 +1694,6 @@ def open_nexradlevel2_datatree(
1694
1694
"""
1695
1695
from xarray .core .treenode import NodePath
1696
1696
1697
- comment = None
1698
-
1699
1697
if isinstance (sweep , str ):
1700
1698
sweep = NodePath (sweep ).name
1701
1699
sweeps = [sweep ]
@@ -1712,18 +1710,19 @@ def open_nexradlevel2_datatree(
1712
1710
)
1713
1711
else :
1714
1712
with NEXRADLevel2File (filename_or_obj , loaddata = False ) as nex :
1715
- nsweeps = nex .msg_5 ["number_elevation_cuts" ]
1716
- n_sweeps = len (nex .msg_31_data_header )
1717
- # check for zero (old files)
1718
- if nsweeps == 0 :
1719
- nsweeps = n_sweeps
1720
- comment = "No message 5 information available"
1721
- # Check if duplicated sweeps ("split cut mode")
1722
- elif nsweeps > n_sweeps :
1723
- nsweeps = n_sweeps
1724
- comment = "Split Cut Mode scanning strategy"
1725
-
1726
- sweeps = [f"sweep_{ i } " for i in range (nsweeps )]
1713
+ # Expected number of elevation cuts from the VCP definition
1714
+ exp_sweeps = nex .msg_5 ["number_elevation_cuts" ]
1715
+ # Actual number of sweeps recorded in the file
1716
+ act_sweeps = len (nex .msg_31_data_header )
1717
+ # Check for AVSET mode: If AVSET was active, the actual number of sweeps (act_sweeps)
1718
+ # will be fewer than the expected number (exp_sweeps), as higher elevations were skipped.
1719
+ # More info https://www.test.roc.noaa.gov/radar-techniques/avset.php
1720
+ # https://www.test.roc.noaa.gov/public-documents/engineering-branch/new-technology/misc/avset/AVSET_AMS_RADAR_CONF_Final.pdf
1721
+ if exp_sweeps > act_sweeps :
1722
+ # Adjust nsweeps to the actual number of recorded sweeps
1723
+ exp_sweeps = act_sweeps
1724
+
1725
+ sweeps = [f"sweep_{ i } " for i in range (act_sweeps )]
1727
1726
1728
1727
sweep_dict = open_sweeps_as_dict (
1729
1728
filename_or_obj = filename_or_obj ,
@@ -1745,8 +1744,6 @@ def open_nexradlevel2_datatree(
1745
1744
)
1746
1745
ls_ds : list [xr .Dataset ] = [sweep_dict [sweep ] for sweep in sweep_dict .keys ()]
1747
1746
ls_ds .insert (0 , xr .Dataset ())
1748
- if comment is not None :
1749
- ls_ds [0 ].attrs ["comment" ] = comment
1750
1747
dtree : dict = {
1751
1748
"/" : _assign_root (ls_ds ),
1752
1749
"/radar_parameters" : _get_subgroup (ls_ds , radar_parameters_subgroup ),
0 commit comments