Skip to content

Commit 739b473

Browse files
authored
saturation_vapor_pressure_slope (#164)
1 parent 0208817 commit 739b473

File tree

4 files changed

+133
-2
lines changed

4 files changed

+133
-2
lines changed

ncl/ncl_entries/meteorology.ipynb

+40-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,8 @@
1818
"- [dewtemp_trh](https://www.ncl.ucar.edu/Document/Functions/Built-in/dewtemp_trh.shtml)\n",
1919
"- [daylight_fao56](https://www.ncl.ucar.edu/Document/Functions/Crop/daylight_fao56.shtml)\n",
2020
"- [satvpr_temp_fao56](https://www.ncl.ucar.edu/Document/Functions/Crop/satvpr_temp_fao56.shtml)\n",
21-
"- [satvpr_tdew_fao56](https://www.ncl.ucar.edu/Document/Functions/Crop/satvpr_tdew_fao56.shtml)"
21+
"- [satvpr_tdew_fao56](https://www.ncl.ucar.edu/Document/Functions/Crop/satvpr_tdew_fao56.shtml)\n",
22+
"- [satvpr_slope_fao56](https://www.ncl.ucar.edu/Document/Functions/Crop/satvpr_slope_fao56.shtml)"
2223
]
2324
},
2425
{
@@ -199,6 +200,43 @@
199200
"actual_saturation_vapor_pressure(temp)"
200201
]
201202
},
203+
{
204+
"cell_type": "markdown",
205+
"metadata": {},
206+
"source": [
207+
"## satvpr_slope_fao56\n",
208+
"\n",
209+
"NCL's `satvpr_slope_fao56` calculates the slope of the saturation vapor pressure curve as described in the Food and Agriculture Organization (FAO) Irrigation and Drainage Paper 56 [(Chapter 3, Equation 13)](https://www.fao.org/4/x0490e/x0490e07.htm) {footcite}`allan_fao_1998`"
210+
]
211+
},
212+
{
213+
"cell_type": "code",
214+
"execution_count": null,
215+
"metadata": {},
216+
"outputs": [],
217+
"source": [
218+
"# Input: Single Value\n",
219+
"from geocat.comp import saturation_vapor_pressure_slope\n",
220+
"\n",
221+
"temp = 60 # Fahrenheit\n",
222+
"\n",
223+
"saturation_vapor_pressure_slope(temp)"
224+
]
225+
},
226+
{
227+
"cell_type": "code",
228+
"execution_count": null,
229+
"metadata": {},
230+
"outputs": [],
231+
"source": [
232+
"# Input: List/Array\n",
233+
"from geocat.comp import saturation_vapor_pressure_slope\n",
234+
"\n",
235+
"temp = [35, 60, 80, 200] # Fahrenheit\n",
236+
"\n",
237+
"saturation_vapor_pressure_slope(temp)"
238+
]
239+
},
202240
{
203241
"cell_type": "markdown",
204242
"metadata": {},
@@ -216,6 +254,7 @@
216254
"- [GeoCAT-comp `max_daylight` Documentation](https://geocat-comp.readthedocs.io/en/latest/user_api/generated/geocat.comp.meteorology.max_daylight.html)\n",
217255
"- [GeoCAT-comp `saturation_vapor_pressure` Documentation](https://geocat-comp.readthedocs.io/en/latest/user_api/generated/geocat.comp.meteorology.saturation_vapor_pressure.html)\n",
218256
"- [GeoCAT-comp `actual_saturation_vapor_pressure` Documentation](https://geocat-comp.readthedocs.io/en/latest/user_api/generated/geocat.comp.meteorology.actual_saturation_vapor_pressure.html)\n",
257+
"- [GeoCAT-comp `saturation_vapor_pressure_slope` Documentation](https://geocat-comp.readthedocs.io/en/latest/user_api/generated/geocat.comp.meteorology.saturation_vapor_pressure_slope.html)\n",
219258
"\n",
220259
"## Additional Reading\n",
221260
"- [NOAA: Dew Point vs. Humidity](https://www.weather.gov/arx/why_dewpoint_vs_humidity)"

ncl/ncl_index/ncl-index-table.csv

+1
Original file line numberDiff line numberDiff line change
@@ -49,3 +49,4 @@ NCL Function,Description,Python Equivalent,Notes
4949
`css2c <https://www.ncl.ucar.edu/Document/Functions/Built-in/css2c.shtml>`__,"Converts spherical coordinates (lat/lon) to Cartesian coordinates on a unit sphere","``astropy.UnitSphericalRepresentation()``",`example notebook <../ncl_entries/great_circle.ipynb#css2c>`__
5050
`satvpr_temp_fao56 <https://www.ncl.ucar.edu/Document/Functions/Crop/satvpr_temp_fao56.shtml>`__,"Compute saturation vapor pressure using temperature as described in FAO 56","``geocat.comp.saturation_vapor_pressure()``",`example notebook <../ncl_entries/meteorology.ipynb#satvpr-temp-fao56>`__
5151
`satvpr_tdew_fao56 <https://www.ncl.ucar.edu/Document/Functions/Crop/satvpr_tdew_fao56.shtml>`__,"Compute actual saturation vapor pressure as described in FAO 56","``geocat.comp.actual_saturation_vapor_pressure()``",`example notebook <../ncl_entries/meteorology.ipynb#satvpr-tdew-fao56>`__
52+
`satvpr_slope_fao56 <https://www.ncl.ucar.edu/Document/Functions/Crop/satvpr_slope_fao56.shtml>`__," Compute the slope of the saturation vapor pressure curve as described in FAO 56","``geocat.comp.saturation_vapor_pressure_slope()``",`example notebook <../ncl_entries/meteorology.ipynb#satvpr-slope-fao56>`__

ncl/ncl_raw/meteorology.ncl

+13
Original file line numberDiff line numberDiff line change
@@ -53,3 +53,16 @@ do temp=33,212
5353
print (temp + "," + act_sat_vpr_pressure)
5454
end
5555
end do
56+
57+
; satvpr_slope_fao56
58+
; Adapted from https://www.ncl.ucar.edu/Document/Functions/Crop/satvpr_slope_fao56.shtml
59+
60+
; ncl -n satvpr_slope_fao56.ncl >> satvpr_slope_fao56_output.txt
61+
62+
print("Temperature (F), Slope of Saturation Vapor Pressure Curve (kPa)")
63+
do temp=33,212
64+
begin
65+
slope_satvpr = satvpr_slope_fao56(temp, (/2, 2/))
66+
print (temp + "," + slope_satvpr)
67+
end
68+
end do

ncl/receipts/meteorology.ipynb

+79-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,8 @@
2727
"- [dewtemp_trh](https://www.ncl.ucar.edu/Document/Functions/Built-in/dewtemp_trh.shtml)\n",
2828
"- [daylight_fao56](https://www.ncl.ucar.edu/Document/Functions/Crop/daylight_fao56.shtml)\n",
2929
"- [satvpr_temp_fao56](https://www.ncl.ucar.edu/Document/Functions/Crop/satvpr_temp_fao56.shtml)\n",
30-
"- [satvpr_tdew_fao56](https://www.ncl.ucar.edu/Document/Functions/Crop/satvpr_tdew_fao56.shtml)"
30+
"- [satvpr_tdew_fao56](https://www.ncl.ucar.edu/Document/Functions/Crop/satvpr_tdew_fao56.shtml)\n",
31+
"- [satvpr_slope_fao56](https://www.ncl.ucar.edu/Document/Functions/Crop/satvpr_slope_fao56.shtml)"
3132
]
3233
},
3334
{
@@ -284,6 +285,60 @@
284285
" geocat_satvpr_tdew_fao56[temp] = actual_saturation_vapor_pressure(temp)"
285286
]
286287
},
288+
{
289+
"cell_type": "markdown",
290+
"id": "a933c4b2-3b1c-46ac-b1a0-47643e302c02",
291+
"metadata": {},
292+
"source": [
293+
"### satvpr_slope_fao56"
294+
]
295+
},
296+
{
297+
"cell_type": "code",
298+
"execution_count": null,
299+
"id": "fc1aa525-542a-4be3-8ed3-7eb998280890",
300+
"metadata": {},
301+
"outputs": [],
302+
"source": [
303+
"#### Collect NCL values for satvpr_slope_fao56 from geocat-datafiles\n",
304+
"import geocat.datafiles as gdf\n",
305+
"import numpy as np\n",
306+
"\n",
307+
"satvpr_slope_fao56_data = gdf.get(\n",
308+
" 'applications_files/ncl_outputs/satvpr_slope_fao56_output.txt'\n",
309+
")\n",
310+
"satvpr_slope_fao56_data = np.loadtxt(satvpr_slope_fao56_data, delimiter=',', skiprows=6)"
311+
]
312+
},
313+
{
314+
"cell_type": "code",
315+
"execution_count": null,
316+
"id": "33edf359-c26d-4eff-b845-d4df8d91f0ae",
317+
"metadata": {},
318+
"outputs": [],
319+
"source": [
320+
"### Collect NCL `satvpr_slope_fao56` value and associated (temp, slope_satvpr) values\n",
321+
"ncl_satvpr_slope_fao56 = dict(\n",
322+
" zip(satvpr_slope_fao56_data[::, 0], satvpr_slope_fao56_data[::, 1])\n",
323+
")"
324+
]
325+
},
326+
{
327+
"cell_type": "code",
328+
"execution_count": null,
329+
"id": "da65e261-19f5-4a1c-973d-1e7e13053621",
330+
"metadata": {},
331+
"outputs": [],
332+
"source": [
333+
"### Calculate GeoCAT-Comp `saturation_vapor_pressure_slope`\n",
334+
"from geocat.comp import saturation_vapor_pressure_slope\n",
335+
"\n",
336+
"geocat_satvpr_slope_fao56 = {}\n",
337+
"\n",
338+
"for temp in range(33, 212 + 1):\n",
339+
" geocat_satvpr_slope_fao56[temp] = saturation_vapor_pressure_slope(temp)"
340+
]
341+
},
287342
{
288343
"cell_type": "markdown",
289344
"id": "3237a0bffc6827fc",
@@ -391,6 +446,29 @@
391446
" ncl_satvpr_tdew_fao56[key], geocat_satvpr_tdew_fao56[key], rel_tol=1e-05\n",
392447
" ) # within 5 decimal points"
393448
]
449+
},
450+
{
451+
"cell_type": "markdown",
452+
"id": "a8b4bee3-7f78-42ba-a9ae-2d13e4b3db59",
453+
"metadata": {},
454+
"source": [
455+
"### satvpr_slope_fao56"
456+
]
457+
},
458+
{
459+
"cell_type": "code",
460+
"execution_count": null,
461+
"id": "35bbca06-937e-4459-89ab-6c82280790c7",
462+
"metadata": {},
463+
"outputs": [],
464+
"source": [
465+
"import math\n",
466+
"\n",
467+
"for key in ncl_satvpr_slope_fao56.keys():\n",
468+
" assert math.isclose(\n",
469+
" ncl_satvpr_slope_fao56[key], geocat_satvpr_slope_fao56[key], rel_tol=1e-05\n",
470+
" ) # within 5 decimal points"
471+
]
394472
}
395473
],
396474
"metadata": {

0 commit comments

Comments
 (0)