Commit cd2b33e1 authored by R.K.Garcia's avatar R.K.Garcia
Browse files

add observation_area and processing_center_name to metadata; returns empty for HCAST currently

parent 8896fd27
......@@ -113,6 +113,8 @@ struct HimawariMetadata {
int resolution;
int32_t wmo_sat_id;
char satellite_name[17];
char processing_center_name[17];
char observation_area[5];
};
......
......@@ -22,6 +22,7 @@ __docformat__ = 'reStructuredText'
import os, sys
import logging, unittest, argparse
from functools import reduce
from pycparser import c_ast, parse_file
LOG = logging.getLogger(__name__)
......
......@@ -233,7 +233,7 @@ class HimawariAHIasCMIP(object):
@property
def resolution_nadir_meters(self):
meta = self.hs.metadata
meta = self._hs.metadata
lres, cres = meta.lines_res_meters, meta.columns_res_meters
res = min(lres, cres)
if res <= 0:
......@@ -262,11 +262,8 @@ class HimawariAHIasCMIP(object):
@property
def datetime_range(self):
meta = self._hs.metadata
when = datetime(meta.year, meta.month, meta.day, meta.hour, meta.minute, meta.second, meta.microsecond)
_, line_times = self._hs.line_times
min_sec_offset = np.nanmin(line_times)
max_sec_offset = np.nanmax(line_times)
return when + timedelta(seconds=min_sec_offset), when + timedelta(seconds=max_sec_offset)
when = lambda davros: datetime(davros.year, davros.month, davros.day, davros.hour, davros.minute, davros.second, davros.microsecond)
return when(meta.start_time), when(meta.end_time)
@property
def _pug_global_attrs(self):
......@@ -415,7 +412,7 @@ class HimawariAHIasCMIP(object):
yield self.p('band_id'), band, self.d(DEFAULT_BAND_DIM_NAME), a
def __call__(self):
def __iter__(self):
"""
iterate PVDA frames equivalent to a PUG nc_walk
"""
......@@ -441,15 +438,21 @@ class HimawariAHIasCMIP(object):
PATH_TEST_DATA = os.environ.get('TEST_DATA', os.path.expanduser("~/Data/test_files/thing.dat"))
PATH_TEST_DATA = os.environ.get('TEST_DATA', os.path.expanduser("~/Data/himawari/sample_bz2/HS_H08_20130710_0300_B16"))
class tests(unittest.TestCase):
def setUp(self):
pass
def test_something(self):
pass
def test_pvda_iterate(self):
from goesr.rockfall import debug
chimp = HimawariAHIasCMIP(PATH_TEST_DATA)
n_frames = 0
for stuff in debug(chimp):
n_frames += 1
print("%d frames" % n_frames)
def _debug(type, value, tb):
......
......@@ -105,6 +105,8 @@ struct HimawariMetadata {
int resolution;
int32_t wmo_sat_id; /* http://www.wmo-sat.info/oscar/satellites */
char satellite_name[17];
char processing_center_name[17];
char observation_area[5];
};
......
......@@ -78,7 +78,12 @@ public:
virtual int calibration(HimawariCalibration &) const = 0;
virtual std::string satelliteName() const = 0;
virtual std::string processingCenterName() const {
return std::string();
}
virtual std::string observationArea() const {
return std::string();
}
// IMPORTANT: All offsets and strides in copy_____() routines are zero-based and relative to the file! i.e. they are not one-based scene coordinates!
......
......@@ -1078,6 +1078,13 @@ public:
return trimmed_string(hsd->basic->satellite_name, sizeof(hsd->basic->satellite_name));
}
virtual std::string observationArea() const {
return trimmed_string(hsd->basic->observation_area, sizeof(hsd->basic->observation_area));
}
virtual std::string processingCenterName() const {
return trimmed_string(hsd->basic->processing_center_name, sizeof(hsd->basic->processing_center_name));
}
virtual int navigation(HimawariNavigation &nav) const {
bzero(&nav, sizeof(nav));
......
......@@ -1016,6 +1016,8 @@ int queryHimawariSceneMetadata(const struct HimawariScene *it, struct HimawariMe
out->available_lines = it->available_lines();
out->wmo_sat_id = wmo_sat_id_for_name(strip(&out->satellite_name[0], &out->satellite_name[16]));
strncpy(out->processing_center_name, firstFile->processingCenterName().c_str(), 17);
strncpy(out->observation_area, firstFile->observationArea().c_str(), 5);
return 0;
}
......
......@@ -77,6 +77,8 @@ module hsd_structs
integer(c_int) :: resolution = 0
integer(c_int32_t) :: wmo_sat_id = 0
character(c_char) :: satellite_name(17)
character(c_char) :: processing_center_name(17)
character(c_char) :: observation_area(5)
end type hsd_metadata
type, bind(c) :: hsd_source
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment