TidalPy.utilities.classes.model package
Submodules
TidalPy.utilities.classes.model.functional_utils module
- TidalPy.utilities.classes.model.functional_utils.is_function(potential_func: Callable, ignore_njit: bool = True) bool[source]
Checks if a function is a python or numba function
- TidalPy.utilities.classes.model.functional_utils.parse_model_docstring(model_func: Callable) Tuple[Tuple[str, ...], Tuple[str, ...]][source]
Parses a function’s docstring looking for TidalPy-specific information regarding the function’s input.
- Constant Argument Signature:
“!TPY_args const: arg1, arg2, …”
- Live Argument Signature:
“!TPY_args live: self.<reference_1>.<reference_2>.__etc__.arg1, self.<reference_1>.<reference_2>.__etc__.arg2, …
- Parameters:
model_func (Callable) – Function to parse
- Returns:
const_args (List[str]) – List of constant arguments (if any) declared in the function’s docstrings
live_args (List[str]) – List of live arguments (if any) declared in the function’s docstrings
TidalPy.utilities.classes.model.model module
- class TidalPy.utilities.classes.model.model.LayerModelHolder[source]
Bases:
ModelHolderParent class for physics models that are stored within a world’s layer
- Provides basic functionality to load in default model inputs and run calculations using those inputs and the layer’s
current state properties (e.g., temperature).
See also
- property layer: PhysicalLayerType
Layer instance which the model performs calculations on
- property layer_type
- model_config_key = None
- property store_config_in_layer: bool
Flag to store model’s configuration dictionary in the layer.config dictionary
- property world: LayeredWorldType
Layered world where the self.layer is stored
- class TidalPy.utilities.classes.model.model.ModelHolder[source]
Bases:
ConfigHolderThis class serves as a parent for most physics models (e.g., Radiogenics, Rheology, etc.)
Provides basic functionality to load in default model inputs and run calculations using those inputs.
- static build_args(arg_names: Tuple[str, ...], parameter_dict: dict = None, is_live_args: bool = False)[source]
Build an input tuple based on the required, constant, arguments and a parameter dictionary
- Parameters:
arg_names (Tuple[str, ...]) – List of required constant argument names needed for this model’s function.
parameter_dict (dict) – Dictionary of parameters.
is_live_args (bool) – Flag if this call is looking for live args, rather than constant args.
- Returns:
args – List of default argument parameters
- Return type:
Tuple[Any, …]
- build_inputs()[source]
Build a list of the live and constant inputs for the model’s calculate function.
- property debug_mode_on: bool
Flag for if the model’s debug function is being used
- property func: Callable
Callable function based on the user-provided model.
See also
- property func_array: Callable
Callable function based on the user-provided model.
See also
- property func_array_defined: bool
Flag for if the func_array property is set or not
- property inputs: NoneType | Tuple[float, ...]
Some models may require additional constants to be passed to the self.func or self.func_array. These are stored in this tuple if applicable.
- known_model_const_args = None
- known_model_live_args = None
- known_models = None
- property live_inputs: NoneType | Tuple[float, ...]
Similar to self.inputs but these are dynamic parameters that can change after initialization (e.g., the viscosity of a layer).
- property model: str
Model name
- reinit(initial_init: bool = False)[source]
Model will look at the user-provided configurations and pull out model information including constants
- Parameters:
initial_init (bool = False) –
- Must be set to True if this is the first time this method has been called (additional steps may be
preformed during the first reinit call).
TidalPy.utilities.classes.model.model_utils module
- TidalPy.utilities.classes.model.model_utils.build_model_default_inputs(const_arg_dict: Dict[str, Tuple[str, ...]], dict_of_defaults: dict, inner_keys: Tuple[str, ...] | str = None) Dict[str, Dict[str, Tuple[Any, ...]]][source]
Builds a dictionary of default input parameters using a constant argument dictionary and a dictionary of default values.
- Parameters:
const_arg_dict (Dict[str, Tuple[str, ...]]) – Constant argument dictionary is assumed to have been built by model_utils.find_all_models.
dict_of_defaults (dict) – Dictionary of default parameters, assumed to have an outer key (generally used for layer types).
inner_keys (Union[Tuple[str, ...], str] (optional)) – Optional list of keys to use after the outer key to find the correct parameter sub dict.
- Returns:
default_args_byfunc – Dictionary of default constant arguments, broken up by function names and then by layer types.
- Return type:
Dict[str, Dict[str, Tuple[Any, …]]]
- TidalPy.utilities.classes.model.model_utils.find_all_models(module: ModuleType, ignore_functional_types: tuple = ()) Tuple[Dict[str, Callable], Dict[str, Tuple[str, ...]], Dict[str, Tuple[str, ...]]][source]
Find all functions within the provided module
Provides the user with information regarding the functions inputs.
- Parameters:
module (ModuleType) – A python module full of function definitions.
ignore_functional_types (tuple = (,)) – A tuple of additional types to ignore when looking for functions.
- Returns:
models (Dict[str, Callable]) – Dictionary of function names: function.
model_const_args (Dict[str, Tuple[str, …]]) – Dictionary of function names: tuple of names of constant arguments for that function.
model_live_args (Dict[str, Tuple[str, …]]) – Dictionary of function names: tuple of names of live arguments for that function.