pyfvcom2.fvcom_reader module
FVCOM data reader for PyFVCOM2
- class pyfvcom2.fvcom_reader.FVCOMReader(file_paths: str | List[str])
Bases:
objectA class to read FVCOM model output and restart files.
This class provides methods to read FVCOM netCDF files and extract relevant data.
- Variables:
filepath (str) – Path to the FVCOM netCDF file.
dataset (xarray.Dataset) – The loaded FVCOM dataset.
- DAYS_PER_MILLISECOND = 1.1574074074074074e-08
- property bathy_elements
Get the bathymetry values at element centroids
- property bathy_nodes
Get the bathymetry values at nodes
- property dates: List[datetime]
Get the available dates in the dataset(s).
- Returns:
List of available datetime objects.
- Return type:
List[datetime]
- get_interpolation_coordinates(horizontal_position: str, vertical_position: str, horizontal_coordinate_system: str | None = 'geographic', vertical_coordinate_system: str | None = 'z', dates: ndarray | None = None) InterpolationCoordinates
Get interpolation coordinates for a specific grid position.
Wrapper for Grid.get_interpolation_coordinates.
- Parameters:
horizontal_position – Whether coordinates are at mesh nodes or element centres (‘node’ or ‘element’).
vertical_position – Whether depth coordinates are at layer centres or layer interfaces (‘layer_centre’ or ‘layer_interface’).
horizontal_coordinate_system – The coordinate system (“geographic” or “cartesian”) for the interpolation coordinates.
vertical_coordinate_system – The vertical coordinate system (“z” or “sigma”) for the interpolation coordinates.
dates – Optional array of datetime objects for the interpolation coordinates.
- Returns:
The interpolation coordinates for the specified grid position.
- Return type:
- get_n_depth_levels(var_name: str) int
Get number of z levels/layers
- Parameters:
var_name (str) – The name of the variable.
- Returns:
Number of sigma levels/layers.
- Return type:
int
- get_sigma_levels(var_name: str) ndarray
Get the sigma levels/layers for the variable based on whether it is node or element based.
- Parameters:
var_name (str) – The name of the variable.
- Returns:
Sigma levels array.
- Return type:
np.ndarray
- get_time_dep_z_levels(var_name: str, target_datetime: datetime = None, tolerance: timedelta | None = None, zeta_var_name: str = 'zeta', relative_to_free_surface: bool = False) ndarray
Get time-dependent z levels/layers for the variable based on whether it is node or element based.
- Parameters:
var_name (str) – The name of the variable.
target_datetime (datetime) – The target datetime for which to retrieve the z levels.
tolerance (timedelta, optional) – The tolerance for matching the target datetime.
zeta_var_name (str, optional) – The name of the zeta (ssh) variable. Defaults to ‘zeta’.
relative_to_free_surface (bool, optional) – Whether to return z levels relative to the
False (free surface or the zero geoid. Defaults to)
- Returns:
Sigma levels array.
- Return type:
np.ndarray
- get_var(var_name: str, target_datetime: datetime | None = None, tolerance: timedelta | None = None) ndarray
Get the data for a given variable at a specific time.
- Parameters:
var_name (str) – The name of the variable to retrieve.
target_datetime (datetime) – The target datetime for which to retrieve the data.
- Returns:
The data array for the specified variable at the given time.
- Return type:
np.ndarray
- get_var_dimensions(var_name: str) tuple
Get the dimensions of a variable.
- Parameters:
var_name (str) – The name of the variable to check.
- Returns:
The dimensions of the variable.
- Return type:
tuple
- get_vertical_position(var_name: str) str
Get the sigma coordinate type for a variable.
- Parameters:
var_name (str) – The name of the variable.
- Returns:
‘layer_centre’ if the variable uses sigma layers, ‘layer_interface’ if it uses sigma levels.
- Return type:
str
- property grid: Grid
Get the Grid object (constructed lazily).
- Returns:
The grid object containing mesh structure and open boundaries.
- Return type:
- property lat_elements
Get the latitude values of element centroids.
- property lat_nodes
Get the latitude values from the dataset.
- property lon_elements
Get the longitude values of element centroids.
- property lon_nodes
Get the longitude values from the dataset.
- property n_elements
Get the number of elements in the FVCOM grid.
- property n_nodes
Get the number of nodes in the FVCOM grid.
- property n_sigma_layers
Get the number of sigma layers in the FVCOM grid.
- property n_sigma_levels
Get the number of sigma levels in the FVCOM grid.
- property sigma_layers_elements
Get the sigma layer values at element centroids (n_layers, n_elements).
- property sigma_layers_nodes
Get the sigma layer values at nodes (n_layers, n_nodes).
- property sigma_levels_elements
Get the sigma level values at element centroids (n_levels, n_elements).
- property sigma_levels_nodes
Get the sigma level values at nodes (n_levels, n_nodes).
- var_is_node_based(var_name: str) bool
Check if a variable is node-based.
- Parameters:
var_name (str) – The name of the variable to check.
- Returns:
True if the variable is node-based, False if element-based.
- Return type:
bool
- property x_elements
Get the Cartesian x-coordinates of element centroids.
- property x_nodes
Get the Cartesian x-coordinates at nodes.
- property y_elements
Get the Cartesian y-coordinates of element centroids.
- property y_nodes
Get the Cartesian y-coordinates at nodes.