Exemple #1
0
def get_growth10(d_temp_maxF, d_temp_minF, c_temp_base, c4_temp):
    # d_temp_max in degree_F ---- 10 degree_C = 50.0 degree_F
    # d_temp_min in degree_F ---- 30 degree_C = 86.0 degree_F

    d_temp_base = FtoC(c_temp_base)
    c4_plants = FtoC(c4_temp)
    d_temp_max = FtoC(d_temp_maxF)
    d_temp_min = FtoC(d_temp_minF)
    growth10 = 0.0

    if d_temp_min < d_temp_base:

        if d_temp_max < c4_plants:

            if d_temp_max < d_temp_base:
                growth10 = 0.0

            else:
                growth10 = (d_temp_max + d_temp_base) / 2.0 - d_temp_base

        else:
            growth10 = (c4_plants + d_temp_min) / 2.0 - d_temp_base

    else:

        if d_temp_max < c4_plants:
            growth10 = (d_temp_max + d_temp_min) / 2.0 - d_temp_base

        else:
            growth10 = (c4_plants + d_temp_min) / 2.0 - d_temp_base

    return growth10
Exemple #2
0
def evapotranspiration_US(Tmin_F, Tmax_F, rh_min, rh_max, sr_mean_wpm2, ws_mph,
                          wind_height_ft, latitude_deg, longitude_deg,
                          altitude_ft, timestamp):
    """Calculate the rate of evapotranspiration during a one hour time period,
    returning result in inches/hr.
 
    Tmin_F: Minimum temperature during the hour in degrees Fahrenheit
 
    Tmax_F: Maximum temperature during the hour in degrees Fahrenheit
 
    rh_min: Minimum relative humidity during the hour in percent.
     
    rh_max: Maximum relative humidity during the hour in percent.
 
    sr_mean_wpm2: Mean solar radiation during the hour in watts per sq meter
 
    ws_mph: Average wind speed during the hour in miles per hour
 
    wind_height_ft: Height in feet at which windspeed is measured
 
    latitude_deg, longitude_deg: Latitude, longitude of the station in degrees
 
    altitude_ft: Altitude of the station in feet.
     
    timestamp: The time, as unix epoch time, at the end of the hour.
     
    Returns: Evapotranspiration in inches/hr
    
    Example (using data from HR station):
    >>> sr_mean_wpm2 = 860
    >>> timestamp = 1469829600  # 29-July-2016 22:00 UTC (15:00 local time)
    >>> print("ET0 = %.3f in/hr" % evapotranspiration_US(Tmin_F=87.8, Tmax_F=89.1,
    ...                                rh_min=34, rh_max=38,
    ...                                sr_mean_wpm2=sr_mean_wpm2, ws_mph=9.58, wind_height_ft=6,
    ...                                latitude_deg=45.7, longitude_deg=-121.5, altitude_ft=700,
    ...                                timestamp=timestamp))
    ET0 = 0.028 in/hr
    """
    try:
        Tmin_C = FtoC(Tmin_F)
        Tmax_C = FtoC(Tmax_F)
        ws_mps = ws_mph * METER_PER_MILE / 3600.0
        wind_height_m = wind_height_ft * METER_PER_FOOT
        altitude_m = altitude_ft * METER_PER_FOOT
    except TypeError:
        return None
    evt = evapotranspiration_Metric(Tmin_C=Tmin_C,
                                    Tmax_C=Tmax_C,
                                    rh_min=rh_min,
                                    rh_max=rh_max,
                                    sr_mean_wpm2=sr_mean_wpm2,
                                    ws_mps=ws_mps,
                                    wind_height_m=wind_height_m,
                                    latitude_deg=latitude_deg,
                                    longitude_deg=longitude_deg,
                                    altitude_m=altitude_m,
                                    timestamp=timestamp)
    return evt / MM_PER_INCH if evt is not None else None
Exemple #3
0
def thw_Metric(t_C, RH, ws_kph):
    """ Uses the air temperature, relative humidity, and wind speed
    (THW = temperature-humidity-wind) to calculate a
    potentially more accurate "felt-air temperature." This is not as accurate, however, as the THSW index, which
    can only be calculated when solar radiation information is available. It uses `calculate_heat_index` and then
    applies additional calculations to it using the wind speed. As such, it returns `None` for input temperatures below
    70 degrees Fahrenheit. The additional calculations come from web forums rumored to contain the proprietary
    Davis Instruments THW index formulas.
    hi is the heat index as calculated by `calculate_heat_index`
    WS is the wind speed in miles per hour
    :param temperature: The temperature in degrees Fahrenheit
    :type temperature: int | long | decimal.Decimal
    :param relative_humidity: The relative humidity as a percentage (88.2 instead of 0.882)
    :type relative_humidity: int | long | decimal.Decimal
    :param wind_speed: The wind speed in miles per hour
    :type wind_speed: int | long | decimal.Decimal
    :return: The THW index temperature in degrees Fahrenheit to one decimal place, or `None` if the temperature is
     less than 70F
    :rtype: decimal.Decimal
    """
    t_F = CtoF(t_C)
    hi_F = heatindexF(t_F, RH)
    WS = kph_to_mph(ws_kph)

    if not hi_F:
        return None

    hi = hi_F - (1.072 * WS)
    thw_C = FtoC(hi)

    return round(thw_C, 1) if thw_C is not None else None
Exemple #4
0
def sealevel_pressure_US(sp_inHg, elev_foot, t_F):
    if sp_inHg is None or elev_foot is None or t_F is None:
        return None
    sp_mbar = sp_inHg / INHG_PER_MBAR
    elev_meter = elev_foot * METER_PER_FOOT
    t_C = FtoC(t_F)
    slp_mbar = sealevel_pressure_Metric(sp_mbar, elev_meter, t_C)
    slp_inHg = slp_mbar * INHG_PER_MBAR
    return slp_inHg
Exemple #5
0
def evapotranspiration_US(tmax_F,
                          tmin_F,
                          sr_avg,
                          ws_mph,
                          z_ft,
                          lat,
                          ts=None,
                          rh_min=None,
                          rh_max=None):
    """Returns ET rate in inches per day"""
    if tmax_F is None or tmin_F is None or sr_avg is None or ws_mph is None:
        return None
    tmax_C = FtoC(tmax_F)
    tmin_C = FtoC(tmin_F)
    ws_mps = ws_mph * METER_PER_MILE / 3600.0
    z_m = z_ft * METER_PER_FOOT
    evt = evapotranspiration_Metric(tmax_C, tmin_C, sr_avg, ws_mps, z_m, lat,
                                    ts, rh_min, rh_max)
    return evt / MM_PER_INCH if evt is not None else None
Exemple #6
0
def winddruck_US(dp_F, t_F, p_inHg, ws_mph):
    """Calculate the Winddruck in N per m2

    dp_F - dewpoint in degree Fahrenheit
    t_F - temperature in degree Fahrenheit
    p_inHg - pressure in inHg
    ws_mph - windSpeed in mile per hour

    """
    if dp_F is None or t_F is None or p_inHg is None or ws_mph is None:
        return None

    t_C = FtoC(t_F)
    dp_C = FtoC(dp_F)
    p_mbar = p_inHg / INHG_PER_MBAR
    ws_kph = ws_mph * 1.609344

    wdru_C = winddruck_Metric(dp_C, t_C, p_mbar, ws_kph)

    return wdru_C if wdru_C is not None else None
Exemple #7
0
def humidexF(t_F, rh):
    """Calculate the humidex in degree Fahrenheit

    t_F - temperature in degree Fahrenheit

    rh - relative humidity [0-100]
    """
    if t_F is None:
        return None
    h_C = humidexC(FtoC(t_F), rh)
    return CtoF(h_C) if h_C is not None else None
Exemple #8
0
def thsw_US(t_F, RH, ws_mph, rahes):

    if t_F is None or ws_mph is None or RH is None or rahes is None:
        return None

    t_C = FtoC(t_F)
    ws_kph = ws_mph * 1.609344
    thsw_C = thsw_Metric(t_C, RH, ws_kph, rahes)
    thsw_F = CtoF(thsw_C)

    return round(thsw_F, 1) if thsw_F is not None else None
Exemple #9
0
def dampfD_F(t_F):

    #  t_F = temperatur degree F

    if t_F is None:
        return None

    t_C = FtoC(t_F)
    dd_C = dampfD_C(t_C)

    return (dd_C * INHG_PER_MBAR) if (dd_C *
                                      INHG_PER_MBAR) is not None else None
Exemple #10
0
def density_US(dp_F, t_F, p_inHg):
    """Calculate the Air Density in kg per m3

    dp_F - dewpoint in degree Fahrenheit

    t_F - temperature in degree Fahrenheit

    p_inHg - pressure in inHg

    calculation airdensity_Metric(dp_C, t_C, p_mbar)
    """

    if dp_F is None or t_F is None or p_inHg is None:
        return None

    t_C = FtoC(t_F)
    dp_C = FtoC(dp_F)
    p_mbar = p_inHg / INHG_PER_MBAR
    aden_C = density_Metric(dp_C, t_C, p_mbar)

    return aden_C if aden_C is not None else None
Exemple #11
0
def cbindex_US(t_F, RH):
    # Chandler Burning Index calculations
    #  t_F = temperatur degree F
    #  RH = outHumidity

    if t_F is None or RH is None:
        return None

    t_C = FtoC(t_F)
    cbI_x = cbindex_Metric(t_C, RH)

    return cbI_x if cbI_x is not None else None
Exemple #12
0
def absF_F(t_F, RH):
    # absolut Humidity
    #  t_F = temperatur degree F
    #  RH = outHumidity

    if t_F is None or RH is None:
        return None

    t_C = FtoC(t_F)
    absF_x = absF_C(t_C, RH)

    return absF_x if absF_x is not None else None
Exemple #13
0
def sumsimIndex_C(t_C, RH):
    # Summer Simmer Index-Berechnung
    # rel. Luftfeuchte RH
    # temperatur in degree C

    if t_C is None or RH is None:
        return None

    t_F = CtoF(t_C)
    ssI_F = sumsimIndex_F(t_F, RH)
    ssI_C = FtoC(ssI_F)

    return ssI_C if ssI_C is not None else None
Exemple #14
0
def wetbulb_US(t_F, RH, p_inHg):
    #  Wet bulb calculations == Kuehlgrenztemperatur, Feuchtekugeltemperatur
    #  t_F = temperatur degree F
    #  RH = outHumidity
    #  p_inHg = pressure in inHg

    if t_F is None or RH is None or p_inHg is None:
        return None

    t_C = FtoC(t_F)
    p_mbar = p_inHg / INHG_PER_MBAR
    wb_C = wetbulb_Metric(t_C, RH, p_mbar)

    return CtoF(wb_C) if wb_C is not None else None
Exemple #15
0
def deltaT_US(t_F, RH, p_inHg):
    #  deltaT calculations == delta Lufttemperatur
    #  t_F = temperatur degree F
    #  RH = outHumidity
    #  p_inHg = pressure in inHg

    if t_F is None or RH is None or p_inHg is None:
        return None

    t_C = FtoC(t_F)
    p_mbar = p_inHg / INHG_PER_MBAR
    deltaT_C = deltaT_Metric(t_C, RH, p_mbar)

    return CtoF(deltaT_C) if deltaT_C is not None else None
Exemple #16
0
def da_US(t_F, p_inHg):
    #  Density altitude calculations
    #  t_F = temperatur degree F
    #  p_inHg = pressure

    if t_F is None or p_inHg is None:
        return None

    t_C = FtoC(t_F)
    p_mbar = p_inHg / INHG_PER_MBAR
    da_m = da_Metric(t_C, p_mbar)
    da_fo = da_m * 3.28084
    da_fo = round(da_fo, 1)

    return da_fo if da_fo is not None else None
Exemple #17
0
def windchillMetricWX(T_C, V_mps):
    """Wind chill, metric version, with wind in mps.
    
    T: Temperature in Celsius
    
    V: Wind speed in mps
    
    Returns wind chill in Celsius"""

    if T_C is None or V_mps is None:
        return None

    T_F = CtoF(T_C)
    V_mph = 2.237 * V_mps

    WcF = windchillF(T_F, V_mph)

    return FtoC(WcF) if WcF is not None else None
Exemple #18
0
def windchillC(T_C, V_kph):
    """Wind chill, metric version.
    
    T: Temperature in Celsius
    
    V: Wind speed in kph
    
    Returns wind chill in Celsius"""

    if T_C is None or V_kph is None:
        return None

    T_F = CtoF(T_C)
    V_mph = 0.621371192 * V_kph

    WcF = windchillF(T_F, V_mph)

    return FtoC(WcF) if WcF is not None else None
Exemple #19
0
def apptempF(t_F, rh, ws_mph):
    """Calculate apparent temperature in degree Fahrenheit

    t_F - temperature in degree Fahrenheit

    rh - relative humidity [0-100]

    ws_mph - wind speed in miles per hour
    """
    if t_F is None:
        return None
    if rh is None or rh < 0 or rh > 100:
        return None
    if ws_mph is None or ws_mph < 0:
        return None
    t_C = FtoC(t_F)
    ws_mps = ws_mph * METER_PER_MILE / 3600.0
    at_C = apptempC(t_C, rh, ws_mps)
    return CtoF(at_C) if at_C is not None else None
Exemple #20
0
def dewpointF(T, R):
    """Calculate dew point. 
    
    T: Temperature in Fahrenheit
    
    R: Relative humidity in percent.
    
    Returns: Dewpoint in Fahrenheit
    Examples:
    
    >>> print "%.1f" % dewpointF(68, 50)
    48.7
    >>> print "%.1f" % dewpointF(32, 50)
    15.5
    >>> print "%.1f" % dewpointF(-10, 50)
    -23.5
    """

    if T is None or R is None:
        return None

    TdC = dewpointC(FtoC(T), R)

    return CtoF(TdC) if TdC is not None else None
Exemple #21
0
def evapotranspiration_US(Tmin_F,
                          Tmax_F,
                          rh_min,
                          rh_max,
                          sr_mean_wpm2,
                          ws_mph,
                          wind_height_ft,
                          latitude_deg,
                          longitude_deg,
                          altitude_ft,
                          timestamp,
                          albedo=0.23,
                          cn=37,
                          cd=0.34):
    """Calculate the rate of evapotranspiration during a one-hour time period,
    returning result in inches/hr.

    See function evapotranspiration_Metric() for references.

    Args:
 
        Tmin_F (float): Minimum temperature during the hour in degrees Fahrenheit.
        Tmax_F (float): Maximum temperature during the hour in degrees Fahrenheit.
        rh_min (float): Minimum relative humidity during the hour in percent.
        rh_max (float): Maximum relative humidity during the hour in percent.
        sr_mean_wpm2 (float): Mean solar radiation during the hour in watts per sq meter.
        ws_mph (float): Average wind speed during the hour in miles per hour.
        wind_height_ft (float): Height in feet at which windspeed is measured.
        latitude_deg (float): Latitude of the station in degrees.
        longitude_deg (float): Longitude of the station in degrees.
        altitude_ft (float): Altitude of the station in feet.
        timestamp (float): The time, as unix epoch time, at the end of the hour.
        albedo (float): Albedo. Default is 0.23 (grass reference crop).
        cn (float): The numerator constant for the reference crop type and time step.
            Default is 37 (short reference crop).
        cd (float): The denominator constant for the reference crop type and time step.
            Default is 0.34 (daytime short reference crop).

    Returns:
        float: Evapotranspiration in inches/hr
    
    Example (using data from HR station):
    >>> sr_mean_wpm2 = 860
    >>> timestamp = 1469829600  # 29-July-2016 22:00 UTC (15:00 local time)
    >>> print("ET0 = %.3f in/hr" % evapotranspiration_US(Tmin_F=87.8, Tmax_F=89.1,
    ...                                rh_min=34, rh_max=38,
    ...                                sr_mean_wpm2=sr_mean_wpm2, ws_mph=9.58, wind_height_ft=6,
    ...                                latitude_deg=45.7, longitude_deg=-121.5, altitude_ft=700,
    ...                                timestamp=timestamp))
    ET0 = 0.028 in/hr
    """
    try:
        Tmin_C = FtoC(Tmin_F)
        Tmax_C = FtoC(Tmax_F)
        ws_mps = ws_mph * METER_PER_MILE / 3600.0
        wind_height_m = wind_height_ft * METER_PER_FOOT
        altitude_m = altitude_ft * METER_PER_FOOT
    except TypeError:
        return None
    evt = evapotranspiration_Metric(Tmin_C=Tmin_C,
                                    Tmax_C=Tmax_C,
                                    rh_min=rh_min,
                                    rh_max=rh_max,
                                    sr_mean_wpm2=sr_mean_wpm2,
                                    ws_mps=ws_mps,
                                    wind_height_m=wind_height_m,
                                    latitude_deg=latitude_deg,
                                    longitude_deg=longitude_deg,
                                    altitude_m=altitude_m,
                                    timestamp=timestamp,
                                    albedo=albedo,
                                    cn=cn,
                                    cd=cd)
    return evt / MM_PER_INCH if evt is not None else None
Exemple #22
0
def heatindexC(T_C, R, algorithm='new'):
    if T_C is None or R is None:
        return None
    T_F = CtoF(T_C)
    hi_F = heatindexF(T_F, R, algorithm)
    return FtoC(hi_F)
Exemple #23
0
def heatindexC(T_C, R):
    if T_C is None or R is None:
        return None
    T_F = CtoF(T_C)
    hi_F = heatindexF(T_F, R)
    return FtoC(hi_F)