eva.transforms package#

Submodules#

eva.transforms.accept_where module#

eva.transforms.accept_where.accept_where(config, data_collections)[source]#

Applies a filtering transformation to data variables based on specified conditions.

Parameters:
  • config (dict) – A configuration dictionary containing transformation parameters.

  • data_collections (DataCollections) – An instance of the DataCollections class containing

  • data. (input) –

Returns:

None

Raises:

ValueError – If the ‘where’ expression format is incorrect.

This function applies a filtering transformation to data variables within the provided data collections. It iterates over the specified collections, groups, and variables, and applies filtering conditions as defined in the ‘where’ expressions within the configuration. The resulting filtered variables are added to the data collections.

Example

config = {
    'collections': [...],
    'groups': [...],
    'variables': [...],
    'new name': 'filtered_variable',
    'starting field': 'original_variable',
    'where': ['${collection}::${group}::${variable} >= 0.0']
}
accept_where(config, data_collections)
eva.transforms.accept_where.generate_accept_where_config(new_name, starting_field, where, collection, var_list)[source]#

Generates a configuration dictionary for the ‘accept where’ transformation.

Parameters:
  • new_name (str) – The new variable name after the transformation.

  • starting_field (str) – The starting variable field for the transformation.

  • where (list) – A list of filter expressions to be applied.

  • collection (str) – The collection name.

  • var_list (list) – A list of variables to apply the transformation to.

Returns:

A configuration dictionary for the ‘accept where’ transformation.

Return type:

dict

This function generates a configuration dictionary for the ‘accept where’ transformation based on the provided parameters. It updates the ‘new name’ and ‘starting field’ fields, adjusts expressions in ‘where’ based on the provided collection and group names, and specifies the ‘for’ dictionary to apply the transformation to the specified variables.

Example

::

new_name = ‘filtered_variable’ starting_field = ‘original_variable’ where = [‘group1 >= 0’, ‘group2 < 10’] collection = ‘my_collection’ var_list = [‘variable1’, ‘variable2’] config = generate_accept_where_config(new_name, starting_field, where,

collection, var_list)

eva.transforms.arithmetic module#

eva.transforms.arithmetic.arithmetic(config, data_collections)[source]#

Applies arithmetic transformations to data variables using specified expressions.

Parameters:
  • config (dict) – A configuration dictionary containing transformation parameters.

  • data_collections (DataCollections) – An instance of the DataCollections class containing

  • data. (input) –

Returns:

None

This function applies arithmetic transformations to data variables within the provided data collections. It iterates over the specified collections, groups, and variables, and applies arithmetic expressions as defined in the ‘equals’ expressions within the configuration. The resulting variables are added to the data collections.

Example

config = {
    'collections': [...],
    'groups': [...],
    'variables': [...],
    'new name': 'result_variable',
    'equals': '(${collection}::${group}::${var1} + ${collection}::${group}::${var2})
               / 2'
}
arithmetic(config, data_collections)
eva.transforms.arithmetic.generate_arithmetic_config(new_name, expression, collection, var_list)[source]#

Generates a configuration dictionary for the ‘arithmetic’ transformation.

Parameters:
  • new_name (str) – The new variable name after the transformation.

  • expression (str) – The arithmetic expression to be applied.

  • collection (str) – The collection name.

  • var_list (list) – A list of variables to apply the transformation to.

Returns:

A configuration dictionary for the ‘arithmetic’ transformation.

Return type:

dict

This function generates a configuration dictionary for the ‘arithmetic’ transformation based on the provided parameters. It updates the ‘new name’ field, adjusts the arithmetic expression based on the provided collection and group names, and specifies the ‘for’ dictionary to apply the transformation to the specified variables.

Example

new_name = 'result_variable'
expression = '(${group1} + ${group2}) / 2'
collection = 'my_collection'
var_list = ['variable1', 'variable2']
config = generate_arithmetic_config(new_name, expression, collection, var_list)
eva.transforms.arithmetic.isfloat(a_string)[source]#

Checks if a string can be converted to a floating-point number.

Parameters:

a_string (str) – The string to be checked.

Returns:

True if the string can be converted to a float, False otherwise.

Return type:

bool

This function determines whether a given string can be successfully converted to a floating-point number.

Example

result = isfloat("3.14")

eva.transforms.channel_stats module#

eva.transforms.channel_stats.channel_stats(config, data_collections)[source]#

Calculates statistical measures for data variables along a specified dimension.

Parameters:
  • config (dict) – A configuration dictionary containing transformation parameters.

  • data_collections (DataCollections) – An instance of the DataCollections class containing

  • data. (input) –

Returns:

None

This function calculates statistical measures for specified channel data variables within the provided data collections. It iterates over the specified collections, groups, and variables, and calculates statistical measures as defined in the ‘statistic list’ expressions within the configuration. The resulting variables are added to the data collections.

Example

config = {
    'collections': [...],
    'groups': [...],
    'variables': [...],
    'variable_name': 'data_variable',
    'statistic list': ['Mean', 'Std', 'Count'],
    'statistic_dimension': 'Location'
}
channel_stats(config, data_collections)

eva.transforms.select_time module#

eva.transforms.select_time.select_time(config, data_collections)[source]#

Selects and processes data variables for specified time cycles or a single time point.

Parameters:
  • config (dict) – A configuration dictionary containing transformation parameters.

  • data_collections (DataCollections) – An instance of the DataCollections class containing

  • data. (input) –

Returns:

None

This function selects and processes data variables within the provided data collections based on specified time cycles or a single time point (given as YYYYMMDDHH). It iterates over the specified collections, groups, and variables, and selects data for the specified time period. If two time cycles are provided, it calculates the mean of a time slice; otherwise, it selects data for a single time point. The resulting processed variables are added to the data collections.

Example

config = {
    'collections': [...],
    'groups': [...],
    'variables': [...],
    'new name': 'time_selected_variable',
    'starting field': 'original_variable',
    'cycle': 'YYYYMMDDHH',
    # OR
    'start cycle': 'YYYYMMDDHH',
    'end cycle': 'YYYYMMDDHH'
}
select_time(config, data_collections)

eva.transforms.transform_driver module#

eva.transforms.transform_driver.transform_driver(config, data_collections, timing, logger)[source]#

Applies a series of transformation methods to data collections.

Parameters:
  • config (dict) – A configuration dictionary containing transformation parameters.

  • data_collections (DataCollections) – An instance of the DataCollections class containing

  • data. (input) –

  • timing (Timing) – An instance of the Timing class for tracking execution times.

  • logger (Logger) – An instance of the logger for logging messages.

Returns:

None

This function applies a series of transformation methods to the provided data collections. It iterates over a list of transform dictionaries specified in the configuration. For each transform, it identifies the transform type, instantiates the corresponding transform object, and calls the transform method. Execution times for each transform are tracked using the Timing instance.

eva.transforms.transform_utils module#

eva.transforms.transform_utils.parse_for_dict(config, logger)[source]#

Parses the ‘for’ dictionary from the configuration and extracts collection, group, and variable values.

Parameters:
  • config (dict) – A configuration dictionary containing transformation parameters.

  • logger (Logger) – An instance of the logger for logging messages.

Returns:

A list containing collection, group, and variable values extracted from the ‘for’ dictionary.

Return type:

list

This function parses the ‘for’ dictionary provided in the configuration and extracts the collection, group, and variable values specified. It returns a list containing these extracted components.

Example

for_dict = {
    'collection': 'my_collection',
    'group': 'my_group',
    'variable': 'my_variable'
}
cgv = parse_for_dict(config, logger)
eva.transforms.transform_utils.replace_cgv(logger, collection, group, variable, *argv)[source]#

Replaces placeholders in template strings with collection, group, and variable values.

Parameters:
  • logger (Logger) – An instance of the logger for logging messages.

  • collection (str) – The collection value.

  • group (str) – The group value.

  • variable (str) – The variable value.

  • *argv (str) – Variable number of template strings to replace.

Returns:

A list of template strings with placeholders replaced by corresponding values.

Return type:

list

This function replaces placeholders in the provided template strings with the specified collection, group, and variable values. It returns a list of template strings with replaced placeholders.

Example

replaced_templates = replace_cgv(logger, 'my_collection', 'my_group',
                                 'my_variable', template1, template2)
eva.transforms.transform_utils.split_collectiongroupvariable(logger, collectiongroupvariable)[source]#

Splits a collectiongroupvariable string into its components.

Parameters:
  • logger (Logger) – An instance of the logger for logging messages.

  • collectiongroupvariable (str) – The collectiongroupvariable string to split.

Returns:

A list containing the collection, group, and variable components.

Return type:

list

This function splits a collectiongroupvariable string into its components (collection, group, variable). It returns a list containing these components.

Example

cgv = split_collectiongroupvariable(logger, 'my_collection::my_group::my_variable')

Module contents#