diff --git a/CHANGELOG.md b/CHANGELOG.md index 28733133b81841ea706b37a6be2cd195c7f51d97..20473a13240b11f756bcdcd2e9c36341dc0c05ae 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 5cdf04d4d11e407d45ed18800ae81e4792a61d98..13543cff291da0fa8fbcad12a0f3bec500aa8a01 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 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 fac15bdae181f343a645d11dcb9ea306ba9c9722..b5d5d185b5402e270c2db2658983361b910defcb 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 95% rename from nes/interpolation/vertical_interpolation.py rename to nes/methods/vertical_interpolation.py index 88f8fb524c7069dd33c7f0194f878b5a18f541d6..40d9c8789691c23902992bc30843a7c0151f43c3 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,13 +38,14 @@ 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 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 @@ -106,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) @@ -133,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 5931073b11eb88815f6b32da88c398d3092d290c..9cb632810e93f26f24c9e9575eeb6517e564e8b6 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 41fd37f2bfd4aaff1d49ca103c918dbcc3d68d5b..a286d5dc0a5237d9c12854afd3ed134edd29e58c 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 ----------