src.spyice.preprocess.initial_boundary_conditions#

exception src.spyice.preprocess.initial_boundary_conditions.SalinityUnavailableError[source]#

Bases: Exception

Exception raised when the S_IC option is not available in initial conditions.

src.spyice.preprocess.initial_boundary_conditions.boundary_condition(argument, t_passed, initial_salinity, **kwargs)[source]#

Calculates the boundary conditions for temperature or salinity.

Parameters:
  • argument (str) – The argument specifying whether to calculate temperature or salinity.

  • t_passed (float) – The time passed.

  • initial_salinity (float) – The initial salinity value.

  • **kwargs – Additional keyword arguments.

Returns:

A tuple containing the boundary conditions for temperature or salinity.

Return type:

tuple

Raises:

None

src.spyice.preprocess.initial_boundary_conditions.calculate_boundary_salinity(initial_salinity)[source]#

Calculates the boundary salinity values based on the initial salinity.

Parameters:

initial_salinity (str) – The initial salinity value.

Returns:

A tuple containing the bottom and top salinity values.

Return type:

tuple

Raises:

SalinityException – If the initial salinity value is not valid.

src.spyice.preprocess.initial_boundary_conditions.calculate_boundary_temperature(t_passed, initial_salinity, kwargs)[source]#

Calculates the boundary temperature based on the given parameters.

Parameters:
  • t_passed (float) – The time passed.

  • initial_salinity (str) – The initial salinity value.

  • kwargs (dict) – Additional keyword arguments.

Returns:

A tuple containing the bottom temperature and the top temperature.

Return type:

tuple

src.spyice.preprocess.initial_boundary_conditions.compute_melting_temperature_from_salinity(initial_salinity)[source]#

Computes the melting temperature from the given initial salinity.

Parameters:

initial_salinity (float) – The initial salinity value.

Returns:

The computed melting temperature.

Return type:

float

src.spyice.preprocess.initial_boundary_conditions.raise_salinity_exception(salinity_value)[source]#

Raises a custom exception if the salinity value is empty.

Parameters:

salinity_value (str) – The salinity value.

Raises:

SalinityUnavailableError – If the salinity value is empty.

src.spyice.preprocess.initial_boundary_conditions.set_boundary_temperature(t_passed, temperature_bottom, **kwargs)[source]#

Sets the boundary temperature based on the given parameters.

Parameters:
  • t_passed (float) – The time passed.

  • temperature_bottom (float) – The bottom temperature.

  • **kwargs – Additional keyword arguments.

Returns:

A tuple containing the top temperature and the bottom temperature.

Return type:

tuple

src.spyice.preprocess.initial_boundary_conditions.set_inital_salinity(initial_salinity, nz, boundary_salinity)[source]#

Sets the initial salinity values for each layer in the model.

Parameters:
  • initial_salinity (str) – The type of initial salinity distribution.

  • nz (int) – The number of layers in the model.

  • boundary_salinity (float) – The salinity value at the boundary.

Returns:

An array of initial salinity values for each layer.

Return type:

numpy.ndarray

Raises:

SalinityException – If the initial_salinity value is not recognized.

src.spyice.preprocess.initial_boundary_conditions.set_inital_temperature(initial_temperature, nz, boundary_salinity, boundary_top_temperature)[source]#

Sets the initial temperature profile based on the given parameters.

Parameters:
  • initial_temperature (str) – The type of initial temperature profile to set.

  • nz (int) – The number of vertical grid points.

  • boundary_salinity (float) – The salinity at the boundary.

  • boundary_top_temperature (float) – The temperature at the top boundary.

Returns:

The initial temperature profile as a 1D numpy array.

Return type:

numpy.ndarray

Raises:

None

src.spyice.preprocess.initial_boundary_conditions.set_initial_conditions(nz, boundary_salinity, initial_temperature='T0', initial_salinity='S1', initial_liquid_fraction='P1', boundary_top_temperature=265.0)[source]#

Sets the initial conditions for the simulation.

Parameters:
  • nz (int) – Number of vertical grid points.

  • boundary_salinity (float) – Salinity value at the boundary.

  • initial_temperature (str, optional) – Initial temperature profile. Defaults to “T0”.

  • initial_salinity (str, optional) – Initial salinity profile. Defaults to “S1”.

  • initial_liquid_fraction (str, optional) – Initial liquid fraction profile. Defaults to “P1”.

  • boundary_top_temperature (float, optional) – Temperature value at the top boundary. Defaults to 265.0.

Returns:

A tuple containing the temperature, salinity, liquid fraction, and upwind velocity arrays.

Return type:

tuple

src.spyice.preprocess.initial_boundary_conditions.set_initial_liquidfraction(initial_liquid_fraction, nz)[source]#

Sets the initial liquid fraction based on the given input.

Parameters:
  • initial_liquid_fraction (str) – The initial liquid fraction type.

  • nz (int) – The number of grid points.

Returns:

The array representing the initial liquid fraction.

Return type:

numpy.ndarray

Raises:

None

Examples

>>> set_initial_liquidfraction("P1", 10)
array([1., 1., 1., 1., 1., 1., 1., 1., 1., 1.])
>>> set_initial_liquidfraction("P_Stefan", 5)
array([0., 0., 0., 0., 0.])
>>> set_initial_liquidfraction("P0", 8)
array([0., 0., 0., 0., 0., 0., 0., 0.])
src.spyice.preprocess.initial_boundary_conditions.t_w3(dt)[source]#

Calculates the top boundary temperature and freeze date.

Parameters:

dt (float) – The time step.

Returns:

A tuple containing the top boundary temperature array and the freeze date.

Return type:

tuple

src.spyice.preprocess.initial_boundary_conditions.temperature_gradient(phi, nz)[source]#

Calculates the temperature gradient based on the given potential temperature profile and number of vertical levels.

Parameters:
  • phi (list) – The potential temperature profile.

  • nz (int) – The number of vertical levels.

Returns:

The calculated temperature gradient.

Return type:

float

Raises:

None