From 84de90f2fb9d5a7c0c039083d54ee6d611ed7649 Mon Sep 17 00:00:00 2001 From: Quarto GHA Workflow Runner Date: Wed, 31 Jan 2024 19:19:05 +0000 Subject: [PATCH] Built site for gh-pages --- .nojekyll | 2 +- Tutorials/SWOTHR_Science_Application.html | 87 +++++++++++++++++++- Tutorials/SWOTHR_s3Access_real_data_v11.html | 15 +++- index.html | 11 ++- prerequisites.html | 11 ++- schedule.html | 11 ++- search.json | 66 ++++++++++++--- sitemap.xml | 12 +-- slides.html | 11 ++- 9 files changed, 196 insertions(+), 30 deletions(-) diff --git a/.nojekyll b/.nojekyll index 9487db7..fd0bc86 100644 --- a/.nojekyll +++ b/.nojekyll @@ -1 +1 @@ -6f773b65 \ No newline at end of file +04c0e4b5 \ No newline at end of file diff --git a/Tutorials/SWOTHR_Science_Application.html b/Tutorials/SWOTHR_Science_Application.html index eb5e541..75b0e53 100644 --- a/Tutorials/SWOTHR_Science_Application.html +++ b/Tutorials/SWOTHR_Science_Application.html @@ -64,6 +64,7 @@ + @@ -110,7 +111,7 @@ - +
@@ -153,6 +154,10 @@
  • Intro to HR Datasets +
  • +
  • + + Science Workflow
  • @@ -168,10 +173,79 @@ +
    + +
    + + @@ -4013,6 +4021,9 @@

    Open data using x

    diff --git a/index.html b/index.html index d9cec9c..3427cc3 100644 --- a/index.html +++ b/index.html @@ -117,6 +117,10 @@
  • Intro to HR Datasets +
  • +
  • + + Science Workflow
  • @@ -194,8 +198,11 @@ + + diff --git a/prerequisites.html b/prerequisites.html index ce5f7b5..710329d 100644 --- a/prerequisites.html +++ b/prerequisites.html @@ -118,6 +118,10 @@
  • Intro to HR Datasets +
  • +
  • + + Science Workflow
  • @@ -195,8 +199,11 @@ + + diff --git a/schedule.html b/schedule.html index e428c9b..a937c7d 100644 --- a/schedule.html +++ b/schedule.html @@ -118,6 +118,10 @@
  • Intro to HR Datasets +
  • +
  • + + Science Workflow
  • @@ -195,8 +199,11 @@ + + diff --git a/search.json b/search.json index 0e1921f..0983c9e 100644 --- a/search.json +++ b/search.json @@ -64,77 +64,121 @@ "href": "Tutorials/SWOTHR_Science_Application.html", "title": "SWOT Hydrology Science Application Tutorial on the Cloud", "section": "", - "text": "This tutorial can only be run in an AWS cloud instance running in us-west-2: NASA Earthdata Cloud data in S3 can be directly accessed via earthaccess python library; this access is limited to requests made within the US West (Oregon) (code: us-west-2) AWS region.\n\n\n\nAn Earthdata Login account is required to access data, as well as discover restricted data, from the NASA Earthdata system. Thus, to access NASA data, you need Earthdata Login. Please visit https://urs.earthdata.nasa.gov to register and manage your Earthdata Login account. This account is free to create and only takes a moment to set up.\nThis code runs using SWOT Level 2 Data Products (Version 1.1).\nNotebook Authors: Arnaud Cerbelaud, Jeffrey Wade, NASA Jet Propulsion Laboratory - California Institute of Technology (Jan 2024)\n\n\n\n\n\nRetrieve SWOT hydrological attributes on river reaches within the AWS cloud (Cal/Val data). Query reaches by:\n\nRiver name\nSpatial bounding box\nDownstream tracing from reach id\nUpstream tracing from reach id\n\n\nRiver longitudinal profile: filtering data to display all reaches located downstream of a given reach (e.g. headwater to outlet)\nWatershed analysis: filtering data to display all reaches located upstream of a given reach (e.g. outlet to full river network)\nVisualize and plot WSE, width, slope data on the filtered data\n\nLast updated: 31 Jan 2024\n\n\n\n\nimport glob\nimport os\nimport requests\nimport s3fs\nimport fiona\nimport netCDF4 as nc\nimport h5netcdf\nimport xarray as xr\nimport pandas as pd\nimport geopandas as gpd\nimport numpy as np\nimport matplotlib.pyplot as plt\nimport hvplot.xarray\nimport earthaccess\nfrom earthaccess import Auth, DataCollections, DataGranules, Store\nfrom pathlib import Path\nimport zipfile\n\n\n\n\n\n\n\n\n\n\n\n\n\nAuthenticate your Earthdata Login (EDL) information using the earthaccess python package as follows:\n\nearthaccess.login() # Login with your EDL credentials if asked\n\nEnter your Earthdata Login username: jswade\nEnter your Earthdata password: ········\n\n\n<earthaccess.auth.Auth at 0x7fd9a7adbee0>\n\n\n\n\n\n\n\n\nOptional step: Get the .kmz file of SWOT passes/swaths (Version 1.1) and import it into Google Earth for visualization\nDetermine which pass number corresponds to the river/basin you want to look at! #### Search for multiple days of data\n\n\n# Enter pass number\npass_number = \"009\" # e.g. 009 for Connecticut in NA, 003 for Rhine in EU\n# Enter continent code\ncontinent_code = \"NA\" # e.g. \"AF\", \"NA\", \"EU\", \"SI\", \"AS\", \"AU\", \"SA\", \"AR\", \"GR\"\n\n# Retrieves granule from the day we want, in this case by passing to `earthdata.search_data` function the data collection shortname and temporal bounds\nriver_results = earthaccess.search_data(short_name = 'SWOT_L2_HR_RIVERSP_1.1', \n temporal = ('2023-04-08 00:00:00', '2023-04-12 23:59:59'),\n granule_name = \"*Reach*_\" + pass_number + \"_\" + continent_code + \"*\")\n\n# Create fiona session to read data\nfs_s3 = earthaccess.get_s3fs_session(results=river_results)\nfiona_session=fiona.session.AWSSession(\n aws_access_key_id=fs_s3.storage_options[\"key\"],\n aws_secret_access_key=fs_s3.storage_options[\"secret\"],\n aws_session_token=fs_s3.storage_options[\"token\"]\n )\n\nGranules found: 5\n\n\n\n\n\n\n# Initialize list of shapefiles containing all dates\nSWOT_HR_shps = []\n\n# Loop through queried granules to stack all acquisition dates\nfor j in range(len(river_results)):\n \n # Get the link for each zip file\n river_link = earthaccess.results.DataGranule.data_links(river_results[j], access='direct')[0]\n \n # We use the zip+ prefix so fiona knows that we are operating on a zip file\n river_shp_url = f\"zip+{river_link}\"\n \n # Read shapefile\n with fiona.Env(session=fiona_session):\n SWOT_HR_shps.append(gpd.read_file(river_shp_url)) \n\n\n\n\n\n# Combine granules from all acquisition dates into one dataframe\nSWOT_HR_df = gpd.GeoDataFrame(pd.concat(SWOT_HR_shps, ignore_index=True))\n\n# Sort dataframe by reach_id and time\nSWOT_HR_df = SWOT_HR_df.sort_values(['reach_id', 'time'])\n\nSWOT_HR_df\n\n\n\n\n\n\n\n\nreach_id\ntime\ntime_tai\ntime_str\np_lat\np_lon\nriver_name\nwse\nwse_u\nwse_r_u\n...\np_wid_var\np_n_nodes\np_dist_out\np_length\np_maf\np_dam_id\np_n_ch_max\np_n_ch_mod\np_low_slp\ngeometry\n\n\n\n\n1958\n72270400231\n-1.000000e+12\n-1.000000e+12\nno_data\n56.794630\n-66.461122\nno_data\n-1.000000e+12\n-1.000000e+12\n-1.000000e+12\n...\n1618.079\n53\n230079.472\n10630.774958\n-1.000000e+12\n0\n1\n1\n0\nLINESTRING (-66.48682 56.83442, -66.48645 56.8...\n\n\n2641\n72270400231\n-1.000000e+12\n-1.000000e+12\nno_data\n56.794630\n-66.461122\nno_data\n-1.000000e+12\n-1.000000e+12\n-1.000000e+12\n...\n1618.079\n53\n230079.472\n10630.774958\n-1.000000e+12\n0\n1\n1\n0\nLINESTRING (-66.48682 56.83442, -66.48645 56.8...\n\n\n1959\n72270400241\n-1.000000e+12\n-1.000000e+12\nno_data\n56.744361\n-66.341905\nno_data\n-1.000000e+12\n-1.000000e+12\n-1.000000e+12\n...\n4831.128\n53\n240728.430\n10648.958289\n-1.000000e+12\n0\n2\n1\n0\nLINESTRING (-66.41602 56.75969, -66.41553 56.7...\n\n\n2642\n72270400241\n-1.000000e+12\n-1.000000e+12\nno_data\n56.744361\n-66.341905\nno_data\n-1.000000e+12\n-1.000000e+12\n-1.000000e+12\n...\n4831.128\n53\n240728.430\n10648.958289\n-1.000000e+12\n0\n2\n1\n0\nLINESTRING (-66.41602 56.75969, -66.41553 56.7...\n\n\n1960\n72270400251\n7.344991e+08\n7.344991e+08\n2023-04-11T03:31:02Z\n56.676087\n-66.219811\nno_data\n2.855340e+02\n1.008930e+00\n1.004910e+00\n...\n412.975\n58\n252286.769\n11558.339052\n-1.000000e+12\n0\n2\n1\n0\nLINESTRING (-66.27812 56.71437, -66.27775 56.7...\n\n\n...\n...\n...\n...\n...\n...\n...\n...\n...\n...\n...\n...\n...\n...\n...\n...\n...\n...\n...\n...\n...\n...\n\n\n615\n73130000061\n-1.000000e+12\n-1.000000e+12\nno_data\n41.424945\n-73.230960\nHousatonic River\n-1.000000e+12\n-1.000000e+12\n-1.000000e+12\n...\n10469.706\n82\n47161.191\n16303.793847\n-1.000000e+12\n0\n2\n1\n0\nLINESTRING (-73.17436 41.38295, -73.17465 41.3...\n\n\n1283\n73130000061\n-1.000000e+12\n-1.000000e+12\nno_data\n41.424945\n-73.230960\nHousatonic River\n-1.000000e+12\n-1.000000e+12\n-1.000000e+12\n...\n10469.706\n82\n47161.191\n16303.793847\n-1.000000e+12\n0\n2\n1\n0\nLINESTRING (-73.17436 41.38295, -73.17465 41.3...\n\n\n1957\n73130000061\n-1.000000e+12\n-1.000000e+12\nno_data\n41.424945\n-73.230960\nHousatonic River\n-1.000000e+12\n-1.000000e+12\n-1.000000e+12\n...\n10469.706\n82\n47161.191\n16303.793847\n-1.000000e+12\n0\n2\n1\n0\nLINESTRING (-73.17436 41.38295, -73.17465 41.3...\n\n\n2640\n73130000061\n-1.000000e+12\n-1.000000e+12\nno_data\n41.424945\n-73.230960\nHousatonic River\n-1.000000e+12\n-1.000000e+12\n-1.000000e+12\n...\n10469.706\n82\n47161.191\n16303.793847\n-1.000000e+12\n0\n2\n1\n0\nLINESTRING (-73.17436 41.38295, -73.17465 41.3...\n\n\n3312\n73130000061\n-1.000000e+12\n-1.000000e+12\nno_data\n41.424945\n-73.230960\nHousatonic River\n-1.000000e+12\n-1.000000e+12\n-1.000000e+12\n...\n10469.706\n82\n47161.191\n16303.793847\n-1.000000e+12\n0\n2\n1\n0\nLINESTRING (-73.17436 41.38295, -73.17465 41.3...\n\n\n\n\n3313 rows × 127 columns\n\n\n\n\n\n\n\n\n\n\nprint('Available dates are:')\nprint(np.unique([i[:10] for i in SWOT_HR_df['time_str']]))\nprint('Available rivers are:')\nprint(np.unique([i for i in SWOT_HR_df['river_name']]))\n\nAvailable dates are:\n['2023-04-08' '2023-04-09' '2023-04-10' '2023-04-11' '2023-04-12'\n 'no_data']\nAvailable rivers are:\n['Allagash River' 'Androscoggin River' 'Big Black River' 'Canal de fuite'\n 'Carrabassett River' 'Concord River' 'Concord River; Sudbury River'\n 'Connecticut River' 'Connecticut River; Westfield River'\n 'Connecticut River; White River' 'Dead River'\n 'Dead River (Kennebec River)' 'Deerfield River' 'Farmington River'\n 'Housatonic River' 'Ikarut River' 'Kennebec River' 'Komaktorvik River'\n 'Magalloway River' 'Merrimack River' 'Moose River'\n 'North Branch Penobscot River' 'Passumsic River' 'Pemigewasset River'\n 'Penobscot River West Branch' 'Quinebaug River' 'Saco River'\n 'Saguenay River' 'Saint Francis River' 'Saint John River'\n 'Saint Lawrence River' 'Sandy River' 'Shetucket River' 'Sudbury River'\n 'Thames River' 'West River' 'White River' 'no_data']\n\n\n\n\n\nNote: Some rivers have multiple names, hence using the contains function\n\n# Enter river name\nriver = \"Connecticut River\" # e.g. \"Rhine\", \"Connecticut River\"\n\n## Filter dataframe\nSWOT_HR_df_river = SWOT_HR_df[(SWOT_HR_df.river_name.str.contains(river))]\n\n# Plot geopandas dataframe with 'explore' by reach id\nSWOT_HR_df_river[['reach_id','river_name','geometry']].explore('reach_id', style_kwds=dict(weight=6))\n\nMake this Notebook Trusted to load map: File -> Trust Notebook\n\n\n\n\n\n\nlat_start = {\"Connecticut River\": 41.5,\n \"Rhine\": 47.5\n }\nlat_end = {\"Connecticut River\": 45,\n \"Rhine\": 51\n }\nlon_start = {\"Connecticut River\": -74,\n \"Rhine\": 7\n }\nlon_end = {\"Connecticut River\": -71,\n \"Rhine\": 10\n }\n\n## Filter dataframe\nSWOT_HR_df_box = SWOT_HR_df[(SWOT_HR_df.p_lat > lat_start[river]) & (SWOT_HR_df.p_lat < lat_end[river]) & (SWOT_HR_df.p_lon > lon_start[river]) & (SWOT_HR_df.p_lon < lon_end[river])]\n\n# Plot geopandas dataframe with 'explore' by river name\nSWOT_HR_df_box[['reach_id','river_name','geometry']].explore('river_name', style_kwds=dict(weight=6))\n\nMake this Notebook Trusted to load map: File -> Trust Notebook\n\n\n\n\n\n\nWARNING: This works as long as the data is exhaustive (no missing SWORD reaches)\n\n\nNote: rch_dn_dict[rch_id] gives a list of all the reaches directly downstream from rch_id\n\n# Format rch_id_dn for dictionary. Rch_id_dn allows for multiple downstream reaches to be stored\n# Also removes spaces in attribute field\nrch_id_dn = [[x.strip() for x in SWOT_HR_df.rch_id_dn[j].split(',')] for j in range(0,len(SWOT_HR_df.rch_id_dn))]\n\n# Filter upstream reach ids to remove 'no_data'\nrch_id_dn_filter = [[x for x in dn_id if x.isnumeric()] for dn_id in rch_id_dn]\n\n# Create lookup dictionary for river network topology: Downstream\nrch_dn_dict = {SWOT_HR_df.reach_id[i]: rch_id_dn_filter[i] for i in range(len(SWOT_HR_df))}\n\n\n\n\n\n# Enter reach_id from which we will trace downstream (e.g. headwaters of the Connecticut River)\nrch_dn_st = {\"Connecticut River\": '73120000691',\n \"Rhine\": '23267000651'\n }\n\n# Initialize list to store downstream reaches, including starting reach\nrch_dn_list = [rch_dn_st[river]]\n# Retrieve first downstream id of starting reach and add to list\nrch_dn_next = rch_dn_dict[rch_dn_st[river]][0]\n\n# Trace next downstream reach until we hit the outlet (or here the last reach on file)\nwhile len(rch_dn_next) != 0:\n # Add reach to list if value exists\n if len(rch_dn_next) != 0:\n rch_dn_list.append(rch_dn_next)\n # Recursively retrieve first downstream id of next reach\n # Catch error if reach isn't in downloaded data\n try:\n rch_dn_next = rch_dn_dict[rch_dn_next][0]\n except:\n break\n\n\n\n\n\n# Filter downloaded data by downstream traced reaches\nSWOT_dn_trace = SWOT_HR_df[SWOT_HR_df.reach_id.isin(rch_dn_list)]\n\n# Remove reaches from rch_dn_list that are not present in SWOT data\nrch_dn_list = [rch for rch in rch_dn_list if rch in SWOT_HR_df.reach_id.values]\n\nSWOT_dn_trace[['reach_id','river_name','geometry']].explore('river_name', style_kwds=dict(weight=6))\n\nMake this Notebook Trusted to load map: File -> Trust Notebook\n\n\n\n\n\n\nWARNING: This works as long as the data is exhaustive (no missing SWORD reaches)\n\n\nNote: rch_up_dict[rch_id] gives a list of all the reaches directly upstream from rch_id\n\n# Format rch_id_up for dictionary. Rch_id_up allows for multiple upstream reaches to be stored\n# Also removes spaces in attribute field\nrch_id_up = [[x.strip() for x in SWOT_HR_df.rch_id_up[j].split(',')] for j in range(0,len(SWOT_HR_df.rch_id_up))]\n\n# Filter upstream reach ids to remove 'no_data'\nrch_id_up_fil = [[x for x in ups_id if x.isnumeric()] for ups_id in rch_id_up]\n\n# Create lookup dictionary for river network topology: Upstream\nrch_up_dict = {SWOT_HR_df.reach_id[i]: rch_id_up_fil[i] for i in range(len(SWOT_HR_df))}\n\n\n\n\nThis adds a bit of complexity, as we need to keep track of multiple branches upstream of the starting reach.\n\n# Enter reach_id from which we will trace upstream (e.g. outlet of the Connecticut River)\nrch_up_st = {\"Connecticut River\": '73120000013',\n \"Rhine\": '23265000051'\n }\n\n# Initialize list to store traced upstream reaches, including starting reach\nrch_up_list = [rch_up_st[river]]\n# Retrieve ids of reaches upstream of starting reach and add to list\nrch_up_next = rch_up_dict[rch_up_st[river]]\n# For upstream tracing, we need to set a list of next upstream ids to start while loop\nrch_next_id = rch_up_next\n\n# Loop until no more reaches to trace\nwhile len(rch_next_id) != 0:\n # Initialize list to store next upstream ids\n rch_next_id = []\n # Loop through next upstream ids for given reach\n for rch_up_sel in rch_up_next:\n # Get values of existing upstream ids of rch_up_next reaches\n # If reach isn't in SWOT data (usually ghost reaches), continue to next reach\n try:\n rch_next_id = rch_next_id + rch_up_dict[rch_up_sel]\n except:\n continue\n # Append id to list\n rch_up_list.append(rch_up_sel)\n # If reaches exist, add to list for next cycle of tracing\n if len(rch_next_id) != 0:\n rch_up_next = rch_next_id\n\n\n\n\n\n# Filter downloaded data by upstream traced reaches\nSWOT_up_trace = SWOT_HR_df[SWOT_HR_df.reach_id.isin(rch_up_list)]\n\n# Remove reaches from rch_up_list that are not present in SWOT data\nrch_up_list = [rch for rch in rch_up_list if rch in SWOT_HR_df.reach_id.values]\n\nSWOT_up_trace[['reach_id','river_name','geometry']].explore('river_name', style_kwds=dict(weight=6))\n\nMake this Notebook Trusted to load map: File -> Trust Notebook\n\n\n\n\n\n\n\n\n\n# Retrieve all possible acquisition dates (keeping only YYYY-MM-DD)\ndates = np.unique([i[:10] for i in [x for x in SWOT_HR_df['time_str'] if x!='no_data']])\n\n# Create a new database for time series analysis with unique reach_ids\nSWOT_dn_trace_time = SWOT_dn_trace.set_index('reach_id').groupby(level=0) \\\n .apply(lambda df: df.reset_index(drop=True)) \\\n .unstack().sort_index(axis=1, level=1)\n\nSWOT_dn_trace_time.columns = ['{}_{}'.format(x[0],dates[x[1]]) for x in SWOT_dn_trace_time.columns]\n\n\n\n\n\n# Explore variables you could choose to plot\nfor var in [\"wse\",\"slope\",\"width\",\"len\"]:\n print(SWOT_dn_trace.columns[SWOT_dn_trace.columns.str.contains(var)])\n\nIndex(['wse', 'wse_u', 'wse_r_u', 'wse_c', 'wse_c_u', 'area_wse', 'p_wse',\n 'p_wse_var'],\n dtype='object')\nIndex(['slope', 'slope_u', 'slope_r_u', 'slope2', 'slope2_u', 'slope2_r_u'], dtype='object')\nIndex(['width', 'width_u', 'width_c', 'width_c_u', 'p_width'], dtype='object')\nIndex(['p_length'], dtype='object')\n\n\n\n# Enter variable of interest for plotting\nvarstr = \"wse\"\n\n\n# Find cumulative length on the longitudinal profile\nlength_list = np.nan_to_num([SWOT_dn_trace.p_length[SWOT_dn_trace.reach_id == rch].mean()/1000 for rch in rch_dn_list])\ncumlength_list = np.cumsum(length_list)\n\n## Plot a longitudinal profile from the downstream tracing database\n\n## Plot a longitudinal profile from the downstream tracing database\nplt.figure(figsize=(12,8))\nfor t in dates:\n \n # Store the quantity of interest (wse, width etc.) at time t\n value = SWOT_dn_trace_time.loc[rch_dn_list,varstr+'_'+t]\n \n # Remove set negative values (bad observations) to NaN and forward fill NaNs\n value[value < 0] = np.nan\n value = value.ffill()\n \n # Plot the data\n plt.plot(cumlength_list, value, label = varstr+'_'+t)\n \nplt.xlabel('Downstream Distance (km)')\nplt.ylabel(varstr)\nplt.legend()\n\n\n\n\n\n\n\n\n\n\n\n\n# Choose a date\ndate = dates[0]\n\n\n#Set one column as the active geometry in the new database\nSWOT_dn_trace_time = SWOT_dn_trace_time.set_geometry(\"geometry_\"+date)\n\n#Set cleaner colorbar bounds for better visualization\nvmin = np.percentile([i for i in SWOT_dn_trace_time[varstr+'_'+date] if i>0],5)\nvmax = np.percentile([i for i in SWOT_dn_trace_time[varstr+'_'+date] if i>0],95)\n\n# Interactive map\nSWOT_dn_trace_time.explore(varstr+'_'+date,\n vmin = vmin,\n vmax = vmax,\n cmap = \"Blues\", #\"Blues\",\n control_scale = True,\n tooltip = varstr+'_'+dates[0], # show \"varstr+'_'+dates[0]\" value in tooltip (on hover)\n popup = True, # show all values in popup (on click)\n #tiles = \"CartoDB positron\", # use \"CartoDB positron\" tiles\n style_kwds=dict(weight=10)\n )\n\nMake this Notebook Trusted to load map: File -> Trust Notebook\n\n\n\n\n\n\n\n\n\nSWOT_up_trace_time = SWOT_up_trace.set_index('reach_id').groupby(level=0) \\\n .apply(lambda df: df.reset_index(drop=True)) \\\n .unstack().sort_index(axis=1, level=1)\n\nSWOT_up_trace_time.columns = ['{}_{}'.format(x[0],dates[x[1]]) for x in SWOT_up_trace_time.columns]\n\nSWOT_up_trace_time = SWOT_up_trace_time.set_geometry(\"geometry_\"+date)\n\n#Set cleaner colorbar bounds for better visualization\nvmin = np.percentile([i for i in SWOT_up_trace_time[varstr+'_'+date] if i>0],5)\nvmax = np.percentile([i for i in SWOT_up_trace_time[varstr+'_'+date] if i>0],95)\n\n# Interactive map\nSWOT_up_trace_time.explore(varstr+'_'+date,\n vmin = vmin,\n vmax = vmax,\n cmap = \"Blues\", #\"Blues\",\n control_scale = True,\n tooltip = varstr+'_'+dates[0], # show \"varstr+'_'+dates[0]\" value in tooltip (on hover)\n popup = True, # show all values in popup (on click)\n tiles = \"CartoDB positron\", # use \"CartoDB positron\" tiles\n style_kwds=dict(weight=5)\n )\n\nMake this Notebook Trusted to load map: File -> Trust Notebook\n\n\n\n\n\nNow you will also need the tile number (in addition to the pass number). You can find it on the .kmz file\n\n# Enter tile number\ntile_number = \"116F\"\n\n# Retrieve granules from all days to find the cycle corresponding to the desired date\nraster_results = earthaccess.search_data(short_name = 'SWOT_L2_HR_Raster_1.1', \n temporal = ('2023-04-01 00:00:00', '2023-04-22 23:59:59'), \n granule_name = \"*100m*_\" + pass_number + \"_\" + tile_number + \"*\")\n# here we filter by files with '100m' in the name, pass=009, scene = 116F (tile = 232L) for Connecticut\n # pass=003, scene = 120F (tile = 239R) for the Rhine\n\nGranules found: 15\n\n\n\n\n\nprint([i for i in raster_results])\n\n[Collection: {'Version': '1.1', 'ShortName': 'SWOT_L2_HR_Raster_1.1'}\nSpatial coverage: {'HorizontalSpatialDomain': {'Orbit': {'StartLatitude': -77.66, 'EndLatitude': 77.66, 'AscendingCrossing': -80.4, 'StartDirection': 'A', 'EndDirection': 'A'}, 'Track': {'Cycle': 484, 'Passes': [{'Pass': 9, 'Tiles': ['230L', '231L', '232L', '233L', '230R', '231R', '232R', '233R']}]}}}\nTemporal coverage: {'RangeDateTime': {'EndingDateTime': '2023-04-08T03:55:38.288Z', 'BeginningDateTime': '2023-04-08T03:55:18.398Z'}}\nSize(MB): 70.40732002258301\nData: ['https://archive.swot.podaac.earthdata.nasa.gov/podaac-swot-ops-cumulus-protected/SWOT_L2_HR_Raster_1.1/SWOT_L2_HR_Raster_100m_UTM19T_N_x_x_x_484_009_116F_20230408T035517_20230408T035538_PIB0_01.nc'], Collection: {'Version': '1.1', 'ShortName': 'SWOT_L2_HR_Raster_1.1'}\nSpatial coverage: {'HorizontalSpatialDomain': {'Orbit': {'StartLatitude': -77.66, 'EndLatitude': 77.66, 'AscendingCrossing': -80.4, 'StartDirection': 'A', 'EndDirection': 'A'}, 'Track': {'Cycle': 485, 'Passes': [{'Pass': 9, 'Tiles': ['230L', '231L', '232L', '233L', '230R', '231R', '232R', '233R']}]}}}\nTemporal coverage: {'RangeDateTime': {'EndingDateTime': '2023-04-09T03:46:16.448Z', 'BeginningDateTime': '2023-04-09T03:45:56.558Z'}}\nSize(MB): 68.41873073577881\nData: ['https://archive.swot.podaac.earthdata.nasa.gov/podaac-swot-ops-cumulus-protected/SWOT_L2_HR_Raster_1.1/SWOT_L2_HR_Raster_100m_UTM19T_N_x_x_x_485_009_116F_20230409T034556_20230409T034616_PIB0_01.nc'], Collection: {'Version': '1.1', 'ShortName': 'SWOT_L2_HR_Raster_1.1'}\nSpatial coverage: {'HorizontalSpatialDomain': {'Orbit': {'StartLatitude': -77.66, 'EndLatitude': 77.66, 'AscendingCrossing': -80.4, 'StartDirection': 'A', 'EndDirection': 'A'}, 'Track': {'Cycle': 486, 'Passes': [{'Pass': 9, 'Tiles': ['230L', '231L', '232L', '233L', '230R', '231R', '232R', '233R']}]}}}\nTemporal coverage: {'RangeDateTime': {'EndingDateTime': '2023-04-10T03:36:54.573Z', 'BeginningDateTime': '2023-04-10T03:36:34.684Z'}}\nSize(MB): 68.47044467926025\nData: ['https://archive.swot.podaac.earthdata.nasa.gov/podaac-swot-ops-cumulus-protected/SWOT_L2_HR_Raster_1.1/SWOT_L2_HR_Raster_100m_UTM19T_N_x_x_x_486_009_116F_20230410T033634_20230410T033655_PIB0_01.nc'], Collection: {'Version': '1.1', 'ShortName': 'SWOT_L2_HR_Raster_1.1'}\nSpatial coverage: {'HorizontalSpatialDomain': {'Orbit': {'StartLatitude': -77.66, 'EndLatitude': 77.66, 'AscendingCrossing': -80.4, 'StartDirection': 'A', 'EndDirection': 'A'}, 'Track': {'Cycle': 487, 'Passes': [{'Pass': 9, 'Tiles': ['230L', '231L', '232L', '233L', '230R', '231R', '232R', '233R']}]}}}\nTemporal coverage: {'RangeDateTime': {'EndingDateTime': '2023-04-11T03:27:32.662Z', 'BeginningDateTime': '2023-04-11T03:27:12.772Z'}}\nSize(MB): 69.02541446685791\nData: ['https://archive.swot.podaac.earthdata.nasa.gov/podaac-swot-ops-cumulus-protected/SWOT_L2_HR_Raster_1.1/SWOT_L2_HR_Raster_100m_UTM19T_N_x_x_x_487_009_116F_20230411T032712_20230411T032733_PIB0_01.nc'], Collection: {'Version': '1.1', 'ShortName': 'SWOT_L2_HR_Raster_1.1'}\nSpatial coverage: {'HorizontalSpatialDomain': {'Orbit': {'StartLatitude': -77.66, 'EndLatitude': 77.66, 'AscendingCrossing': -80.4, 'StartDirection': 'A', 'EndDirection': 'A'}, 'Track': {'Cycle': 488, 'Passes': [{'Pass': 9, 'Tiles': ['230L', '231L', '232L', '233L', '230R', '231R', '232R', '233R']}]}}}\nTemporal coverage: {'RangeDateTime': {'EndingDateTime': '2023-04-12T03:18:10.720Z', 'BeginningDateTime': '2023-04-12T03:17:50.831Z'}}\nSize(MB): 67.56003761291504\nData: ['https://archive.swot.podaac.earthdata.nasa.gov/podaac-swot-ops-cumulus-protected/SWOT_L2_HR_Raster_1.1/SWOT_L2_HR_Raster_100m_UTM19T_N_x_x_x_488_009_116F_20230412T031750_20230412T031811_PIB0_01.nc'], Collection: {'Version': '1.1', 'ShortName': 'SWOT_L2_HR_Raster_1.1'}\nSpatial coverage: {'HorizontalSpatialDomain': {'Orbit': {'StartLatitude': -77.66, 'EndLatitude': 77.66, 'AscendingCrossing': -80.4, 'StartDirection': 'A', 'EndDirection': 'A'}, 'Track': {'Cycle': 489, 'Passes': [{'Pass': 9, 'Tiles': ['230L', '231L', '232L', '233L', '230R', '231R', '232R', '233R']}]}}}\nTemporal coverage: {'RangeDateTime': {'EndingDateTime': '2023-04-13T03:08:48.751Z', 'BeginningDateTime': '2023-04-13T03:08:28.862Z'}}\nSize(MB): 68.72685241699219\nData: ['https://archive.swot.podaac.earthdata.nasa.gov/podaac-swot-ops-cumulus-protected/SWOT_L2_HR_Raster_1.1/SWOT_L2_HR_Raster_100m_UTM19T_N_x_x_x_489_009_116F_20230413T030828_20230413T030849_PIB0_01.nc'], Collection: {'Version': '1.1', 'ShortName': 'SWOT_L2_HR_Raster_1.1'}\nSpatial coverage: {'HorizontalSpatialDomain': {'Orbit': {'StartLatitude': -77.66, 'EndLatitude': 77.66, 'AscendingCrossing': -80.4, 'StartDirection': 'A', 'EndDirection': 'A'}, 'Track': {'Cycle': 490, 'Passes': [{'Pass': 9, 'Tiles': ['230L', '231L', '232L', '233L', '230R', '231R', '232R', '233R']}]}}}\nTemporal coverage: {'RangeDateTime': {'EndingDateTime': '2023-04-14T02:59:26.753Z', 'BeginningDateTime': '2023-04-14T02:59:06.866Z'}}\nSize(MB): 66.47898387908936\nData: ['https://archive.swot.podaac.earthdata.nasa.gov/podaac-swot-ops-cumulus-protected/SWOT_L2_HR_Raster_1.1/SWOT_L2_HR_Raster_100m_UTM19T_N_x_x_x_490_009_116F_20230414T025906_20230414T025927_PIB0_01.nc'], Collection: {'Version': '1.1', 'ShortName': 'SWOT_L2_HR_Raster_1.1'}\nSpatial coverage: {'HorizontalSpatialDomain': {'Orbit': {'StartLatitude': -77.66, 'EndLatitude': 77.66, 'AscendingCrossing': -80.41, 'StartDirection': 'A', 'EndDirection': 'A'}, 'Track': {'Cycle': 491, 'Passes': [{'Pass': 9, 'Tiles': ['230L', '231L', '232L', '233L', '230R', '231R', '232R', '233R']}]}}}\nTemporal coverage: {'RangeDateTime': {'EndingDateTime': '2023-04-15T02:50:04.726Z', 'BeginningDateTime': '2023-04-15T02:49:44.836Z'}}\nSize(MB): 67.29588985443115\nData: ['https://archive.swot.podaac.earthdata.nasa.gov/podaac-swot-ops-cumulus-protected/SWOT_L2_HR_Raster_1.1/SWOT_L2_HR_Raster_100m_UTM19T_N_x_x_x_491_009_116F_20230415T024944_20230415T025005_PIB0_01.nc'], Collection: {'Version': '1.1', 'ShortName': 'SWOT_L2_HR_Raster_1.1'}\nSpatial coverage: {'HorizontalSpatialDomain': {'Orbit': {'StartLatitude': -77.66, 'EndLatitude': 77.66, 'AscendingCrossing': -80.41, 'StartDirection': 'A', 'EndDirection': 'A'}, 'Track': {'Cycle': 492, 'Passes': [{'Pass': 9, 'Tiles': ['230L', '231L', '232L', '233L', '230R', '231R', '232R', '233R']}]}}}\nTemporal coverage: {'RangeDateTime': {'EndingDateTime': '2023-04-16T02:40:43.207Z', 'BeginningDateTime': '2023-04-16T02:40:22.244Z'}}\nSize(MB): 0.933258056640625\nData: ['https://archive.swot.podaac.earthdata.nasa.gov/podaac-swot-ops-cumulus-protected/SWOT_L2_HR_Raster_1.1/SWOT_L2_HR_Raster_100m_UTM19T_N_x_x_x_492_009_116F_20230416T024022_20230416T024043_PIB0_01.nc'], Collection: {'Version': '1.1', 'ShortName': 'SWOT_L2_HR_Raster_1.1'}\nSpatial coverage: {'HorizontalSpatialDomain': {'Orbit': {'StartLatitude': -77.66, 'EndLatitude': 77.66, 'AscendingCrossing': -80.41, 'StartDirection': 'A', 'EndDirection': 'A'}, 'Track': {'Cycle': 493, 'Passes': [{'Pass': 9, 'Tiles': ['230L', '231L', '232L', '233L', '230R', '231R', '232R', '233R']}]}}}\nTemporal coverage: {'RangeDateTime': {'EndingDateTime': '2023-04-17T02:31:21.112Z', 'BeginningDateTime': '2023-04-17T02:31:00.151Z'}}\nSize(MB): 0.9332094192504883\nData: ['https://archive.swot.podaac.earthdata.nasa.gov/podaac-swot-ops-cumulus-protected/SWOT_L2_HR_Raster_1.1/SWOT_L2_HR_Raster_100m_UTM19T_N_x_x_x_493_009_116F_20230417T023100_20230417T023121_PIB0_01.nc'], Collection: {'Version': '1.1', 'ShortName': 'SWOT_L2_HR_Raster_1.1'}\nSpatial coverage: {'HorizontalSpatialDomain': {'Orbit': {'StartLatitude': -77.66, 'EndLatitude': 77.66, 'AscendingCrossing': -80.41, 'StartDirection': 'A', 'EndDirection': 'A'}, 'Track': {'Cycle': 494, 'Passes': [{'Pass': 9, 'Tiles': ['230L', '231L', '232L', '233L', '230R', '231R', '232R', '233R']}]}}}\nTemporal coverage: {'RangeDateTime': {'EndingDateTime': '2023-04-18T02:21:58.990Z', 'BeginningDateTime': '2023-04-18T02:21:38.024Z'}}\nSize(MB): 0.9332304000854492\nData: ['https://archive.swot.podaac.earthdata.nasa.gov/podaac-swot-ops-cumulus-protected/SWOT_L2_HR_Raster_1.1/SWOT_L2_HR_Raster_100m_UTM19T_N_x_x_x_494_009_116F_20230418T022138_20230418T022158_PIB0_01.nc'], Collection: {'Version': '1.1', 'ShortName': 'SWOT_L2_HR_Raster_1.1'}\nSpatial coverage: {'HorizontalSpatialDomain': {'Orbit': {'StartLatitude': -77.66, 'EndLatitude': 77.66, 'AscendingCrossing': -80.41, 'StartDirection': 'A', 'EndDirection': 'A'}, 'Track': {'Cycle': 495, 'Passes': [{'Pass': 9, 'Tiles': ['230L', '231L', '232L', '233L', '230R', '231R', '232R', '233R']}]}}}\nTemporal coverage: {'RangeDateTime': {'EndingDateTime': '2023-04-19T02:12:36.279Z', 'BeginningDateTime': '2023-04-19T02:12:16.394Z'}}\nSize(MB): 63.773990631103516\nData: ['https://archive.swot.podaac.earthdata.nasa.gov/podaac-swot-ops-cumulus-protected/SWOT_L2_HR_Raster_1.1/SWOT_L2_HR_Raster_100m_UTM19T_N_x_x_x_495_009_116F_20230419T021215_20230419T021236_PIB0_01.nc'], Collection: {'Version': '1.1', 'ShortName': 'SWOT_L2_HR_Raster_1.1'}\nSpatial coverage: {'HorizontalSpatialDomain': {'Orbit': {'StartLatitude': -77.66, 'EndLatitude': 77.66, 'AscendingCrossing': -80.41, 'StartDirection': 'A', 'EndDirection': 'A'}, 'Track': {'Cycle': 496, 'Passes': [{'Pass': 9, 'Tiles': ['230L', '231L', '232L', '233L', '230R', '231R', '232R', '233R']}]}}}\nTemporal coverage: {'RangeDateTime': {'EndingDateTime': '2023-04-20T02:03:14.075Z', 'BeginningDateTime': '2023-04-20T02:02:54.187Z'}}\nSize(MB): 62.185853004455566\nData: ['https://archive.swot.podaac.earthdata.nasa.gov/podaac-swot-ops-cumulus-protected/SWOT_L2_HR_Raster_1.1/SWOT_L2_HR_Raster_100m_UTM19T_N_x_x_x_496_009_116F_20230420T020253_20230420T020314_PIB0_01.nc'], Collection: {'Version': '1.1', 'ShortName': 'SWOT_L2_HR_Raster_1.1'}\nSpatial coverage: {'HorizontalSpatialDomain': {'Orbit': {'StartLatitude': -77.66, 'EndLatitude': 77.66, 'AscendingCrossing': -80.41, 'StartDirection': 'A', 'EndDirection': 'A'}, 'Track': {'Cycle': 497, 'Passes': [{'Pass': 9, 'Tiles': ['230L', '231L', '232L', '233L', '230R', '231R', '232R', '233R']}]}}}\nTemporal coverage: {'RangeDateTime': {'EndingDateTime': '2023-04-21T01:53:51.831Z', 'BeginningDateTime': '2023-04-21T01:53:31.942Z'}}\nSize(MB): 61.36593437194824\nData: ['https://archive.swot.podaac.earthdata.nasa.gov/podaac-swot-ops-cumulus-protected/SWOT_L2_HR_Raster_1.1/SWOT_L2_HR_Raster_100m_UTM19T_N_x_x_x_497_009_116F_20230421T015331_20230421T015352_PIB0_01.nc'], Collection: {'Version': '1.1', 'ShortName': 'SWOT_L2_HR_Raster_1.1'}\nSpatial coverage: {'HorizontalSpatialDomain': {'Orbit': {'StartLatitude': -77.66, 'EndLatitude': 77.66, 'AscendingCrossing': -80.41, 'StartDirection': 'A', 'EndDirection': 'A'}, 'Track': {'Cycle': 498, 'Passes': [{'Pass': 9, 'Tiles': ['230L', '231L', '232L', '233L', '230R', '231R', '232R', '233R']}]}}}\nTemporal coverage: {'RangeDateTime': {'EndingDateTime': '2023-04-22T01:44:29.616Z', 'BeginningDateTime': '2023-04-22T01:44:09.731Z'}}\nSize(MB): 61.341376304626465\nData: ['https://archive.swot.podaac.earthdata.nasa.gov/podaac-swot-ops-cumulus-protected/SWOT_L2_HR_Raster_1.1/SWOT_L2_HR_Raster_100m_UTM19T_N_x_x_x_498_009_116F_20230422T014409_20230422T014430_PIB0_01.nc']]\n\n\n\n\n\n\n# Let's look at cycle 485, on the second day of calval\n# Enter cycle\ncycle = \"485\"\n\nraster_results = earthaccess.search_data(short_name = 'SWOT_L2_HR_Raster_1.1', \n temporal = ('2023-04-01 00:00:00', '2023-04-22 23:59:59'), \n granule_name = \"*100m*\" + cycle + \"_\" + pass_number + \"_\" + tile_number + \"*\")\n\n# here we filter by files with '100m' in the name, cycle=484, pass=009, scene = 116F for Connecticut\n # cycle=485, pass=003, scene = 120F for the Rhine\n\nGranules found: 1\n\n\n\n\n\n\nfs_s3 = earthaccess.get_s3fs_session(results=raster_results)\n\n# get link for file and open it\nraster_link = earthaccess.results.DataGranule.data_links(raster_results[0], access='direct')[0]\ns3_file_obj5 = fs_s3.open(raster_link, mode='rb')\n\n# Open data with xarray\nds_raster = xr.open_dataset(s3_file_obj5, engine='h5netcdf')\n\n\n\n\n\n# Plot the data with a filter on water_frac > x, or sig0>50\nds_raster.wse.where(ds_raster.water_frac > 0.5).hvplot.image(y='y', x='x').opts(cmap='Blues', clim=(vmin,vmax), width=1000, height=750)" + "text": "This tutorial can only be run in an AWS cloud instance running in us-west-2: NASA Earthdata Cloud data in S3 can be directly accessed via earthaccess python library; this access is limited to requests made within the US West (Oregon) (code: us-west-2) AWS region.\n\n\n\nAn Earthdata Login account is required to access data, as well as discover restricted data, from the NASA Earthdata system. Thus, to access NASA data, you need Earthdata Login. Please visit https://urs.earthdata.nasa.gov to register and manage your Earthdata Login account. This account is free to create and only takes a moment to set up.\nThis code runs using SWOT Level 2 Data Products (Version 1.1).\nNotebook Authors: Arnaud Cerbelaud, Jeffrey Wade, NASA Jet Propulsion Laboratory - California Institute of Technology (Jan 2024)\n\n\n\n\n\nRetrieve SWOT hydrological attributes on river reaches within the AWS cloud (Cal/Val data). Query reaches by:\n\nRiver name\nSpatial bounding box\nDownstream tracing from reach id\nUpstream tracing from reach id\n\n\nRiver longitudinal profile: filtering data to display all reaches located downstream of a given reach (e.g. headwater to outlet)\nWatershed analysis: filtering data to display all reaches located upstream of a given reach (e.g. outlet to full river network)\nVisualize and plot WSE, width, slope data on the filtered data\n\nLast updated: 31 Jan 2024\n\n\n\n\nimport glob\nimport os\nimport requests\nimport s3fs\nimport fiona\nimport netCDF4 as nc\nimport h5netcdf\nimport xarray as xr\nimport pandas as pd\nimport geopandas as gpd\nimport numpy as np\nimport matplotlib.pyplot as plt\nimport hvplot.xarray\nimport earthaccess\nfrom earthaccess import Auth, DataCollections, DataGranules, Store\nfrom pathlib import Path\nimport zipfile\n\n\n\n\n\n\n\n\n\n\n\n\n\nAuthenticate your Earthdata Login (EDL) information using the earthaccess python package as follows:\n\nearthaccess.login() # Login with your EDL credentials if asked\n\nEnter your Earthdata Login username: jswade\nEnter your Earthdata password: ········\n\n\n<earthaccess.auth.Auth at 0x7fd9a7adbee0>\n\n\n\n\n\n\n\n\nOptional step: Get the .kmz file of SWOT passes/swaths (Version 1.1) and import it into Google Earth for visualization\nDetermine which pass number corresponds to the river/basin you want to look at! #### Search for multiple days of data\n\n\n# Enter pass number\npass_number = \"009\" # e.g. 009 for Connecticut in NA, 003 for Rhine in EU\n# Enter continent code\ncontinent_code = \"NA\" # e.g. \"AF\", \"NA\", \"EU\", \"SI\", \"AS\", \"AU\", \"SA\", \"AR\", \"GR\"\n\n# Retrieves granule from the day we want, in this case by passing to `earthdata.search_data` function the data collection shortname and temporal bounds\nriver_results = earthaccess.search_data(short_name = 'SWOT_L2_HR_RIVERSP_1.1', \n temporal = ('2023-04-08 00:00:00', '2023-04-12 23:59:59'),\n granule_name = \"*Reach*_\" + pass_number + \"_\" + continent_code + \"*\")\n\n# Create fiona session to read data\nfs_s3 = earthaccess.get_s3fs_session(results=river_results)\nfiona_session=fiona.session.AWSSession(\n aws_access_key_id=fs_s3.storage_options[\"key\"],\n aws_secret_access_key=fs_s3.storage_options[\"secret\"],\n aws_session_token=fs_s3.storage_options[\"token\"]\n )\n\nGranules found: 5\n\n\n\n\n\n\n# Initialize list of shapefiles containing all dates\nSWOT_HR_shps = []\n\n# Loop through queried granules to stack all acquisition dates\nfor j in range(len(river_results)):\n \n # Get the link for each zip file\n river_link = earthaccess.results.DataGranule.data_links(river_results[j], access='direct')[0]\n \n # We use the zip+ prefix so fiona knows that we are operating on a zip file\n river_shp_url = f\"zip+{river_link}\"\n \n # Read shapefile\n with fiona.Env(session=fiona_session):\n SWOT_HR_shps.append(gpd.read_file(river_shp_url)) \n\n\n\n\n\n# Combine granules from all acquisition dates into one dataframe\nSWOT_HR_df = gpd.GeoDataFrame(pd.concat(SWOT_HR_shps, ignore_index=True))\n\n# Sort dataframe by reach_id and time\nSWOT_HR_df = SWOT_HR_df.sort_values(['reach_id', 'time'])\n\nSWOT_HR_df\n\n\n\n\n\n\n\n\nreach_id\ntime\ntime_tai\ntime_str\np_lat\np_lon\nriver_name\nwse\nwse_u\nwse_r_u\n...\np_wid_var\np_n_nodes\np_dist_out\np_length\np_maf\np_dam_id\np_n_ch_max\np_n_ch_mod\np_low_slp\ngeometry\n\n\n\n\n1958\n72270400231\n-1.000000e+12\n-1.000000e+12\nno_data\n56.794630\n-66.461122\nno_data\n-1.000000e+12\n-1.000000e+12\n-1.000000e+12\n...\n1618.079\n53\n230079.472\n10630.774958\n-1.000000e+12\n0\n1\n1\n0\nLINESTRING (-66.48682 56.83442, -66.48645 56.8...\n\n\n2641\n72270400231\n-1.000000e+12\n-1.000000e+12\nno_data\n56.794630\n-66.461122\nno_data\n-1.000000e+12\n-1.000000e+12\n-1.000000e+12\n...\n1618.079\n53\n230079.472\n10630.774958\n-1.000000e+12\n0\n1\n1\n0\nLINESTRING (-66.48682 56.83442, -66.48645 56.8...\n\n\n1959\n72270400241\n-1.000000e+12\n-1.000000e+12\nno_data\n56.744361\n-66.341905\nno_data\n-1.000000e+12\n-1.000000e+12\n-1.000000e+12\n...\n4831.128\n53\n240728.430\n10648.958289\n-1.000000e+12\n0\n2\n1\n0\nLINESTRING (-66.41602 56.75969, -66.41553 56.7...\n\n\n2642\n72270400241\n-1.000000e+12\n-1.000000e+12\nno_data\n56.744361\n-66.341905\nno_data\n-1.000000e+12\n-1.000000e+12\n-1.000000e+12\n...\n4831.128\n53\n240728.430\n10648.958289\n-1.000000e+12\n0\n2\n1\n0\nLINESTRING (-66.41602 56.75969, -66.41553 56.7...\n\n\n1960\n72270400251\n7.344991e+08\n7.344991e+08\n2023-04-11T03:31:02Z\n56.676087\n-66.219811\nno_data\n2.855340e+02\n1.008930e+00\n1.004910e+00\n...\n412.975\n58\n252286.769\n11558.339052\n-1.000000e+12\n0\n2\n1\n0\nLINESTRING (-66.27812 56.71437, -66.27775 56.7...\n\n\n...\n...\n...\n...\n...\n...\n...\n...\n...\n...\n...\n...\n...\n...\n...\n...\n...\n...\n...\n...\n...\n...\n\n\n615\n73130000061\n-1.000000e+12\n-1.000000e+12\nno_data\n41.424945\n-73.230960\nHousatonic River\n-1.000000e+12\n-1.000000e+12\n-1.000000e+12\n...\n10469.706\n82\n47161.191\n16303.793847\n-1.000000e+12\n0\n2\n1\n0\nLINESTRING (-73.17436 41.38295, -73.17465 41.3...\n\n\n1283\n73130000061\n-1.000000e+12\n-1.000000e+12\nno_data\n41.424945\n-73.230960\nHousatonic River\n-1.000000e+12\n-1.000000e+12\n-1.000000e+12\n...\n10469.706\n82\n47161.191\n16303.793847\n-1.000000e+12\n0\n2\n1\n0\nLINESTRING (-73.17436 41.38295, -73.17465 41.3...\n\n\n1957\n73130000061\n-1.000000e+12\n-1.000000e+12\nno_data\n41.424945\n-73.230960\nHousatonic River\n-1.000000e+12\n-1.000000e+12\n-1.000000e+12\n...\n10469.706\n82\n47161.191\n16303.793847\n-1.000000e+12\n0\n2\n1\n0\nLINESTRING (-73.17436 41.38295, -73.17465 41.3...\n\n\n2640\n73130000061\n-1.000000e+12\n-1.000000e+12\nno_data\n41.424945\n-73.230960\nHousatonic River\n-1.000000e+12\n-1.000000e+12\n-1.000000e+12\n...\n10469.706\n82\n47161.191\n16303.793847\n-1.000000e+12\n0\n2\n1\n0\nLINESTRING (-73.17436 41.38295, -73.17465 41.3...\n\n\n3312\n73130000061\n-1.000000e+12\n-1.000000e+12\nno_data\n41.424945\n-73.230960\nHousatonic River\n-1.000000e+12\n-1.000000e+12\n-1.000000e+12\n...\n10469.706\n82\n47161.191\n16303.793847\n-1.000000e+12\n0\n2\n1\n0\nLINESTRING (-73.17436 41.38295, -73.17465 41.3...\n\n\n\n\n3313 rows × 127 columns\n\n\n\n\n\n\n\n\n\n\nprint('Available dates are:')\nprint(np.unique([i[:10] for i in SWOT_HR_df['time_str']]))\nprint('Available rivers are:')\nprint(np.unique([i for i in SWOT_HR_df['river_name']]))\n\nAvailable dates are:\n['2023-04-08' '2023-04-09' '2023-04-10' '2023-04-11' '2023-04-12'\n 'no_data']\nAvailable rivers are:\n['Allagash River' 'Androscoggin River' 'Big Black River' 'Canal de fuite'\n 'Carrabassett River' 'Concord River' 'Concord River; Sudbury River'\n 'Connecticut River' 'Connecticut River; Westfield River'\n 'Connecticut River; White River' 'Dead River'\n 'Dead River (Kennebec River)' 'Deerfield River' 'Farmington River'\n 'Housatonic River' 'Ikarut River' 'Kennebec River' 'Komaktorvik River'\n 'Magalloway River' 'Merrimack River' 'Moose River'\n 'North Branch Penobscot River' 'Passumsic River' 'Pemigewasset River'\n 'Penobscot River West Branch' 'Quinebaug River' 'Saco River'\n 'Saguenay River' 'Saint Francis River' 'Saint John River'\n 'Saint Lawrence River' 'Sandy River' 'Shetucket River' 'Sudbury River'\n 'Thames River' 'West River' 'White River' 'no_data']\n\n\n\n\n\nNote: Some rivers have multiple names, hence using the contains function\n\n# Enter river name\nriver = \"Connecticut River\" # e.g. \"Rhine\", \"Connecticut River\"\n\n## Filter dataframe\nSWOT_HR_df_river = SWOT_HR_df[(SWOT_HR_df.river_name.str.contains(river))]\n\n# Plot geopandas dataframe with 'explore' by reach id\nSWOT_HR_df_river[['reach_id','river_name','geometry']].explore('reach_id', style_kwds=dict(weight=6))\n\nMake this Notebook Trusted to load map: File -> Trust Notebook\n\n\n\n\n\n\nlat_start = {\"Connecticut River\": 41.5,\n \"Rhine\": 47.5\n }\nlat_end = {\"Connecticut River\": 45,\n \"Rhine\": 51\n }\nlon_start = {\"Connecticut River\": -74,\n \"Rhine\": 7\n }\nlon_end = {\"Connecticut River\": -71,\n \"Rhine\": 10\n }\n\n## Filter dataframe\nSWOT_HR_df_box = SWOT_HR_df[(SWOT_HR_df.p_lat > lat_start[river]) & (SWOT_HR_df.p_lat < lat_end[river]) & (SWOT_HR_df.p_lon > lon_start[river]) & (SWOT_HR_df.p_lon < lon_end[river])]\n\n# Plot geopandas dataframe with 'explore' by river name\nSWOT_HR_df_box[['reach_id','river_name','geometry']].explore('river_name', style_kwds=dict(weight=6))\n\nMake this Notebook Trusted to load map: File -> Trust Notebook\n\n\n\n\n\n\nWARNING: This works as long as the data is exhaustive (no missing SWORD reaches)\n\n\nNote: rch_dn_dict[rch_id] gives a list of all the reaches directly downstream from rch_id\n\n# Format rch_id_dn for dictionary. Rch_id_dn allows for multiple downstream reaches to be stored\n# Also removes spaces in attribute field\nrch_id_dn = [[x.strip() for x in SWOT_HR_df.rch_id_dn[j].split(',')] for j in range(0,len(SWOT_HR_df.rch_id_dn))]\n\n# Filter upstream reach ids to remove 'no_data'\nrch_id_dn_filter = [[x for x in dn_id if x.isnumeric()] for dn_id in rch_id_dn]\n\n# Create lookup dictionary for river network topology: Downstream\nrch_dn_dict = {SWOT_HR_df.reach_id[i]: rch_id_dn_filter[i] for i in range(len(SWOT_HR_df))}\n\n\n\n\n\n# Enter reach_id from which we will trace downstream (e.g. headwaters of the Connecticut River)\nrch_dn_st = {\"Connecticut River\": '73120000691',\n \"Rhine\": '23267000651'\n }\n\n# Initialize list to store downstream reaches, including starting reach\nrch_dn_list = [rch_dn_st[river]]\n# Retrieve first downstream id of starting reach and add to list\nrch_dn_next = rch_dn_dict[rch_dn_st[river]][0]\n\n# Trace next downstream reach until we hit the outlet (or here the last reach on file)\nwhile len(rch_dn_next) != 0:\n # Add reach to list if value exists\n if len(rch_dn_next) != 0:\n rch_dn_list.append(rch_dn_next)\n # Recursively retrieve first downstream id of next reach\n # Catch error if reach isn't in downloaded data\n try:\n rch_dn_next = rch_dn_dict[rch_dn_next][0]\n except:\n break\n\n\n\n\n\n# Filter downloaded data by downstream traced reaches\nSWOT_dn_trace = SWOT_HR_df[SWOT_HR_df.reach_id.isin(rch_dn_list)]\n\n# Remove reaches from rch_dn_list that are not present in SWOT data\nrch_dn_list = [rch for rch in rch_dn_list if rch in SWOT_HR_df.reach_id.values]\n\nSWOT_dn_trace[['reach_id','river_name','geometry']].explore('river_name', style_kwds=dict(weight=6))\n\nMake this Notebook Trusted to load map: File -> Trust Notebook\n\n\n\n\n\n\nWARNING: This works as long as the data is exhaustive (no missing SWORD reaches)\n\n\nNote: rch_up_dict[rch_id] gives a list of all the reaches directly upstream from rch_id\n\n# Format rch_id_up for dictionary. Rch_id_up allows for multiple upstream reaches to be stored\n# Also removes spaces in attribute field\nrch_id_up = [[x.strip() for x in SWOT_HR_df.rch_id_up[j].split(',')] for j in range(0,len(SWOT_HR_df.rch_id_up))]\n\n# Filter upstream reach ids to remove 'no_data'\nrch_id_up_fil = [[x for x in ups_id if x.isnumeric()] for ups_id in rch_id_up]\n\n# Create lookup dictionary for river network topology: Upstream\nrch_up_dict = {SWOT_HR_df.reach_id[i]: rch_id_up_fil[i] for i in range(len(SWOT_HR_df))}\n\n\n\n\nThis adds a bit of complexity, as we need to keep track of multiple branches upstream of the starting reach.\n\n# Enter reach_id from which we will trace upstream (e.g. outlet of the Connecticut River)\nrch_up_st = {\"Connecticut River\": '73120000013',\n \"Rhine\": '23265000051'\n }\n\n# Initialize list to store traced upstream reaches, including starting reach\nrch_up_list = [rch_up_st[river]]\n# Retrieve ids of reaches upstream of starting reach and add to list\nrch_up_next = rch_up_dict[rch_up_st[river]]\n# For upstream tracing, we need to set a list of next upstream ids to start while loop\nrch_next_id = rch_up_next\n\n# Loop until no more reaches to trace\nwhile len(rch_next_id) != 0:\n # Initialize list to store next upstream ids\n rch_next_id = []\n # Loop through next upstream ids for given reach\n for rch_up_sel in rch_up_next:\n # Get values of existing upstream ids of rch_up_next reaches\n # If reach isn't in SWOT data (usually ghost reaches), continue to next reach\n try:\n rch_next_id = rch_next_id + rch_up_dict[rch_up_sel]\n except:\n continue\n # Append id to list\n rch_up_list.append(rch_up_sel)\n # If reaches exist, add to list for next cycle of tracing\n if len(rch_next_id) != 0:\n rch_up_next = rch_next_id\n\n\n\n\n\n# Filter downloaded data by upstream traced reaches\nSWOT_up_trace = SWOT_HR_df[SWOT_HR_df.reach_id.isin(rch_up_list)]\n\n# Remove reaches from rch_up_list that are not present in SWOT data\nrch_up_list = [rch for rch in rch_up_list if rch in SWOT_HR_df.reach_id.values]\n\nSWOT_up_trace[['reach_id','river_name','geometry']].explore('river_name', style_kwds=dict(weight=6))\n\nMake this Notebook Trusted to load map: File -> Trust Notebook\n\n\n\n\n\n\n\n\n\n# Retrieve all possible acquisition dates (keeping only YYYY-MM-DD)\ndates = np.unique([i[:10] for i in [x for x in SWOT_HR_df['time_str'] if x!='no_data']])\n\n# Create a new database for time series analysis with unique reach_ids\nSWOT_dn_trace_time = SWOT_dn_trace.set_index('reach_id').groupby(level=0) \\\n .apply(lambda df: df.reset_index(drop=True)) \\\n .unstack().sort_index(axis=1, level=1)\n\nSWOT_dn_trace_time.columns = ['{}_{}'.format(x[0],dates[x[1]]) for x in SWOT_dn_trace_time.columns]\n\n\n\n\n\n# Explore variables you could choose to plot\nfor var in [\"wse\",\"slope\",\"width\",\"len\"]:\n print(SWOT_dn_trace.columns[SWOT_dn_trace.columns.str.contains(var)])\n\nIndex(['wse', 'wse_u', 'wse_r_u', 'wse_c', 'wse_c_u', 'area_wse', 'p_wse',\n 'p_wse_var'],\n dtype='object')\nIndex(['slope', 'slope_u', 'slope_r_u', 'slope2', 'slope2_u', 'slope2_r_u'], dtype='object')\nIndex(['width', 'width_u', 'width_c', 'width_c_u', 'p_width'], dtype='object')\nIndex(['p_length'], dtype='object')\n\n\n\n# Enter variable of interest for plotting\nvarstr = \"wse\"\n\n\n# Find cumulative length on the longitudinal profile\nlength_list = np.nan_to_num([SWOT_dn_trace.p_length[SWOT_dn_trace.reach_id == rch].mean()/1000 for rch in rch_dn_list])\ncumlength_list = np.cumsum(length_list)\n\n## Plot a longitudinal profile from the downstream tracing database\n\n## Plot a longitudinal profile from the downstream tracing database\nplt.figure(figsize=(12,8))\nfor t in dates:\n \n # Store the quantity of interest (wse, width etc.) at time t\n value = SWOT_dn_trace_time.loc[rch_dn_list,varstr+'_'+t]\n \n # Remove set negative values (bad observations) to NaN and forward fill NaNs\n value[value < 0] = np.nan\n value = value.ffill()\n \n # Plot the data\n plt.plot(cumlength_list, value, label = varstr+'_'+t)\n \nplt.xlabel('Downstream Distance (km)')\nplt.ylabel(varstr)\nplt.legend()\n\n\n\n\n\n\n\n\n\n\n\n\n# Choose a date\ndate = dates[0]\n\n\n#Set one column as the active geometry in the new database\nSWOT_dn_trace_time = SWOT_dn_trace_time.set_geometry(\"geometry_\"+date)\n\n#Set cleaner colorbar bounds for better visualization\nvmin = np.percentile([i for i in SWOT_dn_trace_time[varstr+'_'+date] if i>0],5)\nvmax = np.percentile([i for i in SWOT_dn_trace_time[varstr+'_'+date] if i>0],95)\n\n# Interactive map\nSWOT_dn_trace_time.explore(varstr+'_'+date,\n vmin = vmin,\n vmax = vmax,\n cmap = \"Blues\", #\"Blues\",\n control_scale = True,\n tooltip = varstr+'_'+dates[0], # show \"varstr+'_'+dates[0]\" value in tooltip (on hover)\n popup = True, # show all values in popup (on click)\n #tiles = \"CartoDB positron\", # use \"CartoDB positron\" tiles\n style_kwds=dict(weight=10)\n )\n\nMake this Notebook Trusted to load map: File -> Trust Notebook\n\n\n\n\n\n\n\n\n\nSWOT_up_trace_time = SWOT_up_trace.set_index('reach_id').groupby(level=0) \\\n .apply(lambda df: df.reset_index(drop=True)) \\\n .unstack().sort_index(axis=1, level=1)\n\nSWOT_up_trace_time.columns = ['{}_{}'.format(x[0],dates[x[1]]) for x in SWOT_up_trace_time.columns]\n\nSWOT_up_trace_time = SWOT_up_trace_time.set_geometry(\"geometry_\"+date)\n\n#Set cleaner colorbar bounds for better visualization\nvmin = np.percentile([i for i in SWOT_up_trace_time[varstr+'_'+date] if i>0],5)\nvmax = np.percentile([i for i in SWOT_up_trace_time[varstr+'_'+date] if i>0],95)\n\n# Interactive map\nSWOT_up_trace_time.explore(varstr+'_'+date,\n vmin = vmin,\n vmax = vmax,\n cmap = \"Blues\", #\"Blues\",\n control_scale = True,\n tooltip = varstr+'_'+dates[0], # show \"varstr+'_'+dates[0]\" value in tooltip (on hover)\n popup = True, # show all values in popup (on click)\n tiles = \"CartoDB positron\", # use \"CartoDB positron\" tiles\n style_kwds=dict(weight=5)\n )\n\nMake this Notebook Trusted to load map: File -> Trust Notebook\n\n\n\n\n\nNow you will also need the tile number (in addition to the pass number). You can find it on the .kmz file\n\n# Enter tile number\ntile_number = \"116F\"\n\n# Retrieve granules from all days to find the cycle corresponding to the desired date\nraster_results = earthaccess.search_data(short_name = 'SWOT_L2_HR_Raster_1.1', \n temporal = ('2023-04-01 00:00:00', '2023-04-22 23:59:59'), \n granule_name = \"*100m*_\" + pass_number + \"_\" + tile_number + \"*\")\n# here we filter by files with '100m' in the name, pass=009, scene = 116F (tile = 232L) for Connecticut\n # pass=003, scene = 120F (tile = 239R) for the Rhine\n\nGranules found: 15\n\n\n\n\n\nprint([i for i in raster_results])\n\n[Collection: {'Version': '1.1', 'ShortName': 'SWOT_L2_HR_Raster_1.1'}\nSpatial coverage: {'HorizontalSpatialDomain': {'Orbit': {'StartLatitude': -77.66, 'EndLatitude': 77.66, 'AscendingCrossing': -80.4, 'StartDirection': 'A', 'EndDirection': 'A'}, 'Track': {'Cycle': 484, 'Passes': [{'Pass': 9, 'Tiles': ['230L', '231L', '232L', '233L', '230R', '231R', '232R', '233R']}]}}}\nTemporal coverage: {'RangeDateTime': {'EndingDateTime': '2023-04-08T03:55:38.288Z', 'BeginningDateTime': '2023-04-08T03:55:18.398Z'}}\nSize(MB): 70.40732002258301\nData: ['https://archive.swot.podaac.earthdata.nasa.gov/podaac-swot-ops-cumulus-protected/SWOT_L2_HR_Raster_1.1/SWOT_L2_HR_Raster_100m_UTM19T_N_x_x_x_484_009_116F_20230408T035517_20230408T035538_PIB0_01.nc'], Collection: {'Version': '1.1', 'ShortName': 'SWOT_L2_HR_Raster_1.1'}\nSpatial coverage: {'HorizontalSpatialDomain': {'Orbit': {'StartLatitude': -77.66, 'EndLatitude': 77.66, 'AscendingCrossing': -80.4, 'StartDirection': 'A', 'EndDirection': 'A'}, 'Track': {'Cycle': 485, 'Passes': [{'Pass': 9, 'Tiles': ['230L', '231L', '232L', '233L', '230R', '231R', '232R', '233R']}]}}}\nTemporal coverage: {'RangeDateTime': {'EndingDateTime': '2023-04-09T03:46:16.448Z', 'BeginningDateTime': '2023-04-09T03:45:56.558Z'}}\nSize(MB): 68.41873073577881\nData: ['https://archive.swot.podaac.earthdata.nasa.gov/podaac-swot-ops-cumulus-protected/SWOT_L2_HR_Raster_1.1/SWOT_L2_HR_Raster_100m_UTM19T_N_x_x_x_485_009_116F_20230409T034556_20230409T034616_PIB0_01.nc'], Collection: {'Version': '1.1', 'ShortName': 'SWOT_L2_HR_Raster_1.1'}\nSpatial coverage: {'HorizontalSpatialDomain': {'Orbit': {'StartLatitude': -77.66, 'EndLatitude': 77.66, 'AscendingCrossing': -80.4, 'StartDirection': 'A', 'EndDirection': 'A'}, 'Track': {'Cycle': 486, 'Passes': [{'Pass': 9, 'Tiles': ['230L', '231L', '232L', '233L', '230R', '231R', '232R', '233R']}]}}}\nTemporal coverage: {'RangeDateTime': {'EndingDateTime': '2023-04-10T03:36:54.573Z', 'BeginningDateTime': '2023-04-10T03:36:34.684Z'}}\nSize(MB): 68.47044467926025\nData: ['https://archive.swot.podaac.earthdata.nasa.gov/podaac-swot-ops-cumulus-protected/SWOT_L2_HR_Raster_1.1/SWOT_L2_HR_Raster_100m_UTM19T_N_x_x_x_486_009_116F_20230410T033634_20230410T033655_PIB0_01.nc'], Collection: {'Version': '1.1', 'ShortName': 'SWOT_L2_HR_Raster_1.1'}\nSpatial coverage: {'HorizontalSpatialDomain': {'Orbit': {'StartLatitude': -77.66, 'EndLatitude': 77.66, 'AscendingCrossing': -80.4, 'StartDirection': 'A', 'EndDirection': 'A'}, 'Track': {'Cycle': 487, 'Passes': [{'Pass': 9, 'Tiles': ['230L', '231L', '232L', '233L', '230R', '231R', '232R', '233R']}]}}}\nTemporal coverage: {'RangeDateTime': {'EndingDateTime': '2023-04-11T03:27:32.662Z', 'BeginningDateTime': '2023-04-11T03:27:12.772Z'}}\nSize(MB): 69.02541446685791\nData: ['https://archive.swot.podaac.earthdata.nasa.gov/podaac-swot-ops-cumulus-protected/SWOT_L2_HR_Raster_1.1/SWOT_L2_HR_Raster_100m_UTM19T_N_x_x_x_487_009_116F_20230411T032712_20230411T032733_PIB0_01.nc'], Collection: {'Version': '1.1', 'ShortName': 'SWOT_L2_HR_Raster_1.1'}\nSpatial coverage: {'HorizontalSpatialDomain': {'Orbit': {'StartLatitude': -77.66, 'EndLatitude': 77.66, 'AscendingCrossing': -80.4, 'StartDirection': 'A', 'EndDirection': 'A'}, 'Track': {'Cycle': 488, 'Passes': [{'Pass': 9, 'Tiles': ['230L', '231L', '232L', '233L', '230R', '231R', '232R', '233R']}]}}}\nTemporal coverage: {'RangeDateTime': {'EndingDateTime': '2023-04-12T03:18:10.720Z', 'BeginningDateTime': '2023-04-12T03:17:50.831Z'}}\nSize(MB): 67.56003761291504\nData: ['https://archive.swot.podaac.earthdata.nasa.gov/podaac-swot-ops-cumulus-protected/SWOT_L2_HR_Raster_1.1/SWOT_L2_HR_Raster_100m_UTM19T_N_x_x_x_488_009_116F_20230412T031750_20230412T031811_PIB0_01.nc'], Collection: {'Version': '1.1', 'ShortName': 'SWOT_L2_HR_Raster_1.1'}\nSpatial coverage: {'HorizontalSpatialDomain': {'Orbit': {'StartLatitude': -77.66, 'EndLatitude': 77.66, 'AscendingCrossing': -80.4, 'StartDirection': 'A', 'EndDirection': 'A'}, 'Track': {'Cycle': 489, 'Passes': [{'Pass': 9, 'Tiles': ['230L', '231L', '232L', '233L', '230R', '231R', '232R', '233R']}]}}}\nTemporal coverage: {'RangeDateTime': {'EndingDateTime': '2023-04-13T03:08:48.751Z', 'BeginningDateTime': '2023-04-13T03:08:28.862Z'}}\nSize(MB): 68.72685241699219\nData: ['https://archive.swot.podaac.earthdata.nasa.gov/podaac-swot-ops-cumulus-protected/SWOT_L2_HR_Raster_1.1/SWOT_L2_HR_Raster_100m_UTM19T_N_x_x_x_489_009_116F_20230413T030828_20230413T030849_PIB0_01.nc'], Collection: {'Version': '1.1', 'ShortName': 'SWOT_L2_HR_Raster_1.1'}\nSpatial coverage: {'HorizontalSpatialDomain': {'Orbit': {'StartLatitude': -77.66, 'EndLatitude': 77.66, 'AscendingCrossing': -80.4, 'StartDirection': 'A', 'EndDirection': 'A'}, 'Track': {'Cycle': 490, 'Passes': [{'Pass': 9, 'Tiles': ['230L', '231L', '232L', '233L', '230R', '231R', '232R', '233R']}]}}}\nTemporal coverage: {'RangeDateTime': {'EndingDateTime': '2023-04-14T02:59:26.753Z', 'BeginningDateTime': '2023-04-14T02:59:06.866Z'}}\nSize(MB): 66.47898387908936\nData: ['https://archive.swot.podaac.earthdata.nasa.gov/podaac-swot-ops-cumulus-protected/SWOT_L2_HR_Raster_1.1/SWOT_L2_HR_Raster_100m_UTM19T_N_x_x_x_490_009_116F_20230414T025906_20230414T025927_PIB0_01.nc'], Collection: {'Version': '1.1', 'ShortName': 'SWOT_L2_HR_Raster_1.1'}\nSpatial coverage: {'HorizontalSpatialDomain': {'Orbit': {'StartLatitude': -77.66, 'EndLatitude': 77.66, 'AscendingCrossing': -80.41, 'StartDirection': 'A', 'EndDirection': 'A'}, 'Track': {'Cycle': 491, 'Passes': [{'Pass': 9, 'Tiles': ['230L', '231L', '232L', '233L', '230R', '231R', '232R', '233R']}]}}}\nTemporal coverage: {'RangeDateTime': {'EndingDateTime': '2023-04-15T02:50:04.726Z', 'BeginningDateTime': '2023-04-15T02:49:44.836Z'}}\nSize(MB): 67.29588985443115\nData: ['https://archive.swot.podaac.earthdata.nasa.gov/podaac-swot-ops-cumulus-protected/SWOT_L2_HR_Raster_1.1/SWOT_L2_HR_Raster_100m_UTM19T_N_x_x_x_491_009_116F_20230415T024944_20230415T025005_PIB0_01.nc'], Collection: {'Version': '1.1', 'ShortName': 'SWOT_L2_HR_Raster_1.1'}\nSpatial coverage: {'HorizontalSpatialDomain': {'Orbit': {'StartLatitude': -77.66, 'EndLatitude': 77.66, 'AscendingCrossing': -80.41, 'StartDirection': 'A', 'EndDirection': 'A'}, 'Track': {'Cycle': 492, 'Passes': [{'Pass': 9, 'Tiles': ['230L', '231L', '232L', '233L', '230R', '231R', '232R', '233R']}]}}}\nTemporal coverage: {'RangeDateTime': {'EndingDateTime': '2023-04-16T02:40:43.207Z', 'BeginningDateTime': '2023-04-16T02:40:22.244Z'}}\nSize(MB): 0.933258056640625\nData: ['https://archive.swot.podaac.earthdata.nasa.gov/podaac-swot-ops-cumulus-protected/SWOT_L2_HR_Raster_1.1/SWOT_L2_HR_Raster_100m_UTM19T_N_x_x_x_492_009_116F_20230416T024022_20230416T024043_PIB0_01.nc'], Collection: {'Version': '1.1', 'ShortName': 'SWOT_L2_HR_Raster_1.1'}\nSpatial coverage: {'HorizontalSpatialDomain': {'Orbit': {'StartLatitude': -77.66, 'EndLatitude': 77.66, 'AscendingCrossing': -80.41, 'StartDirection': 'A', 'EndDirection': 'A'}, 'Track': {'Cycle': 493, 'Passes': [{'Pass': 9, 'Tiles': ['230L', '231L', '232L', '233L', '230R', '231R', '232R', '233R']}]}}}\nTemporal coverage: {'RangeDateTime': {'EndingDateTime': '2023-04-17T02:31:21.112Z', 'BeginningDateTime': '2023-04-17T02:31:00.151Z'}}\nSize(MB): 0.9332094192504883\nData: ['https://archive.swot.podaac.earthdata.nasa.gov/podaac-swot-ops-cumulus-protected/SWOT_L2_HR_Raster_1.1/SWOT_L2_HR_Raster_100m_UTM19T_N_x_x_x_493_009_116F_20230417T023100_20230417T023121_PIB0_01.nc'], Collection: {'Version': '1.1', 'ShortName': 'SWOT_L2_HR_Raster_1.1'}\nSpatial coverage: {'HorizontalSpatialDomain': {'Orbit': {'StartLatitude': -77.66, 'EndLatitude': 77.66, 'AscendingCrossing': -80.41, 'StartDirection': 'A', 'EndDirection': 'A'}, 'Track': {'Cycle': 494, 'Passes': [{'Pass': 9, 'Tiles': ['230L', '231L', '232L', '233L', '230R', '231R', '232R', '233R']}]}}}\nTemporal coverage: {'RangeDateTime': {'EndingDateTime': '2023-04-18T02:21:58.990Z', 'BeginningDateTime': '2023-04-18T02:21:38.024Z'}}\nSize(MB): 0.9332304000854492\nData: ['https://archive.swot.podaac.earthdata.nasa.gov/podaac-swot-ops-cumulus-protected/SWOT_L2_HR_Raster_1.1/SWOT_L2_HR_Raster_100m_UTM19T_N_x_x_x_494_009_116F_20230418T022138_20230418T022158_PIB0_01.nc'], Collection: {'Version': '1.1', 'ShortName': 'SWOT_L2_HR_Raster_1.1'}\nSpatial coverage: {'HorizontalSpatialDomain': {'Orbit': {'StartLatitude': -77.66, 'EndLatitude': 77.66, 'AscendingCrossing': -80.41, 'StartDirection': 'A', 'EndDirection': 'A'}, 'Track': {'Cycle': 495, 'Passes': [{'Pass': 9, 'Tiles': ['230L', '231L', '232L', '233L', '230R', '231R', '232R', '233R']}]}}}\nTemporal coverage: {'RangeDateTime': {'EndingDateTime': '2023-04-19T02:12:36.279Z', 'BeginningDateTime': '2023-04-19T02:12:16.394Z'}}\nSize(MB): 63.773990631103516\nData: ['https://archive.swot.podaac.earthdata.nasa.gov/podaac-swot-ops-cumulus-protected/SWOT_L2_HR_Raster_1.1/SWOT_L2_HR_Raster_100m_UTM19T_N_x_x_x_495_009_116F_20230419T021215_20230419T021236_PIB0_01.nc'], Collection: {'Version': '1.1', 'ShortName': 'SWOT_L2_HR_Raster_1.1'}\nSpatial coverage: {'HorizontalSpatialDomain': {'Orbit': {'StartLatitude': -77.66, 'EndLatitude': 77.66, 'AscendingCrossing': -80.41, 'StartDirection': 'A', 'EndDirection': 'A'}, 'Track': {'Cycle': 496, 'Passes': [{'Pass': 9, 'Tiles': ['230L', '231L', '232L', '233L', '230R', '231R', '232R', '233R']}]}}}\nTemporal coverage: {'RangeDateTime': {'EndingDateTime': '2023-04-20T02:03:14.075Z', 'BeginningDateTime': '2023-04-20T02:02:54.187Z'}}\nSize(MB): 62.185853004455566\nData: ['https://archive.swot.podaac.earthdata.nasa.gov/podaac-swot-ops-cumulus-protected/SWOT_L2_HR_Raster_1.1/SWOT_L2_HR_Raster_100m_UTM19T_N_x_x_x_496_009_116F_20230420T020253_20230420T020314_PIB0_01.nc'], Collection: {'Version': '1.1', 'ShortName': 'SWOT_L2_HR_Raster_1.1'}\nSpatial coverage: {'HorizontalSpatialDomain': {'Orbit': {'StartLatitude': -77.66, 'EndLatitude': 77.66, 'AscendingCrossing': -80.41, 'StartDirection': 'A', 'EndDirection': 'A'}, 'Track': {'Cycle': 497, 'Passes': [{'Pass': 9, 'Tiles': ['230L', '231L', '232L', '233L', '230R', '231R', '232R', '233R']}]}}}\nTemporal coverage: {'RangeDateTime': {'EndingDateTime': '2023-04-21T01:53:51.831Z', 'BeginningDateTime': '2023-04-21T01:53:31.942Z'}}\nSize(MB): 61.36593437194824\nData: ['https://archive.swot.podaac.earthdata.nasa.gov/podaac-swot-ops-cumulus-protected/SWOT_L2_HR_Raster_1.1/SWOT_L2_HR_Raster_100m_UTM19T_N_x_x_x_497_009_116F_20230421T015331_20230421T015352_PIB0_01.nc'], Collection: {'Version': '1.1', 'ShortName': 'SWOT_L2_HR_Raster_1.1'}\nSpatial coverage: {'HorizontalSpatialDomain': {'Orbit': {'StartLatitude': -77.66, 'EndLatitude': 77.66, 'AscendingCrossing': -80.41, 'StartDirection': 'A', 'EndDirection': 'A'}, 'Track': {'Cycle': 498, 'Passes': [{'Pass': 9, 'Tiles': ['230L', '231L', '232L', '233L', '230R', '231R', '232R', '233R']}]}}}\nTemporal coverage: {'RangeDateTime': {'EndingDateTime': '2023-04-22T01:44:29.616Z', 'BeginningDateTime': '2023-04-22T01:44:09.731Z'}}\nSize(MB): 61.341376304626465\nData: ['https://archive.swot.podaac.earthdata.nasa.gov/podaac-swot-ops-cumulus-protected/SWOT_L2_HR_Raster_1.1/SWOT_L2_HR_Raster_100m_UTM19T_N_x_x_x_498_009_116F_20230422T014409_20230422T014430_PIB0_01.nc']]\n\n\n\n\n\n\n# Let's look at cycle 485, on the second day of calval\n# Enter cycle\ncycle = \"485\"\n\nraster_results = earthaccess.search_data(short_name = 'SWOT_L2_HR_Raster_1.1', \n temporal = ('2023-04-01 00:00:00', '2023-04-22 23:59:59'), \n granule_name = \"*100m*\" + cycle + \"_\" + pass_number + \"_\" + tile_number + \"*\")\n\n# here we filter by files with '100m' in the name, cycle=484, pass=009, scene = 116F for Connecticut\n # cycle=485, pass=003, scene = 120F for the Rhine\n\nGranules found: 1\n\n\n\n\n\n\nfs_s3 = earthaccess.get_s3fs_session(results=raster_results)\n\n# get link for file and open it\nraster_link = earthaccess.results.DataGranule.data_links(raster_results[0], access='direct')[0]\ns3_file_obj5 = fs_s3.open(raster_link, mode='rb')\n\n# Open data with xarray\nds_raster = xr.open_dataset(s3_file_obj5, engine='h5netcdf')\n\n\n\n\n\n# Plot the data with a filter on water_frac > x, or sig0>50\nds_raster.wse.where(ds_raster.water_frac > 0.5).hvplot.image(y='y', x='x').opts(cmap='Blues', clim=(vmin,vmax), width=1000, height=750)", + "crumbs": [ + "Tutorials", + "Science Workflow" + ] }, { "objectID": "Tutorials/SWOTHR_Science_Application.html#retrieving-swot-attributes-wse-width-slope-and-plotting-a-longitudinal-profile-along-a-river-or-over-a-basin", "href": "Tutorials/SWOTHR_Science_Application.html#retrieving-swot-attributes-wse-width-slope-and-plotting-a-longitudinal-profile-along-a-river-or-over-a-basin", "title": "SWOT Hydrology Science Application Tutorial on the Cloud", "section": "", - "text": "This tutorial can only be run in an AWS cloud instance running in us-west-2: NASA Earthdata Cloud data in S3 can be directly accessed via earthaccess python library; this access is limited to requests made within the US West (Oregon) (code: us-west-2) AWS region.\n\n\n\nAn Earthdata Login account is required to access data, as well as discover restricted data, from the NASA Earthdata system. Thus, to access NASA data, you need Earthdata Login. Please visit https://urs.earthdata.nasa.gov to register and manage your Earthdata Login account. This account is free to create and only takes a moment to set up.\nThis code runs using SWOT Level 2 Data Products (Version 1.1).\nNotebook Authors: Arnaud Cerbelaud, Jeffrey Wade, NASA Jet Propulsion Laboratory - California Institute of Technology (Jan 2024)" + "text": "This tutorial can only be run in an AWS cloud instance running in us-west-2: NASA Earthdata Cloud data in S3 can be directly accessed via earthaccess python library; this access is limited to requests made within the US West (Oregon) (code: us-west-2) AWS region.\n\n\n\nAn Earthdata Login account is required to access data, as well as discover restricted data, from the NASA Earthdata system. Thus, to access NASA data, you need Earthdata Login. Please visit https://urs.earthdata.nasa.gov to register and manage your Earthdata Login account. This account is free to create and only takes a moment to set up.\nThis code runs using SWOT Level 2 Data Products (Version 1.1).\nNotebook Authors: Arnaud Cerbelaud, Jeffrey Wade, NASA Jet Propulsion Laboratory - California Institute of Technology (Jan 2024)", + "crumbs": [ + "Tutorials", + "Science Workflow" + ] }, { "objectID": "Tutorials/SWOTHR_Science_Application.html#learning-objectives", "href": "Tutorials/SWOTHR_Science_Application.html#learning-objectives", "title": "SWOT Hydrology Science Application Tutorial on the Cloud", "section": "", - "text": "Retrieve SWOT hydrological attributes on river reaches within the AWS cloud (Cal/Val data). Query reaches by:\n\nRiver name\nSpatial bounding box\nDownstream tracing from reach id\nUpstream tracing from reach id\n\n\nRiver longitudinal profile: filtering data to display all reaches located downstream of a given reach (e.g. headwater to outlet)\nWatershed analysis: filtering data to display all reaches located upstream of a given reach (e.g. outlet to full river network)\nVisualize and plot WSE, width, slope data on the filtered data\n\nLast updated: 31 Jan 2024" + "text": "Retrieve SWOT hydrological attributes on river reaches within the AWS cloud (Cal/Val data). Query reaches by:\n\nRiver name\nSpatial bounding box\nDownstream tracing from reach id\nUpstream tracing from reach id\n\n\nRiver longitudinal profile: filtering data to display all reaches located downstream of a given reach (e.g. headwater to outlet)\nWatershed analysis: filtering data to display all reaches located upstream of a given reach (e.g. outlet to full river network)\nVisualize and plot WSE, width, slope data on the filtered data\n\nLast updated: 31 Jan 2024", + "crumbs": [ + "Tutorials", + "Science Workflow" + ] }, { "objectID": "Tutorials/SWOTHR_Science_Application.html#import-packages", "href": "Tutorials/SWOTHR_Science_Application.html#import-packages", "title": "SWOT Hydrology Science Application Tutorial on the Cloud", "section": "", - "text": "import glob\nimport os\nimport requests\nimport s3fs\nimport fiona\nimport netCDF4 as nc\nimport h5netcdf\nimport xarray as xr\nimport pandas as pd\nimport geopandas as gpd\nimport numpy as np\nimport matplotlib.pyplot as plt\nimport hvplot.xarray\nimport earthaccess\nfrom earthaccess import Auth, DataCollections, DataGranules, Store\nfrom pathlib import Path\nimport zipfile" + "text": "import glob\nimport os\nimport requests\nimport s3fs\nimport fiona\nimport netCDF4 as nc\nimport h5netcdf\nimport xarray as xr\nimport pandas as pd\nimport geopandas as gpd\nimport numpy as np\nimport matplotlib.pyplot as plt\nimport hvplot.xarray\nimport earthaccess\nfrom earthaccess import Auth, DataCollections, DataGranules, Store\nfrom pathlib import Path\nimport zipfile", + "crumbs": [ + "Tutorials", + "Science Workflow" + ] }, { "objectID": "Tutorials/SWOTHR_Science_Application.html#authenticate", "href": "Tutorials/SWOTHR_Science_Application.html#authenticate", "title": "SWOT Hydrology Science Application Tutorial on the Cloud", "section": "", - "text": "Authenticate your Earthdata Login (EDL) information using the earthaccess python package as follows:\n\nearthaccess.login() # Login with your EDL credentials if asked\n\nEnter your Earthdata Login username: jswade\nEnter your Earthdata password: ········\n\n\n<earthaccess.auth.Auth at 0x7fd9a7adbee0>" + "text": "Authenticate your Earthdata Login (EDL) information using the earthaccess python package as follows:\n\nearthaccess.login() # Login with your EDL credentials if asked\n\nEnter your Earthdata Login username: jswade\nEnter your Earthdata password: ········\n\n\n<earthaccess.auth.Auth at 0x7fd9a7adbee0>", + "crumbs": [ + "Tutorials", + "Science Workflow" + ] }, { "objectID": "Tutorials/SWOTHR_Science_Application.html#retrieve-swot-hydrological-attributes-on-river-reaches-within-the-aws-cloud-calval-data", "href": "Tutorials/SWOTHR_Science_Application.html#retrieve-swot-hydrological-attributes-on-river-reaches-within-the-aws-cloud-calval-data", "title": "SWOT Hydrology Science Application Tutorial on the Cloud", "section": "", - "text": "Optional step: Get the .kmz file of SWOT passes/swaths (Version 1.1) and import it into Google Earth for visualization\nDetermine which pass number corresponds to the river/basin you want to look at! #### Search for multiple days of data\n\n\n# Enter pass number\npass_number = \"009\" # e.g. 009 for Connecticut in NA, 003 for Rhine in EU\n# Enter continent code\ncontinent_code = \"NA\" # e.g. \"AF\", \"NA\", \"EU\", \"SI\", \"AS\", \"AU\", \"SA\", \"AR\", \"GR\"\n\n# Retrieves granule from the day we want, in this case by passing to `earthdata.search_data` function the data collection shortname and temporal bounds\nriver_results = earthaccess.search_data(short_name = 'SWOT_L2_HR_RIVERSP_1.1', \n temporal = ('2023-04-08 00:00:00', '2023-04-12 23:59:59'),\n granule_name = \"*Reach*_\" + pass_number + \"_\" + continent_code + \"*\")\n\n# Create fiona session to read data\nfs_s3 = earthaccess.get_s3fs_session(results=river_results)\nfiona_session=fiona.session.AWSSession(\n aws_access_key_id=fs_s3.storage_options[\"key\"],\n aws_secret_access_key=fs_s3.storage_options[\"secret\"],\n aws_session_token=fs_s3.storage_options[\"token\"]\n )\n\nGranules found: 5\n\n\n\n\n\n\n# Initialize list of shapefiles containing all dates\nSWOT_HR_shps = []\n\n# Loop through queried granules to stack all acquisition dates\nfor j in range(len(river_results)):\n \n # Get the link for each zip file\n river_link = earthaccess.results.DataGranule.data_links(river_results[j], access='direct')[0]\n \n # We use the zip+ prefix so fiona knows that we are operating on a zip file\n river_shp_url = f\"zip+{river_link}\"\n \n # Read shapefile\n with fiona.Env(session=fiona_session):\n SWOT_HR_shps.append(gpd.read_file(river_shp_url)) \n\n\n\n\n\n# Combine granules from all acquisition dates into one dataframe\nSWOT_HR_df = gpd.GeoDataFrame(pd.concat(SWOT_HR_shps, ignore_index=True))\n\n# Sort dataframe by reach_id and time\nSWOT_HR_df = SWOT_HR_df.sort_values(['reach_id', 'time'])\n\nSWOT_HR_df\n\n\n\n\n\n\n\n\nreach_id\ntime\ntime_tai\ntime_str\np_lat\np_lon\nriver_name\nwse\nwse_u\nwse_r_u\n...\np_wid_var\np_n_nodes\np_dist_out\np_length\np_maf\np_dam_id\np_n_ch_max\np_n_ch_mod\np_low_slp\ngeometry\n\n\n\n\n1958\n72270400231\n-1.000000e+12\n-1.000000e+12\nno_data\n56.794630\n-66.461122\nno_data\n-1.000000e+12\n-1.000000e+12\n-1.000000e+12\n...\n1618.079\n53\n230079.472\n10630.774958\n-1.000000e+12\n0\n1\n1\n0\nLINESTRING (-66.48682 56.83442, -66.48645 56.8...\n\n\n2641\n72270400231\n-1.000000e+12\n-1.000000e+12\nno_data\n56.794630\n-66.461122\nno_data\n-1.000000e+12\n-1.000000e+12\n-1.000000e+12\n...\n1618.079\n53\n230079.472\n10630.774958\n-1.000000e+12\n0\n1\n1\n0\nLINESTRING (-66.48682 56.83442, -66.48645 56.8...\n\n\n1959\n72270400241\n-1.000000e+12\n-1.000000e+12\nno_data\n56.744361\n-66.341905\nno_data\n-1.000000e+12\n-1.000000e+12\n-1.000000e+12\n...\n4831.128\n53\n240728.430\n10648.958289\n-1.000000e+12\n0\n2\n1\n0\nLINESTRING (-66.41602 56.75969, -66.41553 56.7...\n\n\n2642\n72270400241\n-1.000000e+12\n-1.000000e+12\nno_data\n56.744361\n-66.341905\nno_data\n-1.000000e+12\n-1.000000e+12\n-1.000000e+12\n...\n4831.128\n53\n240728.430\n10648.958289\n-1.000000e+12\n0\n2\n1\n0\nLINESTRING (-66.41602 56.75969, -66.41553 56.7...\n\n\n1960\n72270400251\n7.344991e+08\n7.344991e+08\n2023-04-11T03:31:02Z\n56.676087\n-66.219811\nno_data\n2.855340e+02\n1.008930e+00\n1.004910e+00\n...\n412.975\n58\n252286.769\n11558.339052\n-1.000000e+12\n0\n2\n1\n0\nLINESTRING (-66.27812 56.71437, -66.27775 56.7...\n\n\n...\n...\n...\n...\n...\n...\n...\n...\n...\n...\n...\n...\n...\n...\n...\n...\n...\n...\n...\n...\n...\n...\n\n\n615\n73130000061\n-1.000000e+12\n-1.000000e+12\nno_data\n41.424945\n-73.230960\nHousatonic River\n-1.000000e+12\n-1.000000e+12\n-1.000000e+12\n...\n10469.706\n82\n47161.191\n16303.793847\n-1.000000e+12\n0\n2\n1\n0\nLINESTRING (-73.17436 41.38295, -73.17465 41.3...\n\n\n1283\n73130000061\n-1.000000e+12\n-1.000000e+12\nno_data\n41.424945\n-73.230960\nHousatonic River\n-1.000000e+12\n-1.000000e+12\n-1.000000e+12\n...\n10469.706\n82\n47161.191\n16303.793847\n-1.000000e+12\n0\n2\n1\n0\nLINESTRING (-73.17436 41.38295, -73.17465 41.3...\n\n\n1957\n73130000061\n-1.000000e+12\n-1.000000e+12\nno_data\n41.424945\n-73.230960\nHousatonic River\n-1.000000e+12\n-1.000000e+12\n-1.000000e+12\n...\n10469.706\n82\n47161.191\n16303.793847\n-1.000000e+12\n0\n2\n1\n0\nLINESTRING (-73.17436 41.38295, -73.17465 41.3...\n\n\n2640\n73130000061\n-1.000000e+12\n-1.000000e+12\nno_data\n41.424945\n-73.230960\nHousatonic River\n-1.000000e+12\n-1.000000e+12\n-1.000000e+12\n...\n10469.706\n82\n47161.191\n16303.793847\n-1.000000e+12\n0\n2\n1\n0\nLINESTRING (-73.17436 41.38295, -73.17465 41.3...\n\n\n3312\n73130000061\n-1.000000e+12\n-1.000000e+12\nno_data\n41.424945\n-73.230960\nHousatonic River\n-1.000000e+12\n-1.000000e+12\n-1.000000e+12\n...\n10469.706\n82\n47161.191\n16303.793847\n-1.000000e+12\n0\n2\n1\n0\nLINESTRING (-73.17436 41.38295, -73.17465 41.3...\n\n\n\n\n3313 rows × 127 columns" + "text": "Optional step: Get the .kmz file of SWOT passes/swaths (Version 1.1) and import it into Google Earth for visualization\nDetermine which pass number corresponds to the river/basin you want to look at! #### Search for multiple days of data\n\n\n# Enter pass number\npass_number = \"009\" # e.g. 009 for Connecticut in NA, 003 for Rhine in EU\n# Enter continent code\ncontinent_code = \"NA\" # e.g. \"AF\", \"NA\", \"EU\", \"SI\", \"AS\", \"AU\", \"SA\", \"AR\", \"GR\"\n\n# Retrieves granule from the day we want, in this case by passing to `earthdata.search_data` function the data collection shortname and temporal bounds\nriver_results = earthaccess.search_data(short_name = 'SWOT_L2_HR_RIVERSP_1.1', \n temporal = ('2023-04-08 00:00:00', '2023-04-12 23:59:59'),\n granule_name = \"*Reach*_\" + pass_number + \"_\" + continent_code + \"*\")\n\n# Create fiona session to read data\nfs_s3 = earthaccess.get_s3fs_session(results=river_results)\nfiona_session=fiona.session.AWSSession(\n aws_access_key_id=fs_s3.storage_options[\"key\"],\n aws_secret_access_key=fs_s3.storage_options[\"secret\"],\n aws_session_token=fs_s3.storage_options[\"token\"]\n )\n\nGranules found: 5\n\n\n\n\n\n\n# Initialize list of shapefiles containing all dates\nSWOT_HR_shps = []\n\n# Loop through queried granules to stack all acquisition dates\nfor j in range(len(river_results)):\n \n # Get the link for each zip file\n river_link = earthaccess.results.DataGranule.data_links(river_results[j], access='direct')[0]\n \n # We use the zip+ prefix so fiona knows that we are operating on a zip file\n river_shp_url = f\"zip+{river_link}\"\n \n # Read shapefile\n with fiona.Env(session=fiona_session):\n SWOT_HR_shps.append(gpd.read_file(river_shp_url)) \n\n\n\n\n\n# Combine granules from all acquisition dates into one dataframe\nSWOT_HR_df = gpd.GeoDataFrame(pd.concat(SWOT_HR_shps, ignore_index=True))\n\n# Sort dataframe by reach_id and time\nSWOT_HR_df = SWOT_HR_df.sort_values(['reach_id', 'time'])\n\nSWOT_HR_df\n\n\n\n\n\n\n\n\nreach_id\ntime\ntime_tai\ntime_str\np_lat\np_lon\nriver_name\nwse\nwse_u\nwse_r_u\n...\np_wid_var\np_n_nodes\np_dist_out\np_length\np_maf\np_dam_id\np_n_ch_max\np_n_ch_mod\np_low_slp\ngeometry\n\n\n\n\n1958\n72270400231\n-1.000000e+12\n-1.000000e+12\nno_data\n56.794630\n-66.461122\nno_data\n-1.000000e+12\n-1.000000e+12\n-1.000000e+12\n...\n1618.079\n53\n230079.472\n10630.774958\n-1.000000e+12\n0\n1\n1\n0\nLINESTRING (-66.48682 56.83442, -66.48645 56.8...\n\n\n2641\n72270400231\n-1.000000e+12\n-1.000000e+12\nno_data\n56.794630\n-66.461122\nno_data\n-1.000000e+12\n-1.000000e+12\n-1.000000e+12\n...\n1618.079\n53\n230079.472\n10630.774958\n-1.000000e+12\n0\n1\n1\n0\nLINESTRING (-66.48682 56.83442, -66.48645 56.8...\n\n\n1959\n72270400241\n-1.000000e+12\n-1.000000e+12\nno_data\n56.744361\n-66.341905\nno_data\n-1.000000e+12\n-1.000000e+12\n-1.000000e+12\n...\n4831.128\n53\n240728.430\n10648.958289\n-1.000000e+12\n0\n2\n1\n0\nLINESTRING (-66.41602 56.75969, -66.41553 56.7...\n\n\n2642\n72270400241\n-1.000000e+12\n-1.000000e+12\nno_data\n56.744361\n-66.341905\nno_data\n-1.000000e+12\n-1.000000e+12\n-1.000000e+12\n...\n4831.128\n53\n240728.430\n10648.958289\n-1.000000e+12\n0\n2\n1\n0\nLINESTRING (-66.41602 56.75969, -66.41553 56.7...\n\n\n1960\n72270400251\n7.344991e+08\n7.344991e+08\n2023-04-11T03:31:02Z\n56.676087\n-66.219811\nno_data\n2.855340e+02\n1.008930e+00\n1.004910e+00\n...\n412.975\n58\n252286.769\n11558.339052\n-1.000000e+12\n0\n2\n1\n0\nLINESTRING (-66.27812 56.71437, -66.27775 56.7...\n\n\n...\n...\n...\n...\n...\n...\n...\n...\n...\n...\n...\n...\n...\n...\n...\n...\n...\n...\n...\n...\n...\n...\n\n\n615\n73130000061\n-1.000000e+12\n-1.000000e+12\nno_data\n41.424945\n-73.230960\nHousatonic River\n-1.000000e+12\n-1.000000e+12\n-1.000000e+12\n...\n10469.706\n82\n47161.191\n16303.793847\n-1.000000e+12\n0\n2\n1\n0\nLINESTRING (-73.17436 41.38295, -73.17465 41.3...\n\n\n1283\n73130000061\n-1.000000e+12\n-1.000000e+12\nno_data\n41.424945\n-73.230960\nHousatonic River\n-1.000000e+12\n-1.000000e+12\n-1.000000e+12\n...\n10469.706\n82\n47161.191\n16303.793847\n-1.000000e+12\n0\n2\n1\n0\nLINESTRING (-73.17436 41.38295, -73.17465 41.3...\n\n\n1957\n73130000061\n-1.000000e+12\n-1.000000e+12\nno_data\n41.424945\n-73.230960\nHousatonic River\n-1.000000e+12\n-1.000000e+12\n-1.000000e+12\n...\n10469.706\n82\n47161.191\n16303.793847\n-1.000000e+12\n0\n2\n1\n0\nLINESTRING (-73.17436 41.38295, -73.17465 41.3...\n\n\n2640\n73130000061\n-1.000000e+12\n-1.000000e+12\nno_data\n41.424945\n-73.230960\nHousatonic River\n-1.000000e+12\n-1.000000e+12\n-1.000000e+12\n...\n10469.706\n82\n47161.191\n16303.793847\n-1.000000e+12\n0\n2\n1\n0\nLINESTRING (-73.17436 41.38295, -73.17465 41.3...\n\n\n3312\n73130000061\n-1.000000e+12\n-1.000000e+12\nno_data\n41.424945\n-73.230960\nHousatonic River\n-1.000000e+12\n-1.000000e+12\n-1.000000e+12\n...\n10469.706\n82\n47161.191\n16303.793847\n-1.000000e+12\n0\n2\n1\n0\nLINESTRING (-73.17436 41.38295, -73.17465 41.3...\n\n\n\n\n3313 rows × 127 columns", + "crumbs": [ + "Tutorials", + "Science Workflow" + ] }, { "objectID": "Tutorials/SWOTHR_Science_Application.html#exploring-the-dataset", "href": "Tutorials/SWOTHR_Science_Application.html#exploring-the-dataset", "title": "SWOT Hydrology Science Application Tutorial on the Cloud", "section": "", - "text": "print('Available dates are:')\nprint(np.unique([i[:10] for i in SWOT_HR_df['time_str']]))\nprint('Available rivers are:')\nprint(np.unique([i for i in SWOT_HR_df['river_name']]))\n\nAvailable dates are:\n['2023-04-08' '2023-04-09' '2023-04-10' '2023-04-11' '2023-04-12'\n 'no_data']\nAvailable rivers are:\n['Allagash River' 'Androscoggin River' 'Big Black River' 'Canal de fuite'\n 'Carrabassett River' 'Concord River' 'Concord River; Sudbury River'\n 'Connecticut River' 'Connecticut River; Westfield River'\n 'Connecticut River; White River' 'Dead River'\n 'Dead River (Kennebec River)' 'Deerfield River' 'Farmington River'\n 'Housatonic River' 'Ikarut River' 'Kennebec River' 'Komaktorvik River'\n 'Magalloway River' 'Merrimack River' 'Moose River'\n 'North Branch Penobscot River' 'Passumsic River' 'Pemigewasset River'\n 'Penobscot River West Branch' 'Quinebaug River' 'Saco River'\n 'Saguenay River' 'Saint Francis River' 'Saint John River'\n 'Saint Lawrence River' 'Sandy River' 'Shetucket River' 'Sudbury River'\n 'Thames River' 'West River' 'White River' 'no_data']\n\n\n\n\n\nNote: Some rivers have multiple names, hence using the contains function\n\n# Enter river name\nriver = \"Connecticut River\" # e.g. \"Rhine\", \"Connecticut River\"\n\n## Filter dataframe\nSWOT_HR_df_river = SWOT_HR_df[(SWOT_HR_df.river_name.str.contains(river))]\n\n# Plot geopandas dataframe with 'explore' by reach id\nSWOT_HR_df_river[['reach_id','river_name','geometry']].explore('reach_id', style_kwds=dict(weight=6))\n\nMake this Notebook Trusted to load map: File -> Trust Notebook\n\n\n\n\n\n\nlat_start = {\"Connecticut River\": 41.5,\n \"Rhine\": 47.5\n }\nlat_end = {\"Connecticut River\": 45,\n \"Rhine\": 51\n }\nlon_start = {\"Connecticut River\": -74,\n \"Rhine\": 7\n }\nlon_end = {\"Connecticut River\": -71,\n \"Rhine\": 10\n }\n\n## Filter dataframe\nSWOT_HR_df_box = SWOT_HR_df[(SWOT_HR_df.p_lat > lat_start[river]) & (SWOT_HR_df.p_lat < lat_end[river]) & (SWOT_HR_df.p_lon > lon_start[river]) & (SWOT_HR_df.p_lon < lon_end[river])]\n\n# Plot geopandas dataframe with 'explore' by river name\nSWOT_HR_df_box[['reach_id','river_name','geometry']].explore('river_name', style_kwds=dict(weight=6))\n\nMake this Notebook Trusted to load map: File -> Trust Notebook" + "text": "print('Available dates are:')\nprint(np.unique([i[:10] for i in SWOT_HR_df['time_str']]))\nprint('Available rivers are:')\nprint(np.unique([i for i in SWOT_HR_df['river_name']]))\n\nAvailable dates are:\n['2023-04-08' '2023-04-09' '2023-04-10' '2023-04-11' '2023-04-12'\n 'no_data']\nAvailable rivers are:\n['Allagash River' 'Androscoggin River' 'Big Black River' 'Canal de fuite'\n 'Carrabassett River' 'Concord River' 'Concord River; Sudbury River'\n 'Connecticut River' 'Connecticut River; Westfield River'\n 'Connecticut River; White River' 'Dead River'\n 'Dead River (Kennebec River)' 'Deerfield River' 'Farmington River'\n 'Housatonic River' 'Ikarut River' 'Kennebec River' 'Komaktorvik River'\n 'Magalloway River' 'Merrimack River' 'Moose River'\n 'North Branch Penobscot River' 'Passumsic River' 'Pemigewasset River'\n 'Penobscot River West Branch' 'Quinebaug River' 'Saco River'\n 'Saguenay River' 'Saint Francis River' 'Saint John River'\n 'Saint Lawrence River' 'Sandy River' 'Shetucket River' 'Sudbury River'\n 'Thames River' 'West River' 'White River' 'no_data']\n\n\n\n\n\nNote: Some rivers have multiple names, hence using the contains function\n\n# Enter river name\nriver = \"Connecticut River\" # e.g. \"Rhine\", \"Connecticut River\"\n\n## Filter dataframe\nSWOT_HR_df_river = SWOT_HR_df[(SWOT_HR_df.river_name.str.contains(river))]\n\n# Plot geopandas dataframe with 'explore' by reach id\nSWOT_HR_df_river[['reach_id','river_name','geometry']].explore('reach_id', style_kwds=dict(weight=6))\n\nMake this Notebook Trusted to load map: File -> Trust Notebook\n\n\n\n\n\n\nlat_start = {\"Connecticut River\": 41.5,\n \"Rhine\": 47.5\n }\nlat_end = {\"Connecticut River\": 45,\n \"Rhine\": 51\n }\nlon_start = {\"Connecticut River\": -74,\n \"Rhine\": 7\n }\nlon_end = {\"Connecticut River\": -71,\n \"Rhine\": 10\n }\n\n## Filter dataframe\nSWOT_HR_df_box = SWOT_HR_df[(SWOT_HR_df.p_lat > lat_start[river]) & (SWOT_HR_df.p_lat < lat_end[river]) & (SWOT_HR_df.p_lon > lon_start[river]) & (SWOT_HR_df.p_lon < lon_end[river])]\n\n# Plot geopandas dataframe with 'explore' by river name\nSWOT_HR_df_box[['reach_id','river_name','geometry']].explore('river_name', style_kwds=dict(weight=6))\n\nMake this Notebook Trusted to load map: File -> Trust Notebook", + "crumbs": [ + "Tutorials", + "Science Workflow" + ] }, { "objectID": "Tutorials/SWOTHR_Science_Application.html#river-longitudinal-profile-trace-reaches-downstream-of-given-starting-reach-using-rch_id_dn-field", "href": "Tutorials/SWOTHR_Science_Application.html#river-longitudinal-profile-trace-reaches-downstream-of-given-starting-reach-using-rch_id_dn-field", "title": "SWOT Hydrology Science Application Tutorial on the Cloud", "section": "", - "text": "WARNING: This works as long as the data is exhaustive (no missing SWORD reaches)\n\n\nNote: rch_dn_dict[rch_id] gives a list of all the reaches directly downstream from rch_id\n\n# Format rch_id_dn for dictionary. Rch_id_dn allows for multiple downstream reaches to be stored\n# Also removes spaces in attribute field\nrch_id_dn = [[x.strip() for x in SWOT_HR_df.rch_id_dn[j].split(',')] for j in range(0,len(SWOT_HR_df.rch_id_dn))]\n\n# Filter upstream reach ids to remove 'no_data'\nrch_id_dn_filter = [[x for x in dn_id if x.isnumeric()] for dn_id in rch_id_dn]\n\n# Create lookup dictionary for river network topology: Downstream\nrch_dn_dict = {SWOT_HR_df.reach_id[i]: rch_id_dn_filter[i] for i in range(len(SWOT_HR_df))}\n\n\n\n\n\n# Enter reach_id from which we will trace downstream (e.g. headwaters of the Connecticut River)\nrch_dn_st = {\"Connecticut River\": '73120000691',\n \"Rhine\": '23267000651'\n }\n\n# Initialize list to store downstream reaches, including starting reach\nrch_dn_list = [rch_dn_st[river]]\n# Retrieve first downstream id of starting reach and add to list\nrch_dn_next = rch_dn_dict[rch_dn_st[river]][0]\n\n# Trace next downstream reach until we hit the outlet (or here the last reach on file)\nwhile len(rch_dn_next) != 0:\n # Add reach to list if value exists\n if len(rch_dn_next) != 0:\n rch_dn_list.append(rch_dn_next)\n # Recursively retrieve first downstream id of next reach\n # Catch error if reach isn't in downloaded data\n try:\n rch_dn_next = rch_dn_dict[rch_dn_next][0]\n except:\n break\n\n\n\n\n\n# Filter downloaded data by downstream traced reaches\nSWOT_dn_trace = SWOT_HR_df[SWOT_HR_df.reach_id.isin(rch_dn_list)]\n\n# Remove reaches from rch_dn_list that are not present in SWOT data\nrch_dn_list = [rch for rch in rch_dn_list if rch in SWOT_HR_df.reach_id.values]\n\nSWOT_dn_trace[['reach_id','river_name','geometry']].explore('river_name', style_kwds=dict(weight=6))\n\nMake this Notebook Trusted to load map: File -> Trust Notebook" + "text": "WARNING: This works as long as the data is exhaustive (no missing SWORD reaches)\n\n\nNote: rch_dn_dict[rch_id] gives a list of all the reaches directly downstream from rch_id\n\n# Format rch_id_dn for dictionary. Rch_id_dn allows for multiple downstream reaches to be stored\n# Also removes spaces in attribute field\nrch_id_dn = [[x.strip() for x in SWOT_HR_df.rch_id_dn[j].split(',')] for j in range(0,len(SWOT_HR_df.rch_id_dn))]\n\n# Filter upstream reach ids to remove 'no_data'\nrch_id_dn_filter = [[x for x in dn_id if x.isnumeric()] for dn_id in rch_id_dn]\n\n# Create lookup dictionary for river network topology: Downstream\nrch_dn_dict = {SWOT_HR_df.reach_id[i]: rch_id_dn_filter[i] for i in range(len(SWOT_HR_df))}\n\n\n\n\n\n# Enter reach_id from which we will trace downstream (e.g. headwaters of the Connecticut River)\nrch_dn_st = {\"Connecticut River\": '73120000691',\n \"Rhine\": '23267000651'\n }\n\n# Initialize list to store downstream reaches, including starting reach\nrch_dn_list = [rch_dn_st[river]]\n# Retrieve first downstream id of starting reach and add to list\nrch_dn_next = rch_dn_dict[rch_dn_st[river]][0]\n\n# Trace next downstream reach until we hit the outlet (or here the last reach on file)\nwhile len(rch_dn_next) != 0:\n # Add reach to list if value exists\n if len(rch_dn_next) != 0:\n rch_dn_list.append(rch_dn_next)\n # Recursively retrieve first downstream id of next reach\n # Catch error if reach isn't in downloaded data\n try:\n rch_dn_next = rch_dn_dict[rch_dn_next][0]\n except:\n break\n\n\n\n\n\n# Filter downloaded data by downstream traced reaches\nSWOT_dn_trace = SWOT_HR_df[SWOT_HR_df.reach_id.isin(rch_dn_list)]\n\n# Remove reaches from rch_dn_list that are not present in SWOT data\nrch_dn_list = [rch for rch in rch_dn_list if rch in SWOT_HR_df.reach_id.values]\n\nSWOT_dn_trace[['reach_id','river_name','geometry']].explore('river_name', style_kwds=dict(weight=6))\n\nMake this Notebook Trusted to load map: File -> Trust Notebook", + "crumbs": [ + "Tutorials", + "Science Workflow" + ] }, { "objectID": "Tutorials/SWOTHR_Science_Application.html#watershed-analysis-trace-reaches-upstream-of-starting-reach-using-rch_id_up-field", "href": "Tutorials/SWOTHR_Science_Application.html#watershed-analysis-trace-reaches-upstream-of-starting-reach-using-rch_id_up-field", "title": "SWOT Hydrology Science Application Tutorial on the Cloud", "section": "", - "text": "WARNING: This works as long as the data is exhaustive (no missing SWORD reaches)\n\n\nNote: rch_up_dict[rch_id] gives a list of all the reaches directly upstream from rch_id\n\n# Format rch_id_up for dictionary. Rch_id_up allows for multiple upstream reaches to be stored\n# Also removes spaces in attribute field\nrch_id_up = [[x.strip() for x in SWOT_HR_df.rch_id_up[j].split(',')] for j in range(0,len(SWOT_HR_df.rch_id_up))]\n\n# Filter upstream reach ids to remove 'no_data'\nrch_id_up_fil = [[x for x in ups_id if x.isnumeric()] for ups_id in rch_id_up]\n\n# Create lookup dictionary for river network topology: Upstream\nrch_up_dict = {SWOT_HR_df.reach_id[i]: rch_id_up_fil[i] for i in range(len(SWOT_HR_df))}\n\n\n\n\nThis adds a bit of complexity, as we need to keep track of multiple branches upstream of the starting reach.\n\n# Enter reach_id from which we will trace upstream (e.g. outlet of the Connecticut River)\nrch_up_st = {\"Connecticut River\": '73120000013',\n \"Rhine\": '23265000051'\n }\n\n# Initialize list to store traced upstream reaches, including starting reach\nrch_up_list = [rch_up_st[river]]\n# Retrieve ids of reaches upstream of starting reach and add to list\nrch_up_next = rch_up_dict[rch_up_st[river]]\n# For upstream tracing, we need to set a list of next upstream ids to start while loop\nrch_next_id = rch_up_next\n\n# Loop until no more reaches to trace\nwhile len(rch_next_id) != 0:\n # Initialize list to store next upstream ids\n rch_next_id = []\n # Loop through next upstream ids for given reach\n for rch_up_sel in rch_up_next:\n # Get values of existing upstream ids of rch_up_next reaches\n # If reach isn't in SWOT data (usually ghost reaches), continue to next reach\n try:\n rch_next_id = rch_next_id + rch_up_dict[rch_up_sel]\n except:\n continue\n # Append id to list\n rch_up_list.append(rch_up_sel)\n # If reaches exist, add to list for next cycle of tracing\n if len(rch_next_id) != 0:\n rch_up_next = rch_next_id\n\n\n\n\n\n# Filter downloaded data by upstream traced reaches\nSWOT_up_trace = SWOT_HR_df[SWOT_HR_df.reach_id.isin(rch_up_list)]\n\n# Remove reaches from rch_up_list that are not present in SWOT data\nrch_up_list = [rch for rch in rch_up_list if rch in SWOT_HR_df.reach_id.values]\n\nSWOT_up_trace[['reach_id','river_name','geometry']].explore('river_name', style_kwds=dict(weight=6))\n\nMake this Notebook Trusted to load map: File -> Trust Notebook" + "text": "WARNING: This works as long as the data is exhaustive (no missing SWORD reaches)\n\n\nNote: rch_up_dict[rch_id] gives a list of all the reaches directly upstream from rch_id\n\n# Format rch_id_up for dictionary. Rch_id_up allows for multiple upstream reaches to be stored\n# Also removes spaces in attribute field\nrch_id_up = [[x.strip() for x in SWOT_HR_df.rch_id_up[j].split(',')] for j in range(0,len(SWOT_HR_df.rch_id_up))]\n\n# Filter upstream reach ids to remove 'no_data'\nrch_id_up_fil = [[x for x in ups_id if x.isnumeric()] for ups_id in rch_id_up]\n\n# Create lookup dictionary for river network topology: Upstream\nrch_up_dict = {SWOT_HR_df.reach_id[i]: rch_id_up_fil[i] for i in range(len(SWOT_HR_df))}\n\n\n\n\nThis adds a bit of complexity, as we need to keep track of multiple branches upstream of the starting reach.\n\n# Enter reach_id from which we will trace upstream (e.g. outlet of the Connecticut River)\nrch_up_st = {\"Connecticut River\": '73120000013',\n \"Rhine\": '23265000051'\n }\n\n# Initialize list to store traced upstream reaches, including starting reach\nrch_up_list = [rch_up_st[river]]\n# Retrieve ids of reaches upstream of starting reach and add to list\nrch_up_next = rch_up_dict[rch_up_st[river]]\n# For upstream tracing, we need to set a list of next upstream ids to start while loop\nrch_next_id = rch_up_next\n\n# Loop until no more reaches to trace\nwhile len(rch_next_id) != 0:\n # Initialize list to store next upstream ids\n rch_next_id = []\n # Loop through next upstream ids for given reach\n for rch_up_sel in rch_up_next:\n # Get values of existing upstream ids of rch_up_next reaches\n # If reach isn't in SWOT data (usually ghost reaches), continue to next reach\n try:\n rch_next_id = rch_next_id + rch_up_dict[rch_up_sel]\n except:\n continue\n # Append id to list\n rch_up_list.append(rch_up_sel)\n # If reaches exist, add to list for next cycle of tracing\n if len(rch_next_id) != 0:\n rch_up_next = rch_next_id\n\n\n\n\n\n# Filter downloaded data by upstream traced reaches\nSWOT_up_trace = SWOT_HR_df[SWOT_HR_df.reach_id.isin(rch_up_list)]\n\n# Remove reaches from rch_up_list that are not present in SWOT data\nrch_up_list = [rch for rch in rch_up_list if rch in SWOT_HR_df.reach_id.values]\n\nSWOT_up_trace[['reach_id','river_name','geometry']].explore('river_name', style_kwds=dict(weight=6))\n\nMake this Notebook Trusted to load map: File -> Trust Notebook", + "crumbs": [ + "Tutorials", + "Science Workflow" + ] }, { "objectID": "Tutorials/SWOTHR_Science_Application.html#visualize-and-plot-a-time-series-of-wsewidthslope-longitudinal-profiles", "href": "Tutorials/SWOTHR_Science_Application.html#visualize-and-plot-a-time-series-of-wsewidthslope-longitudinal-profiles", "title": "SWOT Hydrology Science Application Tutorial on the Cloud", "section": "", - "text": "# Retrieve all possible acquisition dates (keeping only YYYY-MM-DD)\ndates = np.unique([i[:10] for i in [x for x in SWOT_HR_df['time_str'] if x!='no_data']])\n\n# Create a new database for time series analysis with unique reach_ids\nSWOT_dn_trace_time = SWOT_dn_trace.set_index('reach_id').groupby(level=0) \\\n .apply(lambda df: df.reset_index(drop=True)) \\\n .unstack().sort_index(axis=1, level=1)\n\nSWOT_dn_trace_time.columns = ['{}_{}'.format(x[0],dates[x[1]]) for x in SWOT_dn_trace_time.columns]\n\n\n\n\n\n# Explore variables you could choose to plot\nfor var in [\"wse\",\"slope\",\"width\",\"len\"]:\n print(SWOT_dn_trace.columns[SWOT_dn_trace.columns.str.contains(var)])\n\nIndex(['wse', 'wse_u', 'wse_r_u', 'wse_c', 'wse_c_u', 'area_wse', 'p_wse',\n 'p_wse_var'],\n dtype='object')\nIndex(['slope', 'slope_u', 'slope_r_u', 'slope2', 'slope2_u', 'slope2_r_u'], dtype='object')\nIndex(['width', 'width_u', 'width_c', 'width_c_u', 'p_width'], dtype='object')\nIndex(['p_length'], dtype='object')\n\n\n\n# Enter variable of interest for plotting\nvarstr = \"wse\"\n\n\n# Find cumulative length on the longitudinal profile\nlength_list = np.nan_to_num([SWOT_dn_trace.p_length[SWOT_dn_trace.reach_id == rch].mean()/1000 for rch in rch_dn_list])\ncumlength_list = np.cumsum(length_list)\n\n## Plot a longitudinal profile from the downstream tracing database\n\n## Plot a longitudinal profile from the downstream tracing database\nplt.figure(figsize=(12,8))\nfor t in dates:\n \n # Store the quantity of interest (wse, width etc.) at time t\n value = SWOT_dn_trace_time.loc[rch_dn_list,varstr+'_'+t]\n \n # Remove set negative values (bad observations) to NaN and forward fill NaNs\n value[value < 0] = np.nan\n value = value.ffill()\n \n # Plot the data\n plt.plot(cumlength_list, value, label = varstr+'_'+t)\n \nplt.xlabel('Downstream Distance (km)')\nplt.ylabel(varstr)\nplt.legend()\n\n\n\n\n\n\n\n\n\n\n\n\n# Choose a date\ndate = dates[0]\n\n\n#Set one column as the active geometry in the new database\nSWOT_dn_trace_time = SWOT_dn_trace_time.set_geometry(\"geometry_\"+date)\n\n#Set cleaner colorbar bounds for better visualization\nvmin = np.percentile([i for i in SWOT_dn_trace_time[varstr+'_'+date] if i>0],5)\nvmax = np.percentile([i for i in SWOT_dn_trace_time[varstr+'_'+date] if i>0],95)\n\n# Interactive map\nSWOT_dn_trace_time.explore(varstr+'_'+date,\n vmin = vmin,\n vmax = vmax,\n cmap = \"Blues\", #\"Blues\",\n control_scale = True,\n tooltip = varstr+'_'+dates[0], # show \"varstr+'_'+dates[0]\" value in tooltip (on hover)\n popup = True, # show all values in popup (on click)\n #tiles = \"CartoDB positron\", # use \"CartoDB positron\" tiles\n style_kwds=dict(weight=10)\n )\n\nMake this Notebook Trusted to load map: File -> Trust Notebook" + "text": "# Retrieve all possible acquisition dates (keeping only YYYY-MM-DD)\ndates = np.unique([i[:10] for i in [x for x in SWOT_HR_df['time_str'] if x!='no_data']])\n\n# Create a new database for time series analysis with unique reach_ids\nSWOT_dn_trace_time = SWOT_dn_trace.set_index('reach_id').groupby(level=0) \\\n .apply(lambda df: df.reset_index(drop=True)) \\\n .unstack().sort_index(axis=1, level=1)\n\nSWOT_dn_trace_time.columns = ['{}_{}'.format(x[0],dates[x[1]]) for x in SWOT_dn_trace_time.columns]\n\n\n\n\n\n# Explore variables you could choose to plot\nfor var in [\"wse\",\"slope\",\"width\",\"len\"]:\n print(SWOT_dn_trace.columns[SWOT_dn_trace.columns.str.contains(var)])\n\nIndex(['wse', 'wse_u', 'wse_r_u', 'wse_c', 'wse_c_u', 'area_wse', 'p_wse',\n 'p_wse_var'],\n dtype='object')\nIndex(['slope', 'slope_u', 'slope_r_u', 'slope2', 'slope2_u', 'slope2_r_u'], dtype='object')\nIndex(['width', 'width_u', 'width_c', 'width_c_u', 'p_width'], dtype='object')\nIndex(['p_length'], dtype='object')\n\n\n\n# Enter variable of interest for plotting\nvarstr = \"wse\"\n\n\n# Find cumulative length on the longitudinal profile\nlength_list = np.nan_to_num([SWOT_dn_trace.p_length[SWOT_dn_trace.reach_id == rch].mean()/1000 for rch in rch_dn_list])\ncumlength_list = np.cumsum(length_list)\n\n## Plot a longitudinal profile from the downstream tracing database\n\n## Plot a longitudinal profile from the downstream tracing database\nplt.figure(figsize=(12,8))\nfor t in dates:\n \n # Store the quantity of interest (wse, width etc.) at time t\n value = SWOT_dn_trace_time.loc[rch_dn_list,varstr+'_'+t]\n \n # Remove set negative values (bad observations) to NaN and forward fill NaNs\n value[value < 0] = np.nan\n value = value.ffill()\n \n # Plot the data\n plt.plot(cumlength_list, value, label = varstr+'_'+t)\n \nplt.xlabel('Downstream Distance (km)')\nplt.ylabel(varstr)\nplt.legend()\n\n\n\n\n\n\n\n\n\n\n\n\n# Choose a date\ndate = dates[0]\n\n\n#Set one column as the active geometry in the new database\nSWOT_dn_trace_time = SWOT_dn_trace_time.set_geometry(\"geometry_\"+date)\n\n#Set cleaner colorbar bounds for better visualization\nvmin = np.percentile([i for i in SWOT_dn_trace_time[varstr+'_'+date] if i>0],5)\nvmax = np.percentile([i for i in SWOT_dn_trace_time[varstr+'_'+date] if i>0],95)\n\n# Interactive map\nSWOT_dn_trace_time.explore(varstr+'_'+date,\n vmin = vmin,\n vmax = vmax,\n cmap = \"Blues\", #\"Blues\",\n control_scale = True,\n tooltip = varstr+'_'+dates[0], # show \"varstr+'_'+dates[0]\" value in tooltip (on hover)\n popup = True, # show all values in popup (on click)\n #tiles = \"CartoDB positron\", # use \"CartoDB positron\" tiles\n style_kwds=dict(weight=10)\n )\n\nMake this Notebook Trusted to load map: File -> Trust Notebook", + "crumbs": [ + "Tutorials", + "Science Workflow" + ] }, { "objectID": "Tutorials/SWOTHR_Science_Application.html#supplemental", "href": "Tutorials/SWOTHR_Science_Application.html#supplemental", "title": "SWOT Hydrology Science Application Tutorial on the Cloud", "section": "", - "text": "SWOT_up_trace_time = SWOT_up_trace.set_index('reach_id').groupby(level=0) \\\n .apply(lambda df: df.reset_index(drop=True)) \\\n .unstack().sort_index(axis=1, level=1)\n\nSWOT_up_trace_time.columns = ['{}_{}'.format(x[0],dates[x[1]]) for x in SWOT_up_trace_time.columns]\n\nSWOT_up_trace_time = SWOT_up_trace_time.set_geometry(\"geometry_\"+date)\n\n#Set cleaner colorbar bounds for better visualization\nvmin = np.percentile([i for i in SWOT_up_trace_time[varstr+'_'+date] if i>0],5)\nvmax = np.percentile([i for i in SWOT_up_trace_time[varstr+'_'+date] if i>0],95)\n\n# Interactive map\nSWOT_up_trace_time.explore(varstr+'_'+date,\n vmin = vmin,\n vmax = vmax,\n cmap = \"Blues\", #\"Blues\",\n control_scale = True,\n tooltip = varstr+'_'+dates[0], # show \"varstr+'_'+dates[0]\" value in tooltip (on hover)\n popup = True, # show all values in popup (on click)\n tiles = \"CartoDB positron\", # use \"CartoDB positron\" tiles\n style_kwds=dict(weight=5)\n )\n\nMake this Notebook Trusted to load map: File -> Trust Notebook\n\n\n\n\n\nNow you will also need the tile number (in addition to the pass number). You can find it on the .kmz file\n\n# Enter tile number\ntile_number = \"116F\"\n\n# Retrieve granules from all days to find the cycle corresponding to the desired date\nraster_results = earthaccess.search_data(short_name = 'SWOT_L2_HR_Raster_1.1', \n temporal = ('2023-04-01 00:00:00', '2023-04-22 23:59:59'), \n granule_name = \"*100m*_\" + pass_number + \"_\" + tile_number + \"*\")\n# here we filter by files with '100m' in the name, pass=009, scene = 116F (tile = 232L) for Connecticut\n # pass=003, scene = 120F (tile = 239R) for the Rhine\n\nGranules found: 15\n\n\n\n\n\nprint([i for i in raster_results])\n\n[Collection: {'Version': '1.1', 'ShortName': 'SWOT_L2_HR_Raster_1.1'}\nSpatial coverage: {'HorizontalSpatialDomain': {'Orbit': {'StartLatitude': -77.66, 'EndLatitude': 77.66, 'AscendingCrossing': -80.4, 'StartDirection': 'A', 'EndDirection': 'A'}, 'Track': {'Cycle': 484, 'Passes': [{'Pass': 9, 'Tiles': ['230L', '231L', '232L', '233L', '230R', '231R', '232R', '233R']}]}}}\nTemporal coverage: {'RangeDateTime': {'EndingDateTime': '2023-04-08T03:55:38.288Z', 'BeginningDateTime': '2023-04-08T03:55:18.398Z'}}\nSize(MB): 70.40732002258301\nData: ['https://archive.swot.podaac.earthdata.nasa.gov/podaac-swot-ops-cumulus-protected/SWOT_L2_HR_Raster_1.1/SWOT_L2_HR_Raster_100m_UTM19T_N_x_x_x_484_009_116F_20230408T035517_20230408T035538_PIB0_01.nc'], Collection: {'Version': '1.1', 'ShortName': 'SWOT_L2_HR_Raster_1.1'}\nSpatial coverage: {'HorizontalSpatialDomain': {'Orbit': {'StartLatitude': -77.66, 'EndLatitude': 77.66, 'AscendingCrossing': -80.4, 'StartDirection': 'A', 'EndDirection': 'A'}, 'Track': {'Cycle': 485, 'Passes': [{'Pass': 9, 'Tiles': ['230L', '231L', '232L', '233L', '230R', '231R', '232R', '233R']}]}}}\nTemporal coverage: {'RangeDateTime': {'EndingDateTime': '2023-04-09T03:46:16.448Z', 'BeginningDateTime': '2023-04-09T03:45:56.558Z'}}\nSize(MB): 68.41873073577881\nData: ['https://archive.swot.podaac.earthdata.nasa.gov/podaac-swot-ops-cumulus-protected/SWOT_L2_HR_Raster_1.1/SWOT_L2_HR_Raster_100m_UTM19T_N_x_x_x_485_009_116F_20230409T034556_20230409T034616_PIB0_01.nc'], Collection: {'Version': '1.1', 'ShortName': 'SWOT_L2_HR_Raster_1.1'}\nSpatial coverage: {'HorizontalSpatialDomain': {'Orbit': {'StartLatitude': -77.66, 'EndLatitude': 77.66, 'AscendingCrossing': -80.4, 'StartDirection': 'A', 'EndDirection': 'A'}, 'Track': {'Cycle': 486, 'Passes': [{'Pass': 9, 'Tiles': ['230L', '231L', '232L', '233L', '230R', '231R', '232R', '233R']}]}}}\nTemporal coverage: {'RangeDateTime': {'EndingDateTime': '2023-04-10T03:36:54.573Z', 'BeginningDateTime': '2023-04-10T03:36:34.684Z'}}\nSize(MB): 68.47044467926025\nData: ['https://archive.swot.podaac.earthdata.nasa.gov/podaac-swot-ops-cumulus-protected/SWOT_L2_HR_Raster_1.1/SWOT_L2_HR_Raster_100m_UTM19T_N_x_x_x_486_009_116F_20230410T033634_20230410T033655_PIB0_01.nc'], Collection: {'Version': '1.1', 'ShortName': 'SWOT_L2_HR_Raster_1.1'}\nSpatial coverage: {'HorizontalSpatialDomain': {'Orbit': {'StartLatitude': -77.66, 'EndLatitude': 77.66, 'AscendingCrossing': -80.4, 'StartDirection': 'A', 'EndDirection': 'A'}, 'Track': {'Cycle': 487, 'Passes': [{'Pass': 9, 'Tiles': ['230L', '231L', '232L', '233L', '230R', '231R', '232R', '233R']}]}}}\nTemporal coverage: {'RangeDateTime': {'EndingDateTime': '2023-04-11T03:27:32.662Z', 'BeginningDateTime': '2023-04-11T03:27:12.772Z'}}\nSize(MB): 69.02541446685791\nData: ['https://archive.swot.podaac.earthdata.nasa.gov/podaac-swot-ops-cumulus-protected/SWOT_L2_HR_Raster_1.1/SWOT_L2_HR_Raster_100m_UTM19T_N_x_x_x_487_009_116F_20230411T032712_20230411T032733_PIB0_01.nc'], Collection: {'Version': '1.1', 'ShortName': 'SWOT_L2_HR_Raster_1.1'}\nSpatial coverage: {'HorizontalSpatialDomain': {'Orbit': {'StartLatitude': -77.66, 'EndLatitude': 77.66, 'AscendingCrossing': -80.4, 'StartDirection': 'A', 'EndDirection': 'A'}, 'Track': {'Cycle': 488, 'Passes': [{'Pass': 9, 'Tiles': ['230L', '231L', '232L', '233L', '230R', '231R', '232R', '233R']}]}}}\nTemporal coverage: {'RangeDateTime': {'EndingDateTime': '2023-04-12T03:18:10.720Z', 'BeginningDateTime': '2023-04-12T03:17:50.831Z'}}\nSize(MB): 67.56003761291504\nData: ['https://archive.swot.podaac.earthdata.nasa.gov/podaac-swot-ops-cumulus-protected/SWOT_L2_HR_Raster_1.1/SWOT_L2_HR_Raster_100m_UTM19T_N_x_x_x_488_009_116F_20230412T031750_20230412T031811_PIB0_01.nc'], Collection: {'Version': '1.1', 'ShortName': 'SWOT_L2_HR_Raster_1.1'}\nSpatial coverage: {'HorizontalSpatialDomain': {'Orbit': {'StartLatitude': -77.66, 'EndLatitude': 77.66, 'AscendingCrossing': -80.4, 'StartDirection': 'A', 'EndDirection': 'A'}, 'Track': {'Cycle': 489, 'Passes': [{'Pass': 9, 'Tiles': ['230L', '231L', '232L', '233L', '230R', '231R', '232R', '233R']}]}}}\nTemporal coverage: {'RangeDateTime': {'EndingDateTime': '2023-04-13T03:08:48.751Z', 'BeginningDateTime': '2023-04-13T03:08:28.862Z'}}\nSize(MB): 68.72685241699219\nData: ['https://archive.swot.podaac.earthdata.nasa.gov/podaac-swot-ops-cumulus-protected/SWOT_L2_HR_Raster_1.1/SWOT_L2_HR_Raster_100m_UTM19T_N_x_x_x_489_009_116F_20230413T030828_20230413T030849_PIB0_01.nc'], Collection: {'Version': '1.1', 'ShortName': 'SWOT_L2_HR_Raster_1.1'}\nSpatial coverage: {'HorizontalSpatialDomain': {'Orbit': {'StartLatitude': -77.66, 'EndLatitude': 77.66, 'AscendingCrossing': -80.4, 'StartDirection': 'A', 'EndDirection': 'A'}, 'Track': {'Cycle': 490, 'Passes': [{'Pass': 9, 'Tiles': ['230L', '231L', '232L', '233L', '230R', '231R', '232R', '233R']}]}}}\nTemporal coverage: {'RangeDateTime': {'EndingDateTime': '2023-04-14T02:59:26.753Z', 'BeginningDateTime': '2023-04-14T02:59:06.866Z'}}\nSize(MB): 66.47898387908936\nData: ['https://archive.swot.podaac.earthdata.nasa.gov/podaac-swot-ops-cumulus-protected/SWOT_L2_HR_Raster_1.1/SWOT_L2_HR_Raster_100m_UTM19T_N_x_x_x_490_009_116F_20230414T025906_20230414T025927_PIB0_01.nc'], Collection: {'Version': '1.1', 'ShortName': 'SWOT_L2_HR_Raster_1.1'}\nSpatial coverage: {'HorizontalSpatialDomain': {'Orbit': {'StartLatitude': -77.66, 'EndLatitude': 77.66, 'AscendingCrossing': -80.41, 'StartDirection': 'A', 'EndDirection': 'A'}, 'Track': {'Cycle': 491, 'Passes': [{'Pass': 9, 'Tiles': ['230L', '231L', '232L', '233L', '230R', '231R', '232R', '233R']}]}}}\nTemporal coverage: {'RangeDateTime': {'EndingDateTime': '2023-04-15T02:50:04.726Z', 'BeginningDateTime': '2023-04-15T02:49:44.836Z'}}\nSize(MB): 67.29588985443115\nData: ['https://archive.swot.podaac.earthdata.nasa.gov/podaac-swot-ops-cumulus-protected/SWOT_L2_HR_Raster_1.1/SWOT_L2_HR_Raster_100m_UTM19T_N_x_x_x_491_009_116F_20230415T024944_20230415T025005_PIB0_01.nc'], Collection: {'Version': '1.1', 'ShortName': 'SWOT_L2_HR_Raster_1.1'}\nSpatial coverage: {'HorizontalSpatialDomain': {'Orbit': {'StartLatitude': -77.66, 'EndLatitude': 77.66, 'AscendingCrossing': -80.41, 'StartDirection': 'A', 'EndDirection': 'A'}, 'Track': {'Cycle': 492, 'Passes': [{'Pass': 9, 'Tiles': ['230L', '231L', '232L', '233L', '230R', '231R', '232R', '233R']}]}}}\nTemporal coverage: {'RangeDateTime': {'EndingDateTime': '2023-04-16T02:40:43.207Z', 'BeginningDateTime': '2023-04-16T02:40:22.244Z'}}\nSize(MB): 0.933258056640625\nData: ['https://archive.swot.podaac.earthdata.nasa.gov/podaac-swot-ops-cumulus-protected/SWOT_L2_HR_Raster_1.1/SWOT_L2_HR_Raster_100m_UTM19T_N_x_x_x_492_009_116F_20230416T024022_20230416T024043_PIB0_01.nc'], Collection: {'Version': '1.1', 'ShortName': 'SWOT_L2_HR_Raster_1.1'}\nSpatial coverage: {'HorizontalSpatialDomain': {'Orbit': {'StartLatitude': -77.66, 'EndLatitude': 77.66, 'AscendingCrossing': -80.41, 'StartDirection': 'A', 'EndDirection': 'A'}, 'Track': {'Cycle': 493, 'Passes': [{'Pass': 9, 'Tiles': ['230L', '231L', '232L', '233L', '230R', '231R', '232R', '233R']}]}}}\nTemporal coverage: {'RangeDateTime': {'EndingDateTime': '2023-04-17T02:31:21.112Z', 'BeginningDateTime': '2023-04-17T02:31:00.151Z'}}\nSize(MB): 0.9332094192504883\nData: ['https://archive.swot.podaac.earthdata.nasa.gov/podaac-swot-ops-cumulus-protected/SWOT_L2_HR_Raster_1.1/SWOT_L2_HR_Raster_100m_UTM19T_N_x_x_x_493_009_116F_20230417T023100_20230417T023121_PIB0_01.nc'], Collection: {'Version': '1.1', 'ShortName': 'SWOT_L2_HR_Raster_1.1'}\nSpatial coverage: {'HorizontalSpatialDomain': {'Orbit': {'StartLatitude': -77.66, 'EndLatitude': 77.66, 'AscendingCrossing': -80.41, 'StartDirection': 'A', 'EndDirection': 'A'}, 'Track': {'Cycle': 494, 'Passes': [{'Pass': 9, 'Tiles': ['230L', '231L', '232L', '233L', '230R', '231R', '232R', '233R']}]}}}\nTemporal coverage: {'RangeDateTime': {'EndingDateTime': '2023-04-18T02:21:58.990Z', 'BeginningDateTime': '2023-04-18T02:21:38.024Z'}}\nSize(MB): 0.9332304000854492\nData: ['https://archive.swot.podaac.earthdata.nasa.gov/podaac-swot-ops-cumulus-protected/SWOT_L2_HR_Raster_1.1/SWOT_L2_HR_Raster_100m_UTM19T_N_x_x_x_494_009_116F_20230418T022138_20230418T022158_PIB0_01.nc'], Collection: {'Version': '1.1', 'ShortName': 'SWOT_L2_HR_Raster_1.1'}\nSpatial coverage: {'HorizontalSpatialDomain': {'Orbit': {'StartLatitude': -77.66, 'EndLatitude': 77.66, 'AscendingCrossing': -80.41, 'StartDirection': 'A', 'EndDirection': 'A'}, 'Track': {'Cycle': 495, 'Passes': [{'Pass': 9, 'Tiles': ['230L', '231L', '232L', '233L', '230R', '231R', '232R', '233R']}]}}}\nTemporal coverage: {'RangeDateTime': {'EndingDateTime': '2023-04-19T02:12:36.279Z', 'BeginningDateTime': '2023-04-19T02:12:16.394Z'}}\nSize(MB): 63.773990631103516\nData: ['https://archive.swot.podaac.earthdata.nasa.gov/podaac-swot-ops-cumulus-protected/SWOT_L2_HR_Raster_1.1/SWOT_L2_HR_Raster_100m_UTM19T_N_x_x_x_495_009_116F_20230419T021215_20230419T021236_PIB0_01.nc'], Collection: {'Version': '1.1', 'ShortName': 'SWOT_L2_HR_Raster_1.1'}\nSpatial coverage: {'HorizontalSpatialDomain': {'Orbit': {'StartLatitude': -77.66, 'EndLatitude': 77.66, 'AscendingCrossing': -80.41, 'StartDirection': 'A', 'EndDirection': 'A'}, 'Track': {'Cycle': 496, 'Passes': [{'Pass': 9, 'Tiles': ['230L', '231L', '232L', '233L', '230R', '231R', '232R', '233R']}]}}}\nTemporal coverage: {'RangeDateTime': {'EndingDateTime': '2023-04-20T02:03:14.075Z', 'BeginningDateTime': '2023-04-20T02:02:54.187Z'}}\nSize(MB): 62.185853004455566\nData: ['https://archive.swot.podaac.earthdata.nasa.gov/podaac-swot-ops-cumulus-protected/SWOT_L2_HR_Raster_1.1/SWOT_L2_HR_Raster_100m_UTM19T_N_x_x_x_496_009_116F_20230420T020253_20230420T020314_PIB0_01.nc'], Collection: {'Version': '1.1', 'ShortName': 'SWOT_L2_HR_Raster_1.1'}\nSpatial coverage: {'HorizontalSpatialDomain': {'Orbit': {'StartLatitude': -77.66, 'EndLatitude': 77.66, 'AscendingCrossing': -80.41, 'StartDirection': 'A', 'EndDirection': 'A'}, 'Track': {'Cycle': 497, 'Passes': [{'Pass': 9, 'Tiles': ['230L', '231L', '232L', '233L', '230R', '231R', '232R', '233R']}]}}}\nTemporal coverage: {'RangeDateTime': {'EndingDateTime': '2023-04-21T01:53:51.831Z', 'BeginningDateTime': '2023-04-21T01:53:31.942Z'}}\nSize(MB): 61.36593437194824\nData: ['https://archive.swot.podaac.earthdata.nasa.gov/podaac-swot-ops-cumulus-protected/SWOT_L2_HR_Raster_1.1/SWOT_L2_HR_Raster_100m_UTM19T_N_x_x_x_497_009_116F_20230421T015331_20230421T015352_PIB0_01.nc'], Collection: {'Version': '1.1', 'ShortName': 'SWOT_L2_HR_Raster_1.1'}\nSpatial coverage: {'HorizontalSpatialDomain': {'Orbit': {'StartLatitude': -77.66, 'EndLatitude': 77.66, 'AscendingCrossing': -80.41, 'StartDirection': 'A', 'EndDirection': 'A'}, 'Track': {'Cycle': 498, 'Passes': [{'Pass': 9, 'Tiles': ['230L', '231L', '232L', '233L', '230R', '231R', '232R', '233R']}]}}}\nTemporal coverage: {'RangeDateTime': {'EndingDateTime': '2023-04-22T01:44:29.616Z', 'BeginningDateTime': '2023-04-22T01:44:09.731Z'}}\nSize(MB): 61.341376304626465\nData: ['https://archive.swot.podaac.earthdata.nasa.gov/podaac-swot-ops-cumulus-protected/SWOT_L2_HR_Raster_1.1/SWOT_L2_HR_Raster_100m_UTM19T_N_x_x_x_498_009_116F_20230422T014409_20230422T014430_PIB0_01.nc']]\n\n\n\n\n\n\n# Let's look at cycle 485, on the second day of calval\n# Enter cycle\ncycle = \"485\"\n\nraster_results = earthaccess.search_data(short_name = 'SWOT_L2_HR_Raster_1.1', \n temporal = ('2023-04-01 00:00:00', '2023-04-22 23:59:59'), \n granule_name = \"*100m*\" + cycle + \"_\" + pass_number + \"_\" + tile_number + \"*\")\n\n# here we filter by files with '100m' in the name, cycle=484, pass=009, scene = 116F for Connecticut\n # cycle=485, pass=003, scene = 120F for the Rhine\n\nGranules found: 1\n\n\n\n\n\n\nfs_s3 = earthaccess.get_s3fs_session(results=raster_results)\n\n# get link for file and open it\nraster_link = earthaccess.results.DataGranule.data_links(raster_results[0], access='direct')[0]\ns3_file_obj5 = fs_s3.open(raster_link, mode='rb')\n\n# Open data with xarray\nds_raster = xr.open_dataset(s3_file_obj5, engine='h5netcdf')\n\n\n\n\n\n# Plot the data with a filter on water_frac > x, or sig0>50\nds_raster.wse.where(ds_raster.water_frac > 0.5).hvplot.image(y='y', x='x').opts(cmap='Blues', clim=(vmin,vmax), width=1000, height=750)" + "text": "SWOT_up_trace_time = SWOT_up_trace.set_index('reach_id').groupby(level=0) \\\n .apply(lambda df: df.reset_index(drop=True)) \\\n .unstack().sort_index(axis=1, level=1)\n\nSWOT_up_trace_time.columns = ['{}_{}'.format(x[0],dates[x[1]]) for x in SWOT_up_trace_time.columns]\n\nSWOT_up_trace_time = SWOT_up_trace_time.set_geometry(\"geometry_\"+date)\n\n#Set cleaner colorbar bounds for better visualization\nvmin = np.percentile([i for i in SWOT_up_trace_time[varstr+'_'+date] if i>0],5)\nvmax = np.percentile([i for i in SWOT_up_trace_time[varstr+'_'+date] if i>0],95)\n\n# Interactive map\nSWOT_up_trace_time.explore(varstr+'_'+date,\n vmin = vmin,\n vmax = vmax,\n cmap = \"Blues\", #\"Blues\",\n control_scale = True,\n tooltip = varstr+'_'+dates[0], # show \"varstr+'_'+dates[0]\" value in tooltip (on hover)\n popup = True, # show all values in popup (on click)\n tiles = \"CartoDB positron\", # use \"CartoDB positron\" tiles\n style_kwds=dict(weight=5)\n )\n\nMake this Notebook Trusted to load map: File -> Trust Notebook\n\n\n\n\n\nNow you will also need the tile number (in addition to the pass number). You can find it on the .kmz file\n\n# Enter tile number\ntile_number = \"116F\"\n\n# Retrieve granules from all days to find the cycle corresponding to the desired date\nraster_results = earthaccess.search_data(short_name = 'SWOT_L2_HR_Raster_1.1', \n temporal = ('2023-04-01 00:00:00', '2023-04-22 23:59:59'), \n granule_name = \"*100m*_\" + pass_number + \"_\" + tile_number + \"*\")\n# here we filter by files with '100m' in the name, pass=009, scene = 116F (tile = 232L) for Connecticut\n # pass=003, scene = 120F (tile = 239R) for the Rhine\n\nGranules found: 15\n\n\n\n\n\nprint([i for i in raster_results])\n\n[Collection: {'Version': '1.1', 'ShortName': 'SWOT_L2_HR_Raster_1.1'}\nSpatial coverage: {'HorizontalSpatialDomain': {'Orbit': {'StartLatitude': -77.66, 'EndLatitude': 77.66, 'AscendingCrossing': -80.4, 'StartDirection': 'A', 'EndDirection': 'A'}, 'Track': {'Cycle': 484, 'Passes': [{'Pass': 9, 'Tiles': ['230L', '231L', '232L', '233L', '230R', '231R', '232R', '233R']}]}}}\nTemporal coverage: {'RangeDateTime': {'EndingDateTime': '2023-04-08T03:55:38.288Z', 'BeginningDateTime': '2023-04-08T03:55:18.398Z'}}\nSize(MB): 70.40732002258301\nData: ['https://archive.swot.podaac.earthdata.nasa.gov/podaac-swot-ops-cumulus-protected/SWOT_L2_HR_Raster_1.1/SWOT_L2_HR_Raster_100m_UTM19T_N_x_x_x_484_009_116F_20230408T035517_20230408T035538_PIB0_01.nc'], Collection: {'Version': '1.1', 'ShortName': 'SWOT_L2_HR_Raster_1.1'}\nSpatial coverage: {'HorizontalSpatialDomain': {'Orbit': {'StartLatitude': -77.66, 'EndLatitude': 77.66, 'AscendingCrossing': -80.4, 'StartDirection': 'A', 'EndDirection': 'A'}, 'Track': {'Cycle': 485, 'Passes': [{'Pass': 9, 'Tiles': ['230L', '231L', '232L', '233L', '230R', '231R', '232R', '233R']}]}}}\nTemporal coverage: {'RangeDateTime': {'EndingDateTime': '2023-04-09T03:46:16.448Z', 'BeginningDateTime': '2023-04-09T03:45:56.558Z'}}\nSize(MB): 68.41873073577881\nData: ['https://archive.swot.podaac.earthdata.nasa.gov/podaac-swot-ops-cumulus-protected/SWOT_L2_HR_Raster_1.1/SWOT_L2_HR_Raster_100m_UTM19T_N_x_x_x_485_009_116F_20230409T034556_20230409T034616_PIB0_01.nc'], Collection: {'Version': '1.1', 'ShortName': 'SWOT_L2_HR_Raster_1.1'}\nSpatial coverage: {'HorizontalSpatialDomain': {'Orbit': {'StartLatitude': -77.66, 'EndLatitude': 77.66, 'AscendingCrossing': -80.4, 'StartDirection': 'A', 'EndDirection': 'A'}, 'Track': {'Cycle': 486, 'Passes': [{'Pass': 9, 'Tiles': ['230L', '231L', '232L', '233L', '230R', '231R', '232R', '233R']}]}}}\nTemporal coverage: {'RangeDateTime': {'EndingDateTime': '2023-04-10T03:36:54.573Z', 'BeginningDateTime': '2023-04-10T03:36:34.684Z'}}\nSize(MB): 68.47044467926025\nData: ['https://archive.swot.podaac.earthdata.nasa.gov/podaac-swot-ops-cumulus-protected/SWOT_L2_HR_Raster_1.1/SWOT_L2_HR_Raster_100m_UTM19T_N_x_x_x_486_009_116F_20230410T033634_20230410T033655_PIB0_01.nc'], Collection: {'Version': '1.1', 'ShortName': 'SWOT_L2_HR_Raster_1.1'}\nSpatial coverage: {'HorizontalSpatialDomain': {'Orbit': {'StartLatitude': -77.66, 'EndLatitude': 77.66, 'AscendingCrossing': -80.4, 'StartDirection': 'A', 'EndDirection': 'A'}, 'Track': {'Cycle': 487, 'Passes': [{'Pass': 9, 'Tiles': ['230L', '231L', '232L', '233L', '230R', '231R', '232R', '233R']}]}}}\nTemporal coverage: {'RangeDateTime': {'EndingDateTime': '2023-04-11T03:27:32.662Z', 'BeginningDateTime': '2023-04-11T03:27:12.772Z'}}\nSize(MB): 69.02541446685791\nData: ['https://archive.swot.podaac.earthdata.nasa.gov/podaac-swot-ops-cumulus-protected/SWOT_L2_HR_Raster_1.1/SWOT_L2_HR_Raster_100m_UTM19T_N_x_x_x_487_009_116F_20230411T032712_20230411T032733_PIB0_01.nc'], Collection: {'Version': '1.1', 'ShortName': 'SWOT_L2_HR_Raster_1.1'}\nSpatial coverage: {'HorizontalSpatialDomain': {'Orbit': {'StartLatitude': -77.66, 'EndLatitude': 77.66, 'AscendingCrossing': -80.4, 'StartDirection': 'A', 'EndDirection': 'A'}, 'Track': {'Cycle': 488, 'Passes': [{'Pass': 9, 'Tiles': ['230L', '231L', '232L', '233L', '230R', '231R', '232R', '233R']}]}}}\nTemporal coverage: {'RangeDateTime': {'EndingDateTime': '2023-04-12T03:18:10.720Z', 'BeginningDateTime': '2023-04-12T03:17:50.831Z'}}\nSize(MB): 67.56003761291504\nData: ['https://archive.swot.podaac.earthdata.nasa.gov/podaac-swot-ops-cumulus-protected/SWOT_L2_HR_Raster_1.1/SWOT_L2_HR_Raster_100m_UTM19T_N_x_x_x_488_009_116F_20230412T031750_20230412T031811_PIB0_01.nc'], Collection: {'Version': '1.1', 'ShortName': 'SWOT_L2_HR_Raster_1.1'}\nSpatial coverage: {'HorizontalSpatialDomain': {'Orbit': {'StartLatitude': -77.66, 'EndLatitude': 77.66, 'AscendingCrossing': -80.4, 'StartDirection': 'A', 'EndDirection': 'A'}, 'Track': {'Cycle': 489, 'Passes': [{'Pass': 9, 'Tiles': ['230L', '231L', '232L', '233L', '230R', '231R', '232R', '233R']}]}}}\nTemporal coverage: {'RangeDateTime': {'EndingDateTime': '2023-04-13T03:08:48.751Z', 'BeginningDateTime': '2023-04-13T03:08:28.862Z'}}\nSize(MB): 68.72685241699219\nData: ['https://archive.swot.podaac.earthdata.nasa.gov/podaac-swot-ops-cumulus-protected/SWOT_L2_HR_Raster_1.1/SWOT_L2_HR_Raster_100m_UTM19T_N_x_x_x_489_009_116F_20230413T030828_20230413T030849_PIB0_01.nc'], Collection: {'Version': '1.1', 'ShortName': 'SWOT_L2_HR_Raster_1.1'}\nSpatial coverage: {'HorizontalSpatialDomain': {'Orbit': {'StartLatitude': -77.66, 'EndLatitude': 77.66, 'AscendingCrossing': -80.4, 'StartDirection': 'A', 'EndDirection': 'A'}, 'Track': {'Cycle': 490, 'Passes': [{'Pass': 9, 'Tiles': ['230L', '231L', '232L', '233L', '230R', '231R', '232R', '233R']}]}}}\nTemporal coverage: {'RangeDateTime': {'EndingDateTime': '2023-04-14T02:59:26.753Z', 'BeginningDateTime': '2023-04-14T02:59:06.866Z'}}\nSize(MB): 66.47898387908936\nData: ['https://archive.swot.podaac.earthdata.nasa.gov/podaac-swot-ops-cumulus-protected/SWOT_L2_HR_Raster_1.1/SWOT_L2_HR_Raster_100m_UTM19T_N_x_x_x_490_009_116F_20230414T025906_20230414T025927_PIB0_01.nc'], Collection: {'Version': '1.1', 'ShortName': 'SWOT_L2_HR_Raster_1.1'}\nSpatial coverage: {'HorizontalSpatialDomain': {'Orbit': {'StartLatitude': -77.66, 'EndLatitude': 77.66, 'AscendingCrossing': -80.41, 'StartDirection': 'A', 'EndDirection': 'A'}, 'Track': {'Cycle': 491, 'Passes': [{'Pass': 9, 'Tiles': ['230L', '231L', '232L', '233L', '230R', '231R', '232R', '233R']}]}}}\nTemporal coverage: {'RangeDateTime': {'EndingDateTime': '2023-04-15T02:50:04.726Z', 'BeginningDateTime': '2023-04-15T02:49:44.836Z'}}\nSize(MB): 67.29588985443115\nData: ['https://archive.swot.podaac.earthdata.nasa.gov/podaac-swot-ops-cumulus-protected/SWOT_L2_HR_Raster_1.1/SWOT_L2_HR_Raster_100m_UTM19T_N_x_x_x_491_009_116F_20230415T024944_20230415T025005_PIB0_01.nc'], Collection: {'Version': '1.1', 'ShortName': 'SWOT_L2_HR_Raster_1.1'}\nSpatial coverage: {'HorizontalSpatialDomain': {'Orbit': {'StartLatitude': -77.66, 'EndLatitude': 77.66, 'AscendingCrossing': -80.41, 'StartDirection': 'A', 'EndDirection': 'A'}, 'Track': {'Cycle': 492, 'Passes': [{'Pass': 9, 'Tiles': ['230L', '231L', '232L', '233L', '230R', '231R', '232R', '233R']}]}}}\nTemporal coverage: {'RangeDateTime': {'EndingDateTime': '2023-04-16T02:40:43.207Z', 'BeginningDateTime': '2023-04-16T02:40:22.244Z'}}\nSize(MB): 0.933258056640625\nData: ['https://archive.swot.podaac.earthdata.nasa.gov/podaac-swot-ops-cumulus-protected/SWOT_L2_HR_Raster_1.1/SWOT_L2_HR_Raster_100m_UTM19T_N_x_x_x_492_009_116F_20230416T024022_20230416T024043_PIB0_01.nc'], Collection: {'Version': '1.1', 'ShortName': 'SWOT_L2_HR_Raster_1.1'}\nSpatial coverage: {'HorizontalSpatialDomain': {'Orbit': {'StartLatitude': -77.66, 'EndLatitude': 77.66, 'AscendingCrossing': -80.41, 'StartDirection': 'A', 'EndDirection': 'A'}, 'Track': {'Cycle': 493, 'Passes': [{'Pass': 9, 'Tiles': ['230L', '231L', '232L', '233L', '230R', '231R', '232R', '233R']}]}}}\nTemporal coverage: {'RangeDateTime': {'EndingDateTime': '2023-04-17T02:31:21.112Z', 'BeginningDateTime': '2023-04-17T02:31:00.151Z'}}\nSize(MB): 0.9332094192504883\nData: ['https://archive.swot.podaac.earthdata.nasa.gov/podaac-swot-ops-cumulus-protected/SWOT_L2_HR_Raster_1.1/SWOT_L2_HR_Raster_100m_UTM19T_N_x_x_x_493_009_116F_20230417T023100_20230417T023121_PIB0_01.nc'], Collection: {'Version': '1.1', 'ShortName': 'SWOT_L2_HR_Raster_1.1'}\nSpatial coverage: {'HorizontalSpatialDomain': {'Orbit': {'StartLatitude': -77.66, 'EndLatitude': 77.66, 'AscendingCrossing': -80.41, 'StartDirection': 'A', 'EndDirection': 'A'}, 'Track': {'Cycle': 494, 'Passes': [{'Pass': 9, 'Tiles': ['230L', '231L', '232L', '233L', '230R', '231R', '232R', '233R']}]}}}\nTemporal coverage: {'RangeDateTime': {'EndingDateTime': '2023-04-18T02:21:58.990Z', 'BeginningDateTime': '2023-04-18T02:21:38.024Z'}}\nSize(MB): 0.9332304000854492\nData: ['https://archive.swot.podaac.earthdata.nasa.gov/podaac-swot-ops-cumulus-protected/SWOT_L2_HR_Raster_1.1/SWOT_L2_HR_Raster_100m_UTM19T_N_x_x_x_494_009_116F_20230418T022138_20230418T022158_PIB0_01.nc'], Collection: {'Version': '1.1', 'ShortName': 'SWOT_L2_HR_Raster_1.1'}\nSpatial coverage: {'HorizontalSpatialDomain': {'Orbit': {'StartLatitude': -77.66, 'EndLatitude': 77.66, 'AscendingCrossing': -80.41, 'StartDirection': 'A', 'EndDirection': 'A'}, 'Track': {'Cycle': 495, 'Passes': [{'Pass': 9, 'Tiles': ['230L', '231L', '232L', '233L', '230R', '231R', '232R', '233R']}]}}}\nTemporal coverage: {'RangeDateTime': {'EndingDateTime': '2023-04-19T02:12:36.279Z', 'BeginningDateTime': '2023-04-19T02:12:16.394Z'}}\nSize(MB): 63.773990631103516\nData: ['https://archive.swot.podaac.earthdata.nasa.gov/podaac-swot-ops-cumulus-protected/SWOT_L2_HR_Raster_1.1/SWOT_L2_HR_Raster_100m_UTM19T_N_x_x_x_495_009_116F_20230419T021215_20230419T021236_PIB0_01.nc'], Collection: {'Version': '1.1', 'ShortName': 'SWOT_L2_HR_Raster_1.1'}\nSpatial coverage: {'HorizontalSpatialDomain': {'Orbit': {'StartLatitude': -77.66, 'EndLatitude': 77.66, 'AscendingCrossing': -80.41, 'StartDirection': 'A', 'EndDirection': 'A'}, 'Track': {'Cycle': 496, 'Passes': [{'Pass': 9, 'Tiles': ['230L', '231L', '232L', '233L', '230R', '231R', '232R', '233R']}]}}}\nTemporal coverage: {'RangeDateTime': {'EndingDateTime': '2023-04-20T02:03:14.075Z', 'BeginningDateTime': '2023-04-20T02:02:54.187Z'}}\nSize(MB): 62.185853004455566\nData: ['https://archive.swot.podaac.earthdata.nasa.gov/podaac-swot-ops-cumulus-protected/SWOT_L2_HR_Raster_1.1/SWOT_L2_HR_Raster_100m_UTM19T_N_x_x_x_496_009_116F_20230420T020253_20230420T020314_PIB0_01.nc'], Collection: {'Version': '1.1', 'ShortName': 'SWOT_L2_HR_Raster_1.1'}\nSpatial coverage: {'HorizontalSpatialDomain': {'Orbit': {'StartLatitude': -77.66, 'EndLatitude': 77.66, 'AscendingCrossing': -80.41, 'StartDirection': 'A', 'EndDirection': 'A'}, 'Track': {'Cycle': 497, 'Passes': [{'Pass': 9, 'Tiles': ['230L', '231L', '232L', '233L', '230R', '231R', '232R', '233R']}]}}}\nTemporal coverage: {'RangeDateTime': {'EndingDateTime': '2023-04-21T01:53:51.831Z', 'BeginningDateTime': '2023-04-21T01:53:31.942Z'}}\nSize(MB): 61.36593437194824\nData: ['https://archive.swot.podaac.earthdata.nasa.gov/podaac-swot-ops-cumulus-protected/SWOT_L2_HR_Raster_1.1/SWOT_L2_HR_Raster_100m_UTM19T_N_x_x_x_497_009_116F_20230421T015331_20230421T015352_PIB0_01.nc'], Collection: {'Version': '1.1', 'ShortName': 'SWOT_L2_HR_Raster_1.1'}\nSpatial coverage: {'HorizontalSpatialDomain': {'Orbit': {'StartLatitude': -77.66, 'EndLatitude': 77.66, 'AscendingCrossing': -80.41, 'StartDirection': 'A', 'EndDirection': 'A'}, 'Track': {'Cycle': 498, 'Passes': [{'Pass': 9, 'Tiles': ['230L', '231L', '232L', '233L', '230R', '231R', '232R', '233R']}]}}}\nTemporal coverage: {'RangeDateTime': {'EndingDateTime': '2023-04-22T01:44:29.616Z', 'BeginningDateTime': '2023-04-22T01:44:09.731Z'}}\nSize(MB): 61.341376304626465\nData: ['https://archive.swot.podaac.earthdata.nasa.gov/podaac-swot-ops-cumulus-protected/SWOT_L2_HR_Raster_1.1/SWOT_L2_HR_Raster_100m_UTM19T_N_x_x_x_498_009_116F_20230422T014409_20230422T014430_PIB0_01.nc']]\n\n\n\n\n\n\n# Let's look at cycle 485, on the second day of calval\n# Enter cycle\ncycle = \"485\"\n\nraster_results = earthaccess.search_data(short_name = 'SWOT_L2_HR_Raster_1.1', \n temporal = ('2023-04-01 00:00:00', '2023-04-22 23:59:59'), \n granule_name = \"*100m*\" + cycle + \"_\" + pass_number + \"_\" + tile_number + \"*\")\n\n# here we filter by files with '100m' in the name, cycle=484, pass=009, scene = 116F for Connecticut\n # cycle=485, pass=003, scene = 120F for the Rhine\n\nGranules found: 1\n\n\n\n\n\n\nfs_s3 = earthaccess.get_s3fs_session(results=raster_results)\n\n# get link for file and open it\nraster_link = earthaccess.results.DataGranule.data_links(raster_results[0], access='direct')[0]\ns3_file_obj5 = fs_s3.open(raster_link, mode='rb')\n\n# Open data with xarray\nds_raster = xr.open_dataset(s3_file_obj5, engine='h5netcdf')\n\n\n\n\n\n# Plot the data with a filter on water_frac > x, or sig0>50\nds_raster.wse.where(ds_raster.water_frac > 0.5).hvplot.image(y='y', x='x').opts(cmap='Blues', clim=(vmin,vmax), width=1000, height=750)", + "crumbs": [ + "Tutorials", + "Science Workflow" + ] }, { "objectID": "Tutorials/SWOTHR_s3Access_real_data_v11.html", diff --git a/sitemap.xml b/sitemap.xml index d086762..2016971 100644 --- a/sitemap.xml +++ b/sitemap.xml @@ -2,26 +2,26 @@ https://podaac.github.io/2024-SWOT-Hydro-Workshop/index.html - 2024-01-31T18:22:02.235Z + 2024-01-31T19:18:16.665Z https://podaac.github.io/2024-SWOT-Hydro-Workshop/slides.html - 2024-01-31T18:22:02.235Z + 2024-01-31T19:18:16.669Z https://podaac.github.io/2024-SWOT-Hydro-Workshop/Tutorials/SWOTHR_Science_Application.html - 2024-01-31T18:22:02.195Z + 2024-01-31T19:18:16.625Z https://podaac.github.io/2024-SWOT-Hydro-Workshop/Tutorials/SWOTHR_s3Access_real_data_v11.html - 2024-01-31T18:22:02.235Z + 2024-01-31T19:18:16.665Z https://podaac.github.io/2024-SWOT-Hydro-Workshop/schedule.html - 2024-01-31T18:22:02.235Z + 2024-01-31T19:18:16.669Z https://podaac.github.io/2024-SWOT-Hydro-Workshop/prerequisites.html - 2024-01-31T18:22:02.235Z + 2024-01-31T19:18:16.665Z diff --git a/slides.html b/slides.html index 820736f..6ea09b9 100644 --- a/slides.html +++ b/slides.html @@ -118,6 +118,10 @@
  • Intro to HR Datasets +
  • +
  • + + Science Workflow
  • @@ -195,8 +199,11 @@ + +