Skip to content

Commit 3008321

Browse files
authored
coriolis_param (#176)
1 parent bc78660 commit 3008321

File tree

5 files changed

+149
-4
lines changed

5 files changed

+149
-4
lines changed

ncl/ncl_entries/meteorology.ipynb

+52-3
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,8 @@
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",
2121
"- [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)"
22+
"- [satvpr_slope_fao56](https://www.ncl.ucar.edu/Document/Functions/Crop/satvpr_slope_fao56.shtml)\n",
23+
"- [coriolis_param](https://www.ncl.ucar.edu/Document/Functions/Contributed/coriolis_param.shtml)"
2324
]
2425
},
2526
{
@@ -92,9 +93,9 @@
9293
"\n",
9394
"{math}`N = \\frac{24}{{\\pi}} {\\omega}_{s}`\n",
9495
"\n",
95-
"And {math}`{\\omega}_{s}` is the sunset hour angle in radians [(Chapter 3, Equation 25)](https://www.fao.org/4/X0490E/x0490e07.htm#chapter%203%20%20%20meteorological%20data) {footcite}`allan_fao_1998` which is calculated from the latitude of the observer on Earth ({math}`\\phi`) and the sun's declination ({math}`\\delta`):\n",
96+
"And {math}`{\\omega}_{s}` is the sunset hour angle in radians [(Chapter 3, Equation 25)](https://www.fao.org/4/X0490E/x0490e07.htm#chapter%203%20%20%20meteorological%20data) {footcite}`allan_fao_1998` which is calculated from the latitude of the observer on Earth ({math}`\\varphi`) and the sun's declination ({math}`\\delta`):\n",
9697
"\n",
97-
"{math}`{\\omega}_{s} = arccos[-tan({\\phi})tan({\\delta})]`"
98+
"{math}`{\\omega}_{s} = arccos[-tan({\\varphi})tan({\\delta})]`"
9899
]
99100
},
100101
{
@@ -265,6 +266,53 @@
265266
"saturation_vapor_pressure_slope(temp)"
266267
]
267268
},
269+
{
270+
"cell_type": "markdown",
271+
"metadata": {},
272+
"source": [
273+
"## coriolis_param\n",
274+
"\n",
275+
"NCL's `coriolis_param` calculates the Coriolis parameter at a given latitude\n",
276+
"\n",
277+
"The Coriolis parameter (also known as the Coriolis frequency or the Coriolis coefficient) is calculated as twice the rotation rate ({math}`{\\Omega}`) of the Earth times the sine of the latitude ({math}`{\\varphi}`){footcite}`hobbs_wallace_1997`\n",
278+
"\n",
279+
"{math}`f = 2{\\Omega}sin({\\varphi})`\n",
280+
"\n",
281+
"The rotation rate depends on the length of the rotation period of the Earth (T) which is defined as one sidereal day (23 hours and 56 minutes):\n",
282+
"\n",
283+
"{math}`{\\Omega} = \\frac{2 * {\\pi}}{T} = 7.292\\text{e-5} \\frac{rad}{s}`"
284+
]
285+
},
286+
{
287+
"cell_type": "code",
288+
"execution_count": null,
289+
"metadata": {},
290+
"outputs": [],
291+
"source": [
292+
"# Input: Single Value\n",
293+
"from metpy.calc import coriolis_parameter\n",
294+
"from metpy.units import units\n",
295+
"\n",
296+
"latitude = 40 # degrees\n",
297+
"\n",
298+
"coriolis_parameter(latitude * units.degree).magnitude"
299+
]
300+
},
301+
{
302+
"cell_type": "code",
303+
"execution_count": null,
304+
"metadata": {},
305+
"outputs": [],
306+
"source": [
307+
"# Input: List/Array\n",
308+
"from metpy.calc import coriolis_parameter\n",
309+
"from metpy.units import units\n",
310+
"\n",
311+
"latitude = [-20, 40, 65] # degrees\n",
312+
"\n",
313+
"coriolis_parameter(latitude * units.degree).magnitude"
314+
]
315+
},
268316
{
269317
"cell_type": "markdown",
270318
"metadata": {},
@@ -283,6 +331,7 @@
283331
"- [GeoCAT-comp `saturation_vapor_pressure` Documentation](https://geocat-comp.readthedocs.io/en/latest/user_api/generated/geocat.comp.meteorology.saturation_vapor_pressure.html)\n",
284332
"- [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",
285333
"- [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",
334+
"- [MetPy `coriolis_parameter` Documentation](https://unidata.github.io/MetPy/latest/api/generated/metpy.calc.coriolis_parameter.html)\n",
286335
"\n",
287336
"## Additional Reading\n",
288337
"- [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
@@ -50,3 +50,4 @@ NCL Function,Description,Python Equivalent,Notes
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>`__
5252
`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>`__
53+
`coriolis_param <https://www.ncl.ucar.edu/Document/Functions/Contributed/coriolis_param.shtml>`__,"Calculate the Coriolis parameter","``metpy.calc.coriolis_parameter()``",`example notebook <../ncl_entries/meteorology.ipynb#coriolis-param>`__

ncl/ncl_raw/meteorology.ncl

+10
Original file line numberDiff line numberDiff line change
@@ -66,3 +66,13 @@ do temp=33,212
6666
print (temp + "," + slope_satvpr)
6767
end
6868
end do
69+
70+
; coriolis_param
71+
; Adapted from https://www.ncl.ucar.edu/Document/Functions/Contributed/coriolis_param.shtml
72+
73+
; ncl -n coriolis_param.ncl >> coriolis_param_output.txt
74+
75+
print("Latitude (Degree), Coriolis Parameter")
76+
do lat=-90,90
77+
print(lat + "," + coriolis_param(lat))
78+
end do

ncl/receipts/meteorology.ipynb

+78-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,8 @@
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",
3030
"- [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)"
31+
"- [satvpr_slope_fao56](https://www.ncl.ucar.edu/Document/Functions/Crop/satvpr_slope_fao56.shtml)\n",
32+
"- [coriolis_param](https://www.ncl.ucar.edu/Document/Functions/Contributed/coriolis_param.shtml)"
3233
]
3334
},
3435
{
@@ -339,6 +340,59 @@
339340
" geocat_satvpr_slope_fao56[temp] = saturation_vapor_pressure_slope(temp)"
340341
]
341342
},
343+
{
344+
"cell_type": "markdown",
345+
"id": "3b9ce2e3-833a-4dbc-8d6a-35eb86397b19",
346+
"metadata": {},
347+
"source": [
348+
"### coriolis_param"
349+
]
350+
},
351+
{
352+
"cell_type": "code",
353+
"execution_count": null,
354+
"id": "c2646150-8327-4faa-8979-b70e98be9631",
355+
"metadata": {},
356+
"outputs": [],
357+
"source": [
358+
"#### Collect NCL values for coriolis_param from geocat-datafiles\n",
359+
"import geocat.datafiles as gdf\n",
360+
"import numpy as np\n",
361+
"\n",
362+
"coriolis_param_data = gdf.get(\n",
363+
" 'applications_files/ncl_outputs/coriolis_param_output.txt'\n",
364+
")\n",
365+
"coriolis_param_data = np.loadtxt(coriolis_param_data, delimiter=',', skiprows=6)"
366+
]
367+
},
368+
{
369+
"cell_type": "code",
370+
"execution_count": null,
371+
"id": "9a699cc2-5a21-4a49-92f9-353635036d06",
372+
"metadata": {},
373+
"outputs": [],
374+
"source": [
375+
"### Collect NCL `coriolis_param_data` value and associated coriolis parameter values\n",
376+
"ncl_coriolis_param = dict(zip(coriolis_param_data[::, 0], coriolis_param_data[::, 1]))"
377+
]
378+
},
379+
{
380+
"cell_type": "code",
381+
"execution_count": null,
382+
"id": "04410fd1-3033-4c6b-812f-e6b12b3e884e",
383+
"metadata": {},
384+
"outputs": [],
385+
"source": [
386+
"### Calculate MetPy \"coriolis_parameter\"\n",
387+
"from metpy.calc import coriolis_parameter\n",
388+
"from metpy.units import units\n",
389+
"\n",
390+
"metpy_coriolis_para = {}\n",
391+
"\n",
392+
"for lat in range(-90, 90 + 1):\n",
393+
" metpy_coriolis_para[lat] = coriolis_parameter(lat * units.degree).magnitude"
394+
]
395+
},
342396
{
343397
"cell_type": "markdown",
344398
"id": "3237a0bffc6827fc",
@@ -469,6 +523,29 @@
469523
" ncl_satvpr_slope_fao56[key], geocat_satvpr_slope_fao56[key], rel_tol=1e-05\n",
470524
" ) # within 5 decimal points"
471525
]
526+
},
527+
{
528+
"cell_type": "markdown",
529+
"id": "980c82cf-3860-4f46-bb98-65e4bea9f3cf",
530+
"metadata": {},
531+
"source": [
532+
"### coriolis_param"
533+
]
534+
},
535+
{
536+
"cell_type": "code",
537+
"execution_count": null,
538+
"id": "1229100a-0e88-46ef-afad-d557b043a713",
539+
"metadata": {},
540+
"outputs": [],
541+
"source": [
542+
"import math\n",
543+
"\n",
544+
"for key in ncl_coriolis_param.keys():\n",
545+
" assert math.isclose(\n",
546+
" ncl_coriolis_param[key], metpy_coriolis_para[key], rel_tol=1e-04\n",
547+
" ) # within 4 decimal points"
548+
]
472549
}
473550
],
474551
"metadata": {

references.bib

+8
Original file line numberDiff line numberDiff line change
@@ -128,3 +128,11 @@ @misc{usgs_1987
128128
title = {Map projections: A working manual},
129129
doi = {10.3133/pp1395}
130130
}
131+
132+
@book{hobbs_wallace_1997,
133+
author = {Hobbs, Peter V. and Wallace, John Michael},
134+
title = {Atmospheric Science: An Introductory Survey},
135+
year = {1977},
136+
pages = {277},
137+
publisher = {Academic Press}
138+
}

0 commit comments

Comments
 (0)