From e26e98c41125d19f22252343d5fedb47b43da446 Mon Sep 17 00:00:00 2001 From: ctena Date: Thu, 12 Jan 2023 15:53:44 +0100 Subject: [PATCH 1/3] Preparing release v1.0.1 --- CHANGELOG.md | 10 +++++++++- nes/__init__.py | 4 ++-- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2873313..20473a1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,13 @@ # NES CHANGELOG +### 1.0.1 +* Release date: 2023/01/18 +* Changes and new features: + * Horizontal Interpolation: Lat-Lon to cartesian method improved (aligned with PROVIDENTIA) + * NetCDF metadata: level.positive attribute used properly. + * Vertical Interpolation: will switch from 'up' to 'down' if vertical direction is reversed in that process. + + ### 1.0.0 * Release date: 2022/11/24 * Changes and new features: @@ -12,7 +20,7 @@ * Mercator * Points * Points in GHOST format - * Points in Providentia format + * Points in PROVIDENTIA format * Parallelization: * Balanced / Unbalanced * By time axis diff --git a/nes/__init__.py b/nes/__init__.py index 5cdf04d..13543cf 100644 --- a/nes/__init__.py +++ b/nes/__init__.py @@ -1,5 +1,5 @@ -__date__ = "2022-11-24" -__version__ = "1.0.0" +__date__ = "2023-01-18" +__version__ = "1.0.1" from .load_nes import open_netcdf, concatenate_netcdfs from .create_nes import create_nes, from_shapefile -- GitLab From d086cb8c2a299f6bd9beb6b5186536c99c44e847 Mon Sep 17 00:00:00 2001 From: ctena Date: Thu, 12 Jan 2023 16:45:59 +0100 Subject: [PATCH 2/3] Added Error message when trying to vertically interpolate a 1D data --- nes/interpolation/vertical_interpolation.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/nes/interpolation/vertical_interpolation.py b/nes/interpolation/vertical_interpolation.py index 88f8fb5..c767d0b 100644 --- a/nes/interpolation/vertical_interpolation.py +++ b/nes/interpolation/vertical_interpolation.py @@ -44,7 +44,8 @@ def interpolate_vertical(self, new_levels, new_src_vertical=None, kind='linear', info: None, bool Indicates if you want to print extra information. """ - + if len(self.lev) == 1: + raise RuntimeError("1D data cannot be vertically interpolated.") if info is None: info = self.info -- GitLab From 461efdc435eb32448c96388384384829a9f82b65 Mon Sep 17 00:00:00 2001 From: ctena Date: Thu, 19 Jan 2023 17:54:11 +0100 Subject: [PATCH 3/3] Changed name of folder --- nes/{interpolation => methods}/__init__.py | 0 .../horizontal_interpolation.py | 14 +++++++------- .../vertical_interpolation.py | 8 ++++---- nes/nc_projections/default_nes.py | 14 +++++++------- nes/nes_formats/cams_ra_format.py | 2 +- 5 files changed, 19 insertions(+), 19 deletions(-) rename nes/{interpolation => methods}/__init__.py (100%) rename nes/{interpolation => methods}/horizontal_interpolation.py (97%) rename nes/{interpolation => methods}/vertical_interpolation.py (96%) diff --git a/nes/interpolation/__init__.py b/nes/methods/__init__.py similarity index 100% rename from nes/interpolation/__init__.py rename to nes/methods/__init__.py diff --git a/nes/interpolation/horizontal_interpolation.py b/nes/methods/horizontal_interpolation.py similarity index 97% rename from nes/interpolation/horizontal_interpolation.py rename to nes/methods/horizontal_interpolation.py index fac15bd..b5d5d18 100644 --- a/nes/interpolation/horizontal_interpolation.py +++ b/nes/methods/horizontal_interpolation.py @@ -16,7 +16,7 @@ import pyproj def interpolate_horizontal(self, dst_grid, weight_matrix_path=None, kind='NearestNeighbour', n_neighbours=4, info=False, to_providentia=False): """ - Horizontal interpolation from one grid to another one. + Horizontal methods from one grid to another one. Parameters ---------- @@ -27,11 +27,11 @@ def interpolate_horizontal(self, dst_grid, weight_matrix_path=None, kind='Neares weight_matrix_path : str, None Path to the weight matrix to read/create. kind : str - Kind of horizontal interpolation. Accepted values: ['NearestNeighbour']. + Kind of horizontal methods. Accepted values: ['NearestNeighbour']. n_neighbours : int Used if kind == NearestNeighbour. Number of nearest neighbours to interpolate. Default: 4. info : bool - Indicates if you want to print extra info during the interpolation process. + Indicates if you want to print extra info during the methods process. to_providentia : bool Indicates if we want the interpolated grid in Providentia format. """ @@ -65,7 +65,7 @@ def interpolate_horizontal(self, dst_grid, weight_matrix_path=None, kind='Neares # Apply weights for var_name, var_info in self.variables.items(): if info and self.master: - print("\t{var} horizontal interpolation".format(var=var_name)) + print("\t{var} horizontal methods".format(var=var_name)) sys.stdout.flush() src_shape = var_info['data'].shape if isinstance(dst_grid, nes.PointsNes): @@ -174,7 +174,7 @@ def get_weights_idx_t_axis(self, dst_grid, weight_matrix_path, kind, n_neighbour weight_matrix_path : str, None Path to the weight matrix to read/create. kind : str - Kind of horizontal interpolation. Accepted values: ['NearestNeighbour']. + Kind of horizontal methods. Accepted values: ['NearestNeighbour']. n_neighbours : int Used if kind == NearestNeighbour. Number of nearest neighbours to interpolate. Default: 4. @@ -244,7 +244,7 @@ def get_weights_idx_xy_axis(self, dst_grid, weight_matrix_path, kind, n_neighbou weight_matrix_path : str, None Path to the weight matrix to read/create. kind : str - Kind of horizontal interpolation. Accepted values: ['NearestNeighbour'] + Kind of horizontal methods. Accepted values: ['NearestNeighbour'] n_neighbours : int Used if kind == NearestNeighbour. Number of nearest neighbours to interpolate. Default: 4. @@ -355,7 +355,7 @@ def create_nn_weight_matrix(self, dst_grid, n_neighbours=4, info=False): n_neighbours : int Used if kind == NearestNeighbour. Number of nearest neighbours to interpolate. Default: 4. info: bool - Indicates if you want to print extra info during the interpolation process. + Indicates if you want to print extra info during the methods process. Returns ------- diff --git a/nes/interpolation/vertical_interpolation.py b/nes/methods/vertical_interpolation.py similarity index 96% rename from nes/interpolation/vertical_interpolation.py rename to nes/methods/vertical_interpolation.py index c767d0b..40d9c87 100644 --- a/nes/interpolation/vertical_interpolation.py +++ b/nes/methods/vertical_interpolation.py @@ -28,7 +28,7 @@ def add_4d_vertical_info(self, info_to_add): def interpolate_vertical(self, new_levels, new_src_vertical=None, kind='linear', extrapolate=None, info=None): """ - Vertical interpolation method. + Vertical methods method. Parameters ---------- @@ -38,7 +38,7 @@ def interpolate_vertical(self, new_levels, new_src_vertical=None, kind='linear', List of new vertical levels. new_src_vertical kind : str - Vertical interpolation type. + Vertical methods type. extrapolate : None, tuple, str Extrapolate method (for non linear operations). info: None, bool @@ -107,7 +107,7 @@ def interpolate_vertical(self, new_levels, new_src_vertical=None, kind='linear', if flip: self.variables[var_name]['data'] = np.flip(self.variables[var_name]['data'], axis=1) if info and self.master: - print("\t{var} vertical interpolation".format(var=var_name)) + print("\t{var} vertical methods".format(var=var_name)) sys.stdout.flush() nt, nz, ny, nx = self.variables[var_name]['data'].shape dst_data = np.empty((nt, nz_new, ny, nx), dtype=self.variables[var_name]['data'].dtype) @@ -134,7 +134,7 @@ def interpolate_vertical(self, new_levels, new_src_vertical=None, kind='linear', else: fill_value = extrapolate - # We force the interpolation with float64 to avoid negative values + # We force the methods with float64 to avoid negative values # We don't know why the negatives appears with float34 if current_level: # 1D vertical component diff --git a/nes/nc_projections/default_nes.py b/nes/nc_projections/default_nes.py index 5931073..9cb6328 100644 --- a/nes/nc_projections/default_nes.py +++ b/nes/nc_projections/default_nes.py @@ -16,8 +16,8 @@ import geopandas as gpd from shapely.geometry import Polygon from copy import deepcopy, copy import datetime -from ..interpolation import vertical_interpolation -from ..interpolation import horizontal_interpolation +from ..methods import vertical_interpolation +from ..methods import horizontal_interpolation from ..nes_formats import to_netcdf_cams_ra from ..nc_projections import * @@ -2829,7 +2829,7 @@ class Nes(object): def interpolate_vertical(self, new_levels, new_src_vertical=None, kind='linear', extrapolate=None, info=None): """ - Vertical interpolation method. + Vertical methods method. Parameters ---------- @@ -2839,7 +2839,7 @@ class Nes(object): List of new vertical levels. new_src_vertical kind : str - Vertical interpolation type. + Vertical methods type. extrapolate : None, tuple, str Extrapolate method (for non linear operations). info: None, bool @@ -2852,7 +2852,7 @@ class Nes(object): def interpolate_horizontal(self, dst_grid, weight_matrix_path=None, kind='NearestNeighbour', n_neighbours=4, info=False, to_providentia=False): """ - Horizontal interpolation from the current grid to another one. + Horizontal methods from the current grid to another one. Parameters ---------- @@ -2861,11 +2861,11 @@ class Nes(object): weight_matrix_path : str, None Path to the weight matrix to read/create. kind : str - Kind of horizontal interpolation. choices = ['NearestNeighbour']. + Kind of horizontal methods. choices = ['NearestNeighbour']. n_neighbours: int Used if kind == NearestNeighbour. Number of nearest neighbours to interpolate. Default: 4. info: bool - Indicates if you want to print extra info during the interpolation process. + Indicates if you want to print extra info during the methods process. to_providentia : bool Indicates if we want the interpolated grid in Providentia format. """ diff --git a/nes/nes_formats/cams_ra_format.py b/nes/nes_formats/cams_ra_format.py index 41fd37f..a286d5d 100644 --- a/nes/nes_formats/cams_ra_format.py +++ b/nes/nes_formats/cams_ra_format.py @@ -12,7 +12,7 @@ from copy import copy def to_netcdf_cams_ra(self, path): """ - Horizontal interpolation from one grid to another one. + Horizontal methods from one grid to another one. Parameters ---------- -- GitLab