Skip to content

Commit

Permalink
ruff
Browse files Browse the repository at this point in the history
  • Loading branch information
OnnoEbbens committed Oct 16, 2024
1 parent cc2ec0b commit ef49211
Showing 1 changed file with 31 additions and 21 deletions.
52 changes: 31 additions & 21 deletions examples/07_fews.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -72,9 +72,9 @@
"outputs": [],
"source": [
"# download test file\n",
"if not os.path.exists('./fewsdata'):\n",
" os.mkdir('./fewsdata')\n",
"xml_file_url = 'https://raw.githubusercontent.com/ArtesiaWater/hydropandas/refs/heads/master/tests/data/2019-FEWS-test/test_wsvv_fews.xml'\n",
"if not os.path.exists(\"./fewsdata\"):\n",
" os.mkdir(\"./fewsdata\")\n",
"xml_file_url = \"https://raw.githubusercontent.com/ArtesiaWater/hydropandas/refs/heads/master/tests/data/2019-FEWS-test/test_wsvv_fews.xml\"\n",
"r = requests.get(xml_file_url)\n",
"with open(\"./fewsdata/test_wsvv_fews.xml\", \"w+\") as f:\n",
" f.write(r.text)"
Expand Down Expand Up @@ -200,7 +200,7 @@
],
"source": [
"# read a single xml file\n",
"fname = './fewsdata/test_wsvv_fews.xml'\n",
"fname = \"./fewsdata/test_wsvv_fews.xml\"\n",
"oc = hpd.read_fews(fname, ObsClass=hpd.MeteoObs)\n",
"oc"
]
Expand Down Expand Up @@ -240,9 +240,13 @@
],
"source": [
"# plot the measurements\n",
"f, axes = plt.subplots(2,1, figsize=(10, 6), sharex=True)\n",
"oc.get_obs('FEWS_RADAR_241_P.radar.h')['value'].plot(ax=axes[0], marker='.', legend=True, ylabel='P [mm/d]')\n",
"oc.get_obs('FEWS_RADAR_241_Eact.d')['value'].plot(ax=axes[1], marker='.', legend=True, ylabel='Eact [mm/d]')\n"
"f, axes = plt.subplots(2, 1, figsize=(10, 6), sharex=True)\n",
"oc.get_obs(\"FEWS_RADAR_241_P.radar.h\")[\"value\"].plot(\n",
" ax=axes[0], marker=\".\", legend=True, ylabel=\"P [mm/d]\"\n",
")\n",
"oc.get_obs(\"FEWS_RADAR_241_Eact.d\")[\"value\"].plot(\n",
" ax=axes[1], marker=\".\", legend=True, ylabel=\"Eact [mm/d]\"\n",
")"
]
},
{
Expand All @@ -261,7 +265,7 @@
"outputs": [],
"source": [
"# download zip directory\n",
"zip_file_url = 'https://github.com/ArtesiaWater/hydropandas/raw/refs/heads/master/tests/data/2019-FEWS-test/WaalenBurg_201810-20190215_prod.zip'\n",
"zip_file_url = \"https://github.com/ArtesiaWater/hydropandas/raw/refs/heads/master/tests/data/2019-FEWS-test/WaalenBurg_201810-20190215_prod.zip\"\n",
"r = requests.get(zip_file_url)\n",
"with open(\"./fewsdata/WaalenBurg_201810-20190215_prod.zip\", \"wb\") as f:\n",
" f.write(r.content)"
Expand Down Expand Up @@ -403,7 +407,7 @@
],
"source": [
"# read a zipfile\n",
"fdir = './fewsdata/WaalenBurg_201810-20190215_prod.zip'\n",
"fdir = \"./fewsdata/WaalenBurg_201810-20190215_prod.zip\"\n",
"oc = hpd.read_fews(fdir)\n",
"oc"
]
Expand Down Expand Up @@ -436,9 +440,13 @@
],
"source": [
"# plot the measurements\n",
"f, ax= plt.subplots(figsize=(10, 3))\n",
"oc.get_obs('MPN-N-1_H.meting')['value'].plot(ax=ax, marker='.', legend=True, ylabel='m NAP')\n",
"oc.get_obs('MPN-N-2_H.meting')['value'].plot(ax=ax, marker='.', legend=True, ylabel='m NAP')\n"
"f, ax = plt.subplots(figsize=(10, 3))\n",
"oc.get_obs(\"MPN-N-1_H.meting\")[\"value\"].plot(\n",
" ax=ax, marker=\".\", legend=True, ylabel=\"m NAP\"\n",
")\n",
"oc.get_obs(\"MPN-N-2_H.meting\")[\"value\"].plot(\n",
" ax=ax, marker=\".\", legend=True, ylabel=\"m NAP\"\n",
")"
]
},
{
Expand All @@ -462,22 +470,24 @@
"outputs": [],
"source": [
"# put here the URL of your fews database\n",
"fews_db_url = \"\" # enter fews database url here\n",
"location_id = \"\" # enter location id here\n",
"fews_db_url = \"\" # enter fews database url here\n",
"location_id = \"\" # enter location id here\n",
"\n",
"# read as observation objects\n",
"params = {\"locationIds\": location_id,\n",
" \"documentVersion\": \"1.26\",\n",
" \"documentFormat\": \"PI_XML\"}\n",
"params = {\n",
" \"locationIds\": location_id,\n",
" \"documentVersion\": \"1.26\",\n",
" \"documentFormat\": \"PI_XML\",\n",
"}\n",
"\n",
"r = requests.get(fews_db_url, params=params, verify=True)\n",
"xmlstring = r.text\n",
"\n",
"oc = hpd.ObsCollection.from_fews_xml(\n",
" xmlstring=xmlstr,\n",
" ObsClass=hpd.Obs,\n",
" low_memory=False,\n",
" )\n",
" xmlstring=xmlstr,\n",
" ObsClass=hpd.Obs,\n",
" low_memory=False,\n",
")\n",
"\n",
"oc"
]
Expand Down

0 comments on commit ef49211

Please sign in to comment.