Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
55 changes: 55 additions & 0 deletions ncl/ncl_entries/meteorology.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
"\n",
"- [dewtemp_trh](https://www.ncl.ucar.edu/Document/Functions/Built-in/dewtemp_trh.shtml)\n",
"- [daylight_fao56](https://www.ncl.ucar.edu/Document/Functions/Crop/daylight_fao56.shtml)\n",
"- [heat_index_nws](https://www.ncl.ucar.edu/Document/Functions/Contributed/heat_index_nws.shtml)"
"- [satvpr_temp_fao56](https://www.ncl.ucar.edu/Document/Functions/Crop/satvpr_temp_fao56.shtml)\n",
"- [satvpr_tdew_fao56](https://www.ncl.ucar.edu/Document/Functions/Crop/satvpr_tdew_fao56.shtml)\n",
"- [satvpr_slope_fao56](https://www.ncl.ucar.edu/Document/Functions/Crop/satvpr_slope_fao56.shtml)"
Expand Down Expand Up @@ -139,6 +140,15 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"## heat_index_nws\n",
"\n",
"NCL's `heat_index_nws` computes the heat index as calculated by the National Weather Service{footcite}`nws_heat_index`\n",
"\n",
"Default coefficients when temperature if greater 80°F and relative humidity is greater than 40%\n",
"\n",
"Alternate coefficients when temperature is between 70°F and 115°F and relative humidity less than 80%\n",
"\n",
"The equation for the heat index to match the NOAA National Weather Service table is derived from regression analysis, so the default coefficients have a degree of error up to ±1.3°F{footcite}`rothfusz_heat_index`"
"## satvpr_temp_fao56\n",
"\n",
"NCL's `satvpr_temp_fao56` calculates saturation vapor pressure using temperature as described in the Food and Agriculture Organization (FAO) Irrigation and Drainage Paper 56 [(Chapter 3, Equation 11)](https://www.fao.org/4/x0490e/x0490e07.htm) {footcite}`allan_fao_1998`.\n",
Expand All @@ -157,6 +167,28 @@
},
{
"cell_type": "code",
"execution_count": 9,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"array([85.3104587])"
]
},
"execution_count": 9,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"# Input: Single Value\n",
"from geocat.comp import heat_index\n",
"\n",
"temp = 85 # Degrees Fahrenheit\n",
"rh = 45 # %\n",
"\n",
"heat_index(temp, rh)"
"execution_count": null,
"metadata": {},
"outputs": [],
Expand Down Expand Up @@ -253,6 +285,28 @@
},
{
"cell_type": "code",
"execution_count": 10,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"array([137.36135724, 135.8679973 , 85.3104587 ])"
]
},
"execution_count": 10,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"# Input: List/Array\n",
"from geocat.comp import heat_index\n",
"\n",
"temps = [104, 100, 85] # Degrees Fahrenheit\n",
"rhs = [55, 65, 45] # %\n",
"\n",
"heat_index(temps, rhs)"
"execution_count": null,
"metadata": {},
"outputs": [],
Expand All @@ -279,6 +333,7 @@
"## Python Resources\n",
"- [GeoCAT-comp `dewtemp` documentation](https://geocat-comp.readthedocs.io/en/latest/user_api/generated/geocat.comp.meteorology.dewtemp.html)\n",
"- [Convert between different temperature scales in SciPy](https://docs.scipy.org/doc/scipy/reference/generated/scipy.constants.convert_temperature.html)\n",
"- [GeoCAT-comp `heat_index` documentation](https://geocat-comp.readthedocs.io/en/stable/user_api/generated/geocat.comp.meteorology.heat_index.html)\n",
"- [GeoCAT-comp `max_daylight` Documentation](https://geocat-comp.readthedocs.io/en/latest/user_api/generated/geocat.comp.meteorology.max_daylight.html)\n",
"- [GeoCAT-comp `saturation_vapor_pressure` Documentation](https://geocat-comp.readthedocs.io/en/latest/user_api/generated/geocat.comp.meteorology.saturation_vapor_pressure.html)\n",
"- [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",
Expand Down
3 changes: 2 additions & 1 deletion ncl/ncl_index/ncl-index-table.csv
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,9 @@ NCL Function,Description,Python Equivalent,Notes
`round <https://www.ncl.ucar.edu/Document/Functions/Built-in/round.shtml>`__,"Rounds a float or double variable to the nearest whole number","``round()`` or ``numpy.round()``",`example notebook <../ncl_entries/general_applied_math.ipynb#decimalplaces-round>`__
`daylight_fao56 <https://www.ncl.ucar.edu/Document/Functions/Crop/daylight_fao56.shtml>`__," Compute maximum number of daylight hours as described in FAO 56","``geocat.comp.meteorology.max_daylight()``",`example notebook <../ncl_entries/meteorology.ipynb#daylight-fao56>`__
`dewtemp_trh <https://www.ncl.ucar.edu/Document/Functions/Built-in/dewtemp_trh.shtml>`__,"Calculates the dew point temperature given temperature and relative humidity","``geocat.comp.dewtemp()``",`example notebook <../ncl_entries/meteorology.ipynb#dewtemp-trh>`__
`heat_index_nws <https://www.ncl.ucar.edu/Document/Functions/Contributed/heat_index_nws.shtml>`__,"Compute the 'heat index' as calculated by the National Weather Service","``geocat.comp.heat_index()``",`example notebook <../ncl_entries/meteorology.ipynb#heat-index-nws>`__
`area_poly_sphere <https://www.ncl.ucar.edu/Document/Functions/Built-in/area_poly_sphere.shtml>`__,"Calculates the area enclosed by an arbitrary polygon on the sphere","``pyproj.Geod()`` and ``shapely.geometry.polygon.Polygon()``",`example notebook <../ncl_entries/great_circle.ipynb#area-poly-sphere>`__
`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>`__
`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>`__
`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>`__
`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>`__
`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>`__
32 changes: 22 additions & 10 deletions ncl/ncl_raw/meteorology.ncl
Original file line number Diff line number Diff line change
@@ -1,3 +1,18 @@
; dewtemp_trh
; Adapted from https://www.ncl.ucar.edu/Document/Functions/Built-in/dewtemp_trh.shtml

; ncl -n dewtemp_trh.ncl >> dewtemp_trh_output.txt

print("Temperature (K), Relative Humidity (%), Dew Temperature (C)")
do tk=273,374
do rh=1,100
begin
dewtemp = dewtemp_trh(tk,rh)-273.15
print (tk +","+ rh +","+ dewtemp)
end
end do
end do

; daylight_fao56
; Adapted from https://www.ncl.ucar.edu/Document/Functions/Crop/daylight_fao56.shtml

Expand All @@ -13,20 +28,17 @@ do doy=0,365
end do
end do

; dewtemp_trh
; Adapted from https://www.ncl.ucar.edu/Document/Functions/Built-in/dewtemp_trh.shtml
; heat_index_nws
; https://www.ncl.ucar.edu/Document/Functions/Contributed/heat_index_nws.shtml

; ncl -n dewtemp_trh.ncl >> dewtemp_trh_output.txt
; ncl -n heat_index_nws.ncl >> heat_index_nws_output.txt

print("Temperature (K), Relative Humidity (%), Dew Temperature (C)")
do tk=273,374
print("Temperature (F), Relative Humidity (%), Alternate Coefs (True/False), Heat Index (F)")
do tf=0, 115
do rh=1,100
begin
dewtemp = dewtemp_trh(tk,rh)-273.15
print (tk +","+ rh +","+ dewtemp)
end
end do
end do
heatindex = heat_index_nws(tf,rh,(/2,2/), False)
print (tf +","+ rh +"," + "0" + "," + heatindex)

; satvpr_temp_fao56
; Adapted from https://www.ncl.ucar.edu/Document/Functions/Crop/satvpr_temp_fao56.shtml
Expand Down
18 changes: 18 additions & 0 deletions ncl/receipts/heat_index_nws.ncl
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
print("Temperature (F), Relative Humidity (%), Alternate Coefs (True/False), Heat Index (F)")
do tf=0, 115
do rh=1,100
begin
heatindex = heat_index_nws(tf,rh,(/2,2/), False)
print (tf +","+ rh +"," + "0" + "," + heatindex)
end
end do
end do

do tf=0,115
do rh=1,100
begin
heatindex = heat_index_nws(tf,rh,(/2,2/), True)
print (tf +","+ rh +"," + "1" + "," + heatindex)
end
end do
end do
Loading
Loading