diff --git a/examples/07_fews.ipynb b/examples/07_fews.ipynb index d4e5d248..98b28f85 100644 --- a/examples/07_fews.ipynb +++ b/examples/07_fews.ipynb @@ -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)" @@ -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" ] @@ -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", + ")" ] }, { @@ -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)" @@ -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" ] @@ -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", + ")" ] }, { @@ -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" ]