Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

A minor comments on the PET module #6

Open
RY4GIT opened this issue Sep 1, 2023 · 0 comments
Open

A minor comments on the PET module #6

RY4GIT opened this issue Sep 1, 2023 · 0 comments

Comments

@RY4GIT
Copy link

RY4GIT commented Sep 1, 2023

A few notes about things that I noticed while borrowing your PET module. All are not urgent but minor improvements!

PET module

def calculate_relative_humidity(self, row):
specific_humidity = row["SPFH_2maboveground"]
temperature = row["TMP_2maboveground"] - 273.15
pressure = row["PRES_surface"]/100
p_sat = 6.112 * math.exp((17.67 * temperature) / (temperature + 243.5))
relative_humidity = (specific_humidity / (1 - specific_humidity)) * (p_sat / pressure) * 100
return relative_humidity
def calculate_actual_vapor_pressure(self, row):
temperature = row["TMP_2maboveground"] - 273.15 # Temperature in Celsius
specific_humidity = row["SPFH_2maboveground"] # Specific humidity
pressure = row["PRES_surface"] # Atmospheric pressure in pascals
actual_vapor_pressure = specific_humidity * pressure / (0.622 + 0.378 * specific_humidity)
return actual_vapor_pressure

Missing reference

If there is any reference/readme/comments about reference constructing the equations, it would be highly appreciated!

Relative humidity calculation

Currently, relative humidity is calculated as being independent of actual vapor pressure calculated afterwards.

Alternatively, the relative humidity can be derived as a ratio of actual water vapor pressure to the saturation vapor pressure as follows.

    def calculate_relative_humidity(self, row):
        air_sat_vap_press_Pa = self.calc_air_saturation_vapor_pressure_Pa(row)
        actual_vapor_pressure_Pa = self.calculate_actual_vapor_pressure_Pa(row)
        relative_humidity = actual_vapor_pressure_Pa / air_sat_vap_press_Pa
        return relative_humidity
    
    def calc_air_saturation_vapor_pressure_Pa(self, row):
        air_temperature_C = row["temperature"] # Air temperature in degree Celcius
        air_sat_vap_press_Pa = 611.0 * math.exp(17.27 * air_temperature_C / (237.3 + air_temperature_C))
        return air_sat_vap_press_Pa

    def calculate_actual_vapor_pressure_Pa(self, row):
        q = row["specific_humidity"]  # Specific humidity in kg/kg
        p = row["pressure"]  # Atmospheric pressure in pascals
        actual_vapor_pressure_Pa = q * p / (0.622 + 0.378 * q)
        return actual_vapor_pressure_Pa 

Reference for the above functions

https://cran.r-project.org/web/packages/humidity/vignettes/humidity-measures.html#eq:1
https://github.com/NOAA-OWP/evapotranspiration/blob/1df115fdd5376fe37be8ceafcb5df3b2dd0577e4/include/pet_tools.h#L161C9-L161C9
https://github.com/NOAA-OWP/evapotranspiration/blob/1e971ffe784ade3c7ab322ccce6f49f48e942e3d/src/pet.c#L95

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant