Skip to content

Commit

Permalink
3.6.3-corrected paths in code snippetes
Browse files Browse the repository at this point in the history
  • Loading branch information
meghanakr7 committed Aug 14, 2024
1 parent 3be356a commit 265c283
Showing 1 changed file with 25 additions and 34 deletions.
59 changes: 25 additions & 34 deletions book/chapters/amsr.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -13278,7 +13278,7 @@
},
{
"cell_type": "code",
"execution_count": 147,
"execution_count": 166,
"id": "1345cc04",
"metadata": {},
"outputs": [],
Expand All @@ -13296,10 +13296,15 @@
"import dask.bag as db\n",
"import xarray as xr\n",
"import subprocess\n",
"work_dir = \"/Users/meghana/Documents/projects/swe-workflow-book/amsr\"\n",
"\n",
"\n",
"# For demonstration purposes, we're using one week of data for training.\n",
"# The training period is set from December 24, 2022, to December 31, 2022.\n",
"train_start_date = \"2022-12-24\"\n",
"train_end_date = \"2022-12-31\"\n",
"# from snowcast_utils import work_dir, train_start_date, train_end_date"
"\n",
"homedir = os.path.expanduser('~')\n",
"work_dir = f\"{homedir}/gridmet_test_run\""
]
},
{
Expand Down Expand Up @@ -13363,7 +13368,7 @@
},
{
"cell_type": "code",
"execution_count": 149,
"execution_count": 167,
"id": "fee15083",
"metadata": {},
"outputs": [],
Expand Down Expand Up @@ -13420,7 +13425,7 @@
},
{
"cell_type": "code",
"execution_count": 150,
"execution_count": 168,
"id": "adce19d9",
"metadata": {},
"outputs": [],
Expand Down Expand Up @@ -13525,7 +13530,7 @@
},
{
"cell_type": "code",
"execution_count": 151,
"execution_count": 172,
"id": "93048e0f",
"metadata": {},
"outputs": [],
Expand Down Expand Up @@ -13631,35 +13636,21 @@
},
{
"cell_type": "code",
"execution_count": 154,
"execution_count": 173,
"id": "977fb644",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
" stationTriplet stationId stateCode networkCode name \\\n",
"0 ABY:CA:SNOW ABY CA SNOW Abbey \n",
"1 0010:ID:COOP 0010 ID COOP Aberdeen Experimnt Stn \n",
"2 0041:NM:COOP 0041 NM COOP Abiquiu Dam \n",
"3 08108010:NM:BOR 08108010 NM BOR Abiquiu Reservoir \n",
"4 13E19:ID:SNOW 13E19 ID SNOW Above Gilmore \n",
"\n",
" dcoCode countyName huc elevation latitude longitude \\\n",
"0 UN Plumas 1.802012e+11 5650.0 39.95500 -120.53800 \n",
"1 ID Bingham 1.704021e+11 4410.0 42.95000 -112.83333 \n",
"2 UN Rio Arriba 1.302010e+11 6380.0 36.23333 -106.43333 \n",
"3 CO Rio Arriba 1.302010e+11 6180.0 36.23700 -106.42912 \n",
"4 ID Lemhi 1.706020e+11 8289.0 44.45615 -113.30097 \n",
"\n",
" dataTimeZone pedonCode shefId beginDate endDate \n",
"0 NaN NaN NaN 1963-02-01 00:00:00.0 2100-01-01 \n",
"1 NaN NaN ABDI1 1914-01-01 00:00:00.0 2100-01-01 \n",
"2 NaN NaN ABIN5 1957-01-01 00:00:00.0 2100-01-01 \n",
"3 NaN NaN NaN 1964-09-01 00:00:00.0 2100-01-01 \n",
"4 NaN NaN ABGI1 1961-01-01 00:00:00.0 2100-01-01 \n",
"File /Users/meghana/Documents/projects/swe-workflow-book/amsr/training_snotel_station_to_amsr_mapper.csv already exists, skipping..\n",
" latitude longitude modis_x modis_y\n",
"0 39.95500 -120.53800 123 251\n",
"1 42.95000 -112.83333 337 168\n",
"2 36.23333 -106.43333 515 354\n",
"3 36.23700 -106.42912 515 354\n",
"4 44.45615 -113.30097 324 126\n",
"File /Users/meghana/Documents/projects/swe-workflow-book/training_snotel_station_to_amsr_mapper.csv already exists, skipping..\n",
"/Users/meghana/Documents/projects/swe-workflow-book/amsr/AMSR_U2_L3_DailySnow_B02_20221226.he5\n",
"/Users/meghana/Documents/projects/swe-workflow-book/amsr/AMSR_U2_L3_DailySnow_B02_20221224.he5\n",
"/Users/meghana/Documents/projects/swe-workflow-book/amsr/AMSR_U2_L3_DailySnow_B02_20221230.he5\n",
Expand All @@ -13676,22 +13667,22 @@
"/Users/meghana/Documents/projects/swe-workflow-book/amsr/AMSR_U2_L3_DailySnow_B02_20200210.he5\n",
"2020-02-10 00:00:00 is not in the training period, skipping..\n",
"/Users/meghana/Documents/projects/swe-workflow-book/amsr/AMSR_U2_L3_DailySnow_B02_20221227.he5\n",
"Merged data saved to /Users/meghana/Documents/projects/swe-workflow-book/all_snotel_cdec_stations_active_in_westus.csv_amsr_dask.csv\n"
"Merged data saved to /Users/meghana/Documents/projects/swe-workflow-book/all_training_points_snotel_ghcnd_in_westus.csv_amsr_dask_all_training_ponits_with_ghcnd.csv\n"
]
}
],
"source": [
"if __name__ == \"__main__\":\n",
" amsr_data_dir = '/Users/meghana/Documents/projects/swe-workflow-book/amsr'\n",
" new_base_station_list_file = \"/Users/meghana/Documents/projects/swe-workflow-book/all_snotel_cdec_stations_active_in_westus.csv\"\n",
" new_base_df = pd.read_csv(new_base_station_list_file)\n",
" amsr_data_dir = f\"{work_dir}/amsr\"\n",
" all_training_points_with_snotel_ghcnd_file = f\"{work_dir}/all_training_points_snotel_ghcnd_in_westus.csv\"\n",
" new_base_df = pd.read_csv(all_training_points_with_snotel_ghcnd_file)\n",
" print(new_base_df.head())\n",
" output_csv_file = f\"{new_base_station_list_file}_amsr_dask.csv\"\n",
" output_csv_file = f\"{all_training_points_with_snotel_ghcnd_file}_amsr_dask_all_training_ponits_with_ghcnd.csv\"\n",
" \n",
" start_date = train_start_date\n",
" end_date = train_end_date\n",
"\n",
" extract_amsr_values_save_to_csv(amsr_data_dir, output_csv_file, new_base_station_list_file, start_date, end_date)\n"
" extract_amsr_values_save_to_csv(amsr_data_dir, output_csv_file, all_training_points_with_snotel_ghcnd_file, start_date, end_date)\n"
]
},
{
Expand Down

0 comments on commit 265c283

Please sign in to comment.