Repository: climate Updated Branches: refs/heads/master 16f956a10 -> 9f3482714
CLIMATE-872 - spatial_regrid has a critical issue when longitude=180 exists inside the RCM domain - By checking monotonicity of the longitude before regridding, the issue is resolved. Project: http://git-wip-us.apache.org/repos/asf/climate/repo Commit: http://git-wip-us.apache.org/repos/asf/climate/commit/d43266c7 Tree: http://git-wip-us.apache.org/repos/asf/climate/tree/d43266c7 Diff: http://git-wip-us.apache.org/repos/asf/climate/diff/d43266c7 Branch: refs/heads/master Commit: d43266c7dd99042a12c7739dc22bebb9dc6b86af Parents: 16f956a Author: huikyole <huiky...@argo.jpl.nasa.gov> Authored: Fri Sep 9 20:19:27 2016 -0700 Committer: huikyole <huiky...@argo.jpl.nasa.gov> Committed: Fri Sep 9 20:19:27 2016 -0700 ---------------------------------------------------------------------- ocw/dataset_processor.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/climate/blob/d43266c7/ocw/dataset_processor.py ---------------------------------------------------------------------- diff --git a/ocw/dataset_processor.py b/ocw/dataset_processor.py index a41b9ce..0bc15ac 100755 --- a/ocw/dataset_processor.py +++ b/ocw/dataset_processor.py @@ -208,10 +208,14 @@ def spatial_regrid(target_dataset, new_latitudes, new_longitudes, else: new_lons = new_longitudes new_lats = new_latitudes - + ny_old, nx_old = lats.shape ny_new, nx_new = new_lats.shape + for iy in np.arange(ny_old): + if not all(x<y for x,y in zip(lons[iy,:], lons[iy,1:])): + lons[iy,:][lons[iy,:] <0] = lons[iy,:][lons[iy,:] <0]+360. + # Make masked array of shape (times, new_latitudes,new_longitudes) new_values = ma.zeros([len(target_dataset.times), ny_new, nx_new]) @@ -289,7 +293,7 @@ def spatial_regrid(target_dataset, new_latitudes, new_longitudes, # Regrid the data on each time slice for i in range(len(target_dataset.times)): - if len(target_dataset.times) == 1: + if len(target_dataset.times) == 1 and target_dataset.values.ndim == 2: values_original = ma.array(target_dataset.values) else: values_original = ma.array(target_dataset.values[i]) @@ -311,7 +315,6 @@ def spatial_regrid(target_dataset, new_latitudes, new_longitudes, qmdi_r = map_coordinates(qmdi, [new_lats_indices.flatten( ), new_lons_indices.flatten()], order=1).reshape(new_lats.shape) mdimask = (qmdi_r != 0.0) - # Combine missing data mask, with outside domain mask define above. new_values[i].mask = np.logical_or(mdimask, new_values[i].mask)