-
Notifications
You must be signed in to change notification settings - Fork 43
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
update external imports and How To's
Change the how to section to emulate the earthdata cloud cookbook more by pulling in the openscapes qmd files. Changed the authentication to not be imported anymore and updated it to reflect earthaccess.
- Loading branch information
1 parent
03c39cb
commit 662d5f6
Showing
24 changed files
with
747 additions
and
95 deletions.
There are no files selected for viewing
11 changes: 11 additions & 0 deletions
11
_freeze/external/if-im-in-the-cloud/execute-results/html.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
{ | ||
"hash": "d57ba16a6e1faee9126398bbab2814e2", | ||
"result": { | ||
"markdown": "---\ntitle: How do I access data stored in Earthdata Cloud?\nexecute:\n eval: false\naliases:\n - working-with-data-in-cloud/Direct-Cloud-Access.html\n - working-with-data-in-cloud/Access-EULA-Data.html\n---\n\n## Direct Access\n\nWhen you have found the data you want to use, you have two options. You can download the data to work locally, or access the data directly to work in the cloud. This second way of working is called \"_Direct Cloud Access_\" or simply, \"_Direct Access_\". Your compute instance needs to be in Amazon Web Services (AWS) Region `us-west-2` in order for the code to run successfully. We authenticate using a netrc file and an Earthdata Login, see the [appendix](../appendix/authentication.qmd) for more information on [Earthdata Login](https://urs.earthdata.nasa.gov/) and netrc setup.\n\n::: {.panel-tabset group=\"language\"}\n\n## Python\n\nWe can use the [`earthaccess`](https://nsidc.github.io/earthaccess/) python library to grab the file URLs and then access them with the `xarray` library. \n\n::: {.cell execution_count=1}\n``` {.python .cell-code}\n#Import packages\nimport earthaccess\nimport xarray as xr\n\n#Authentication with Earthdata Login\nauth = earthaccess.login(strategy=\"netrc\")\n\n#Access land ice height from ATLAS/ICESat-2 V005 (10.5067/ATLAS/ATL06.005), searching for data over western Greenland coast over two weeks in July 2022. The data are provided as HDF5 granules (files) that span about 1/14th of an orbit.\n\nresults = earthaccess.search_data(short_name=\"ATL06\",\n version=\"005\",\n cloud_hosted=True,\n temporal = (\"2022-07-17\",\"2022-07-31\"),\n bounding_box = (-51.96423,68.10554,-48.71969,70.70529))\n\n#Use xarray to load the data as a multifile dataset for a single group in the HDF5 file, in this case land ice segments:\nds = xr.open_mfdataset(earthaccess.open(results), group='/gt1l/land_ice_segments')\nds\n```\n:::\n\n\n## R\n\nR code coming soon!\n\n\n```{bash}\n# Coming soon!\n```\n\n\n## Matlab\n\nMatlab code coming soon!\n\n\n```{bash}\n#| echo: true\n# Coming soon!\n```\n\n\n## Command Line\n\nWith `wget` and `curl`:\n\n\n```{bash}\n# Coming soon!\n```\n\n\n\n:::\n\n## End User License Agreement (EULA)\n\nSometimes, accessing data in NASA Earthdata Cloud requires an End-User License Agreement (EULA). If you cannot access a dataset, this may be your issue! See [these instructions](https://urs.earthdata.nasa.gov/documentation/for_users/how_to_preauth_app) for how to authorize EULAs.\n\n", | ||
"supporting": [ | ||
"if-im-in-the-cloud_files" | ||
], | ||
"filters": [], | ||
"includes": {} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
{ | ||
"hash": "ba888749ae9043089653c068ae8166db", | ||
"result": { | ||
"markdown": "---\ntitle: How do I access Cloud Data from my Local Machine?\nexecute:\n eval: false\n---\n\n## Downloading data\n\nWhen you have found the data you want to use, you have two options. You can download the data to work locally, or access the data directly to work in the cloud. This second way of working is called \"_Direct Cloud Access_\" or simply, \"_Direct Access_\". \n\nThis page covers two situations of downloading data from Earthdata Cloud to your local machine:\n\n* Downloading data using the `earthaccess` library\n* Downloading data from an OPeNDAP server\n\n## earthaccess\n\n::: {.panel-tabset group=\"language\"}\n\n## Python\n\nWe can use the [`earthaccess`](https://nsidc.github.io/earthaccess/) python library to grab the file URLs and then access them with the `xarray` library. \n\n::: {.cell execution_count=1}\n``` {.python .cell-code}\n#Import packages\nimport earthaccess\nimport xarray as xr\n\n#Authentication with Earthdata Login\nauth = earthaccess.login(strategy=\"netrc\")\n\n#Access land ice height from ATLAS/ICESat-2 V005 (10.5067/ATLAS/ATL06.005), searching for data over western Greenland coast over two weeks in July 2022. The data are provided as HDF5 granules (files) that span about 1/14th of an orbit.\n\nresults = earthaccess.search_data(short_name=\"ATL06\",\n version=\"005\",\n cloud_hosted=True,\n temporal = (\"2022-07-17\",\"2022-07-31\"),\n bounding_box = (-51.96423,68.10554,-48.71969,70.70529))\n\nfiles = earthaccess.download(results, \"./local_folder\")\n\n#Use xarray to load the data as a multifile dataset for a single group in the HDF5 file, in this case land ice segments:\nds = xr.open_mfdataset(files, group='/gt1l/land_ice_segments')\nds\n```\n:::\n\n\n## R\n\nR code coming soon!\n\n\n```{bash}\n# Coming soon!\n```\n\n\n## Matlab\n\nMatlab code coming soon!\n\n\n```{bash}\n#| echo: true\n# Coming soon!\n```\n\n\n## Command Line\n\nWith `wget` and `curl`:\n\n\n```{bash}\n# Coming soon!\n```\n\n\n\n:::\n\n\n\n\n\n## OPeNDAP\n\nOPeNDAP, or the [Open-source Project for a Network Data Access Protocol](https://www.earthdata.nasa.gov/engage/open-data-services-and-software/api/opendap), is a data server that allows for accessing scientific datasets through the public internet. OPeNDAP links can be acquired through dataset landing pages or the [common metadata repository](https://cmr.earthdata.nasa.gov/search/site/collections/directory/eosdis). Once you have the desired link(s), you can open them as follows:\n\n::: {.cell execution_count=2}\n``` {.python .cell-code}\n#Import packages\nimport xarray as xr\n\nds_https = xr.open_dataset(https://opendap.earthdata.nasa.gov/collections/C2532426483-ORNL_CLOUD/granules/Daymet_Daily_V4R1.daymet_v4_daily_hi_tmax_2010.nc)\n\n# For datasets that contain dap4 specific datatypes, such as `int64`, replace `https` with `dap4` at the beginning to open with xarray. For example:\nurl = https://opendap.earthdata.nasa.gov/collections/C2036881966-POCLOUD/granules/AQUA_MODIS.20220109_20220116.L3m.8D.SST4.sst4.4km\ndap4_url = url.replace(\"https://\", \"dap4://\")\n# dap4_url output: dap4://opendap.earthdata.nasa.gov/collections/C2036881966-POCLOUD/granules/AQUA_MODIS.20220109_20220116.L3m.8D.SST4.sst4.4km\nds_dap4 = xr.open_dataset(dap4_url)\n\n# Note: Some datasets have their variables organized in groups, so within the open_dataset function, you may need to specify 'group=' to access the dataset.\n```\n:::\n\n\nFor more information, see the [OPeNDAP Data Access Client Tutorials](https://opendap.github.io/documentation/tutorials/DataAccessTutorials.html).\n\n", | ||
"supporting": [ | ||
"if-im-local_files" | ||
], | ||
"filters": [], | ||
"includes": {} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
{ | ||
"hash": "92e42afeb89a1782ef1e15830da0d4e9", | ||
"result": { | ||
"markdown": "---\ntitle: Read Data\nexecute:\n eval: false\n---\n\n\n\n## netCDF\n\n\n::: {.panel-tabset group=\"language\"}\n\n## Python\n\nWe recommend using `xarray`'s [open_dataset](https://docs.xarray.dev/en/stable/generated/xarray.open_dataset.html)\n\n### For a single file\n\n::: {.cell}\n\n```{.python .cell-code}\nimport xarray as xr\nds = xr.open_dataset(filename)\n```\n:::\n\n\n### For multiple files\n\n::: {.cell}\n\n```{.python .cell-code}\nimport xarray as xr\nds = xr.open_mfdataset(list_of_filenames)\n```\n:::\n\n\n\n## R\n\nR code coming soon!\n\n\n::: {.cell}\n\n```{.r .cell-code}\n# Coming soon!\n```\n:::\n\n\n## Matlab\n\nMatlab code coming soon!\n\n\n::: {.cell}\n\n```{.bash .cell-code}\n# Coming soon!\n```\n:::\n\n\n\n\n:::\n\n\n## HDF5\n\n::: {.panel-tabset group=\"language\"}\n\n## Python\n\nFor HDF5 files, there are two methods we can use: `xarray`'s [open_dataset](https://docs.xarray.dev/en/stable/generated/xarray.open_dataset.html) and [`h5py`](https://docs.h5py.org/en/stable/quick.html)\n\n\n::: {.cell}\n\n```{.python .cell-code}\nimport xarray as xr\nds = xr.open_dataset(filename,\n group=path_to_H5netCDF_group)\n```\n:::\n\n::: {.cell}\n\n```{.python .cell-code}\n# add in directions for h5py\n```\n:::\n\n\n\n## R\n\nR code coming soon!\n\n\n::: {.cell}\n\n```{.r .cell-code}\n# Coming soon!\n```\n:::\n\n\n## Matlab\n\nMatlab code coming soon!\n\n\n::: {.cell}\n\n```{.bash .cell-code}\n# Coming soon!\n```\n:::\n\n\n\n:::\n\n\n\n## GeoTIFF\n\n::: {.panel-tabset group=\"language\"}\n\n## Python\nFor GeoTIFF files, we recommend using `rioxarray`'s [`open_rasterio`](https://corteva.github.io/rioxarray/html/rioxarray.html#rioxarray.open_rasterio)\n\n\n::: {.cell}\n\n```{.python .cell-code}\nimport rioxarray\nxds = rioxarray.open_rasterio(\"my.tif\")\n```\n:::\n\n\n\n## R\n\nR code coming soon!\n\n\n::: {.cell}\n\n```{.r .cell-code}\n# Coming soon!\n```\n:::\n\n\n## Matlab\n\nMatlab code coming soon!\n\n\n::: {.cell}\n\n```{.bash .cell-code}\n# Coming soon!\n```\n:::\n\n\n\n:::\n\n\n\n## Shapefiles & GeoJSON\n\n\n::: {.panel-tabset group=\"language\"}\n\n## Python\nTo open shapefiles or GeoJSON, we recommend using `geopandas`'s [`read_file`](https://geopandas.org/en/stable/docs/reference/api/geopandas.read_file.html#geopandas.read_file).\n\n\n::: {.cell}\n\n```{.python .cell-code}\nimport geopandas as gpd\ngdf = gpd.read_file(filename)\n```\n:::\n\n\n\n## R\n\nR code coming soon!\n\n\n::: {.cell}\n\n```{.r .cell-code}\n# Coming soon!\n```\n:::\n\n\n## Matlab\n\nMatlab code coming soon!\n\n\n::: {.cell}\n\n```{.bash .cell-code}\n# Coming soon!\n```\n:::\n\n\n\n\n:::\n\n\n## CSV\n\n::: {.panel-tabset group=\"language\"}\n\n## Python\nTo open CSV files, we recommend using `pandas`'s [`read_csv`](https://pandas.pydata.org/docs/reference/api/pandas.read_csv.html).\n\n\n::: {.cell}\n\n```{.python .cell-code}\nimport pandas as pd\ndf = pd.read_csv(filename)\n```\n:::\n\n\n\n## R\n\nR code coming soon!\n\n\n::: {.cell}\n\n```{.r .cell-code}\n# Coming soon!\n```\n:::\n\n\n## Matlab\n\nMatlab code coming soon!\n\n\n::: {.cell}\n\n```{.bash .cell-code}\n# Coming soon!\n```\n:::\n\n\n\n\n:::\n\n\n## Excel\n\n\n::: {.panel-tabset group=\"language\"}\n\n## Python\n\nTo open Excel files, we recommend using `pandas`'s [`read_excel`](https://pandas.pydata.org/docs/reference/api/pandas.read_excel.html)\n\n::: {.cell}\n\n```{.python .cell-code}\nimport pandas as pd\ndf = pd.read_excel(filename)\n```\n:::\n\n\n\n## R\n\nR code coming soon!\n\n\n::: {.cell}\n\n```{.r .cell-code}\n# Coming soon!\n```\n:::\n\n\n## Matlab\n\nMatlab code coming soon!\n\n\n::: {.cell}\n\n```{.bash .cell-code}\n# Coming soon!\n```\n:::\n\n\n\n\n:::\n\n## .mat Files\n\n\n::: {.panel-tabset group=\"language\"}\n\n## Python\n\n\n\n::: {.cell}\n\n```{.python .cell-code}\n#coming soon! scipy & .mat\n```\n:::\n\n\n\n## R\n\nR code coming soon!\n\n\n::: {.cell}\n\n```{.r .cell-code}\n# Coming soon!\n```\n:::\n\n\n## Matlab\n\nMatlab code coming soon!\n\n\n::: {.cell}\n\n```{.bash .cell-code}\n# Coming soon!\n```\n:::\n\n\n\n\n:::\n\n\n## Binary Files\n\n::: {.panel-tabset group=\"language\"}\n\n## Python\nTo open binary files, we recommend using `numpy`'s [`from_file`](https://numpy.org/doc/stable/reference/generated/numpy.fromfile.html). You will need to know the dimensions and data type of the binary file and if there is an offset or header information in the binary file.\n\n\n::: {.cell}\n\n```{.python .cell-code}\nimport numpy as np\narr = np.from_file(filepath, dtype=data_type).reshape(nrows, ncols)\n```\n:::\n\n\n\n## R\n\nR code coming soon!\n\n\n::: {.cell}\n\n```{.r .cell-code}\n# Coming soon!\n```\n:::\n\n\n## Matlab\n\nMatlab code coming soon!\n\n\n::: {.cell}\n\n```{.bash .cell-code}\n# Coming soon!\n```\n:::\n\n\n\n\n:::\n", | ||
"supporting": [], | ||
"filters": [ | ||
"rmarkdown/pagebreak.lua" | ||
], | ||
"includes": {}, | ||
"engineDependencies": {}, | ||
"preserve": {}, | ||
"postProcess": true | ||
} | ||
} |
Oops, something went wrong.