Skip to content

added get_valid_midpoints to gridded forecast #137

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 24, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions csep/core/forecasts.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,20 @@ def get_longitudes(self):
""" Returns the lognitude of the lower left node of the spatial grid """
return self.region.origins()[:,0]

def get_valid_midpoints(self):
""" Returns the midpoints of the valid testing region

Returns:
lons (numpy.array), lats (numpy.array): two numpy arrays containing the valid midpoints from the forecast
"""
latitudes = []
longitudes = []
for idx in range(self.region.num_nodes):
if self.region.bbox_max[idx] == 0:
latitudes.append(self.region.midpoints()[idx,1])
longitudes.append(self.region.midpoints()[idx,0])
return numpy.array(longitudes), numpy.array(latitudes)

@property
def polygons(self):
return self.region.polygons
Expand Down
2 changes: 1 addition & 1 deletion csep/core/regions.py
Original file line number Diff line number Diff line change
Expand Up @@ -548,7 +548,7 @@ def __init__(self, polygons, dh, name='cartesian2d', mask=None):
self.name = name
a, xs, ys = self._build_bitmask_vec()
# in mask, True = bad value and False = good value
self.bbox_mask = a[:, :, 0]
self.bbox_mask = a[:,:,0]
# contains the mapping from polygon_index to the mask
self.idx_map = a[:,:,1]
# index values of polygons array into the 2d cartesian grid, based on the midpoint.
Expand Down