From 5b34d13c8e6eb174bc3c0cd3d63abc5055743aca Mon Sep 17 00:00:00 2001 From: eric Date: Mon, 1 Apr 2024 18:26:02 -0700 Subject: [PATCH] finding bug --- .../automatic_weather_station_examples.ipynb | 441 +++++++++++++++++- easysnowdata/automatic_weather_stations.py | 30 +- 2 files changed, 449 insertions(+), 22 deletions(-) diff --git a/docs/examples/automatic_weather_station_examples.ipynb b/docs/examples/automatic_weather_station_examples.ipynb index e0896b2..4b1da02 100644 --- a/docs/examples/automatic_weather_station_examples.ipynb +++ b/docs/examples/automatic_weather_station_examples.ipynb @@ -2601,7 +2601,7 @@ }, { "cell_type": "code", - "execution_count": 26, + "execution_count": 63, "id": "9d5c0b8d", "metadata": {}, "outputs": [ @@ -2620,7 +2620,7 @@ }, { "cell_type": "code", - "execution_count": 27, + "execution_count": 64, "id": "bff062db", "metadata": {}, "outputs": [], @@ -2630,7 +2630,7 @@ }, { "cell_type": "code", - "execution_count": 28, + "execution_count": 65, "id": "7d817742-e0f9-43c2-91cd-bbf90ae4ea3b", "metadata": { "tags": [] @@ -2640,15 +2640,43 @@ "name": "stderr", "output_type": "stream", "text": [ - "100%|██████████| 130/130 [00:45<00:00, 2.83it/s]\n" + " 0%| | 0/130 [00:00 3805\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m \u001b[38;5;28;43mself\u001b[39;49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43m_engine\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mget_loc\u001b[49m\u001b[43m(\u001b[49m\u001b[43mcasted_key\u001b[49m\u001b[43m)\u001b[49m\n\u001b[1;32m 3806\u001b[0m \u001b[38;5;28;01mexcept\u001b[39;00m \u001b[38;5;167;01mKeyError\u001b[39;00m \u001b[38;5;28;01mas\u001b[39;00m err:\n", + "File \u001b[0;32mindex.pyx:167\u001b[0m, in \u001b[0;36mpandas._libs.index.IndexEngine.get_loc\u001b[0;34m()\u001b[0m\n", + "File \u001b[0;32mindex.pyx:196\u001b[0m, in \u001b[0;36mpandas._libs.index.IndexEngine.get_loc\u001b[0;34m()\u001b[0m\n", + "File \u001b[0;32mpandas/_libs/hashtable_class_helper.pxi:7081\u001b[0m, in \u001b[0;36mpandas._libs.hashtable.PyObjectHashTable.get_item\u001b[0;34m()\u001b[0m\n", + "File \u001b[0;32mpandas/_libs/hashtable_class_helper.pxi:7089\u001b[0m, in \u001b[0;36mpandas._libs.hashtable.PyObjectHashTable.get_item\u001b[0;34m()\u001b[0m\n", + "\u001b[0;31mKeyError\u001b[0m: '1900-01-01'", + "\nThe above exception was the direct cause of the following exception:\n", + "\u001b[0;31mKeyError\u001b[0m Traceback (most recent call last)", + "Cell \u001b[0;32mIn[65], line 1\u001b[0m\n\u001b[0;32m----> 1\u001b[0m \u001b[43mccssStations\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mget_data\u001b[49m\u001b[43m(\u001b[49m\u001b[43mstations\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mccss_only\u001b[49m\u001b[43m,\u001b[49m\u001b[43mvariables\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[38;5;124;43mWTEQ\u001b[39;49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[43m)\u001b[49m\n", + "File \u001b[0;32m~/repos/easysnowdata/easysnowdata/automatic_weather_stations.py:175\u001b[0m, in \u001b[0;36mStationCollection.get_data\u001b[0;34m(self, stations, variables, start_date, end_date)\u001b[0m\n\u001b[1;32m 173\u001b[0m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39mget_multiple_station_data(start_date\u001b[38;5;241m=\u001b[39mstart_date, end_date\u001b[38;5;241m=\u001b[39mend_date)\n\u001b[1;32m 174\u001b[0m \u001b[38;5;28;01melse\u001b[39;00m:\n\u001b[0;32m--> 175\u001b[0m \u001b[38;5;28;43mself\u001b[39;49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mget_multiple_station_data\u001b[49m\u001b[43m(\u001b[49m\u001b[43mvariables\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mvariables\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mstart_date\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mstart_date\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mend_date\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mend_date\u001b[49m\u001b[43m)\u001b[49m\n", + "File \u001b[0;32m~/repos/easysnowdata/easysnowdata/automatic_weather_stations.py:238\u001b[0m, in \u001b[0;36mStationCollection.get_multiple_station_data\u001b[0;34m(self, variables, start_date, end_date)\u001b[0m\n\u001b[1;32m 235\u001b[0m \u001b[38;5;28;01mexcept\u001b[39;00m:\n\u001b[1;32m 236\u001b[0m \u001b[38;5;28mprint\u001b[39m(\u001b[38;5;124mf\u001b[39m\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mfailed to retrieve \u001b[39m\u001b[38;5;132;01m{\u001b[39;00mstation\u001b[38;5;132;01m}\u001b[39;00m\u001b[38;5;124m\"\u001b[39m)\n\u001b[0;32m--> 238\u001b[0m station_data_df \u001b[38;5;241m=\u001b[39m \u001b[43mpd\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mDataFrame\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mfrom_dict\u001b[49m\u001b[43m(\u001b[49m\u001b[38;5;28;43mself\u001b[39;49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mstation_dict\u001b[49m\u001b[43m)\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mloc\u001b[49m\u001b[43m[\u001b[49m\u001b[43mstart_date\u001b[49m\u001b[43m:\u001b[49m\u001b[43mend_date\u001b[49m\u001b[43m]\u001b[49m\n\u001b[1;32m 240\u001b[0m \u001b[38;5;28msetattr\u001b[39m(\u001b[38;5;28mself\u001b[39m, \u001b[38;5;124mf\u001b[39m\u001b[38;5;124m\"\u001b[39m\u001b[38;5;132;01m{\u001b[39;00mvariable\u001b[38;5;132;01m}\u001b[39;00m\u001b[38;5;124m\"\u001b[39m, station_data_df)\n\u001b[1;32m 241\u001b[0m \u001b[38;5;28mprint\u001b[39m(\n\u001b[1;32m 242\u001b[0m \u001b[38;5;124mf\u001b[39m\u001b[38;5;124m\"\u001b[39m\u001b[38;5;132;01m{\u001b[39;00mvariable\u001b[38;5;132;01m}\u001b[39;00m\u001b[38;5;124m dataframe has been added to the Station object. Please use the .\u001b[39m\u001b[38;5;132;01m{\u001b[39;00mvariable\u001b[38;5;132;01m}\u001b[39;00m\u001b[38;5;124m attribute to access the dataframe.\u001b[39m\u001b[38;5;124m\"\u001b[39m\n\u001b[1;32m 243\u001b[0m )\n", + "File \u001b[0;32m~/miniconda3/envs/easysnowdata/lib/python3.12/site-packages/pandas/core/indexing.py:1191\u001b[0m, in \u001b[0;36m_LocationIndexer.__getitem__\u001b[0;34m(self, key)\u001b[0m\n\u001b[1;32m 1189\u001b[0m maybe_callable \u001b[38;5;241m=\u001b[39m com\u001b[38;5;241m.\u001b[39mapply_if_callable(key, \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39mobj)\n\u001b[1;32m 1190\u001b[0m maybe_callable \u001b[38;5;241m=\u001b[39m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39m_check_deprecated_callable_usage(key, maybe_callable)\n\u001b[0;32m-> 1191\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m \u001b[38;5;28;43mself\u001b[39;49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43m_getitem_axis\u001b[49m\u001b[43m(\u001b[49m\u001b[43mmaybe_callable\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43maxis\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43maxis\u001b[49m\u001b[43m)\u001b[49m\n", + "File \u001b[0;32m~/miniconda3/envs/easysnowdata/lib/python3.12/site-packages/pandas/core/indexing.py:1411\u001b[0m, in \u001b[0;36m_LocIndexer._getitem_axis\u001b[0;34m(self, key, axis)\u001b[0m\n\u001b[1;32m 1409\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m \u001b[38;5;28misinstance\u001b[39m(key, \u001b[38;5;28mslice\u001b[39m):\n\u001b[1;32m 1410\u001b[0m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39m_validate_key(key, axis)\n\u001b[0;32m-> 1411\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m \u001b[38;5;28;43mself\u001b[39;49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43m_get_slice_axis\u001b[49m\u001b[43m(\u001b[49m\u001b[43mkey\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43maxis\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43maxis\u001b[49m\u001b[43m)\u001b[49m\n\u001b[1;32m 1412\u001b[0m \u001b[38;5;28;01melif\u001b[39;00m com\u001b[38;5;241m.\u001b[39mis_bool_indexer(key):\n\u001b[1;32m 1413\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39m_getbool_axis(key, axis\u001b[38;5;241m=\u001b[39maxis)\n", + "File \u001b[0;32m~/miniconda3/envs/easysnowdata/lib/python3.12/site-packages/pandas/core/indexing.py:1443\u001b[0m, in \u001b[0;36m_LocIndexer._get_slice_axis\u001b[0;34m(self, slice_obj, axis)\u001b[0m\n\u001b[1;32m 1440\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m obj\u001b[38;5;241m.\u001b[39mcopy(deep\u001b[38;5;241m=\u001b[39m\u001b[38;5;28;01mFalse\u001b[39;00m)\n\u001b[1;32m 1442\u001b[0m labels \u001b[38;5;241m=\u001b[39m obj\u001b[38;5;241m.\u001b[39m_get_axis(axis)\n\u001b[0;32m-> 1443\u001b[0m indexer \u001b[38;5;241m=\u001b[39m \u001b[43mlabels\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mslice_indexer\u001b[49m\u001b[43m(\u001b[49m\u001b[43mslice_obj\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mstart\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mslice_obj\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mstop\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mslice_obj\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mstep\u001b[49m\u001b[43m)\u001b[49m\n\u001b[1;32m 1445\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m \u001b[38;5;28misinstance\u001b[39m(indexer, \u001b[38;5;28mslice\u001b[39m):\n\u001b[1;32m 1446\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39mobj\u001b[38;5;241m.\u001b[39m_slice(indexer, axis\u001b[38;5;241m=\u001b[39maxis)\n", + "File \u001b[0;32m~/miniconda3/envs/easysnowdata/lib/python3.12/site-packages/pandas/core/indexes/base.py:6662\u001b[0m, in \u001b[0;36mIndex.slice_indexer\u001b[0;34m(self, start, end, step)\u001b[0m\n\u001b[1;32m 6618\u001b[0m \u001b[38;5;28;01mdef\u001b[39;00m \u001b[38;5;21mslice_indexer\u001b[39m(\n\u001b[1;32m 6619\u001b[0m \u001b[38;5;28mself\u001b[39m,\n\u001b[1;32m 6620\u001b[0m start: Hashable \u001b[38;5;241m|\u001b[39m \u001b[38;5;28;01mNone\u001b[39;00m \u001b[38;5;241m=\u001b[39m \u001b[38;5;28;01mNone\u001b[39;00m,\n\u001b[1;32m 6621\u001b[0m end: Hashable \u001b[38;5;241m|\u001b[39m \u001b[38;5;28;01mNone\u001b[39;00m \u001b[38;5;241m=\u001b[39m \u001b[38;5;28;01mNone\u001b[39;00m,\n\u001b[1;32m 6622\u001b[0m step: \u001b[38;5;28mint\u001b[39m \u001b[38;5;241m|\u001b[39m \u001b[38;5;28;01mNone\u001b[39;00m \u001b[38;5;241m=\u001b[39m \u001b[38;5;28;01mNone\u001b[39;00m,\n\u001b[1;32m 6623\u001b[0m ) \u001b[38;5;241m-\u001b[39m\u001b[38;5;241m>\u001b[39m \u001b[38;5;28mslice\u001b[39m:\n\u001b[1;32m 6624\u001b[0m \u001b[38;5;250m \u001b[39m\u001b[38;5;124;03m\"\"\"\u001b[39;00m\n\u001b[1;32m 6625\u001b[0m \u001b[38;5;124;03m Compute the slice indexer for input labels and step.\u001b[39;00m\n\u001b[1;32m 6626\u001b[0m \n\u001b[0;32m (...)\u001b[0m\n\u001b[1;32m 6660\u001b[0m \u001b[38;5;124;03m slice(1, 3, None)\u001b[39;00m\n\u001b[1;32m 6661\u001b[0m \u001b[38;5;124;03m \"\"\"\u001b[39;00m\n\u001b[0;32m-> 6662\u001b[0m start_slice, end_slice \u001b[38;5;241m=\u001b[39m \u001b[38;5;28;43mself\u001b[39;49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mslice_locs\u001b[49m\u001b[43m(\u001b[49m\u001b[43mstart\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mend\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mstep\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mstep\u001b[49m\u001b[43m)\u001b[49m\n\u001b[1;32m 6664\u001b[0m \u001b[38;5;66;03m# return a slice\u001b[39;00m\n\u001b[1;32m 6665\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m \u001b[38;5;129;01mnot\u001b[39;00m is_scalar(start_slice):\n", + "File \u001b[0;32m~/miniconda3/envs/easysnowdata/lib/python3.12/site-packages/pandas/core/indexes/base.py:6879\u001b[0m, in \u001b[0;36mIndex.slice_locs\u001b[0;34m(self, start, end, step)\u001b[0m\n\u001b[1;32m 6877\u001b[0m start_slice \u001b[38;5;241m=\u001b[39m \u001b[38;5;28;01mNone\u001b[39;00m\n\u001b[1;32m 6878\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m start \u001b[38;5;129;01mis\u001b[39;00m \u001b[38;5;129;01mnot\u001b[39;00m \u001b[38;5;28;01mNone\u001b[39;00m:\n\u001b[0;32m-> 6879\u001b[0m start_slice \u001b[38;5;241m=\u001b[39m \u001b[38;5;28;43mself\u001b[39;49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mget_slice_bound\u001b[49m\u001b[43m(\u001b[49m\u001b[43mstart\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[38;5;124;43mleft\u001b[39;49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[43m)\u001b[49m\n\u001b[1;32m 6880\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m start_slice \u001b[38;5;129;01mis\u001b[39;00m \u001b[38;5;28;01mNone\u001b[39;00m:\n\u001b[1;32m 6881\u001b[0m start_slice \u001b[38;5;241m=\u001b[39m \u001b[38;5;241m0\u001b[39m\n", + "File \u001b[0;32m~/miniconda3/envs/easysnowdata/lib/python3.12/site-packages/pandas/core/indexes/base.py:6804\u001b[0m, in \u001b[0;36mIndex.get_slice_bound\u001b[0;34m(self, label, side)\u001b[0m\n\u001b[1;32m 6801\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39m_searchsorted_monotonic(label, side)\n\u001b[1;32m 6802\u001b[0m \u001b[38;5;28;01mexcept\u001b[39;00m \u001b[38;5;167;01mValueError\u001b[39;00m:\n\u001b[1;32m 6803\u001b[0m \u001b[38;5;66;03m# raise the original KeyError\u001b[39;00m\n\u001b[0;32m-> 6804\u001b[0m \u001b[38;5;28;01mraise\u001b[39;00m err\n\u001b[1;32m 6806\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m \u001b[38;5;28misinstance\u001b[39m(slc, np\u001b[38;5;241m.\u001b[39mndarray):\n\u001b[1;32m 6807\u001b[0m \u001b[38;5;66;03m# get_loc may return a boolean array, which\u001b[39;00m\n\u001b[1;32m 6808\u001b[0m \u001b[38;5;66;03m# is OK as long as they are representable by a slice.\u001b[39;00m\n\u001b[1;32m 6809\u001b[0m \u001b[38;5;28;01massert\u001b[39;00m is_bool_dtype(slc\u001b[38;5;241m.\u001b[39mdtype)\n", + "File \u001b[0;32m~/miniconda3/envs/easysnowdata/lib/python3.12/site-packages/pandas/core/indexes/base.py:6798\u001b[0m, in \u001b[0;36mIndex.get_slice_bound\u001b[0;34m(self, label, side)\u001b[0m\n\u001b[1;32m 6796\u001b[0m \u001b[38;5;66;03m# we need to look up the label\u001b[39;00m\n\u001b[1;32m 6797\u001b[0m \u001b[38;5;28;01mtry\u001b[39;00m:\n\u001b[0;32m-> 6798\u001b[0m slc \u001b[38;5;241m=\u001b[39m \u001b[38;5;28;43mself\u001b[39;49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mget_loc\u001b[49m\u001b[43m(\u001b[49m\u001b[43mlabel\u001b[49m\u001b[43m)\u001b[49m\n\u001b[1;32m 6799\u001b[0m \u001b[38;5;28;01mexcept\u001b[39;00m \u001b[38;5;167;01mKeyError\u001b[39;00m \u001b[38;5;28;01mas\u001b[39;00m err:\n\u001b[1;32m 6800\u001b[0m \u001b[38;5;28;01mtry\u001b[39;00m:\n", + "File \u001b[0;32m~/miniconda3/envs/easysnowdata/lib/python3.12/site-packages/pandas/core/indexes/base.py:3812\u001b[0m, in \u001b[0;36mIndex.get_loc\u001b[0;34m(self, key)\u001b[0m\n\u001b[1;32m 3807\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m \u001b[38;5;28misinstance\u001b[39m(casted_key, \u001b[38;5;28mslice\u001b[39m) \u001b[38;5;129;01mor\u001b[39;00m (\n\u001b[1;32m 3808\u001b[0m \u001b[38;5;28misinstance\u001b[39m(casted_key, abc\u001b[38;5;241m.\u001b[39mIterable)\n\u001b[1;32m 3809\u001b[0m \u001b[38;5;129;01mand\u001b[39;00m \u001b[38;5;28many\u001b[39m(\u001b[38;5;28misinstance\u001b[39m(x, \u001b[38;5;28mslice\u001b[39m) \u001b[38;5;28;01mfor\u001b[39;00m x \u001b[38;5;129;01min\u001b[39;00m casted_key)\n\u001b[1;32m 3810\u001b[0m ):\n\u001b[1;32m 3811\u001b[0m \u001b[38;5;28;01mraise\u001b[39;00m InvalidIndexError(key)\n\u001b[0;32m-> 3812\u001b[0m \u001b[38;5;28;01mraise\u001b[39;00m \u001b[38;5;167;01mKeyError\u001b[39;00m(key) \u001b[38;5;28;01mfrom\u001b[39;00m \u001b[38;5;21;01merr\u001b[39;00m\n\u001b[1;32m 3813\u001b[0m \u001b[38;5;28;01mexcept\u001b[39;00m \u001b[38;5;167;01mTypeError\u001b[39;00m:\n\u001b[1;32m 3814\u001b[0m \u001b[38;5;66;03m# If we have a listlike key, _check_indexing_error will raise\u001b[39;00m\n\u001b[1;32m 3815\u001b[0m \u001b[38;5;66;03m# InvalidIndexError. Otherwise we fall through and re-raise\u001b[39;00m\n\u001b[1;32m 3816\u001b[0m \u001b[38;5;66;03m# the TypeError.\u001b[39;00m\n\u001b[1;32m 3817\u001b[0m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39m_check_indexing_error(key)\n", + "\u001b[0;31mKeyError\u001b[0m: '1900-01-01'" ] } ], @@ -2656,6 +2684,405 @@ "ccssStations.get_data(stations=ccss_only,variables=\"WTEQ\")" ] }, + { + "cell_type": "code", + "execution_count": 70, + "id": "2d2bf79e", + "metadata": {}, + "outputs": [ + { + "data": { + "text/html": [ + "
\n", + "\n", + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "
FRWBNKCDPCRLCHMHHMHNTMUMSDFRTL...QUALLPFORGEMWTMSLTSLISLKSTLTMR
datetime
2000-10-21 00:00:000.00.0061NaN0.00.00.00330.00610.00.00610.0396...0.0183NaN0.00.00.00.00.00.0NaN0.0061
2000-10-22 00:00:000.00.0061NaN0.00.00.00000.00610.00.00610.0396...0.0152NaN0.00.00.00.00.00.0NaN0.0061
2000-10-23 00:00:000.00.0061NaN0.00.00.00000.00610.00.00910.0396...0.0152NaN0.00.00.00.00.00.0NaN0.0061
2000-10-24 00:00:000.00.0061NaN0.00.00.00000.00610.00.00910.0396...0.0152NaN0.00.00.00.00.00.0NaN0.0061
2000-10-25 00:00:000.00.0061NaN0.00.00.00000.00610.00.00910.0396...0.0152NaN0.00.00.00.00.00.0NaN0.0030
..................................................................
1963-02-10 00:00:00NaNNaNNaNNaNNaNNaNNaNNaNNaNNaN...NaNNaNNaNNaNNaNNaNNaNNaN0.4572NaN
1963-02-11 00:00:00NaNNaNNaNNaNNaNNaNNaNNaNNaNNaN...NaNNaNNaNNaNNaNNaNNaNNaN0.4572NaN
1963-02-12 00:00:00NaNNaNNaNNaNNaNNaNNaNNaNNaNNaN...NaNNaNNaNNaNNaNNaNNaNNaN0.4826NaN
1963-02-13 00:00:00NaNNaNNaNNaNNaNNaNNaNNaNNaNNaN...NaNNaNNaNNaNNaNNaNNaNNaN0.5080NaN
1963-02-14 00:00:00NaNNaNNaNNaNNaNNaNNaNNaNNaNNaN...NaNNaNNaNNaNNaNNaNNaNNaN0.5334NaN
\n", + "

39458 rows × 130 columns

\n", + "
" + ], + "text/plain": [ + " FRW BNK CDP CRL CHM HHM HNT MUM SDF \\\n", + "datetime \n", + "2000-10-21 00:00:00 0.0 0.0061 NaN 0.0 0.0 0.0033 0.0061 0.0 0.0061 \n", + "2000-10-22 00:00:00 0.0 0.0061 NaN 0.0 0.0 0.0000 0.0061 0.0 0.0061 \n", + "2000-10-23 00:00:00 0.0 0.0061 NaN 0.0 0.0 0.0000 0.0061 0.0 0.0091 \n", + "2000-10-24 00:00:00 0.0 0.0061 NaN 0.0 0.0 0.0000 0.0061 0.0 0.0091 \n", + "2000-10-25 00:00:00 0.0 0.0061 NaN 0.0 0.0 0.0000 0.0061 0.0 0.0091 \n", + "... ... ... ... ... ... ... ... ... ... \n", + "1963-02-10 00:00:00 NaN NaN NaN NaN NaN NaN NaN NaN NaN \n", + "1963-02-11 00:00:00 NaN NaN NaN NaN NaN NaN NaN NaN NaN \n", + "1963-02-12 00:00:00 NaN NaN NaN NaN NaN NaN NaN NaN NaN \n", + "1963-02-13 00:00:00 NaN NaN NaN NaN NaN NaN NaN NaN NaN \n", + "1963-02-14 00:00:00 NaN NaN NaN NaN NaN NaN NaN NaN NaN \n", + "\n", + " RTL ... QUA LLP FOR GEM WTM SLT SLI SLK \\\n", + "datetime ... \n", + "2000-10-21 00:00:00 0.0396 ... 0.0183 NaN 0.0 0.0 0.0 0.0 0.0 0.0 \n", + "2000-10-22 00:00:00 0.0396 ... 0.0152 NaN 0.0 0.0 0.0 0.0 0.0 0.0 \n", + "2000-10-23 00:00:00 0.0396 ... 0.0152 NaN 0.0 0.0 0.0 0.0 0.0 0.0 \n", + "2000-10-24 00:00:00 0.0396 ... 0.0152 NaN 0.0 0.0 0.0 0.0 0.0 0.0 \n", + "2000-10-25 00:00:00 0.0396 ... 0.0152 NaN 0.0 0.0 0.0 0.0 0.0 0.0 \n", + "... ... ... ... ... ... ... ... ... ... ... \n", + "1963-02-10 00:00:00 NaN ... NaN NaN NaN NaN NaN NaN NaN NaN \n", + "1963-02-11 00:00:00 NaN ... NaN NaN NaN NaN NaN NaN NaN NaN \n", + "1963-02-12 00:00:00 NaN ... NaN NaN NaN NaN NaN NaN NaN NaN \n", + "1963-02-13 00:00:00 NaN ... NaN NaN NaN NaN NaN NaN NaN NaN \n", + "1963-02-14 00:00:00 NaN ... NaN NaN NaN NaN NaN NaN NaN NaN \n", + "\n", + " STL TMR \n", + "datetime \n", + "2000-10-21 00:00:00 NaN 0.0061 \n", + "2000-10-22 00:00:00 NaN 0.0061 \n", + "2000-10-23 00:00:00 NaN 0.0061 \n", + "2000-10-24 00:00:00 NaN 0.0061 \n", + "2000-10-25 00:00:00 NaN 0.0030 \n", + "... ... ... \n", + "1963-02-10 00:00:00 0.4572 NaN \n", + "1963-02-11 00:00:00 0.4572 NaN \n", + "1963-02-12 00:00:00 0.4826 NaN \n", + "1963-02-13 00:00:00 0.5080 NaN \n", + "1963-02-14 00:00:00 0.5334 NaN \n", + "\n", + "[39458 rows x 130 columns]" + ] + }, + "execution_count": 70, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "pd.DataFrame.from_dict(ccssStations.station_dict)" + ] + }, { "cell_type": "code", "execution_count": 29, diff --git a/easysnowdata/automatic_weather_stations.py b/easysnowdata/automatic_weather_stations.py index b0233b3..e8ee706 100644 --- a/easysnowdata/automatic_weather_stations.py +++ b/easysnowdata/automatic_weather_stations.py @@ -25,15 +25,15 @@ class StationCollection: def __init__( self, - data_available: bool = True, - snotel_stations: bool = True, - ccss_stations: bool = True, + #data_available: bool = True, + #snotel_stations: bool = True, + #ccss_stations: bool = True, sortby_dist_to_geom=None, ): - self.data_available = data_available - self.snotel_stations = snotel_stations - self.ccss_stations = ccss_stations + #self.data_available = data_available + #self.snotel_stations = snotel_stations + #self.ccss_stations = ccss_stations self.sortby_dist_to_geom = sortby_dist_to_geom self.all_stations = None @@ -75,17 +75,17 @@ def get_all_stations(self): "https://raw.githubusercontent.com/egagli/snotel_ccss_stations/main/all_stations.geojson" ).set_index("code") - # Filter based on data availability - if self.data_available: - all_stations_gdf = all_stations_gdf[all_stations_gdf["csvData"]] + # # Filter based on data availability + # if self.data_available: + # all_stations_gdf = all_stations_gdf[all_stations_gdf["csvData"]] - # Filter out SNOTEL stations if not required - if not self.snotel_stations: - all_stations_gdf = all_stations_gdf[all_stations_gdf["network"] != "SNOTEL"] + # # Filter out SNOTEL stations if not required + # if not self.snotel_stations: + # all_stations_gdf = all_stations_gdf[all_stations_gdf["network"] != "SNOTEL"] - # Filter out CCSS stations if not required - if not self.ccss_stations: - all_stations_gdf = all_stations_gdf[all_stations_gdf["network"] != "CCSS"] + # # Filter out CCSS stations if not required + # if not self.ccss_stations: + # all_stations_gdf = all_stations_gdf[all_stations_gdf["network"] != "CCSS"] # If a geometry is passed in, calculate the distance to this geometry for each station if self.sortby_dist_to_geom is not None: