diff --git a/pyart/xradar/accessor.py b/pyart/xradar/accessor.py index e79a1bcb15..e64d30b802 100644 --- a/pyart/xradar/accessor.py +++ b/pyart/xradar/accessor.py @@ -275,17 +275,26 @@ def __init__(self, xradar, default_sweep="sweep_0", scan_type=None): self.nsweeps = len(self.sweep_group_names) self.combined_sweeps = self._combine_sweeps() self.fields = self._find_fields(self.combined_sweeps) + + # Check to see if the time is multidimensional - if it is, collapse it + if len(self.combined_sweeps.time.dims) > 1: + time = self.combined_sweeps.time.isel(range=0) + else: + time = self.combined_sweeps.time self.time = dict( - data=(self.combined_sweeps.time - self.combined_sweeps.time.min()).astype( - "int64" - ) - / 1e9, + data=(time - time.min()).astype("int64").values / 1e9, units=f"seconds since {pd.to_datetime(self.combined_sweeps.time.min().values).strftime('%Y-%m-%d %H:%M:%S.0')}", calendar="gregorian", ) self.range = dict(data=self.combined_sweeps.range.values) self.azimuth = dict(data=self.combined_sweeps.azimuth.values) self.elevation = dict(data=self.combined_sweeps.elevation.values) + # Check to see if the time is multidimensional - if it is, collapse it + if len(self.combined_sweeps.sweep_fixed_angle.dims) > 1: + self.combined_sweeps["sweep_fixed_angle"] = ( + "sweep_number", + np.unique(self.combined_sweeps.sweep_fixed_angle), + ) self.fixed_angle = dict(data=self.combined_sweeps.sweep_fixed_angle.values) self.antenna_transition = None self.latitude = dict( @@ -590,6 +599,10 @@ def _combine_sweeps(self): # Stack the sweep number and azimuth together stacked = merged.stack(gates=["sweep_number", "azimuth"]).transpose() + # Select the valid azimuths + good_azimuths = stacked.time.dropna("gates", how="all").gates + stacked = stacked.sel(gates=good_azimuths) + # Drop the missing gates cleaned = stacked.where(stacked.time == stacked.time.dropna("gates"))