From 2d48cdd38cc9653a521dbfeea2bd41c352def306 Mon Sep 17 00:00:00 2001 From: "R.K.Garcia" <rkgarcia@wisc.edu> Date: Thu, 12 Oct 2017 17:44:39 -0500 Subject: [PATCH] more correct handling of band dimension in CMI and L1b still need better handling of multi-band possibility --- goesr/l1b.py | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/goesr/l1b.py b/goesr/l1b.py index 149fc7c..e7991f6 100644 --- a/goesr/l1b.py +++ b/goesr/l1b.py @@ -269,6 +269,7 @@ class PugFile(object): or a multi-band NetCDF4 file and an offset in the band dimension """ nc = None # if we opened the file for you, it's here + _band_offset = None band = None # band number central_wavelength = None # um platform_id = None # platform_ID as string @@ -276,7 +277,7 @@ class PugFile(object): time_span = None # (start,end) datetime pair timeline_id = None # string, instrument mode bit_depth = None # bit depth - shape_m = None # nadir-meter dy,dx approximation + shape_m = None # nadir-meter dy,dx approximation : FUTURE: deprecate this toward cell_size, too confusing vs .shape being whole array scene_id = None # string, type of scene e.g. "Full Disk" resolution = None # approximate nadir meters: 500, 1000, 2000, 4000 display_time = None # str form of timeline YYYY-mm-dd HH:MM @@ -305,15 +306,17 @@ class PugFile(object): :param primary_var_name: radiance variable to convert to BT/Refl :param band_offset: typically 0, eventually nonzero for multi-band files """ + # FUTURE: handle band dimension more effectively, including surveying metadata for multi-band files super(PugFile, self).__init__() if not isinstance(nc, nc4.Dataset): # then we can open and retain the file for our use nc = nc4.Dataset(nc) self.nc = nc self.primary_var_name = primary_var_name primary_var = nc[primary_var_name] + self._band_offset = band_offset self.band = int(nc['band_id'][band_offset]) # FUTURE: this has a band dimension self.nav = nc_nav_values(nc, primary_var_name) - self.shape = primary_var.shape + self.shape = primary_var.shape[-2:] self.platform_id = nc.platform_ID self.instrument_type = nc.instrument_type self.instrument_name = "ABI" if "Himawari" not in self.instrument_type else "AHI" @@ -591,14 +594,14 @@ class PugCmiTools(PugFile): def data(self): if None is self.nc: return None - return self.nc[self.primary_var_name][:, :].squeeze() + return self.nc[self.primary_var_name][self._band_offset, :, :].squeeze() @property def bt(self): if None is self.nc: return None if 'bt' == self.bt_or_refl: - return self.nc[self.primary_var_name][:,:].squeeze() + return self.nc[self.primary_var_name][self._band_offset,:,:].squeeze() LOG.warning('cannot request bt from non-emissive band') return None @@ -607,7 +610,7 @@ class PugCmiTools(PugFile): if None is self.nc: return None if 'refl' == self.bt_or_refl: - return self.nc[self.primary_var_name][:,:].squeeze() + return self.nc[self.primary_var_name][self._band_offset, :,:].squeeze() LOG.warning('cannot request refl from non-reflectance band') return None -- GitLab