credit.preblock._utils
======================

.. py:module:: credit.preblock._utils


Functions
---------

.. autoapisummary::

   credit.preblock._utils._parse_variable_selection


Module Contents
---------------

.. py:function:: _parse_variable_selection(variable_list: list, state_dict: dict, data_types: list = None) -> list

   The goal of this function is to expand partial variables in `variable_list` based on the keys in `state_dict`.
   For example, if `variable_list` contains "ERA5/prognostic/3d", then this function should expand that partial name
   to include every variable in `state_dict` that has the matching partial name.

   :param variable_list: A list of partial or full variable names. An empty list means that all variables should be used.
   :type variable_list: list
   :param state_dict: A dictionary of the data state following the CREDIT convention, nested as
   :type state_dict: dict
   :param `state_dict[data_type][source][var_name]`. The data types:
   :type `state_dict[data_type][source][var_name]`. The data types: input, target, prediction
   :param highest level key:
   :type highest level key: e.g. "era5"
   :param then the source:
   :type then the source: e.g. "era5"
   :param (e.g. `"era5/prognostic/3d/temperature"`).:
   :param data_types: A list of data types to include. If None, all data types will be included.
   :type data_types: list

   :returns: The full variable names from `state_dict` matched by `variable_list`, with duplicates
             removed and order preserved.
   :rtype: list


