vvmtools.analyze.DataRetriever.get_var

vvmtools.analyze.DataRetriever.get_var#

DataRetriever.get_var(var, time, domain_range=(None, None, None, None, None, None), numpy=False, compute_mean=False, axis=None)[source]#

Get a variable’s data at a specified time and domain range.

This function searches for the appropriate file based on variable type and time step. It supports optional domain range filtering, and the result can be returned as a NumPy array.

Parameters:
  • var (str) – Name of the variable to retrieve.

  • time (int) – Time step for which the variable data is requested.

  • domain_range (tuple, optional) – Tuple specifying the range in each dimension (k1, k2, j1, j2, i1, i2), defaults to (None, None, None, None, None, None).

  • numpy (bool, optional) – Whether to return the data as a NumPy array, defaults to False.

  • compute_mean (bool, optional) – Whether to compute the mean of the variable data, defaults to False.

  • axis (int or tuple of ints, optional) – Axis or axes along which the mean is computed, defaults to None.

Returns:

The variable data, either as a NumPy array or as xarray data depending on options.

Return type:

numpy.ndarray or xarray.DataArray

Example:
>>> import numpy as np
>>> import vvmtools
>>> my_vvmtool = vvmtools.analyze.DataRetriever(case_path="path/to/case")
>>> u = my_vvmtool.get_var("u", 0, numpy=True)
>>> u_mean = my_vvmtool.get_var("u", 0, numpy=True, compute_mean=True)
>>> u_mean_along_x = my_vvmtool.get_var("u", 0, numpy=True, compute_mean=True, axis=1)