Climate utils functions

AUTHORS: Julien Ruffault (julien.ruff@gmail.com), Nicolas Martin-StPaul (nicolas.martin@inrae.fr)

source

compute_vpd_from_t_rh

 compute_vpd_from_t_rh (relative_humidity:float, temperature:float,
                        air_pressure:float=101325)

Compute vapor pressure deficit (VPD) from air relative humidity and air temperature

Type Default Details
relative_humidity float Air relative_humidity (%)
temperature float Air temperature (degrees Celsius)
air_pressure float 101325 Unknown parameter definition Air pressure, used?
Returns float

Example: Compute VPD

compute_vpd_from_t_rh(relative_humidity=80, temperature=25)
0.6339533962744358

source

compute_etp_pt

 compute_etp_pt (tmoy:float, net_radiation:float, pt_coeff:float=1.26,
                 g:float=0)

Calcule Potential evapotranspiration (mm) PET using Pristeley Taylor Formulation

Type Default Details
tmoy float Mean temperature over the considered time step (degrees Celsius)
net_radiation float Cumulative Net radiation over the considered time sep (MJ.m2)
pt_coeff float 1.26 An empirical constant accounting for the vapor pressure deficit and resistance values Typically, α is 1.26 for open bodies of water, but has a wide range of values from less than 1 (humid conditions) to almost 2 (arid conditions).
g float 0 Unknown parameter definition
Returns float

Example: Compute ETP

compute_etp_pt(tmoy=80, net_radiation=25)
12.429220134837708
compute_etp_pt(tmoy=20, net_radiation=1, pt_coeff=1.14)
0.3186733971169735

source

compute_etp_pm

 compute_etp_pm (tmoy:float, net_radiation:float, u:float, vpd:float,
                 g:float=0)

Compute reference ETP from Penmman formulation

Type Default Details
tmoy float Mean temperature over the considered time step (degrees Celsius)
net_radiation float Cumulative Net radiation over the considered time sep (MJ.m2)
u float Wind speed (m.s-1)
vpd float Vapor pressure deficit (kpa)
g float 0 Unknown parameter definition
Returns float

source

calculate_radiation_diurnal_pattern

 calculate_radiation_diurnal_pattern (time_of_the_day:List[int],
                                      day_length:int)

Calculated diurnal pattern of temperature assuming a sinusoidal pattern with T = tmin at sunrise and T = (tmin + tmax)/2 at sunset. From sunset to sunrise follows a linear trend

Type Details
time_of_the_day typing.List[int]
day_length int value indicating the duration of the day (in seconds)
Returns float

Example: Calculate radiation diurnal pattern

calculate_radiation_diurnal_pattern(time_of_the_day=1, day_length=40)
0.0036562495459173377

source

calculate_temperature_diurnal_pattern

 calculate_temperature_diurnal_pattern (time_of_the_day:List[int],
                                        day_length:int, tmin:float,
                                        tmax:float, tmin_prev:float,
                                        tmax_prev:float, tmin_next:float)

Calculated diurnal pattern of temperature assuming a sinusoidal pattern with T = tmin at sunrise and T = (tmin+tmax)/2 at sunset. From sunset to sunrise follows a linear trend

Type Details
time_of_the_day typing.List[int]
day_length int value indicating the duration of the day (in seconds)
tmin float Unknown parameter definition
tmax float Unknown parameter definition
tmin_prev float Unknown parameter definition
tmax_prev float Unknown parameter definition
tmin_next float Unknown parameter definition
Returns float

source

calculate_rh_diurnal_pattern

 calculate_rh_diurnal_pattern (temperature:float, rhmin:float,
                               rhmax:float, tmin:float, tmax:float)

Calculate diurnal pattern of relative humidity from temperature

Type Details
temperature float Unknown parameter definition
rhmin float Unknown parameter definition
rhmax float Unknown parameter definition
tmin float Unknown parameter definition
tmax float Unknown parameter definition
Returns float

source

ppfd_umol_to_rg_watt

 ppfd_umol_to_rg_watt (ppfd:float, j_to_mol:float=4.6, frac_par:float=0.5)

Convert ppfd (umol) to rg (watt)

Type Default Details
ppfd float Photosynthetic photon flux density (umol.m-2.s-1)
j_to_mol float 4.6 Conversion factor
frac_par float 0.5 Function of solar rdiation that is photosynthetically active radiation (PAR)
Returns float

source

rg_watt_to_ppfd_umol

 rg_watt_to_ppfd_umol (rg:float, j_to_mol:float=4.6, frac_par:float=0.5)

Convert rg (watt) to ppfd (umol)

Type Default Details
rg float Global radiation (W/m2)
j_to_mol float 4.6 Conversion factor
frac_par float 0.5 Function of solar rdiation that is photosynthetically active radiation (PAR)
Returns float

source

rg_convertions

 rg_convertions (rg_watts:float=None, rg_mj:float=None, nhours:float=None)

Convert instantaneous radiation in watt to dialy cumulative radiation in MJ (MJ.day-1)

Type Default Details
rg_watts float None instantaneous radiation (watt)
rg_mj float None instantaneous radiation (in Mega Jule?)
nhours float None Unknown parameter definition
Returns float

Example: RG conversions

rg_convertions(rg_watts=1)
Conversion of rg from watts to Mega Jules
0.0864
rg_convertions(rg_mj=1)
Conversion of rg from Mega Jules to Watts
11.574074074074073
rg_convertions(rg_mj=1, nhours=100)
Conversion of rg from Mega Jules to Watts/hour
2.7777777777777777
rg_convertions(rg_watts=1, rg_mj=1, nhours=1)
Select one conversion rg_mj or rg_watts

source

declination

 declination (doy:int)

Calculate declination of sun (radians ? ) for a given julian day (DOY)

Type Details
doy int julian day (day of the year)
def potential_par(time_of_day: float, lat: float, doy: float):
    "Determine potential for a given place and date /used to determine cloud cover return potential par in W.m2"

    # Constants -----------------------------------------------------------------
    diffuse_fraction = 0.1
    solar_constant = 2084
    attenuation_coef = -0.174353387144778

    decl = declination(doy)

    pn = -cos(lat * pi / 180)
    pz = sin(lat * pi / 180)
    h_rad = (time_of_day - 6) * 3.1416 / 12
    se = cos(h_rad) * cos(decl)
    sn = -pz * sin(h_rad) * cos(decl) - pn * sin(decl)
    sz = -pn * sin(h_rad) * cos(decl) + pz * sin(decl)
    alt = atan(sz / ((se * se + sn * sn) ^ 0.5))
    azi = 3.1416 + atan(se / sn)

    # azi[sn > 0] = azi[sn > 0] + 3.1416 I dont understand the meaning of this
    if sn > 0:
        azi = azi + pi

    pfd = solar_constant * exp(attenuation_coef / sin(alt))

    # pfd[alt < 0] = 0 I dont understand the meaning of this
    dpfd = diffuse_fraction * pfd
    # dpfd[alt<0] = 0 I dont understand the meaning of this

    return dpfd + pfd * sin(alt)