Skip to content

Commit

Permalink
Fix of RH and VPD
Browse files Browse the repository at this point in the history
  • Loading branch information
kebasaa committed Apr 20, 2022
1 parent 4380bdf commit cb83ccf
Show file tree
Hide file tree
Showing 5 changed files with 324 additions and 343 deletions.
73 changes: 27 additions & 46 deletions 02_laser.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -186,47 +186,30 @@
"\n",
"# Calculates VPD from different environmental variables\n",
"def calculate_VPD(T_C, h2o_mmol_mol, P_Pa):\n",
" # Convert temperature from C to K\n",
" T_K = T_C + 273.15\n",
" \n",
" h2o_mol_mol = h2o_mmol_mol * 10**(-3)\n",
" # Unit conversions \n",
" T_K = T_C + 273.15 # Temperature in K\n",
" h2o_mol_mol = h2o_mmol_mol * 10**(-3) # water in [mol mol-1]\n",
"\n",
" # From Eddypro manual: https://www.licor.com/env/support/EddyPro/topics/calculate-micromet-variables.html\n",
" R = 8.314463 # Ideal gas constant (J K-1 mol-1)\n",
" M_d = 0.02897 # molecular weights of dry air (kg mol-1)\n",
" M_h2o = 0.01802 # molecular weights of water vapour (kg mol-1)\n",
" R_h2o = R / M_h2o # Water vapor gas constant (J K-1 mol-1)\n",
" e = h2o_mol_mol * P_Pa # Water vapor partial pressure (Pa)\n",
" es = calculate_es(T_C, P_Pa) # Water vapor partial pressure at saturation (Pa)\n",
" P_d = P_Pa - es # Dry air partial pressure (P_d, P_a)\n",
" rho_d = P_d / (R / M_d * T_K) # Dry air mass density (rho_d, kg m-3)\n",
" v_d = M_d / rho_d # Dry air molar volume (vd, m3 mol-1)\n",
" v_a = v_d * P_d/P_Pa # Air molar volume (vd, m3mol-1) \n",
" rho_h2o = h2o_mol_mol * M_h2o / v_a # Water vapor mole fraction\n",
" e = rho_h2o * R_h2o * T_K # Water vapor partial pressure (Pa) \n",
" VPD = es - e # VPD (Pa)\n",
" return(VPD)\n",
"\n",
"# Converts water concentration [mmol_mol] to RH [%]\n",
"# Converts water concentration [mmol mol] to RH [%]\n",
"def convert_mmol_RH(T_C, h2o_mmol_mol, P_Pa):\n",
" # Unit conversions \n",
" T_K = T_C + 273.15 # Temperature in K\n",
" h2o_mol_mol = h2o_mmol_mol * 10**(-3) # water in [mol mol-1]\n",
" \n",
" T_K = T_C + 273.15\n",
" #es = calculate_es(T_C, P_Pa)\n",
" #RH <- 0.263*P_Pa*((h2o_mmol_mol*18.02/28.97)/1000)*np.exp(17.67*(T_C)/(T_K-29.65))**(-1)\n",
" #RH = 100 if (RH > 100) else RH\n",
" #RH = np.nan if (RH < 5) else RH\n",
"\n",
" # From Eddypro manual: https://www.licor.com/env/support/EddyPro/topics/calculate-micromet-variables.html\n",
" R = 8.314463 # Ideal gas constant (J K-1 mol-1)\n",
" M_d = 0.02897 # molecular weights of dry air (kg mol-1)\n",
" M_h2o = 0.01802 # molecular weights of water vapour (kg mol-1)\n",
" R_h2o = R / M_h2o # Water vapor gas constant (J K-1 mol-1)\n",
" e = h2o_mol_mol * P_Pa # Water vapor partial pressure (Pa)\n",
" es = calculate_es(T_C, P_Pa) # Water vapor partial pressure at saturation (Pa)\n",
" P_d = P_Pa - es # Dry air partial pressure (P_d, P_a)\n",
" rho_d = P_d / (R / M_d * T_K) # Dry air mass density (rho_d, kg m-3)\n",
" v_d = M_d / rho_d # Dry air molar volume (vd, m3 mol-1)\n",
" v_a = v_d * P_d/P_Pa # Air molar volume (vd, m3mol-1) \n",
" rho_h2o = h2o_mmol_mol/1000 * M_h2o / v_a # Water vapor mole fraction\n",
" e = rho_h2o * R_h2o * T_K # Water vapor partial pressure (Pa) \n",
" RH = e/es * 100 # RH (%)\n",
" return(RH)\n",
"\n",
Expand All @@ -242,19 +225,20 @@
"\n",
"# Density of moist air\n",
"def calculate_rho_moist_air(T_C, h2o_mmol_mol, P_Pa):\n",
" # Temperature in K\n",
" T_K = T_C + 273.15\n",
" # Unit conversions \n",
" T_K = T_C + 273.15 # Temperature in K\n",
" h2o_mol_mol = h2o_mmol_mol * 10**(-3) # water in [mol mol-1]\n",
"\n",
" # Preparations\n",
" R = 8.314463 # Ideal gas constant (J K-1 mol-1)\n",
" M_d = 0.02897 # molecular weights of dry air (kg mol-1)\n",
" M_h2o = 0.01802 # molecular weights of water vapour (kg mol-1)\n",
" es = calculate_es(T_C, P_Pa) # Saturation vapour pressure (Pa)\n",
" P_d = P_Pa - es # Dry air partial pressure (P_d, P_a)\n",
" e = h2o_mol_mol * P_Pa # Water vapor partial pressure (Pa)\n",
" P_d = P_Pa - e # Dry air partial pressure (P_d, P_a)\n",
" rho_d = P_d / (R / M_d * T_K) # Dry air mass density (rho_d, kg m-3)\n",
" v_d = M_d / rho_d # Dry air molar volume (vd, m3 mol-1)\n",
" v_a = v_d * P_d/P_Pa # Air molar volume (vd, m3mol-1) \n",
" rho_h2o = h2o_mmol_mol/1000 * M_h2o / v_a # Water vapor mole fraction\n",
" rho_h2o = h2o_mol_mol * M_h2o / v_a # Ambient water vapor mass density (kg m-3)\n",
"\n",
" # Moist air mass density (ρa, kg m-3) \n",
" rho_air = rho_d + rho_h2o\n",
Expand All @@ -272,8 +256,9 @@
"# cp_m in [J kg-1 K-1]\n",
"# https://www.licor.com/env/support/EddyPro/topics/calculate-micromet-variables.html\n",
"def calculate_cp_moist_air(T_C, h2o_mmol_mol, P_Pa):\n",
" # Temperature in K\n",
" T_K = T_C + 273.15\n",
" # Unit conversions \n",
" T_K = T_C + 273.15 # Temperature in K\n",
" h2o_mol_mol = h2o_mmol_mol * 10**(-3) # water in [mol mol-1]\n",
"\n",
" # RH\n",
" RH = convert_mmol_RH(T_C, h2o_mmol_mol, P_Pa)\n",
Expand All @@ -285,12 +270,12 @@
" R = 8.314463 # Ideal gas constant (J K-1 mol-1)\n",
" M_d = 0.02897 # molecular weights of dry air (kg mol-1)\n",
" M_h2o = 0.01802 # molecular weights of water vapour (kg mol-1)\n",
" es = calculate_es(T_C, P_Pa) # Saturation vapour pressure (Pa)\n",
" P_d = P_Pa - es # Dry air partial pressure (P_d, P_a)\n",
" e = h2o_mol_mol * P_Pa # Water vapor partial pressure (Pa)\n",
" P_d = P_Pa - e # Dry air partial pressure (P_d, P_a)\n",
" rho_d = P_d / (R / M_d * T_K) # Dry air mass density (rho_d, kg m-3)\n",
" v_d = M_d / rho_d # Dry air molar volume (vd, m3 mol-1)\n",
" v_a = v_d * P_d/P_Pa # Air molar volume (vd, m3mol-1) \n",
" rho_h2o = h2o_mmol_mol/1000 * M_h2o / v_a # Water vapor mole fraction\n",
" rho_h2o = h2o_mol_mol * M_h2o / v_a # Ambient water vapor mass density (kg m-3)\n",
"\n",
" # Moist air mass density (ρa, kg m-3) \n",
" rho_air = rho_d + rho_h2o\n",
Expand All @@ -304,19 +289,17 @@
"\n",
"# Calculates the flux of water\n",
"def calculate_h2o_flux(T_C, P_Pa, h2o_mmol_mol_ambient, h2o_mmol_mol_chamber, airflow_lpm, area_m2):\n",
" # Temperature in K\n",
" T_K = T_C + 273.15\n",
" \n",
" # Unit conversions\n",
" T_K = T_C + 273.15 # Temperature in K\n",
" h2o_mol_mol_ambient = h2o_mmol_mol_ambient * 10**(-3)\n",
" h2o_mol_mol_chamber = h2o_mmol_mol_chamber * 10**(-3)\n",
" \n",
" # Preparations\n",
" R = 8.314463 # Ideal gas constant (J K-1 mol-1)\n",
" M_d = 0.02897 # molecular weights of dry air (kg mol-1)\n",
" M_h2o = 0.01802 # molecular weights of water vapour (kg mol-1)\n",
" es = calculate_es(T_C, P_Pa) # Saturation vapour pressure (Pa)\n",
" P_d = P_Pa - es # Dry air partial pressure (P_d, P_a)\n",
" e = h2o_mol_mol_chamber * P_Pa # Water vapor partial pressure (Pa)\n",
" P_d = P_Pa - e # Dry air partial pressure (P_d, P_a)\n",
" rho_d = P_d / (R / M_d * T_K) # Dry air mass density (rho_d, kg m-3)\n",
" v_d = M_d / rho_d # Dry air molar volume (v_d, m3 mol-1)\n",
" v_a = v_d * P_d/P_Pa # Air molar volume (v_a, m3mol-1)\n",
Expand All @@ -341,19 +324,17 @@
"\n",
"# Inspired from LI-6400 manual: Uses the water flux because water changes the air density. If stomata are open and H2o is added, the gas is more 'diluted'\n",
"def calculate_gas_flux(T_C, P_Pa, h2o_mmol_mol_ambient, h2o_mmol_mol_chamber, gas_mol_mol_ambient, gas_mol_mol_chamber, airflow_lpm, area_m2):\n",
" # Temperature in K\n",
" T_K = T_C + 273.15\n",
" \n",
" # Unit conversions\n",
" T_K = T_C + 273.15 # Temperature in K\n",
" h2o_mol_mol_ambient = h2o_mmol_mol_ambient * 10**(-3)\n",
" h2o_mol_mol_chamber = h2o_mmol_mol_chamber * 10**(-3)\n",
" \n",
" # Preparations\n",
" R = 8.314463 # Ideal gas constant (J K-1 mol-1)\n",
" M_d = 0.02897 # molecular weights of dry air (kg mol-1)\n",
" M_h2o = 0.01802 # molecular weights of water vapour (kg mol-1)\n",
" es = calculate_es(T_C, P_Pa) # Saturation vapour pressure (Pa)\n",
" P_d = P_Pa - es # Dry air partial pressure (P_d, P_a)\n",
" e = h2o_mol_mol_chamber * P_Pa # Water vapor partial pressure (Pa)\n",
" P_d = P_Pa - e # Dry air partial pressure (P_d, P_a)\n",
" rho_d = P_d / (R / M_d * T_K) # Dry air mass density (rho_d, kg m-3)\n",
" v_d = M_d / rho_d # Dry air molar volume (vd, m3 mol-1)\n",
" v_a = v_d * P_d/P_Pa # Air molar volume (vd, m3mol-1)\n",
Expand Down
Loading

0 comments on commit cb83ccf

Please sign in to comment.