Skip to content

Commit

Permalink
change GeoDatasetRead.get_lonlat_arrays to work for an older file; up…
Browse files Browse the repository at this point in the history
…date tests
  • Loading branch information
tdcwilliams committed Apr 19, 2024
1 parent 821527c commit 11ebbf7
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 10 deletions.
14 changes: 7 additions & 7 deletions geodataset/geodataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -427,15 +427,15 @@ def get_lonlat_arrays(self, ij_range=(None, None, None, None), **kwargs):
lat : numpy.ndarray
2D array with latitude
"""
if not self.is_lonlat_dim:
return [
self.get_variable_array(name, ij_range=ij_range)
for name in self.lonlat_names]
lon_name, lat_name = self.lonlat_names
lon = self.variables[lon_name]
lat = self.variables[lat_name]
i0, i1, j0, j1 = ij_range
lon = self[lon_name][j0:j1]
lat = self[lat_name][i0:i1]
return np.meshgrid(lon, lat)
slat = slice(i0, i1)
slon = slice(j0, j1)
if lon.ndim == 2:
return [a[slat, slon] for a in (lon, lat)]
return np.meshgrid(lon[slon], lat[slat])

def get_area_euclidean(self, mapping, **kwargs):
"""
Expand Down
4 changes: 2 additions & 2 deletions geodataset/tests/test_custom_geodataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@
import pyproj
from pyproj.exceptions import CRSError

from geodataset.custom_geodataset import UniBremenAlbedoMPF
from geodataset.custom_geodataset import UniBremenAlbedoMPF, NERSCProductBase

from geodataset.utils import InvalidDatasetError
from geodataset.tests.base_for_tests import BaseForTests


class UniBremenAlbedoMPFBaseTest(BaseForTests):
class UniBremenAlbedoMPFTest(BaseForTests):

def test_get_xy_arrays_1(self):
""" test get_xy_arrays with default options """
Expand Down
2 changes: 1 addition & 1 deletion geodataset/tests/test_geodataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ def setUp(self):
self.moorings_var = 'sic'
# ECMWF forecast file - lon,lat are dims
self.ec2_file = os.path.join(os.environ['TEST_DATA_DIR'],
"ec2_start20220401.nc")
"ec2_start20240401.nc")


class GeoDatasetBaseTest(GeodatasetTestBase):
Expand Down

0 comments on commit 11ebbf7

Please sign in to comment.