diff --git a/pyremap/test/test_interpolate.py b/pyremap/test/test_interpolate.py index 15c5136..1d107d6 100644 --- a/pyremap/test/test_interpolate.py +++ b/pyremap/test/test_interpolate.py @@ -69,13 +69,16 @@ def get_stereographic_array_descriptor(self): '+lon_0=0.0 +k_0=1.0 +x_0=0.0 +y_0=0.0 ' '+ellps=WGS84') - # a square 61x61 cell map with 100 km resolution and + # a 61x51 cell map with 100 km resolution and xMax = 3000e3 + yMax = 2500e3 res = 100e3 nx = 2 * int(xMax / res) + 1 + ny = 2 * int(yMax / res) + 1 x = numpy.linspace(-xMax, xMax, nx) + y = numpy.linspace(-yMax, yMax, ny) meshName = '{}km_Antarctic_stereo'.format(int(res * 1e-3)) - descriptor = ProjectionGridDescriptor.create(projection, x, x, + descriptor = ProjectionGridDescriptor.create(projection, x, y, meshName) return descriptor @@ -101,6 +104,9 @@ def check_remap(self, inFileName, outFileName, refFileName, remapper, remap_file=True): dsRef = xarray.open_dataset(refFileName) + for var in ['lat_bnds', 'lon_bnds', 'gw', 'area', 'nvertices']: + if var in dsRef: + dsRef = dsRef.drop_vars([var]) if remap_file: # first, test interpolation with ncremap remapper.remap_file(inFileName=inFileName, @@ -111,8 +117,9 @@ def check_remap(self, inFileName, outFileName, refFileName, remapper, dsRemapped = xarray.open_dataset(outFileName) # drop some extra vairables added by ncremap that aren't in the # reference data set - dsRemapped = dsRemapped.drop_vars(['lat_bnds', 'lon_bnds', 'gw', - 'area']) + for var in ['lat_bnds', 'lon_bnds', 'gw', 'area', 'nvertices']: + if var in dsRemapped: + dsRemapped = dsRemapped.drop_vars([var]) self.assertDatasetApproxEqual(dsRemapped, dsRef) # now, try in-memory remapping @@ -120,7 +127,7 @@ def check_remap(self, inFileName, outFileName, refFileName, remapper, dsRemapped = remapper.remap(ds, self.renormalizationThreshold) self.assertDatasetApproxEqual(dsRemapped, dsRef) - def test_mpas_to_latlon_file(self): + def test_mpas_to_latlon(self): ''' test horizontal interpolation from an MPAS mesh to a destination lat/lon grid determined from a file containing 'lat' and 'lon' coords @@ -130,7 +137,7 @@ def test_mpas_to_latlon_file(self): ''' weightFileName, outFileName, refFileName = \ - self.get_file_names(suffix='mpas_to_latlon_file') + self.get_file_names(suffix='mpas_to_latlon') sourceDescriptor, mpasMeshFileName, timeSeriesFileName = \ self.get_mpas_descriptor() @@ -142,27 +149,6 @@ def test_mpas_to_latlon_file(self): self.check_remap(timeSeriesFileName, outFileName, refFileName, remapper, remap_file=True) - def test_mpas_to_latlon_array(self): - ''' - test horizontal interpolation from an MPAS mesh to a destination - lat/lon grid determined from config options 'lat' and 'lon'. - - Xylar Asay-Davis - 04/06/2017 - ''' - - weightFileName, outFileName, refFileName = \ - self.get_file_names(suffix='mpas_to_latlon_array') - - sourceDescriptor, mpasMeshFileName, timeSeriesFileName = \ - self.get_mpas_descriptor() - destinationDescriptor = self.get_latlon_array_descriptor() - - remapper = self.build_remapper(sourceDescriptor, destinationDescriptor, - weightFileName) - self.check_remap(timeSeriesFileName, outFileName, refFileName, - remapper, remap_file=True) - def test_latlon_file_to_latlon_array(self): ''' test horizontal interpolation from a lat/lon grid to a destination @@ -184,7 +170,7 @@ def test_latlon_file_to_latlon_array(self): self.check_remap(latLonGridFileName, outFileName, refFileName, remapper, remap_file=True) - def test_mpas_to_stereographic_array(self): + def test_mpas_to_stereographic(self): ''' test horizontal interpolation from an MPAS mesh to a destination stereographic grid. @@ -194,7 +180,7 @@ def test_mpas_to_stereographic_array(self): ''' weightFileName, outFileName, refFileName = \ - self.get_file_names(suffix='mpas_to_stereographic_array') + self.get_file_names(suffix='mpas_to_stereographic') sourceDescriptor, mpasMeshFileName, timeSeriesFileName = \ self.get_mpas_descriptor() @@ -206,9 +192,9 @@ def test_mpas_to_stereographic_array(self): # ncremap doesn't support stereographic grids so just check the # Remapper self.check_remap(timeSeriesFileName, outFileName, refFileName, - remapper, remap_file=False) + remapper, remap_file=True) - def test_latlon_file_to_stereographic_array(self): + def test_latlon_to_stereographic(self): ''' test horizontal interpolation from a lat/lon grid to a destination stereographic grid. @@ -218,7 +204,7 @@ def test_latlon_file_to_stereographic_array(self): ''' weightFileName, outFileName, refFileName = \ - self.get_file_names(suffix='latlon_file_to_stereographic_array') + self.get_file_names(suffix='latlon_to_stereographic') sourceDescriptor, latLonGridFileName = \ self.get_latlon_file_descriptor() @@ -230,7 +216,7 @@ def test_latlon_file_to_stereographic_array(self): # ncremap doesn't support stereographic grids so just check the # Remapper self.check_remap(latLonGridFileName, outFileName, refFileName, - remapper, remap_file=False) + remapper, remap_file=True) def test_stereographic_array_to_latlon_array(self): ''' @@ -243,7 +229,7 @@ def test_stereographic_array_to_latlon_array(self): ''' weightFileName, outFileName, refFileName = \ - self.get_file_names(suffix='stereographic_array_to_latlon_array') + self.get_file_names(suffix='stereographic_to_latlon') sourceDescriptor = self.get_stereographic_array_descriptor() destinationDescriptor = self.get_latlon_array_descriptor() @@ -256,10 +242,10 @@ def test_stereographic_array_to_latlon_array(self): inField = inField.repeat(3, axis=0) inField = inField.repeat(2, axis=3) - datasetDict = {'dims': ('dim0', 'x', 'y', 'dim3'), + datasetDict = {'dims': ('dim0', 'y', 'x', 'dim3'), 'coords': sourceDescriptor.coords, 'data_vars': {'complicated': - {'dims': ('dim0', 'x', 'y', 'dim3'), + {'dims': ('dim0', 'y', 'x', 'dim3'), 'data': inField}}} ds = xarray.Dataset.from_dict(datasetDict) diff --git a/pyremap/test/test_interpolate/ref_latlon_file_to_stereographic_array.nc b/pyremap/test/test_interpolate/ref_latlon_file_to_stereographic_array.nc deleted file mode 100644 index 7546584..0000000 Binary files a/pyremap/test/test_interpolate/ref_latlon_file_to_stereographic_array.nc and /dev/null differ diff --git a/pyremap/test/test_interpolate/ref_latlon_to_stereographic.nc b/pyremap/test/test_interpolate/ref_latlon_to_stereographic.nc new file mode 100644 index 0000000..8358182 Binary files /dev/null and b/pyremap/test/test_interpolate/ref_latlon_to_stereographic.nc differ diff --git a/pyremap/test/test_interpolate/ref_mpas_to_latlon_file.nc b/pyremap/test/test_interpolate/ref_mpas_to_latlon.nc similarity index 100% rename from pyremap/test/test_interpolate/ref_mpas_to_latlon_file.nc rename to pyremap/test/test_interpolate/ref_mpas_to_latlon.nc diff --git a/pyremap/test/test_interpolate/ref_mpas_to_latlon_array.nc b/pyremap/test/test_interpolate/ref_mpas_to_latlon_array.nc deleted file mode 100644 index a577ba9..0000000 Binary files a/pyremap/test/test_interpolate/ref_mpas_to_latlon_array.nc and /dev/null differ diff --git a/pyremap/test/test_interpolate/ref_mpas_to_stereographic.nc b/pyremap/test/test_interpolate/ref_mpas_to_stereographic.nc new file mode 100644 index 0000000..306f09b Binary files /dev/null and b/pyremap/test/test_interpolate/ref_mpas_to_stereographic.nc differ diff --git a/pyremap/test/test_interpolate/ref_mpas_to_stereographic_array.nc b/pyremap/test/test_interpolate/ref_mpas_to_stereographic_array.nc deleted file mode 100644 index 701b277..0000000 Binary files a/pyremap/test/test_interpolate/ref_mpas_to_stereographic_array.nc and /dev/null differ diff --git a/pyremap/test/test_interpolate/ref_stereographic_array_to_latlon_array.nc b/pyremap/test/test_interpolate/ref_stereographic_to_latlon.nc similarity index 82% rename from pyremap/test/test_interpolate/ref_stereographic_array_to_latlon_array.nc rename to pyremap/test/test_interpolate/ref_stereographic_to_latlon.nc index 9ae40fb..ee09d82 100644 Binary files a/pyremap/test/test_interpolate/ref_stereographic_array_to_latlon_array.nc and b/pyremap/test/test_interpolate/ref_stereographic_to_latlon.nc differ