analysis.py

analysis - submodule of SLOTH

Description: analysis.py is aimed to hold standalone functions used for analysis purpose. Basically this are functions calculating some variabels.

[TBE]

sloth.analysis.calc_wtd(press, cellDepths)[source]

Calculate the water table depth.

Parameters:
  • press (ndarray) – Array of pressure values. The dimensions depend on the scenario: - For 3D: (z, y, x) - For 4D: (t, z, y, x)

  • cellDepths (ndarray) – Array of cell depths.

Returns:

wtd – Array of water table depths.

Return type:

ndarray

Notes

The function calculates the water table depth based on the given pressure values and cell depths. The water table depth is determined by subtracting the lower most pressure values and cell depths from the total column depth.

  • For 3D input, the water table depth is calculated as:

    wtd = totalColumnDepth - (press[0] + cellDepths[0] * 0.5)

  • For 4D input, assuming a time series of pressure values, the water table depth is calculated as:

    wtd = totalColumnDepth - (press[:, 0, …] + cellDepths[0] * 0.5)

Negative water table depths are set to 0 using np.where().

sloth.analysis.calc_wtd_HT(press, cellDepths)[source]

Calculate the water table depth.

Parameters:
  • press (htdarray) – Array of pressure values. The dimensions depend on the scenario: - For 3D: (z, y, x) - For 4D: (t, z, y, x)

  • cellDepths (ndarray) – Array of cell depths.

Returns:

wtd – Array of water table depths.

Return type:

ndarray

Notes

The function calculates the water table depth based on the given pressure values and cell depths. The water table depth is determined by subtracting the lower most pressure values and cell depths from the total column depth.

  • For 3D input, the water table depth is calculated as:

    wtd = totalColumnDepth - (press[0] + cellDepths[0] * 0.5)

  • For 4D input, assuming a time series of pressure values, the water table depth is calculated as:

    wtd = totalColumnDepth - (press[:, 0, …] + cellDepths[0] * 0.5)

Negative water table depths are set to 0 using np.where().

sloth.analysis.get_3Dgroundwaterbody_mask(satur)[source]

Calculate a 3D mask of the groundwater body.

The groundwater body refers to the volume of a soil column that is continuously fully saturated, starting from the very bottom of the model domain (bedrock).

Parameters:

satur (ndarray) – Input array representing the saturation level of the soil column. Shape: (nz, ny, nx)

Returns:

  • gwb_mask (ndarray) – Numpy array of the same shape as the ‘satur’ input, where each pixel belonging to the groundwater body is assigned a value of 1, and 0 otherwise. Shape: (nz, ny, nx)

  • wtd_z_index (ndarray) – Numpy array of the same 2D shape as the ‘satur’ input (without the z dimension). It holds the index of the first unsaturated layer, counted from the bottom/bedrock to the top/surface, for each soil column. If the index has a value of N+1, where N is the number of layers in the model, the entire column is saturated.

sloth.analysis.get_3Dgroundwaterbody_mask_HT(satur)[source]

Calculate a 3D mask of the groundwater body.

The groundwater body refers to the volume of a soil column that is continuously fully saturated, starting from the very bottom of the model domain (bedrock).

Parameters:

satur (htdarray) – Input array representing the saturation level of the soil column. Shape: (nz, ny, nx)

Returns:

  • gwb_mask (ndarray) – Numpy array of the same shape as the ‘satur’ input, where each pixel belonging to the groundwater body is assigned a value of 1, and 0 otherwise. Shape: (nz, ny, nx)

  • wtd_z_index (ndarray) – Numpy array of the same 2D shape as the ‘satur’ input (without the z dimension). It holds the index of the first unsaturated layer, counted from the bottom/bedrock to the top/surface, for each soil column. If the index has a value of N+1, where N is the number of layers in the model, the entire column is saturated.

sloth.analysis.vanGenuchten(refP, sSat, sRes, nVanG, aVanG)[source]

Calculate the degree of saturation as a function of the pressure head.

The degree of saturation is calculated as a function of the pressure head according to the M. Th. van Genuchten equation.

Reference: M. Th. van Genuchten. “A Closed‐form Equation for Predicting the Hydraulic Conductivity of Unsaturated Soils.” Soil Science Society of America Journal, 1980. DOI: https://doi.org/10.2136/sssaj1980.03615995004400050002x

Parameters:
  • refP (ndarray) – Pressure head. [L]

  • sSat (float) – Relative saturated water content. [-]

  • sRes (float) – Relative residual saturation. [-]

  • nVanG (float) – Non-linearity coefficient of the soil. [-]

  • aVanG (float) – Air entry value of the soil. [L^-1]

Returns:

vanG – Degree of saturation.

Return type:

ndarray

Notes

This function calculates the degree of saturation as a function of the pressure head using the van Genuchten equation. The van Genuchten equation relates the degree of saturation to the pressure head and soil-specific parameters.

The equation is given by:

vanG = ((sSat - sRes) / (1 + (aVanG * np.absolute(refP)) ** nVanG) ** mVanG) + sRes

Where: - sSat is the relative saturated water content, - sRes is the relative residual saturation, - nVanG is the non-linearity coefficient of the soil, - aVanG is the air entry value of the soil.

The coefficient mVanG is calculated as mVanG = 1 - (1 / nVanG).

To avoid unsaturated values where water is ponding, the output vanG is adjusted to 1 wherever refP is greater than or equal to 0.