extract_args

NumbaMinpack requires all arguments to be passed as a single flat array. This module provides functions to pack and unpack model variables into/from such a flat array, supporting variable grid sizes and optional arrays.

This is done using a mapping of indices for each scalar variable in the packed array, as well as pointers to the start of variable-length arrays (e.g. firn temperature, lid temperature).

The intent here is to ensure that we just have one set of logic to move data from the Python structured array format into the flat array format required by NumbaMinpack, and one set of functions we can use and re-use to extract the relevant parameters from this packed array.

The indices defined below is the “canonical” mapping of model variables to positions in the packed args array. If you want to use a new variable inside the heat equation solver (or equivalently surface fluxes, since this is called inside the heat equation solver), you need to add it here.

We define functions to extract the specific parameters we need, which is determined by the needs of the specific physics functions.

Attributes

HEADER_SIZE

IDX_AIR_TEMP

IDX_ALBEDO

IDX_DP_TEMP

IDX_DT

IDX_DZ

IDX_EXPOSED_WATER

IDX_FIRN_DEPTH

IDX_K_LID_SCALAR

IDX_LAKE

IDX_LAKE_DEPTH

IDX_LID

IDX_LID_DEPTH

IDX_LW_IN

IDX_MELT

IDX_N_GRID

IDX_P_AIR

IDX_SCALARS_END

IDX_SFRAC_LID_SCALAR

IDX_SNOW_LID

IDX_SW_IN

IDX_V_LID

IDX_V_LID_DEPTH

IDX_V_LID_TEMP

IDX_WIND

PTR_FIRN_T

PTR_LAKE_T

PTR_LFRAC

PTR_LID_T

PTR_SFRAC

PTR_SIZE

Functions

extract_firn_arrays(args)

Extract only the variable-length firn arrays from the packed args array.

extract_lake_variables(args)

Extract only the variable-length lake arrays from the packed args array.

extract_lid_variables(args)

Extract only the variable-length lid arrays from the packed args array.

extract_met_data(args)

Extract only the meteorological data from the packed args array.

extract_scalars(args)

Extract only the scalar parameters from the packed args array.

pack_args(cell, met_data, dt, dz[, N, k_lid, Sfrac_lid])

Convert the variables from the model grid into a unified flat buffer.

Module Contents

extract_args.HEADER_SIZE = 25
extract_args.IDX_AIR_TEMP = 20
extract_args.IDX_ALBEDO = 8
extract_args.IDX_DP_TEMP = 22
extract_args.IDX_DT = 9
extract_args.IDX_DZ = 10
extract_args.IDX_EXPOSED_WATER = 2
extract_args.IDX_FIRN_DEPTH = 15
extract_args.IDX_K_LID_SCALAR = 11
extract_args.IDX_LAKE = 5
extract_args.IDX_LAKE_DEPTH = 6
extract_args.IDX_LID = 3
extract_args.IDX_LID_DEPTH = 4
extract_args.IDX_LW_IN = 18
extract_args.IDX_MELT = 1
extract_args.IDX_N_GRID = 0
extract_args.IDX_P_AIR = 21
extract_args.IDX_SCALARS_END = 17
extract_args.IDX_SFRAC_LID_SCALAR = 12
extract_args.IDX_SNOW_LID = 7
extract_args.IDX_SW_IN = 19
extract_args.IDX_V_LID = 13
extract_args.IDX_V_LID_DEPTH = 14
extract_args.IDX_V_LID_TEMP = 16
extract_args.IDX_WIND = 23
extract_args.PTR_FIRN_T = 27
extract_args.PTR_LAKE_T = 26
extract_args.PTR_LFRAC = 29
extract_args.PTR_LID_T = 25
extract_args.PTR_SFRAC = 28
extract_args.PTR_SIZE = 30