Skip to content
Snippets Groups Projects
Commit 2d48cdd3 authored by Ray Garcia's avatar Ray Garcia :scream_cat:
Browse files

more correct handling of band dimension in CMI and L1b

still need better handling of multi-band possibility
parent 59deb1bc
No related branches found
Tags v20171013
No related merge requests found
......@@ -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
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment