pyfvcom2.fvcom_reader module
FVCOM data reader for PyFVCOM2
- class pyfvcom2.fvcom_reader.FVCOMReader(file_paths: str | List[str])[source]
Bases:
objectA class to read FVCOM model output and restart files.
This class provides methods to read FVCOM netCDF files and extract relevant data.
- Attributes:
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[datetime]: List of available datetime objects.
- 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[source]
Get interpolation coordinates for a specific grid position.
Wrapper for Grid.get_interpolation_coordinates.
- Args:
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:
InterpolationCoordinates: The interpolation coordinates for the specified grid position.
- get_n_depth_levels(var_name: str) int[source]
Get number of z levels/layers
- Args:
var_name (str): The name of the variable.
- Returns:
int: Number of sigma levels/layers.
- get_sigma_levels(var_name: str) ndarray[source]
Get the sigma levels/layers for the variable based on whether it is node or element based.
- Args:
var_name (str): The name of the variable.
- Returns:
np.ndarray: Sigma levels array.
- 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[source]
Get time-dependent z levels/layers for the variable based on whether it is node or element based.
- Args:
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 free surface or the zero geoid. Defaults to False (relative to zero geoid).
- Returns:
np.ndarray: Sigma levels array.
- get_var(var_name: str, target_datetime: datetime | None = None, tolerance: timedelta | None = None) ndarray[source]
Get the data for a given variable at a specific time.
- Args:
var_name (str): The name of the variable to retrieve. target_datetime (datetime): The target datetime for which to retrieve the data.
- Returns:
np.ndarray: The data array for the specified variable at the given time.
- get_var_dimensions(var_name: str) tuple[source]
Get the dimensions of a variable.
- Args:
var_name (str): The name of the variable to check.
- Returns:
tuple: The dimensions of the variable.
- get_vertical_position(var_name: str) str[source]
Get the sigma coordinate type for a variable.
- Args:
var_name (str): The name of the variable.
- Returns:
str: ‘layer_centre’ if the variable uses sigma layers, ‘layer_interface’ if it uses sigma levels.
- property grid: Grid
Get the Grid object (constructed lazily).
- Returns:
Grid: The grid object containing mesh structure and open boundaries.
- 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[source]
Check if a variable is node-based.
- Args:
var_name (str): The name of the variable to check.
- Returns:
bool: True if the variable is node-based, False if element-based.
- 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.