Skip to content
Snippets Groups Projects
Commit e3a51b48 authored by Bruce Flynn's avatar Bruce Flynn
Browse files

rdrgen Fix attr comparison issues, support additional mission names

parent bb6b5e6d
No related branches found
No related tags found
No related merge requests found
......@@ -294,6 +294,14 @@ class BinnedTemporaryFileManager(object):
shutil.rmtree(self.dir)
missions = {
"npp": "S-NPP/JPSS",
"snpp": "S-NPP/JPSS",
"j01": "NOAA-20/JPSS",
"jpss1": "NOAA-20/JPSS",
"noaa20": "NOAA-20/JPSS",
}
class RdrWriter(object):
def __init__(
self,
......@@ -341,7 +349,7 @@ class RdrWriter(object):
self._h5_file,
{
"Distributor": distributor,
"Mission_Name": "S-NPP/JPSS", # FIXME: what will this be for J1?
"Mission_Name": missions[self.sat],
"N_Dataset_Source": origin,
"N_HDF_Creation_Date": self._format_date_attr(self._creation_time),
"N_HDF_Creation_Time": self._format_time_attr(self._creation_time),
......@@ -443,13 +451,21 @@ class RdrWriter(object):
@staticmethod
def _set_h5_attrs(h5_obj, attrs):
attrs = _encodeall(attrs)
def tpcnv(v):
if isinstance(v, list):
return [tpcnv(x) for x in v]
elif isinstance(v, str):
return np.array(v.encode('ascii'), dtype="S")
elif isinstance(v, bytes):
return np.array(v, dtype="S")
return v
# for some reason all the H5 attributes are in 2-D arrays in IDPS files
for name, value in attrs.items():
if isinstance(value, list):
value = [[x] for x in value]
else:
value = [[value]]
h5_obj.attrs[name] = value
h5_obj.attrs[name] = tpcnv(value)
@staticmethod
def _format_date_attr(t):
......
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