src.spyice.preprocess.store#
This module contains helper functions for initializing matrices, storing simulation results, creating output directories, and saving results to disk.
—
set_up_matrices#
- set_up_matrices(iter_max, nz)#
Initialize matrices with one column for each time step.
- Parameters:
iter_max (int) – The maximum number of iterations (time steps).
nz (int) – The number of vertical grid cells.
- Returns:
A tuple containing initialized NumPy arrays:
all_T (ndarray) – 2D array of shape
(iter_max, nz)filled with zeros.all_S_sw (ndarray) – 2D array of shape
(iter_max, nz)filled with zeros.all_phi (ndarray) – 2D array of shape
(iter_max, nz)filled with zeros.all_H (ndarray) – 2D array of shape
(iter_max, nz)filled with zeros.all_H_solid (ndarray) – 2D array of shape
(iter_max, nz)filled with zeros.all_w (ndarray) – 2D array of shape
(iter_max, nz)filled with zeros.all_thick (ndarray) – 1D array of length
iter_maxfilled with zeros.all_t_passed (ndarray) – 1D array of length
iter_maxfilled with zeros.
—
store_results#
- store_results(T, S_sw, phi, H, H_solid, w, thickness, t_passed, all_T, all_S_sw, all_phi, all_H, all_H_solid, all_w, all_thick, all_t_passed, t)#
Store simulation results for a given time step.
- Parameters:
T (numpy.ndarray) – Temperature values.
S_sw (numpy.ndarray) – Salinity values.
phi (numpy.ndarray) – Liquid fraction values.
H (numpy.ndarray) – Enthalpy values.
H_solid (numpy.ndarray) – Solid-state enthalpy values.
w (numpy.ndarray) – Velocity values.
thickness (float) – Ice thickness.
t_passed (float) – Elapsed simulation time.
all_T (numpy.ndarray) – Array storing temperature history.
all_S_sw (numpy.ndarray) – Array storing salinity history.
all_phi (numpy.ndarray) – Array storing liquid fraction history.
all_H (numpy.ndarray) – Array storing enthalpy history.
all_H_solid (numpy.ndarray) – Array storing solid enthalpy history.
all_w (numpy.ndarray) – Array storing velocity history.
all_thick (numpy.ndarray) – Array storing thickness history.
all_t_passed (numpy.ndarray) – Array storing elapsed time history.
t (int) – Current time step index.
- Returns:
Tuple containing all updated arrays.
—
create_directory#
- create_directory()#
Create a new directory using the current timestamp as its name.
The directory is created inside a predefined parent directory. The generated path is appended to
sys.path.- Returns:
None
—
save_results#
- save_results(all_T, all_S, all_phi, all_H, all_H_solid, all_w, all_thick, all_t_passed)#
Save simulation results to disk using compressed HKL files.
- Parameters:
all_T (list) – Temperature history.
all_S (list) – Salinity history.
all_phi (list) – Liquid fraction history.
all_H (list) – Enthalpy history.
all_H_solid (list) – Solid-state enthalpy history.
all_w (list) – Velocity history.
all_thick (list) – Thickness history.
all_t_passed (list) – Time history.
- Returns:
None