# Projections

## Default projection

class nes.nc_projections.default_nes.Nes(comm: Comm | None = None, path: str | None = None, info: bool = False, dataset: Dataset | None = None, parallel_method: str = 'Y', avoid_first_hours: int = 0, avoid_last_hours: int = 0, first_level: int = 0, last_level: int | None = None, create_nes: bool = False, balanced: bool = False, times: List[datetime] | None = None, **kwargs)

  Bases: `object`

  A class to handle netCDF data with parallel processing capabilities using MPI.

  ### Attributes

  commMPI.Comm

    MPI communicator.

  rankint

    MPI rank.

  masterbool

    True when rank == 0.

  sizeint

    Size of the communicator.

  infobool

    Indicates if you want to print reading/writing info.

  __ini_pathstr

    Path to the original file to read when open_netcdf is called.

  hours_startint

    Number of hours to avoid from the first original values.

  hours_endint

    Number of hours to avoid from the last original values.

  datasetDataset

    netcdf4-python Dataset.

  variablesDict[str, Dict[str, Any]]

    Variables information. The dictionary structure is: {

    > var_name: {

    >   “data”: ndarray or None, # Array values or None if the variable is not loaded. attr_name: attr_value, # Variable attributes. …

    }

  _full_timeList[datetime]

    Complete list of original time step values.

  _full_levDict[str, array]

    Vertical level dictionary with the complete “data” key for all the values and the rest of the attributes. {

    > “data”: ndarray, # Array of vertical level values. attr_name: attr_value, # Vertical level attributes. …

    }

  _full_latdict

    Latitudes dictionary with the complete “data” key for all the values and the rest of the attributes. {

    > “data”: ndarray, # Array of latitude values. attr_name: attr_value, # Latitude attributes. …

    }

  _full_londict

    Longitudes dictionary with the complete “data” key for all the values and the rest of the attributes. {

    > “data”: ndarray, # Array of longitude values. attr_name: attr_value, # Longitude attributes. …

    }

  _full_lat_bndsdict

    Latitude bounds dictionary with the complete “data” key for the latitudinal boundaries of each grid and the rest of the attributes. {

    > “data”: ndarray, # Array of latitude bounds. attr_name: attr_value, # Latitude bounds attributes. …

    }

  _full_lon_bndsdict

    Longitude bounds dictionary with the complete “data” key for the longitudinal boundaries of each grid and the rest of the attributes. {

    > “data”: ndarray, # Array of longitude bounds. attr_name: attr_value, # Longitude bounds attributes. …

    }

  parallel_methodstr

    Parallel method to read/write. Can be chosen from any of the following axes to parallelize: “T”, “Y”, or “X”.

  read_axis_limitsdict

    Dictionary with the 4D limits of the rank data to read. Structure: {

    > “t_min”: int, “t_max”: int, # Time axis limits. “z_min”: int, “z_max”: int, # Vertical axis limits. “y_min”: int, “y_max”: int, # Latitudinal axis limits. “x_min”: int, “x_max”: int, # Longitudinal axis limits.

    }

  write_axis_limitsdict

    Dictionary with the 4D limits of the rank data to write. Structure: {

    > “t_min”: int, “t_max”: int, # Time axis limits. “z_min”: int, “z_max”: int, # Vertical axis limits. “y_min”: int, “y_max”: int, # Latitudinal axis limits. “x_min”: int, “x_max”: int, # Longitudinal axis limits.

    }

  timeList[datetime]

    List of time steps of the rank data.

  levdict

    Vertical levels dictionary with the portion of “data” corresponding to the rank values. Structure: {

    > “data”: ndarray, # Array of vertical level values for the rank. attr_name: attr_value, # Vertical level attributes. …

    }

  latdict

    Latitudes dictionary with the portion of “data” corresponding to the rank values. Structure: {

    > “data”: ndarray, # Array of latitude values for the rank. attr_name: attr_value, # Latitude attributes. …

    }

  londict

    Longitudes dictionary with the portion of “data” corresponding to the rank values. Structure: {

    > “data”: ndarray, # Array of longitude values for the rank. attr_name: attr_value, # Longitude attributes. …

    }

  lat_bndsdict

    Latitude bounds dictionary with the portion of “data” for the latitudinal boundaries corresponding to the rank values. Structure: {

    > “data”: ndarray, # Array of latitude bounds for the rank. attr_name: attr_value, # Latitude bounds attributes. …

    }

  lon_bndsdict

    Longitude bounds dictionary with the portion of “data” for the longitudinal boundaries corresponding to the rank values. Structure: {

    > “data”: ndarray, # Array of longitude bounds for the rank. attr_name: attr_value, # Longitude bounds attributes. …

    }

  global_attrsdict

    Global attributes with the attribute name as key and data as values. Structure: {

    > attr_name: attr_value, # Global attribute name and value. …

    }

  _var_dimtuple

    Name of the Y and X dimensions for the variables.

  _lat_dimtuple

    Name of the dimensions of the Latitude values.

  _lon_dimtuple

    Name of the dimensions of the Longitude values.

  projectionProj

    Grid projection.

  projection_datadict

    Dictionary with the projection information. Structure: {

    > proj_param: proj_value, # Projection parameters. …

    }

  add_4d_vertical_info(info_to_add)

    To add the vertical information from other source.

    #### Parameters

    info_to_addnes.Nes, str

      Nes object with the vertical information as variable or str with the path to the NetCDF file that contains the vertical data.

  add_variables_to_shapefile(var_list, idx_lev=0, idx_time=0)

    Add variables data to shapefile.

    var_listList or str

      Variables to be loaded and saved in the shapefile.

    idx_levint

      Index of vertical level for which the data will be saved in the shapefile.

    idx_timeint

      Index of time for which the data will be saved in the shapefile.

  append_time_step_data(i_time, out_format='DEFAULT')

    Fill the netCDF data for the indicated index time.

    #### Parameters

    i_timeint

      index of the time step to write

    out_formatstr

      Indicates the output format type to change the units (if needed)

  static calculate_geometry_area(geometry_list, earth_radius_minor_axis=6356752.3142, earth_radius_major_axis=6378137.0)

    Get coordinate bounds and call function to calculate the area of each cell of a set of geometries.

    #### Parameters

    geometry_listList

      A List with polygon geometries.

    earth_radius_minor_axisfloat

      Radius of the minor axis of the Earth.

    earth_radius_major_axisfloat

      Radius of the major axis of the Earth.

  calculate_grid_area(overwrite=True)

    Get coordinate bounds and call function to calculate the area of each cell of a grid.

    #### Parameters

    selfnes.Nes

      Source projection Nes Object.

    overwritebool

      Indicates if we want to overwrite the grid area.

  clear_communicator()

    Erase the communicator and the parallelization indexes.

  close()

    Close the NetCDF with netcdf4-python.

  concatenate(aux_nessy)

    Concatenate different variables into the same nes object.

    #### Parameters

    aux_nessyNes, str

      Nes object or str with the path to the NetCDF file that contains the variables to add.

    #### Returns

    list

      A List of var names added.

  copy(copy_vars: bool = False)

    Copy the Nes object. The copy will avoid to copy the communicator, dataset and variables by default.

    #### Parameters

    copy_vars: bool

      Indicates if you want to copy the variables (in lazy mode).

    #### Returns

    nessyNes

      Copy of the Nes object.

  create_providentia_exp_centre_coordinates()

    Calculate centre latitudes and longitudes from original coordinates and store as 2D arrays.

    #### Returns

    model_centre_latdict

      Dictionary with data of centre coordinates for latitude in 2D (latitude, longitude).

    model_centre_londict

      Dictionary with data of centre coordinates for longitude in 2D (latitude, longitude).

  create_providentia_exp_grid_edge_coordinates()

    Calculate grid edge latitudes and longitudes and get model grid outline.

    #### Returns

    grid_edge_latdict

      Dictionary with data of grid edge latitudes.

    grid_edge_londict

      Dictionary with data of grid edge longitudes.

  create_shapefile()

    Create spatial GeoDataFrame (shapefile).

    #### Returns

    shapefileGeoPandasDataFrame

      Shapefile dataframe.

  create_spatial_bounds()

    Calculate longitude and latitude bounds and set them.

  daily_statistic(op, type_op='calendar')

    Calculate daily statistic.

    #### Parameters

    opstr

      Statistic to perform. Accepted values: “max”, “mean” and “min”.

    type_opstr

      Type of statistic to perform. Accepted values: “calendar”, “alltsteps”, and “withoutt0”. - “calendar”: Calculate the statistic using the time metadata. It will avoid single time step by day

      > calculations

      - “alltsteps”: Calculate a single time statistic with all the time steps.

      - “withoutt0”: Calculate a single time statistic with all the time steps avoiding the first one.

  find_time_id(time)

    Find index of time in time array.

    #### Parameters

    timedatetime

      Time element.

    #### Returns

    int

      Index of time element.

  free_vars(var_list)

    Erase the selected variables from the variables’ information.

    #### Parameters

    var_listList or str

      List (or single string) of the variables to be loaded.

  get_centroids_from_coordinates()

    Get centroids from geographical coordinates.

    #### Returns

    centroids_gdf: GeoPandasDataFrame

      Centroids dataframe.

  get_climatology()

    Get whether the dataset represents climatological data.

    #### Returns

    bool

      True if the dataset represents climatological data, False otherwise.

  static get_earth_radius(ellps)

    Get minor and major axis of Earth.

    #### Parameters

    ellpsstr

      Spatial reference system.

  get_fids(use_read=False)

    Obtain the FIDs in a 2D format.

    #### Parameters

    use_readbool

      Indicate if you want to use the read_axis_limits

    #### Returns

    array

      2D array with the FID data.

  get_full_latitudes() → Dict[str, Any]

    Retrieve the complete latitude information.

    #### Returns

    Dict[str, Any]

      A dictionary containing the complete latitude data and its attributes. The dictionary structure is: {

      > “data”: ndarray, # Array of latitude values. attr_name: attr_value, # Latitude attributes. …

      }

  get_full_latitudes_boundaries() → Dict[str, Any]

    Retrieve the complete latitude boundaries information.

    #### Returns

    Dict[str, Any]

      A dictionary containing the complete latitude boundaries data and its attributes. The dictionary structure is: {

      > “data”: ndarray, # Array of latitude boundaries values. attr_name: attr_value, # Latitude boundaries attributes. …

      }

  get_full_levels() → Dict[str, Any]

    Retrieve the complete vertical level information.

    #### Returns

    Dict[str, Any]

      A dictionary containing the complete vertical level data and its attributes. The dictionary structure is: {

      > “data”: ndarray, # Array of vertical level values. attr_name: attr_value, # Vertical level attributes. …

      }

  get_full_longitudes() → Dict[str, Any]

    Retrieve the complete longitude information.

    #### Returns

    Dict[str, Any]

      A dictionary containing the complete longitude data and its attributes. The dictionary structure is: {

      > “data”: ndarray, # Array of longitude values. attr_name: attr_value, # Longitude attributes. …

      }

  get_full_longitudes_boundaries() → Dict[str, Any]

    Retrieve the complete longitude boundaries information.

    #### Returns

    Dict[str, Any]

      A dictionary containing the complete longitude boundaries data and its attributes. The dictionary structure is: {

      > “data”: ndarray, # Array of longitude boundaries values. attr_name: attr_value, # Longitude boundaries attributes. …

      }

  get_full_shape()

    Obtain the Full 2D shape of tha data

    #### Returns

    tuple

      2D shape of tha data.

  get_full_time_bnds() → List[datetime]

    Retrieve the complete list of original time step boundaries.

    #### Returns

    List[datetime]

      The complete list of original time step boundary values from the netCDF data.

  get_full_times() → List[datetime]

    Retrieve the complete list of original time step values.

    #### Returns

    List[datetime]

      The complete list of original time step values from the netCDF data.

  get_spatial_bounds_mesh_format()

    Get the spatial bounds in the pcolormesh format:

    see: https://matplotlib.org/stable/api/_as_gen/matplotlib.pyplot.pcolormesh.html

    #### Returns

    lon_bnds_meshnumpy.ndarray

      Longitude boundaries in the mesh format

    lat_bnds_meshnumpy.ndarray

      Latitude boundaries in the mesh format

  property get_time_interval

    Calculate the interrval of hours between time steps.

    #### Returns

    int

      Number of hours between time steps.

  interpolate_horizontal(dst_grid, weight_matrix_path=None, kind='NearestNeighbour', n_neighbours=4, info=False, to_providentia=False, only_create_wm=False, wm=None, flux=False)

    Horizontal methods from the current grid to another one.

    #### Parameters

    dst_gridnes.Nes

      Final projection Nes object.

    weight_matrix_pathstr, None

      Path to the weight matrix to read/create.

    kindstr

      Kind of horizontal methods. choices = [“NearestNeighbour”, “Conservative”].

    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 methods process.

    to_providentiabool

      Indicates if we want the interpolated grid in Providentia format.

    only_create_wmbool

      Indicates if you want to only create the Weight Matrix.

    wmNes

      Weight matrix Nes File.

    fluxbool

      Indicates if you want to calculate the weight matrix for flux variables.

  interpolate_vertical(new_levels, new_src_vertical=None, kind='linear', extrapolate=None, info=None, overwrite=False)

    Vertical interpolation function.

    #### Parameters

    selfNes

      Source Nes object.

    new_levelsList

      A List of new vertical levels.

    new_src_verticalnes.Nes, str

      Nes object with the vertical information as variable or str with the path to the NetCDF file that contains the vertical data.

    kindstr

      Vertical methods type.

    extrapolatebool or tuple or None or number or NaN
      If bool:

        - If True, both extrapolation options are set to “extrapolate”.

        - If False, extrapolation options are set to (“bottom”, “top”).

      If tuple:

        - The first element represents the extrapolation option for the lower bound.

        - The second element represents the extrapolation option for the upper bound.

        - If any element is bool:

            - If True, it represents “extrapolate”.

            - If False:

                - If it”s the first element, it represents “bottom”.

                - If it”s the second element, it represents “top”.

        - If any element is None, it is replaced with numpy.nan.

        - Other numeric values are kept as they are.

        - If any element is NaN, it is kept as NaN.

      If None:

        - Both extrapolation options are set to (NaN, NaN).

      If number:

        - Both extrapolation options are set to the provided number.

      If NaN:

        - Both extrapolation options are set to NaN.

    info: None, bool

      Indicates if you want to print extra information.

    overwrite: bool

      Indicates if you want to compute the vertical interpolation in the same object or not.

  keep_vars(var_list)

    Keep the selected variables and erases the rest.

    #### Parameters

    var_listList or str

      List (or single string) of the variables to be loaded.

  last_time_step()

    Modify variables to keep only the last time step.

  load(var_list=None)

    Load of the selected variables.

    That function will fill the variable “data” key with the corresponding values.

    #### Parameters

    var_listList, str, None

      List (or single string) of the variables to be loaded.

  static lon_lat_to_cartesian_ecef(lon, lat)

    # Convert observational/model geographic longitude/latitude coordinates to cartesian ECEF (Earth Centred, # Earth Fixed) coordinates, assuming WGS84 datum and ellipsoid, and that all heights = 0. # ECEF coordinates represent positions (in meters) as X, Y, Z coordinates, approximating the earth surface # as an ellipsoid of revolution. # This conversion is for the subsequent calculation of Euclidean distances of the model grid cell centres # from each observational station. # Defining the distance between two points on the earth’s surface as simply the Euclidean distance # between the two lat/lon pairs could lead to inaccurate results depending on the distance # between two points (i.e. 1 deg. of longitude varies with latitude).

    #### Parameters

    lonarray

      Longitude values.

    latarray

      Latitude values.

  static new(comm=None, path=None, info=False, dataset=None, parallel_method='Y', avoid_first_hours=0, avoid_last_hours=0, first_level=0, last_level=None, create_nes=False, balanced=False, times=None, **kwargs)

    Initialize the Nes class.

    #### Parameters

    comm: MPI.COMM

      MPI Communicator.

    path: str

      Path to the NetCDF to initialize the object.

    info: bool

      Indicates if you want to get reading/writing info.

    dataset: Dataset

      NetCDF4-python Dataset to initialize the class.

    parallel_methodstr

      Indicates the parallelization method that you want. Default over Y axis accepted values: [“X”, “Y”, “T”].

    avoid_first_hoursint

      Number of hours to remove from first time steps.

    avoid_last_hoursint

      Number of hours to remove from last time steps.

    first_levelint

      Index of the first level to use.

    last_levelint or None

      Index of the last level to use. None if it is the last.

    create_nesbool

      Indicates if you want to create the object from scratch (True) or through an existing file.

    balancedbool

      Indicates if you want a balanced parallelization or not. Balanced dataset cannot be written in chunking mode.

    timesList[datetime] or None

      List of times to substitute the current ones while creation.

  reverse_level_direction()

    Reverse the current direction of the vertical level values.

    #### Returns

    bool

      True if the direction was reversed successfully.

  rolling_mean(var_list=None, hours=8)

    Calculate rolling mean for given hours

    #### Parameters

    var_list: List, str, None

      List (or single string) of the variables to be loaded.

    hoursint, optional

      Window hours to calculate rolling mean, by default 8

    #### Returns

    Nes

      A Nes object

  sel(hours_start=None, time_min=None, hours_end=None, time_max=None, lev_min=None, lev_max=None, lat_min=None, lat_max=None, lon_min=None, lon_max=None)

    Select a slice of time, vertical level, latitude, or longitude given minimum and maximum limits.

    #### Parameters

    hours_startint, optional

      The number of hours from the start to begin the selection.

    time_mindatetime, optional

      The minimum datetime for the time selection. Mutually exclusive with hours_start.

    hours_endint, optional

      The number of hours from the end to end the selection.

    time_maxdatetime, optional

      The maximum datetime for the time selection. Mutually exclusive with hours_end.

    lev_minint, optional

      The minimum vertical level index for the selection.

    lev_maxint, optional

      The maximum vertical level index for the selection.

    lat_minfloat, optional

      The minimum latitude for the selection.

    lat_maxfloat, optional

      The maximum latitude for the selection.

    lon_minfloat, optional

      The minimum longitude for the selection.

    lon_maxfloat, optional

      The maximum longitude for the selection.

    #### Returns

    None

    #### Raises

    ValueError

      If any variables are already loaded or if mutually exclusive parameters are both provided.

    #### Notes

    This method updates the selection criteria for the dataset and recalculates the read and write axis limits accordingly. It also updates the time, level, latitude, and longitude slices based on the new criteria.

  sel_time(time, inplace=True)

    To select only one time step.

    #### Parameters

    timedatetime

      Time stamp to select.

    inplacebool

      Indicates if you want a copy with the selected time step (False) or to modify te existing one (True).

    #### Returns

    Nes

      A Nes object with the data (and metadata) of the selected time step.

  set_climatology(is_climatology)

    Set whether the dataset represents climatological data.

    #### Parameters

    is_climatologybool

      A boolean indicating if the dataset represents climatological data.

    #### Returns

    None

    #### Raises

    TypeError

      If is_climatology is not a boolean.

  set_communicator(comm)

    Set a new communicator and the correspondent parallelization indexes.

    #### Parameters

    comm: MPI.COMM

      Communicator to be set.

  set_full_latitudes(data: Dict[str, Any]) → None

    Set the complete latitude information.

    #### Parameters

    dataDict[str, Any]

      A dictionary containing the complete latitude data and its attributes. The dictionary structure is: {

      > “data”: ndarray, # Array of latitude values. attr_name: attr_value, # Latitude attributes. …

      }

  set_full_latitudes_boundaries(data: Dict[str, Any]) → None

    Set the complete latitude boundaries information.

    #### Parameters

    dataDict[str, Any]

      A dictionary containing the complete latitude boundaries data and its attributes. The dictionary structure is: {

      > “data”: ndarray, # Array of latitude boundaries values. attr_name: attr_value, # Latitude boundaries attributes. …

      }

  set_full_levels(data: Dict[str, Any]) → None

    Set the complete vertical level information.

    #### Parameters

    dataDict[str, Any]

      A dictionary containing the complete vertical level data and its attributes. The dictionary structure is: {

      > “data”: ndarray, # Array of vertical level values. attr_name: attr_value, # Vertical level attributes. …

      }

  set_full_longitudes(data: Dict[str, Any]) → None

    Set the complete longitude information.

    #### Parameters

    dataDict[str, Any]

      A dictionary containing the complete longitude data and its attributes. The dictionary structure is: {

      > “data”: ndarray, # Array of longitude values. attr_name: attr_value, # Longitude attributes. …

      }

  set_full_longitudes_boundaries(data: Dict[str, Any]) → None

    Set the complete longitude boundaries information.

    #### Parameters

    dataDict[str, Any]

      A dictionary containing the complete longitude boundaries data and its attributes. The dictionary structure is: {

      > “data”: ndarray, # Array of longitude boundaries values. attr_name: attr_value, # Longitude boundaries attributes. …

      }

  set_full_time_bnds(data: List[datetime]) → None

    Set the complete list of original time step boundaries.

    #### Parameters

    dataList[datetime]

      The complete list of original time step boundary values to set.

  set_full_times(data: List[datetime]) → None

    Set the complete list of original time step values.

    #### Parameters

    dataList[datetime]

      The complete list of original time step values to set.

  set_level_direction(new_direction)

    Set the direction of the vertical level values.

    #### Parameters

    new_directionstr

      The new direction for the vertical levels. Must be either “up” or “down”.

    #### Returns

    bool

      True if the direction was set successfully.

    #### Raises

    ValueError

      If new_direction is not “up” or “down”.

  set_levels(levels)

    Modify the original level values with new ones.

    #### Parameters

    levelsdict

      Dictionary with the new level information to be set.

  set_strlen(strlen=75)

    Set the strlen

    75 is the standard value used in GHOST data

    #### Parameters

    strlenint or None

      Max length of the string

  set_time(time_list)

    Modify the original level values with new ones.

    #### Parameters

    time_listList[datetime]

      List of time steps

  set_time_bnds(time_bnds)

    Modify the original time bounds values with new ones.

    #### Parameters

    time_bndsList

      AList with the new time bounds information to be set.

  set_time_resolution(new_resolution)

    Set the time resolution for the dataset.

    #### Parameters

    new_resolutionstr

      The new time resolution. Accepted values are “second”, “seconds”, “minute”, “minutes”, “hour”, “hours”, “day”, “days”.

    #### Returns

    bool

      True if the time resolution was set successfully.

    #### Raises

    ValueError

      If new_resolution is not one of the accepted values.

  spatial_join(ext_shp, method=None, var_list=None, info=False, apply_bbox=True)

    Compute overlay intersection of two GeoPandasDataFrames.

    #### Parameters

    ext_shpGeoPandasDataFrame or str

      File or path from where the data will be obtained on the intersection.

    methodstr

      Overlay method. Accepted values: [“nearest”, “intersection”, “centroid”].

    var_listList or None

      Variables that will be included in the resulting shapefile.

    infobool

      Indicates if you want to print the process info.

    apply_bboxbool

      Indicates if you want to reduce the shapefile to a bbox.

  sum_axis(axis='Z')
  to_dtype(data_type='float32')

    Cast variables data into selected data type.

    #### Parameters

    data_typestr or Type

      Data type, by default “float32”

  to_grib2(path, grib_keys, grib_template_path, lat_flip=True, info=False)

    Write output file with grib2 format.

    #### Parameters

    pathstr

      Path to the output file.

    grib_keysdict

      Dictionary with the grib2 keys.

    grib_template_pathstr

      Path to the grib2 file to use as template.

    lat_flipbool

      Indicates if the latitude values (and data) has to be flipped

    infobool

      Indicates if you want to print extra information during the process.

  to_netcdf(path, compression_level=0, serial=False, info=False, chunking=False, nc_type='NES', keep_open=False)

    Write the netCDF output file.

    #### Parameters

    pathstr

      Path to the output netCDF file.

    compression_levelint

      Level of compression (0 to 9) Default: 0 (no compression).

    serialbool

      Indicates if you want to write in serial or not. Default: False.

    infobool

      Indicates if you want to print the information of each writing step by stdout Default: False.

    chunkingbool

      Indicates if you want a chunked netCDF output. Only available with non-serial writes. Default: False.

    nc_typestr

      Type to NetCDf to write. “CAMS_RA” or “NES”

    keep_openbool

      Indicates if you want to keep open the NetCDH to fill the data by time-step

  to_shapefile(path, time=None, lev=None, var_list=None)

    Create shapefile from NES data.

    1. Create grid shapefile.

    2. Add variables to shapefile (as independent function).

    3. Write shapefile.

    #### Parameters

    pathstr

      Path to the output file.

    timedatetime

      Time stamp to select.

    levint

      Vertical level to select.

    var_listList, str, None

      List (or single string) of the variables to be loaded and saved in the shapefile.

  write_shapefile(path)

    Save spatial GeoDataFrame (shapefile).

    #### Parameters

    pathstr

      Path to the output file.

## Regulat lat lon projection

class nes.nc_projections.latlon_nes.LatLonNes(comm=None, path=None, info=False, dataset=None, parallel_method='Y', avoid_first_hours=0, avoid_last_hours=0, first_level=0, last_level=None, create_nes=False, balanced=False, times=None, **kwargs)

  Bases: `Nes`

  ### Attributes

  _var_dimtuple

    A Tuple with the name of the Y and X dimensions for the variables. (“lat”, “lon”) for a regular latitude-longitude projection.

  _lat_dimtuple

    A Tuple with the name of the dimensions of the Latitude values. (“lat”, ) for a regular latitude-longitude projection.

  _lon_dimtuple

    A Tuple with the name of the dimensions of the Longitude values. (“lon”, ) for a regular latitude-longitude projection.

  create_providentia_exp_centre_coordinates()

    Calculate centre latitudes and longitudes from original coordinates and store as 2D arrays.

    #### Returns

    model_centre_latdict

      Dictionary with data of centre coordinates for latitude in 2D (latitude, longitude).

    model_centre_londict

      Dictionary with data of centre coordinates for longitude in 2D (latitude, longitude).

  create_providentia_exp_grid_edge_coordinates()

    Calculate grid edge latitudes and longitudes and get model grid outline.

    #### Returns

    grid_edge_latdict

      Dictionary with data of grid edge latitudes.

    grid_edge_londict

      Dictionary with data of grid edge longitudes.

  static new(comm=None, path=None, info=False, dataset=None, parallel_method='Y', avoid_first_hours=0, avoid_last_hours=0, first_level=0, last_level=None, create_nes=False, balanced=False, times=None, **kwargs)

    Initialize the Nes class.

    #### Parameters

    comm: MPI.COMM

      MPI Communicator.

    path: str

      Path to the NetCDF to initialize the object.

    info: bool

      Indicates if you want to get reading/writing info.

    dataset: Dataset

      NetCDF4-python Dataset to initialize the class.

    parallel_methodstr

      Indicates the parallelization method that you want. Default: “Y”. Accepted values: [“X”, “Y”, “T”].

    avoid_first_hoursint

      Number of hours to remove from first time steps.

    avoid_last_hoursint

      Number of hours to remove from last time steps.

    first_levelint

      Index of the first level to use.

    last_levelint, None

      Index of the last level to use. None if it is the last.

    create_nesbool

      Indicates if you want to create the object from scratch (True) or through an existing file.

    balancedbool

      Indicates if you want a balanced parallelization or not. Balanced dataset cannot be written in chunking mode.

    timeslist, None

      List of times to substitute the current ones while creation.

  to_grib2(path, grib_keys, grib_template_path, lat_flip=False, info=False)

    Write output file with grib2 format.

    #### Parameters

    lat_flipbool

      Indicates if the latitudes have to be flipped

    pathstr

      Path to the output file.

    grib_keysdict

      Dictionary with the grib2 keys.

    grib_template_pathstr

      Path to the grib2 file to use as template.

    infobool

      Indicates if you want to print extra information during the process.

## LCC projection

class nes.nc_projections.lcc_nes.LCCNes(comm=None, path=None, info=False, dataset=None, parallel_method='Y', avoid_first_hours=0, avoid_last_hours=0, first_level=0, last_level=None, create_nes=False, balanced=False, times=None, **kwargs)

  Bases: `Nes`

  ### Attributes

  _full_ydict

    Y coordinates dictionary with the complete “data” key for all the values and the rest of the attributes.

  _full_xdict

    X coordinates dictionary with the complete “data” key for all the values and the rest of the attributes.

  ydict

    Y coordinates dictionary with the portion of “data” corresponding to the rank values.

  xdict

    X coordinates dictionary with the portion of “data” corresponding to the rank values.

  _var_dimtuple

    A Tuple with the name of the Y and X dimensions for the variables. (“y”, “x”, ) for an LCC projection.

  _lat_dimtuple

    A Tuple with the name of the dimensions of the Latitude values. (“y”, “x”, ) for an LCC projection.

  _lon_dimtuple

    ATuple with the name of the dimensions of the Longitude values. (“y”, “x”) for an LCC projection.

  create_providentia_exp_centre_coordinates()

    Calculate centre latitudes and longitudes from original coordinates and store as 2D arrays.

    #### Returns

    model_centre_latdict

      Dictionary with data of centre coordinates for latitude in 2D (latitude, longitude).

    model_centre_londict

      Dictionary with data of centre coordinates for longitude in 2D (latitude, longitude).

  create_providentia_exp_grid_edge_coordinates()

    Calculate grid edge latitudes and longitudes and get model grid outline.

    #### Returns

    grid_edge_latdict

      Dictionary with data of grid edge latitudes.

    grid_edge_londict

      Dictionary with data of grid edge longitudes.

  create_shapefile()

    Create spatial GeoDataFrame (shapefile).

    #### Returns

    shapefileGeoPandasDataFrame

      Shapefile dataframe.

  create_spatial_bounds()

    Calculate longitude and latitude bounds and set them.

  get_centroids_from_coordinates()

    Get centroids from geographical coordinates.

    #### Returns

    centroids_gdf: GeoPandasDataFrame

      Centroids dataframe.

  get_full_x() → Dict[str, Any]

    Retrieve the complete X information.

    #### Returns

    Dict[str, Any]

      A dictionary containing the complete longitude data and its attributes. The dictionary structure is: {

      > “data”: ndarray, # Array of longitude values. attr_name: attr_value, # Longitude attributes. …

      }

  get_full_y() → Dict[str, Any]

    Retrieve the complete Y information.

    #### Returns

    Dict[str, Any]

      A dictionary containing the complete latitude data and its attributes. The dictionary structure is: {

      > “data”: ndarray, # Array of latitude values. attr_name: attr_value, # Latitude attributes. …

      }

  static new(comm=None, path=None, info=False, dataset=None, parallel_method='Y', avoid_first_hours=0, avoid_last_hours=0, first_level=0, last_level=None, create_nes=False, balanced=False, times=None, **kwargs)

    Initialize the Nes class.

    #### Parameters

    comm: MPI.COMM

      MPI Communicator.

    path: str

      Path to the NetCDF to initialize the object.

    info: bool

      Indicates if you want to get reading/writing info.

    dataset: Dataset

      NetCDF4-python Dataset to initialize the class.

    parallel_methodstr

      Indicates the parallelization method that you want. Default: “Y”. Accepted values: [“X”, “Y”, “T”].

    avoid_first_hoursint

      Number of hours to remove from first time steps.

    avoid_last_hoursint

      Number of hours to remove from last time steps.

    first_levelint

      Index of the first level to use.

    last_levelint, None

      Index of the last level to use. None if it is the last.

    create_nesbool

      Indicates if you want to create the object from scratch (True) or through an existing file.

    balancedbool

      Indicates if you want a balanced parallelization or not. Balanced dataset cannot be written in chunking mode.

    timeslist, None

      List of times to substitute the current ones while creation.

  set_full_x(data: Dict[str, Any]) → None

    Set the complete rotated longitude information.

    #### Parameters

    dataDict[str, Any]

      A dictionary containing the complete longitude data and its attributes. The dictionary structure is: {

      > “data”: ndarray, # Array of longitude values. attr_name: attr_value, # Longitude attributes. …

      }

  set_full_y(data: Dict[str, Any]) → None

    Set the complete Y information.

    #### Parameters

    dataDict[str, Any]

      A dictionary containing the complete latitude data and its attributes. The dictionary structure is: {

      > “data”: ndarray, # Array of latitude values. attr_name: attr_value, # Latitude attributes. …

      }

  to_grib2(path, grib_keys, grib_template_path, lat_flip=False, info=False)

    Write output file with grib2 format.

    #### Parameters

    lat_flipbool

      Indicates if the latitudes need to be flipped Up-Down or Down-Up. Default False.

    pathstr

      Path to the output file.

    grib_keysdict

      Dictionary with the grib2 keys.

    grib_template_pathstr

      Path to the grib2 file to use as template.

    infobool

      Indicates if you want to print extra information during the process.

## Mercator projection

class nes.nc_projections.mercator_nes.MercatorNes(comm=None, path=None, info=False, dataset=None, parallel_method='Y', avoid_first_hours=0, avoid_last_hours=0, first_level=0, last_level=None, create_nes=False, balanced=False, times=None, **kwargs)

  Bases: `Nes`

  ### Attributes

  _full_ydict

    Y coordinates dictionary with the complete “data” key for all the values and the rest of the attributes.

  _full_xdict

    X coordinates dictionary with the complete “data” key for all the values and the rest of the attributes.

  ydict

    Y coordinates dictionary with the portion of “data” corresponding to the rank values.

  xdict

    X coordinates dictionary with the portion of “data” corresponding to the rank values.

  _var_dimtuple

    A Tuple with the name of the Y and X dimensions for the variables. (“y”, “x”) for a Mercator projection.

  _lat_dimtuple

    A Tuple with the name of the dimensions of the Latitude values. (“y”, “x”) for a Mercator projection.

  _lon_dimtuple

    A Tuple with the name of the dimensions of the Longitude values. (“y”, “x”) for a Mercator projection.

  create_providentia_exp_centre_coordinates()

    Calculate centre latitudes and longitudes from original coordinates and store as 2D arrays.

    #### Returns

    model_centre_latdict

      Dictionary with data of centre coordinates for latitude in 2D (latitude, longitude).

    model_centre_londict

      Dictionary with data of centre coordinates for longitude in 2D (latitude, longitude).

  create_providentia_exp_grid_edge_coordinates()

    Calculate grid edge latitudes and longitudes and get model grid outline.

    #### Returns

    grid_edge_latdict

      Dictionary with data of grid edge latitudes.

    grid_edge_londict

      Dictionary with data of grid edge longitudes.

  create_shapefile()

    Create spatial GeoDataFrame (shapefile).

    #### Returns

    shapefileGeoPandasDataFrame

      Shapefile dataframe.

  create_spatial_bounds()

    Calculate longitude and latitude bounds and set them.

  get_centroids_from_coordinates()

    Get centroids from geographical coordinates.

    #### Returns

    centroids_gdf: GeoPandasDataFrame

      Centroids dataframe.

  get_full_x() → Dict[str, Any]

    Retrieve the complete X information.

    #### Returns

    Dict[str, Any]

      A dictionary containing the complete longitude data and its attributes. The dictionary structure is: {

      > “data”: ndarray, # Array of longitude values. attr_name: attr_value, # Longitude attributes. …

      }

  get_full_y() → Dict[str, Any]

    Retrieve the complete Y information.

    #### Returns

    Dict[str, Any]

      A dictionary containing the complete latitude data and its attributes. The dictionary structure is: {

      > “data”: ndarray, # Array of latitude values. attr_name: attr_value, # Latitude attributes. …

      }

  static new(comm=None, path=None, info=False, dataset=None, parallel_method='Y', avoid_first_hours=0, avoid_last_hours=0, first_level=0, last_level=None, create_nes=False, balanced=False, times=None, **kwargs)

    Initialize the Nes class.

    #### Parameters

    comm: MPI.COMM

      MPI Communicator.

    path: str

      Path to the NetCDF to initialize the object.

    info: bool

      Indicates if you want to get reading/writing info.

    dataset: Dataset

      NetCDF4-python Dataset to initialize the class.

    parallel_methodstr

      Indicates the parallelization method that you want. Default: “Y”. Accepted values: [“X”, “Y”, “T”].

    avoid_first_hoursint

      Number of hours to remove from first time steps.

    avoid_last_hoursint

      Number of hours to remove from last time steps.

    first_levelint

      Index of the first level to use.

    last_levelint, None

      Index of the last level to use. None if it is the last.

    create_nesbool

      Indicates if you want to create the object from scratch (True) or through an existing file.

    balancedbool

      Indicates if you want a balanced parallelization or not. Balanced dataset cannot be written in chunking mode.

    timeslist, None

      List of times to substitute the current ones while creation.

  set_full_x(data: Dict[str, Any]) → None

    Set the complete rotated longitude information.

    #### Parameters

    dataDict[str, Any]

      A dictionary containing the complete longitude data and its attributes. The dictionary structure is: {

      > “data”: ndarray, # Array of longitude values. attr_name: attr_value, # Longitude attributes. …

      }

  set_full_y(data: Dict[str, Any]) → None

    Set the complete Y information.

    #### Parameters

    dataDict[str, Any]

      A dictionary containing the complete latitude data and its attributes. The dictionary structure is: {

      > “data”: ndarray, # Array of latitude values. attr_name: attr_value, # Latitude attributes. …

      }

  to_grib2(path, grib_keys, grib_template_path, lat_flip=False, info=False)

    Write output file with grib2 format.

    #### Parameters

    lat_flipbool

      Indicates if you want to flip latitudes Up-Down

    pathstr

      Path to the output file.

    grib_keysdict

      Dictionary with the grib2 keys.

    grib_template_pathstr

      Path to the grib2 file to use as template.

    infobool

      Indicates if you want to print extra information during the process.

## Points projection

class nes.nc_projections.points_nes.PointsNes(comm=None, path=None, info=False, dataset=None, parallel_method='X', avoid_first_hours=0, avoid_last_hours=0, first_level=0, last_level=None, create_nes=False, balanced=False, times=None, **kwargs)

  Bases: `Nes`

  ### Attributes

  _var_dimtuple

    A Tuple with the name of the Y and X dimensions for the variables. (“lat”, “lon”, ) for a points grid.

  _lat_dimtuple

    A Tuple with the name of the dimensions of the Latitude values. (“lat”, ) for a points grid.

  _lon_dimtuple

    A Tuple with the name of the dimensions of the Longitude values. (“lon”, ) for a points grid.

  _stationtuple

    A Tuple with the name of the dimensions of the station values. (“station”, ) for a points grid.

  add_variables_to_shapefile(var_list, idx_lev=0, idx_time=0)

    Add variables data to shapefile.

    var_listlist, str

      List (or single string) of the variables to be loaded and saved in the shapefile.

    idx_levint

      Index of vertical level for which the data will be saved in the shapefile.

    idx_timeint

      Index of time for which the data will be saved in the shapefile.

  create_shapefile()

    Create spatial GeoDataFrame (shapefile).

    #### Returns

    shapefileGeoPandasDataFrame

      Shapefile dataframe.

  create_spatial_bounds()

    Calculate longitude and latitude bounds and set them.

  get_centroids_from_coordinates()

    Get centroids from geographical coordinates.

    #### Returns

    centroids_gdf: GeoPandasDataFrame

      Centroids dataframe.

  static new(comm=None, path=None, info=False, dataset=None, parallel_method='X', avoid_first_hours=0, avoid_last_hours=0, first_level=0, last_level=None, create_nes=False, balanced=False, times=None, **kwargs)

    Initialize the Nes class.

    #### Parameters

    comm: MPI.COMM

      MPI Communicator.

    path: str

      Path to the NetCDF to initialize the object.

    info: bool

      Indicates if you want to get reading/writing info.

    dataset: Dataset

      NetCDF4-python Dataset to initialize the class.

    parallel_methodstr

      Indicates the parallelization method that you want. Default: “X”. accepted values: [“X”, “T”].

    avoid_first_hoursint

      Number of hours to remove from first time steps.

    avoid_last_hoursint

      Number of hours to remove from last time steps.

    first_levelint

      Index of the first level to use.

    last_levelint, None

      Index of the last level to use. None if it is the last.

    create_nesbool

      Indicates if you want to create the object from scratch (True) or through an existing file.

    balancedbool

      Indicates if you want a balanced parallelization or not. Balanced dataset cannot be written in chunking mode.

    timeslist, None

      List of times to substitute the current ones while creation.

  to_grib2(path, grib_keys, grib_template_path, lat_flip=False, info=False)

    Write output file with grib2 format.

    #### Parameters

    lat_flipbool

      Indicates if you want to flip the latitude direction.

    pathstr

      Path to the output file.

    grib_keysdict

      Dictionary with the grib2 keys.

    grib_template_pathstr

      Path to the grib2 file to use as template.

    infobool

      Indicates if you want to print extra information during the process.

  to_providentia(model_centre_lon, model_centre_lat, grid_edge_lon, grid_edge_lat)

    Transform a PointsNes into a PointsNesProvidentia object

    #### Returns

    points_nes_providentianes.Nes

      Points Nes Providentia Object

## GHOST projection

class nes.nc_projections.points_nes_ghost.PointsNesGHOST(comm=None, path=None, info=False, dataset=None, parallel_method='X', avoid_first_hours=0, avoid_last_hours=0, first_level=0, last_level=None, create_nes=False, balanced=False, times=None, **kwargs)

  Bases: `PointsNes`

  ### Attributes

  _qadict

    Quality flags (GHOST checks) dictionary with the complete “data” key for all the values and the rest of the attributes.

  _flagdict

    Data flags (given by data provider) dictionary with the complete “data” key for all the values and the rest of the attributes.

  _qadict

    Quality flags (GHOST checks) dictionary with the portion of “data” corresponding to the rank values.

  _flagdict

    Data flags (given by data provider) dictionary with the portion of “data” corresponding to the rank values.

  add_variables_to_shapefile(var_list, idx_lev=0, idx_time=0)

    Add variables data to shapefile.

    var_listlist, str

      List (or single string) of the variables to be loaded and saved in the shapefile.

    idx_levint

      Index of vertical level for which the data will be saved in the shapefile.

    idx_timeint

      Index of time for which the data will be saved in the shapefile.

  erase_flags()
  static get_standard_metadata(ghost_version)

    Get all possible GHOST variables for each version.

    #### Parameters

    ghost_versionstr

      Version of GHOST file.

    #### Returns

    metadata_variables[GHOST_version]list

      A List of metadata variables for a certain GHOST version

  static new(comm=None, path=None, info=False, dataset=None, parallel_method='X', avoid_first_hours=0, avoid_last_hours=0, first_level=0, last_level=None, create_nes=False, balanced=False, times=None, **kwargs)

    Initialize the PointsNesGHOST class.

    #### Parameters

    comm: MPI.COMM

      MPI Communicator.

    path: str

      Path to the NetCDF to initialize the object.

    info: bool

      Indicates if you want to get reading/writing info.

    dataset: Dataset

      NetCDF4-python Dataset to initialize the class.

    parallel_methodstr

      Indicates the parallelization method that you want. Default: “X”. Accepted values: [“X”].

    avoid_first_hoursint

      Number of hours to remove from first time steps.

    avoid_last_hoursint

      Number of hours to remove from last time steps.

    first_levelint

      Index of the first level to use.

    last_levelint, None

      Index of the last level to use. None if it is the last.

    create_nesbool

      Indicates if you want to create the object from scratch (True) or through an existing file.

    balancedbool

      Indicates if you want a balanced parallelization or not. Balanced dataset cannot be written in chunking mode.

    timeslist, None

      List of times to substitute the current ones while creation.

  to_netcdf(path, compression_level=0, serial=False, info=False, chunking=False, nc_type='NES', keep_open=False)

    Write the netCDF output file.

    #### Parameters

    keep_open : bool nc_type : str path : str

    > Path to the output netCDF file.

    compression_levelint

      Level of compression (0 to 9) Default: 0 (no compression).

    serialbool

      Indicates if you want to write in serial or not. Default: False.

    infobool

      Indicates if you want to print the information of each writing step by stdout Default: False.

    chunkingbool

      Indicates if you want a chunked netCDF output. Only available with non-serial writes. Default: False.

  to_points()

    Transform a PointsNesGHOST into a PointsNes object

    #### Returns

    points_nesnes.Nes

      Points Nes Object (without GHOST metadata variables)

## Providentia projection

class nes.nc_projections.points_nes_providentia.PointsNesProvidentia(comm=None, path=None, info=False, dataset=None, parallel_method='X', avoid_first_hours=0, avoid_last_hours=0, first_level=0, last_level=None, create_nes=False, balanced=False, times=None, model_centre_lon=None, model_centre_lat=None, grid_edge_lon=None, grid_edge_lat=None, **kwargs)

  Bases: `PointsNes`

  ### Attributes

  _model_centre_londict

    Model centre longitudes dictionary with the complete “data” key for all the values and the rest of the attributes.

  _model_centre_latdict

    Model centre latitudes dictionary with the complete “data” key for all the values and the rest of the attributes.

  _grid_edge_londict

    Grid edge longitudes dictionary with the complete “data” key for all the values and the rest of the attributes.

  _grid_edge_latdict

    Grid edge latitudes dictionary with the complete “data” key for all the values and the rest of the attributes.

  model_centre_londict

    Model centre longitudes dictionary with the portion of “data” corresponding to the rank values.

  model_centre_latdict

    Model centre latitudes dictionary with the portion of “data” corresponding to the rank values.

  grid_edge_londict

    Grid edge longitudes dictionary with the portion of “data” corresponding to the rank values.

  grid_edge_latdict

    Grid edge latitudes dictionary with the portion of “data” corresponding to the rank values.

  add_variables_to_shapefile(var_list, idx_lev=0, idx_time=0)

    Add variables data to shapefile.

    var_listlist, str

      List (or single string) of the variables to be loaded and saved in the shapefile.

    idx_levint

      Index of vertical level for which the data will be saved in the shapefile.

    idx_timeint

      Index of time for which the data will be saved in the shapefile.

  static new(comm=None, path=None, info=False, dataset=None, parallel_method='X', avoid_first_hours=0, avoid_last_hours=0, first_level=0, last_level=None, create_nes=False, balanced=False, times=None, model_centre_lon=None, model_centre_lat=None, grid_edge_lon=None, grid_edge_lat=None, **kwargs)

    Initialize the PointsNesProvidentia class.

    #### Parameters

    comm: MPI.COMM

      MPI Communicator.

    path: str

      Path to the NetCDF to initialize the object.

    info: bool

      Indicates if you want to get reading/writing info.

    dataset: Dataset

      NetCDF4-python Dataset to initialize the class.

    parallel_methodstr

      Indicates the parallelization method that you want. Default: “X”. Accepted values: [“X”].

    avoid_first_hoursint

      Number of hours to remove from first time steps.

    avoid_last_hoursint

      Number of hours to remove from last time steps.

    first_levelint

      Index of the first level to use

    last_levelint, None

      Index of the last level to use. None if it is the last.

    balancedbool

      Indicates if you want a balanced parallelization or not. Balanced dataset cannot be written in chunking mode.

    timeslist, None

      List of times to substitute the current ones while creation.

    create_nesbool

      Indicates if you want to create the object from scratch (True) or through an existing file.

    model_centre_londict

      Model centre longitudes dictionary with the portion of “data” corresponding to the rank values.

    model_centre_latdict

      Model centre latitudes dictionary with the portion of “data” corresponding to the rank values.

    grid_edge_londict

      Grid edge longitudes dictionary with the portion of “data” corresponding to the rank values.

    grid_edge_latdict

      Grid edge latitudes dictionary with the portion of “data” corresponding to the rank values.

  to_netcdf(path, compression_level=0, serial=False, info=False, chunking=False, nc_type='NES', keep_open=False)

    Write the netCDF output file.

    #### Parameters

    pathstr

      Path to the output netCDF file.

    compression_levelint

      Level of compression (0 to 9) Default: 0 (no compression).

    serialbool

      Indicates if you want to write in serial or not. Default: False.

    infobool

      Indicates if you want to print the information of each writing step by stdout Default: False.

    chunkingbool

      Indicates if you want a chunked netCDF output. Only available with non-serial writes. Default: False.

    nc_typestr

      Type to NetCDf to write. “CAMS_RA” or “NES”

    keep_openbool

      Indicates if you want to keep open the NetCDH to fill the data by time-step

## Rotated projection

class nes.nc_projections.rotated_nes.RotatedNes(comm=None, path=None, info=False, dataset=None, parallel_method='Y', avoid_first_hours=0, avoid_last_hours=0, first_level=0, last_level=None, create_nes=False, balanced=False, times=None, **kwargs)

  Bases: `Nes`

  ### Attributes

  _full_rlatdict

    Rotated latitudes dictionary with the complete “data” key for all the values and the rest of the attributes.

  _full_rlondict

    Rotated longitudes dictionary with the complete “data” key for all the values and the rest of the attributes.

  rlatdict

    Rotated latitudes dictionary with the portion of “data” corresponding to the rank values.

  rlondict

    Rotated longitudes dictionary with the portion of “data” corresponding to the rank values.

  _var_dimtuple

    A Tuple with the name of the Y and X dimensions for the variables. (“rlat”, “rlon”) for a rotated projection.

  _lat_dimtuple

    A Tuple with the name of the dimensions of the Latitude values. (“rlat”, “rlon”) for a rotated projection.

  _lon_dimtuple

    A Tuple with the name of the dimensions of the Longitude values. (“rlat”, “rlon”) for a rotated projection.

  create_providentia_exp_centre_coordinates()

    Calculate centre latitudes and longitudes from original coordinates and store as 2D arrays.

    #### Returns

    model_centre_latdict

      Dictionary with data of centre coordinates for latitude in 2D (latitude, longitude).

    model_centre_londict

      Dictionary with data of centre coordinates for longitude in 2D (latitude, longitude).

  create_providentia_exp_grid_edge_coordinates()

    Calculate grid edge latitudes and longitudes and get model grid outline.

    #### Returns

    grid_edge_latdict

      Dictionary with data of grid edge latitudes.

    grid_edge_londict

      Dictionary with data of grid edge longitudes.

  create_shapefile()

    Create spatial geodataframe (shapefile).

    #### Returns

    shapefileGeoPandasDataFrame

      Shapefile dataframe.

  create_spatial_bounds()

    Calculate longitude and latitude bounds and set them.

  get_centroids_from_coordinates()

    Get centroids from geographical coordinates.

    #### Returns

    centroids_gdf: GeoPandasDataFrame

      Centroids dataframe.

  get_full_rlat() → Dict[str, Any]

    Retrieve the complete rotated latitude information.

    #### Returns

    Dict[str, Any]

      A dictionary containing the complete latitude data and its attributes. The dictionary structure is: {

      > “data”: ndarray, # Array of latitude values. attr_name: attr_value, # Latitude attributes. …

      }

  get_full_rlon() → Dict[str, Any]

    Retrieve the complete rotated longitude information.

    #### Returns

    Dict[str, Any]

      A dictionary containing the complete longitude data and its attributes. The dictionary structure is: {

      > “data”: ndarray, # Array of longitude values. attr_name: attr_value, # Longitude attributes. …

      }

  static new(comm=None, path=None, info=False, dataset=None, parallel_method='Y', avoid_first_hours=0, avoid_last_hours=0, first_level=0, last_level=None, create_nes=False, balanced=False, times=None, **kwargs)

    Initialize the Nes class.

    #### Parameters

    comm: MPI.COMM

      MPI Communicator.

    path: str

      Path to the NetCDF to initialize the object.

    info: bool

      Indicates if you want to get reading/writing info.

    dataset: Dataset

      NetCDF4-python Dataset to initialize the class.

    parallel_methodstr

      Indicates the parallelization method that you want. Default over Y axis accepted values: [“X”, “Y”, “T”].

    avoid_first_hoursint

      Number of hours to remove from first time steps.

    avoid_last_hoursint

      Number of hours to remove from last time steps.

    first_levelint

      Index of the first level to use.

    last_levelint or None

      Index of the last level to use. None if it is the last.

    create_nesbool

      Indicates if you want to create the object from scratch (True) or through an existing file.

    balancedbool

      Indicates if you want a balanced parallelization or not. Balanced dataset cannot be written in chunking mode.

    timesList[datetime] or None

      List of times to substitute the current ones while creation.

  rotated2latlon(lon_deg, lat_deg, lon_min=-180)

    Calculate the unrotated coordinates using the rotated ones.

    #### Parameters

    lon_degarray

      Rotated longitude coordinate.

    lat_degarray

      Rotated latitude coordinate.

    lon_minfloat

      Minimum value for the longitudes: -180 (-180 to 180) or 0 (0 to 360).

    #### Returns

    almdarray

      Unrotated longitudes.

    aphdarray

      Unrotated latitudes.

  set_full_rlat(data: Dict[str, Any]) → None

    Set the complete rotated latitude information.

    #### Parameters

    dataDict[str, Any]

      A dictionary containing the complete latitude data and its attributes. The dictionary structure is: {

      > “data”: ndarray, # Array of latitude values. attr_name: attr_value, # Latitude attributes. …

      }

  set_full_rlon(data: Dict[str, Any]) → None

    Set the complete rotated longitude information.

    #### Parameters

    dataDict[str, Any]

      A dictionary containing the complete longitude data and its attributes. The dictionary structure is: {

      > “data”: ndarray, # Array of longitude values. attr_name: attr_value, # Longitude attributes. …

      }

  to_grib2(path, grib_keys, grib_template_path, lat_flip=False, info=False)

    Write output file with grib2 format.

    #### Parameters

    lat_flipbool

      Indicates if you want to flip the latitude coordinates.

    pathstr

      Path to the output file.

    grib_keysdict

      Dictionary with the grib2 keys.

    grib_template_pathstr

      Path to the grib2 file to use as template.

    infobool

      Indicates if you want to print extra information during the process.

## Rotated nested projection

class nes.nc_projections.rotated_nested_nes.RotatedNestedNes(comm=None, path=None, info=False, dataset=None, parallel_method='Y', avoid_first_hours=0, avoid_last_hours=0, first_level=0, last_level=None, create_nes=False, balanced=False, times=None, **kwargs)

  Bases: `RotatedNes`