Skip to content

Commit

Permalink
update notebook for navgem
Browse files Browse the repository at this point in the history
  • Loading branch information
blaylockbk committed Oct 29, 2024
1 parent 66c7aff commit 575cac5
Showing 1 changed file with 76 additions and 18 deletions.
94 changes: 76 additions & 18 deletions docs/gallery/usnavy_models/navgem.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -1414,7 +1414,7 @@
},
{
"cell_type": "code",
"execution_count": 1,
"execution_count": 3,
"id": "062e3c33",
"metadata": {},
"outputs": [],
Expand Down Expand Up @@ -2581,22 +2581,26 @@
},
{
"cell_type": "code",
"execution_count": 2,
"execution_count": 5,
"id": "1f017ce0",
"metadata": {},
"outputs": [
{
"ename": "AttributeError",
"evalue": "'Herbie' object has no attribute 'level'",
"output_type": "error",
"traceback": [
"\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
"\u001b[0;31mAttributeError\u001b[0m Traceback (most recent call last)",
"Cell \u001b[0;32mIn[2], line 1\u001b[0m\n\u001b[0;32m----> 1\u001b[0m H \u001b[38;5;241m=\u001b[39m \u001b[43mHerbie\u001b[49m\u001b[43m(\u001b[49m\n\u001b[1;32m 2\u001b[0m \u001b[43m \u001b[49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[38;5;124;43m2024-01-04 00:00\u001b[39;49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[43m,\u001b[49m\n\u001b[1;32m 3\u001b[0m \u001b[43m \u001b[49m\u001b[43mmodel\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[38;5;124;43mnavgem_godae\u001b[39;49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[43m,\u001b[49m\n\u001b[1;32m 4\u001b[0m \u001b[43m \u001b[49m\u001b[43mvariable\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[38;5;124;43mTMP:2 m\u001b[39;49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[43m,\u001b[49m\n\u001b[1;32m 5\u001b[0m \u001b[43m \u001b[49m\u001b[43mfxx\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[38;5;241;43m6\u001b[39;49m\u001b[43m,\u001b[49m\n\u001b[1;32m 6\u001b[0m \u001b[43m)\u001b[49m\n",
"File \u001b[0;32m~/GitHub.com/blaylockbk/Herbie/herbie/core.py:235\u001b[0m, in \u001b[0;36mHerbie.__init__\u001b[0;34m(self, date, valid_date, model, fxx, product, priority, save_dir, overwrite, verbose, **kwargs)\u001b[0m\n\u001b[1;32m 227\u001b[0m \u001b[38;5;28msetattr\u001b[39m(\u001b[38;5;28mself\u001b[39m, key, value)\n\u001b[1;32m 229\u001b[0m \u001b[38;5;66;03m# Get details from the template of the specified model.\u001b[39;00m\n\u001b[1;32m 230\u001b[0m \u001b[38;5;66;03m# This attaches the details from the `models.<model>.template`\u001b[39;00m\n\u001b[1;32m 231\u001b[0m \u001b[38;5;66;03m# class to this Herbie object.\u001b[39;00m\n\u001b[1;32m 232\u001b[0m \u001b[38;5;66;03m# This line is equivalent to `model_templates.gfs.template(self)`.\u001b[39;00m\n\u001b[1;32m 233\u001b[0m \u001b[38;5;66;03m# I do it this way because the model name is a variable.\u001b[39;00m\n\u001b[1;32m 234\u001b[0m \u001b[38;5;66;03m# (see https://stackoverflow.com/a/7936588/2383070 for what I'm doing here)\u001b[39;00m\n\u001b[0;32m--> 235\u001b[0m \u001b[38;5;28;43mgetattr\u001b[39;49m\u001b[43m(\u001b[49m\u001b[43mmodel_templates\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[38;5;28;43mself\u001b[39;49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mmodel\u001b[49m\u001b[43m)\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mtemplate\u001b[49m\u001b[43m(\u001b[49m\u001b[38;5;28;43mself\u001b[39;49m\u001b[43m)\u001b[49m\n\u001b[1;32m 237\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m product \u001b[38;5;129;01mis\u001b[39;00m \u001b[38;5;28;01mNone\u001b[39;00m:\n\u001b[1;32m 238\u001b[0m \u001b[38;5;66;03m# The user didn't specify a product, so let's use the first\u001b[39;00m\n\u001b[1;32m 239\u001b[0m \u001b[38;5;66;03m# product in the model template.\u001b[39;00m\n\u001b[1;32m 240\u001b[0m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39mproduct \u001b[38;5;241m=\u001b[39m \u001b[38;5;28mlist\u001b[39m(\u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39mPRODUCTS)[\u001b[38;5;241m0\u001b[39m]\n",
"File \u001b[0;32m~/GitHub.com/blaylockbk/Herbie/herbie/models/usnavy.py:35\u001b[0m, in \u001b[0;36mnavgem_godae.template\u001b[0;34m(self)\u001b[0m\n\u001b[1;32m 27\u001b[0m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39mPRODUCTS \u001b[38;5;241m=\u001b[39m {\n\u001b[1;32m 28\u001b[0m \u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mGMET\u001b[39m\u001b[38;5;124m\"\u001b[39m: \u001b[38;5;124m\"\u001b[39m\u001b[38;5;124m\"\u001b[39m,\n\u001b[1;32m 29\u001b[0m \u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mGLND\u001b[39m\u001b[38;5;124m\"\u001b[39m: \u001b[38;5;124m\"\u001b[39m\u001b[38;5;124m\"\u001b[39m,\n\u001b[1;32m 30\u001b[0m \u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mGCOM\u001b[39m\u001b[38;5;124m\"\u001b[39m: \u001b[38;5;124m\"\u001b[39m\u001b[38;5;124m\"\u001b[39m,\n\u001b[1;32m 31\u001b[0m }\n\u001b[1;32m 33\u001b[0m \u001b[38;5;66;03m# Please review https://usgodae.org/docs/layout/mdllayout.pns.html\u001b[39;00m\n\u001b[1;32m 34\u001b[0m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39mSOURCES \u001b[38;5;241m=\u001b[39m {\n\u001b[0;32m---> 35\u001b[0m \u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mnavgem\u001b[39m\u001b[38;5;124m\"\u001b[39m: \u001b[38;5;124mf\u001b[39m\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mhttps://usgodae.org/ftp/outgoing/fnmoc/models/navgem_0.5/\u001b[39m\u001b[38;5;132;01m{\u001b[39;00m\u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39mdate\u001b[38;5;132;01m:\u001b[39;00m\u001b[38;5;124m%Y/%Y%m%d%H\u001b[39m\u001b[38;5;132;01m}\u001b[39;00m\u001b[38;5;124m/US058\u001b[39m\u001b[38;5;132;01m{\u001b[39;00m\u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39mproduct\u001b[38;5;132;01m}\u001b[39;00m\u001b[38;5;124m-GR1mdl.0018_0056_\u001b[39m\u001b[38;5;132;01m{\u001b[39;00m\u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39mfxx\u001b[38;5;132;01m:\u001b[39;00m\u001b[38;5;124m03d\u001b[39m\u001b[38;5;132;01m}\u001b[39;00m\u001b[38;5;124m00F0RL\u001b[39m\u001b[38;5;132;01m{\u001b[39;00m\u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39mdate\u001b[38;5;132;01m:\u001b[39;00m\u001b[38;5;124m%Y%m%d%H\u001b[39m\u001b[38;5;132;01m}\u001b[39;00m\u001b[38;5;124m_\u001b[39m\u001b[38;5;132;01m{\u001b[39;00m\u001b[38;5;28;43mself\u001b[39;49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mlevel\u001b[49m\u001b[38;5;132;01m}\u001b[39;00m\u001b[38;5;132;01m{\u001b[39;00m\u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39mvariable\u001b[38;5;132;01m}\u001b[39;00m\u001b[38;5;124m\"\u001b[39m,\n\u001b[1;32m 36\u001b[0m \u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mnogaps\u001b[39m\u001b[38;5;124m\"\u001b[39m: \u001b[38;5;124mf\u001b[39m\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mhttps://usgodae.org/ftp/outgoing/fnmoc/models/nogaps/\u001b[39m\u001b[38;5;132;01m{\u001b[39;00m\u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39mdate\u001b[38;5;132;01m:\u001b[39;00m\u001b[38;5;124m%Y/%Y%m%d%H\u001b[39m\u001b[38;5;132;01m}\u001b[39;00m\u001b[38;5;124m/US058\u001b[39m\u001b[38;5;132;01m{\u001b[39;00m\u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39mproduct\u001b[38;5;132;01m}\u001b[39;00m\u001b[38;5;124m-GR1mdl.0058_0240_\u001b[39m\u001b[38;5;132;01m{\u001b[39;00m\u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39mfxx\u001b[38;5;132;01m:\u001b[39;00m\u001b[38;5;124m03d\u001b[39m\u001b[38;5;132;01m}\u001b[39;00m\u001b[38;5;124m00F0RL\u001b[39m\u001b[38;5;132;01m{\u001b[39;00m\u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39mdate\u001b[38;5;132;01m:\u001b[39;00m\u001b[38;5;124m%Y%m%d%H\u001b[39m\u001b[38;5;132;01m}\u001b[39;00m\u001b[38;5;124m_\u001b[39m\u001b[38;5;132;01m{\u001b[39;00m\u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39mlevel\u001b[38;5;132;01m}\u001b[39;00m\u001b[38;5;132;01m{\u001b[39;00m\u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39mvariable\u001b[38;5;132;01m}\u001b[39;00m\u001b[38;5;124m\"\u001b[39m,\n\u001b[1;32m 37\u001b[0m }\n\u001b[1;32m 38\u001b[0m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39mLOCALFILE \u001b[38;5;241m=\u001b[39m \u001b[38;5;124mf\u001b[39m\u001b[38;5;124m\"\u001b[39m\u001b[38;5;132;01m{\u001b[39;00m\u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39mget_remoteFileName\u001b[38;5;132;01m}\u001b[39;00m\u001b[38;5;124m\"\u001b[39m\n",
"\u001b[0;31mAttributeError\u001b[0m: 'Herbie' object has no attribute 'level'"
"name": "stdout",
"output_type": "stream",
"text": [
"✅ Found ┊ model=navgem_godae ┊ \u001b[3mproduct=GMET\u001b[0m ┊ \u001b[38;2;41;130;13m2024-Jan-04 00:00 UTC\u001b[92m F06\u001b[0m ┊ \u001b[38;2;255;153;0m\u001b[3mGRIB2 @ navgem\u001b[0m ┊ \u001b[38;2;255;153;0m\u001b[3mIDX @ None\u001b[0m\n"
]
},
{
"data": {
"text/plain": [
"'https://usgodae.org/ftp/outgoing/fnmoc/models/navgem_0.5/2024/2024010400/US058GMET-GR1mdl.0018_0056_00600F0RL2024010400_0105_000020-000000air_temp'"
]
},
"execution_count": 5,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
Expand All @@ -2605,22 +2609,76 @@
" model=\"navgem_godae\",\n",
" variable=\"TMP:2 m\",\n",
" fxx=6,\n",
")"
")\n",
"H.grib"
]
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 6,
"id": "68ffa21f",
"metadata": {},
"outputs": [],
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"✅ Found ┊ model=navgem_godae ┊ \u001b[3mproduct=GMET\u001b[0m ┊ \u001b[38;2;41;130;13m2024-Jan-04 00:00 UTC\u001b[92m F06\u001b[0m ┊ \u001b[38;2;255;153;0m\u001b[3mGRIB2 @ navgem\u001b[0m ┊ \u001b[38;2;255;153;0m\u001b[3mIDX @ None\u001b[0m\n"
]
},
{
"data": {
"text/plain": [
"'https://usgodae.org/ftp/outgoing/fnmoc/models/navgem_0.5/2024/2024010400/US058GMET-GR1mdl.0018_0056_00600F0RL2024010400_0100_000500-000000rltv_hum'"
]
},
"execution_count": 6,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"H = Herbie(\n",
" \"2024-01-04 00:00\",\n",
" model=\"navgem_godae\",\n",
" variable=\"RH:500 mb\",\n",
" fxx=6,\n",
")"
")\n",
"H.grib"
]
},
{
"cell_type": "code",
"execution_count": 7,
"id": "28358924",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"✅ Found ┊ model=navgem_godae ┊ \u001b[3mproduct=GMET\u001b[0m ┊ \u001b[38;2;41;130;13m2024-Jan-04 00:00 UTC\u001b[92m F06\u001b[0m ┊ \u001b[38;2;255;153;0m\u001b[3mGRIB2 @ navgem\u001b[0m ┊ \u001b[38;2;255;153;0m\u001b[3mIDX @ None\u001b[0m\n"
]
},
{
"data": {
"text/plain": [
"'https://usgodae.org/ftp/outgoing/fnmoc/models/navgem_0.5/2024/2024010400/US058GMET-GR1mdl.0018_0056_00600F0RL2024010400_0001_000000-000000cape'"
]
},
"execution_count": 7,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"H = Herbie(\n",
" \"2024-01-04 00:00\",\n",
" model=\"navgem_godae\",\n",
" variable=\"CAPE:surface\",\n",
" fxx=6,\n",
")\n",
"H.grib\n"
]
},
{
Expand Down Expand Up @@ -3176,7 +3234,7 @@
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"display_name": "flight",
"language": "python",
"name": "python3"
},
Expand All @@ -3190,7 +3248,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.12.7"
"version": "3.12.3"
}
},
"nbformat": 4,
Expand Down

0 comments on commit 575cac5

Please sign in to comment.