def extrapolate_precipitation(prec, altitudes, met_station_height):
"""Extrapolate precipitation to any given height.
This function can be used to extrapolate precipitation data from the height
of the meteorological measurement station to any given height. The routine
is take from the Excel version, which was released by the Cemaneige's
authors [1].
Args:
prec: Numpy [t] array, which contains the precipitation input as
measured at the meteorological station.
altitudes: Numpty [n] array of the median altitudes of each elevation
layer.
met_station_height: Scalar, which is the elevation above sea level of
the meteorological station.
Returns:
layer_prec: Numpy [t,n] array, with the precipitation of each elevation
layer n.
[1] https://webgr.irstea.fr/en/modeles/modele-de-neige/
"""
# precipitation gradient [1/m] defined in Cemaneige excel version
beta_altitude = 0.0004
# elevation threshold
z_thresh = 4000
# Number of elevation layer
num_layers = len(altitudes)
# Number of timesteps
num_timesteps = prec.shape[0]
# array for extrapolated precipitation of each elevation layer
layer_prec = np.zeros((num_timesteps, num_layers), dtype=np.float64)
# different extrapolation schemes depending on layer elevation
for l in prange(num_layers):
# layer median height smaller than threshold value
if altitudes[l] <= z_thresh:
layer_prec[:, l] = prec * np.exp((altitudes[l] - met_station_height)
* beta_altitude)
# layer median greater than threshold value
else:
# elevation of meteorological station smaller than threshold
if met_station_height <= z_thresh:
layer_prec[:, l] = prec * np.exp((z_thresh - met_station_height)
* beta_altitude)
# no extrapolation if station and layer median above threshold
else:
layer_prec[:, l] = prec
return layer_prec
评论列表
文章目录