From 665c5d4fa96d2217d202cff6b6a5bda9feb4c966 Mon Sep 17 00:00:00 2001 From: "K.-Michael Aye" Date: Fri, 8 Feb 2019 12:53:49 -0700 Subject: [PATCH] fix double occultations with different dimension names --- pyuvis/io.py | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/pyuvis/io.py b/pyuvis/io.py index 01acf22..3bf2e89 100644 --- a/pyuvis/io.py +++ b/pyuvis/io.py @@ -62,7 +62,7 @@ def waves(self): @property def xarray(self): - da = xr.DataArray(self.data) + return xr.DataArray(self.data) class FUV_PDS(QUBE): @@ -78,6 +78,7 @@ def __init__(self, fname, freq): self.freq = freq self.timestr = self.ds.start_time_str[:20] + "000" self.n_integrations = self.ds["integrations"].size + self.orig_dims = list(self.ds.dims.keys()) @property def start_time(self): @@ -96,6 +97,18 @@ def times(self): ) return times + @property + def spatial_dim(self): + for dim in self.orig_dims: + if dim.startswith("spatial_dim"): + return dim + + @property + def spectral_dim(self): + for dim in self.orig_dims: + if dim.startswith("spectral_dim"): + return dim + class HSP(UVIS_NetCDF): @@ -222,14 +235,14 @@ class FUV(UVIS_NetCDF): def __init__(self, fname, freq="1s"): super().__init__(fname, freq) - self.n_spec_bins = self.ds["spectral_dim_0"].size + self.n_spec_bins = self.ds[self.spectral_dim].size self.waves = np.linspace(self.wave_min, self.wave_max, self.n_spec_bins) self.ds["times"] = xr.DataArray(self.times.values, dims="integrations") - self.ds["wavelengths"] = xr.DataArray(self.waves, dims="spectral_dim_0") + self.ds["wavelengths"] = xr.DataArray(self.waves, dims=self.spectral_dim) self.ds = self.ds.swap_dims( - {"integrations": "times", "spectral_dim_0": "wavelengths"} + {"integrations": "times", self.spectral_dim: "wavelengths"} ) - self.ds = self.ds.rename({"window_0": "counts", "spatial_dim_0": "pixels"}) + self.ds = self.ds.rename({"window_0": "counts", self.spatial_dim: "pixels"}) @property def data(self):