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

heat_index_nws #124

Draft
wants to merge 14 commits into
base: main
Choose a base branch
from
80 changes: 78 additions & 2 deletions ncl/ncl_entries/meteorology.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@
"This section covers meteorology functions from NCL:\n",
"\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)"
"- [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)"
]
},
{
Expand Down Expand Up @@ -116,6 +117,80 @@
"max_daylight(days_of_year, latitudes)"
]
},
{
"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`"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Grab and Go"
]
},
{
"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)"
]
},
{
"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)"
]
},
{
"cell_type": "markdown",
"metadata": {},
Expand All @@ -130,7 +205,8 @@
"## 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 `max_daylight` Documentation](https://geocat-comp.readthedocs.io/en/latest/user_api/generated/geocat.comp.meteorology.max_daylight.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 `heat_index` documentation](https://geocat-comp.readthedocs.io/en/stable/user_api/generated/geocat.comp.meteorology.heat_index.html)\n",
"\n",
"## Additional Reading\n",
"- [NOAA: Dew Point vs. Humidity](https://www.weather.gov/arx/why_dewpoint_vs_humidity)"
Expand Down
1 change: 1 addition & 0 deletions ncl/ncl_index/ncl-index-table.csv
Original file line number Diff line number Diff line change
Expand Up @@ -45,3 +45,4 @@ 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>`__
14 changes: 0 additions & 14 deletions ncl/ncl_raw/daylight_fao56.ncl

This file was deleted.

14 changes: 0 additions & 14 deletions ncl/ncl_raw/dewtemp_trh.ncl

This file was deleted.

53 changes: 53 additions & 0 deletions ncl/ncl_raw/meteorology.ncl
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
; 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

; ncl -n daylight_fao56.ncl >> daylight_fao56_output.txt

print("DOY, Latitude (Degrees), Daylight Hours")
do doy=0,365
do lat=-66,66
begin
daylight_hours = daylight_fao56(doy, lat)
print (doy +","+ lat +","+ daylight_hours)
end
end do
end do

; heat_index_nws
; https://www.ncl.ucar.edu/Document/Functions/Contributed/heat_index_nws.shtml

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

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
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