You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Revisiting Steve Loch's subsetting edits for wrapped coordinates.
Merged in new develop.
Differences:
moved calculate_haversine_distance from coast.py to general_utils.py
Rewrite of coast/subset_indices_lonlat_box(self, lonbounds, latbounds). Now general_utils/subset_indices_lonlat_box(self, ww=np.NaN, ee=np.NaN, ss=np.NaN, nn=np.NaN) With new arguments.
preserved old structure (not sure if this is good practise or not):
Removed option of the cheap and dirty (and fast method):
def subset_indices_lonlat_box(self, lonbounds, latbounds):
"""Generates array indices for data which lies in a given lon/lat box.
Keyword arguments:
lon -- Longitudes, 1D or 2D.
lat -- Latitudes, 1D or 2D
lonbounds -- Array of form [min_longitude=-180, max_longitude=180]
latbounds -- Array of form [min_latitude, max_latitude]
return: Indices corresponding to datapoints inside specified box
"""
debug(f"Subsetting {get_slug(self)} indices within lon/lat")
lon_str = "longitude"
lat_str = "latitude"
lon = self.dataset[lon_str].copy() # TODO Add a comment explaining why this needs to be copied
lat = self.dataset[lat_str]
ff = lon > lonbounds[0]
ff *= lon < lonbounds[1]
ff *= lat > latbounds[0]
ff *= lat < latbounds[1]
return np.where(ff)
Added some examples scripts:
example_scripts/subsetting_by_lon_lat.py (Requires no input data) example_scripts/find_models_nearest_point.py (Requires input data)
The text was updated successfully, but these errors were encountered:
Revisiting Steve Loch's subsetting edits for wrapped coordinates.
Merged in new
develop
.Differences:
moved calculate_haversine_distance from
coast.py
togeneral_utils.py
Rewrite of
coast/subset_indices_lonlat_box(self, lonbounds, latbounds)
. Nowgeneral_utils/subset_indices_lonlat_box(self, ww=np.NaN, ee=np.NaN, ss=np.NaN, nn=np.NaN)
With new arguments.preserved old structure (not sure if this is good practise or not):
example_scripts/subsetting_by_lon_lat.py
(Requires no input data)example_scripts/find_models_nearest_point.py
(Requires input data)The text was updated successfully, but these errors were encountered: