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

caching of navigation speeds up cmi_changer a LOT

parent 23fb0bcc
No related merge requests found
......@@ -51,6 +51,9 @@ class HimawariAHIasCMIP(object):
_data_name = DEFAULT_CMIP_NAME
_projection_name = DEFAULT_CMIP_PROJECTION_NAME
_when = None
y = None
x = None
shape_m = None
def __init__(self, path, as_radiances=False, data_name=None):
"""
......@@ -68,6 +71,10 @@ class HimawariAHIasCMIP(object):
data_name = DEFAULT_CMIP_NAME if not as_radiances else DEFAULT_CMIP_RAD_NAME
self._data_name = data_name
self._when = datetime.utcnow()
# cache the y and x angles
self.y = self._y
self.x = self._x
self.shape_m = self._shape_m
def p(self, *strings):
return (self.path,) + tuple(strings)
......@@ -590,7 +597,7 @@ class HimawariAHIasCMIP(object):
return self._hs.radiances()
@property
def y(self):
def _y(self):
"""
negate y values to match PUG convention
also see yx_pvda regarding negation of scale_factor and add_offset to keep monotonic increasing unscaled values
......@@ -600,7 +607,7 @@ class HimawariAHIasCMIP(object):
return -y.squeeze()
@property
def x(self):
def _x(self):
_, x = self._hs.coords(lines=1)
return x.squeeze()
......@@ -633,7 +640,7 @@ class HimawariAHIasCMIP(object):
return np.require(self.x, dtype=np.float64) * self.perspective_point_height
@property
def shape_m(self):
def _shape_m(self):
"""
:return: (y, x) nadir-meters nominal size of a cell
"""
......@@ -641,7 +648,9 @@ class HimawariAHIasCMIP(object):
h = self.perspective_point_height
return mb.my * h, mb.mx * h
cell_size = shape_m
@property
def cell_size(self):
return self.shape_m
@property
def origin(self):
......
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