Skip to content

Commit 665c5d4

Browse files
committed
fix double occultations with different dimension names
1 parent 770e3f9 commit 665c5d4

File tree

1 file changed

+18
-5
lines changed

1 file changed

+18
-5
lines changed

pyuvis/io.py

+18-5
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ def waves(self):
6262

6363
@property
6464
def xarray(self):
65-
da = xr.DataArray(self.data)
65+
return xr.DataArray(self.data)
6666

6767

6868
class FUV_PDS(QUBE):
@@ -78,6 +78,7 @@ def __init__(self, fname, freq):
7878
self.freq = freq
7979
self.timestr = self.ds.start_time_str[:20] + "000"
8080
self.n_integrations = self.ds["integrations"].size
81+
self.orig_dims = list(self.ds.dims.keys())
8182

8283
@property
8384
def start_time(self):
@@ -96,6 +97,18 @@ def times(self):
9697
)
9798
return times
9899

100+
@property
101+
def spatial_dim(self):
102+
for dim in self.orig_dims:
103+
if dim.startswith("spatial_dim"):
104+
return dim
105+
106+
@property
107+
def spectral_dim(self):
108+
for dim in self.orig_dims:
109+
if dim.startswith("spectral_dim"):
110+
return dim
111+
99112

100113
class HSP(UVIS_NetCDF):
101114

@@ -222,14 +235,14 @@ class FUV(UVIS_NetCDF):
222235

223236
def __init__(self, fname, freq="1s"):
224237
super().__init__(fname, freq)
225-
self.n_spec_bins = self.ds["spectral_dim_0"].size
238+
self.n_spec_bins = self.ds[self.spectral_dim].size
226239
self.waves = np.linspace(self.wave_min, self.wave_max, self.n_spec_bins)
227240
self.ds["times"] = xr.DataArray(self.times.values, dims="integrations")
228-
self.ds["wavelengths"] = xr.DataArray(self.waves, dims="spectral_dim_0")
241+
self.ds["wavelengths"] = xr.DataArray(self.waves, dims=self.spectral_dim)
229242
self.ds = self.ds.swap_dims(
230-
{"integrations": "times", "spectral_dim_0": "wavelengths"}
243+
{"integrations": "times", self.spectral_dim: "wavelengths"}
231244
)
232-
self.ds = self.ds.rename({"window_0": "counts", "spatial_dim_0": "pixels"})
245+
self.ds = self.ds.rename({"window_0": "counts", self.spatial_dim: "pixels"})
233246

234247
@property
235248
def data(self):

0 commit comments

Comments
 (0)