pyissm.model.classes.stochasticforcing
- class pyissm.model.classes.stochasticforcing(other=None)
Bases:
manage_stateStochastic forcing parameters class for ISSM.
This class encapsulates parameters for stochastic forcing in the ISSM (Ice Sheet System Model) framework. It allows users to apply random forcing to various physical processes such as surface mass balance, basal melting, and calving, enabling uncertainty quantification and probabilistic modeling.
- Parameters:
other (any, optional) – Any other class object that contains common fields to inherit from. If values in other differ from default values, they will override the default values.
- isstochasticforcing
Is stochasticity activated?
- Type:
int, default=0
- fields
Fields with stochasticity applied, e.g. [‘SMBautoregression’], or [‘SMBforcing’,’DefaultCalving’].
- Type:
str, default=’List of fields’
- defaultdimension
Dimensionality of the noise terms (does not apply to fields with their specific dimension).
- Type:
int, default=0
- default_id
ID of each element for partitioning of the noise terms (does not apply to fields with their specific partition).
- Type:
ndarray, default=nan
- covariance
Covariance matrix for within- and between-fields covariance (units must be squared field units), multiple matrices can be concatenated along 3rd dimension to apply different covariances in time.
- Type:
float, default=nan
- timecovariance
Starting dates at which covariances apply (only applicable if multiple covariance matrices are prescribed).
- Type:
float, default=nan
- stochastictimestep
Timestep at which new stochastic noise terms are generated (default: md.timestepping.time_step).
- Type:
float, default=0
- randomflag
Whether to apply real randomness (true) or pseudo-randomness with fixed seed (false).
- Type:
int, default=1
- __init__(self, other=None)
Initializes the stochasticforcing parameters, optionally inheriting from another instance.
- __repr__(self)
Returns a detailed string representation of the stochasticforcing parameters.
- __str__(self)
Returns a short string identifying the class.
Examples
md.stochasticforcing = pyissm.model.classes.stochasticforcing() md.stochasticforcing.isstochasticforcing = 1 md.stochasticforcing.fields = [‘SMBforcing’] md.stochasticforcing.defaultdimension = 1 md.stochasticforcing.covariance = covariance_matrix
- __init__(other=None)
Initialize the instance with optional field inheritance.
- Parameters:
other (
object, optional) – Another instance to inherit field values from. If provided, any fields in the current instance that differ from the default values and exist in ‘other’ will be replaced with the values from ‘other’.
Notes
The inheritance process:
Iterates through all attributes of the current instance
Checks if the same attribute exists in the ‘other’ instance
Compares field values using _fields_equal()
If different, replaces the current value with the ‘other’ value
This enables the common ISSM pattern where classes can inherit configurations from existing instances while maintaining their default values for unspecified fields.
Methods
__init__([other])Initialize the instance with optional field inheritance.
check_consistency(md, solution, analyses)Check consistency of the [stochasticforcing.stochasticforcing] parameters.
issm_enum_string()Default ISSM C++ enum string used during marshalling.
marshall_class(fid, prefix[, md])Marshall [stochasticforcing.stochasticforcing] parameters to a binary file.
- check_consistency(md, solution, analyses)
Check consistency of the [stochasticforcing.stochasticforcing] parameters.
- Parameters:
md (
pyissm.model.Model) – The model object to check.solution (
str) – The solution name to check.analyses (list of
str) – List of analyses to check consistency for.
- Returns:
md – The model object with any consistency errors noted.
- Return type:
- marshall_class(fid, prefix, md=None)
Marshall [stochasticforcing.stochasticforcing] parameters to a binary file.
- Parameters:
fid (file object) – The file object to write the binary data to.
prefix (str) – Prefix string used for data identification in the binary file.
md (ISSM model object, optional.) – ISSM model object needed in some cases.
- Return type:
None