pycmor.fesom_1p4 package#

Submodules#

pycmor.fesom_1p4.load_mesh_data module#

class pycmor.fesom_1p4.load_mesh_data.fesom_mesh(path, abg=[50, 15, -90], get3d=True)[source]#

Bases: object

Creates instance of the FESOM mesh.

This class creates instance that contain information about FESOM mesh. At present the class works with ASCII representation of the FESOM grid, but should be extended to be able to read also netCDF version (probably UGRID convention).

Minimum requirement is to provide the path to the directory, where following files should be located (not nessesarely all of them will be used):

  • nod2d.out

  • nod3d.out

  • elem2d.out

  • aux3d.out

Parameters:
  • path (str) – Path to the directory with mesh files

  • abg (list) – alpha, beta and gamma Euler angles. Default [50, 15, -90]

  • get3d (bool) – do we load complete 3d mesh or only 2d nodes.

path#

Path to the directory with mesh files

Type:

str

x2#

x position (lon) of the surface node

Type:

array

y2#

y position (lat) of the surface node

Type:

array

n2d#

number of 2d nodes

Type:

int

e2d#

number of 2d elements (triangles)

Type:

int

n3d#

number of 3d nodes

Type:

int

nlev#

number of vertical levels

Type:

int

zlevs#

array of vertical level depths

Type:

array

voltri#

array with 2d volume of triangles

Type:

array

alpha#

Euler angle alpha

Type:

float

beta#

Euler angle beta

Type:

float

gamma#

Euler angle gamma

Type:

float

Returns:

mesh – fesom_mesh object

Return type:

object

read2d()[source]#

Reads only surface part of the mesh. Useful if your mesh is large and you want to visualize only surface.

read3d()[source]#

Reads 3d part of the mesh.

pycmor.fesom_1p4.load_mesh_data.ind_for_depth(depth, mesh)[source]#

Return indexes that belong to certain depth.

Parameters:
  • depth (float) – desired depth. Note there will be no interpolation, the model level that is closest to desired depth will be selected.

  • mesh (object) – FESOM mesh object

Returns:

  • ind_depth (1d array) – vector with the size equal to the size of the surface nodes with index values where we have data values and missing values where we don’t have data values.

  • ind_noempty (1d array) – vector with indexes of the ind_depth that have data values.

  • ind_empty (1d array) – vector with indexes of the ind_depth that do not have data values.

pycmor.fesom_1p4.load_mesh_data.load_mesh(path, abg=[50, 15, -90], get3d=True, usepickle=True, usejoblib=False)[source]#

Loads FESOM mesh

Parameters:
  • path (str) – Path to the directory with mesh files

  • abg (list) – alpha, beta and gamma Euler angles. Default [50, 15, -90]

  • get3d (bool) – do we load complete 3d mesh or only 2d nodes.

Returns:

mesh – fesom_mesh object

Return type:

object

pycmor.fesom_1p4.load_mesh_data.scalar_r2g(al, be, ga, rlon, rlat)[source]#

Converts rotated coordinates to geographical coordinates.

Parameters:
  • al (float) – alpha Euler angle

  • be (float) – beta Euler angle

  • ga (float) – gamma Euler angle

  • rlon (array) – 1d array of longitudes in rotated coordinates

  • rlat (array) – 1d araay of latitudes in rotated coordinates

Returns:

  • lon (array) – 1d array of longitudes in geographical coordinates

  • lat (array) – 1d array of latitudes in geographical coordinates

pycmor.fesom_1p4.nodes_to_levels module#

This module contains a function to convert FESOM 1.4 output data stored in the dimensions (nodes, time) to the dimensions (nodes, levels, time).

You can include it in your Pipeline by using the step:

pycmor.fesom1.nodes_to_levels

This script can also be used stand-alone:

$ pycmor scripts fesom1 nodes_to_levels mesh in_path out_path [variable]

The argument [variable] defaults to "temp".

pycmor.fesom_1p4.nodes_to_levels._convert(meshpath, ipath, opath, variable, ncore, skip)[source]#

Main CLI for FESOM unstructured-to-structured conversion.

pycmor.fesom_1p4.nodes_to_levels.indicies_from_mesh(mesh)[source]#
pycmor.fesom_1p4.nodes_to_levels.interpolate_dataarray(ds_in, mesh, indices)[source]#

Applies depth-level interpolation across an entire dataset.

Parameters:
  • ds_in (xarray.DataArray) – Input dataset.

  • mesh (object) – FESOM mesh object.

  • variable (str) – Variable name to interpolate.

  • indices (dict) – Precomputed depth and mask indices.

Returns:

Dataset with interpolated values.

Return type:

xarray.Dataset

pycmor.fesom_1p4.nodes_to_levels.interpolate_dataset(ds_in, variable, mesh, indices)[source]#

Interpolate Dataset -> Interpolate DataArray converter function

pycmor.fesom_1p4.nodes_to_levels.interpolate_to_levels(data, mesh, indices)[source]#

Interpolates unstructured data onto depth levels for FESOM.

Parameters:
  • data (np.ndarray) – Input data for a single time step.

  • mesh (object) – FESOM mesh object.

  • indices (dict) – Precomputed depth and mask indices.

Returns:

Interpolated data (depth, ncells).

Return type:

np.ndarray

pycmor.fesom_1p4.nodes_to_levels.nodes_to_levels(data, rule)[source]#
pycmor.fesom_1p4.nodes_to_levels.open_dataset(filepath)[source]#

Open a dataset with Xarray.

pycmor.fesom_1p4.nodes_to_levels.process_dataset(input_path, output_path, processor, skip=False)[source]#

General framework for loading, processing, and saving datasets.

Parameters:
  • input_path (str) – Path to the input file.

  • output_path (str) – Path to the output file.

  • processor (function) – Function that takes an Xarray dataset and returns a processed one.

  • skip (bool) – Whether to skip processing if the output file exists.

pycmor.fesom_1p4.nodes_to_levels.save_dataset(ds, filepath, compute=True)[source]#

Save an Xarray dataset to a NetCDF file.