|
| 1 | +# Getting started with iceflow |
| 2 | + |
| 3 | +## Jupyter Notebooks |
| 4 | + |
| 5 | +[Jupyter notebooks](https://docs.jupyter.org/en/latest/) provide executable |
| 6 | +examples of how to use `iceflow`: |
| 7 | + |
| 8 | +- [iceflow-example.ipynb](./iceflow-example.ipynb) provides an example of how to |
| 9 | + search for, download, and interact with `ILATM1B v1` data for a small area of |
| 10 | + interest. This notebook also illustrates how to perform |
| 11 | + [ITRF](https://itrf.ign.fr/) transformations to facilitate comparisons across |
| 12 | + datasets. To learn more about ITRF transformations, see the |
| 13 | + [corrections.ipynb](https://github.com/nsidc/NSIDC-Data-Tutorials/blob/main/notebooks/iceflow/corrections.ipynb) |
| 14 | + notebook in the |
| 15 | + [NSIDC-Data-Tutorials GitHub repository](https://github.com/nsidc/NSIDC-Data-Tutorials). |
| 16 | + |
| 17 | +- [iceflow-with-icepyx.ipynb](./iceflow-with-icepyx.ipynb) shows how to search |
| 18 | + for, download, and interact with a large amount of data across many datasets |
| 19 | + supported by `iceflow`. It also illustrates how to utilize |
| 20 | + [icepyx](https://icepyx.readthedocs.io/en/latest/) to find and access ICESat-2 |
| 21 | + data. Finally, the notebook provides a simple time-series analysis for |
| 22 | + elevation change over an area of interest across `iceflow` supported datasets |
| 23 | + and ICESat-2. |
| 24 | + |
| 25 | +## API overview |
| 26 | + |
| 27 | +`iceflow` provides a simple API for finding, downloading, and accessing |
| 28 | +iceflow-supported datasets. |
| 29 | + |
| 30 | +### Finding data |
| 31 | + |
| 32 | +To find `iceflow`-supported data for an area of interest and timeframe, use |
| 33 | +[`find_iceflow_data`](nsidc.iceflow.find_iceflow_data): |
| 34 | + |
| 35 | +``` |
| 36 | +import datetime as dt |
| 37 | +
|
| 38 | +from nsidc.iceflow import ( |
| 39 | + find_iceflow_data, |
| 40 | + DatasetSearchParameters, |
| 41 | + BoundingBox, |
| 42 | +) |
| 43 | +
|
| 44 | +
|
| 45 | +search_results = find_iceflow_data( |
| 46 | + dataset_search_params=DatasetSearchParameters( |
| 47 | + bounding_box=BoundingBox(lower_left_lon=-103.125559, lower_left_lat=-75.180563, upper_right_lon=-102.677327, upper_right_lat=-74.798063), |
| 48 | + temporal=(dt.date(2009, 11, 1), dt.date(2009, 12, 31)), |
| 49 | + ), |
| 50 | +) |
| 51 | +``` |
| 52 | + |
| 53 | +### Downloading data |
| 54 | + |
| 55 | +Once search results have been found, download data with |
| 56 | +[`download_iceflow_results`](nsidc.iceflow.download_iceflow_results): |
| 57 | + |
| 58 | +``` |
| 59 | +from pathlib import Path |
| 60 | +from nsidc.iceflow import download_iceflow_results |
| 61 | +
|
| 62 | +downloaded_filepaths = download_iceflow_results( |
| 63 | + iceflow_search_result=iceflow_search_result, |
| 64 | + output_dir=Path("/path/to/data/dir/"), |
| 65 | +) |
| 66 | +``` |
| 67 | + |
| 68 | +### Accessing data |
| 69 | + |
| 70 | +Iceflow data can be very large, and fitting it into memory can be a challenge! |
| 71 | +To facilitate analysis of iceflow data, |
| 72 | +[`make_iceflow_parquet`](nsidc.iceflow.make_iceflow_parquet) provides a |
| 73 | +mechanism to create a [parquet](https://parquet.apache.org/docs/overview/) |
| 74 | +datastore that can be used alongside [dask](https://www.dask.org/): |
| 75 | + |
| 76 | +``` |
| 77 | +import dask.dataframe as dd |
| 78 | +from nsidc.iceflow import make_iceflow_parquet |
| 79 | +
|
| 80 | +parquet_path = make_iceflow_parquet( |
| 81 | + data_dir=Path("/path/to/data/dir/"), |
| 82 | + target_itrf="ITRF2014", |
| 83 | +) |
| 84 | +df = dd.read_parquet(parquet_path) |
| 85 | +``` |
| 86 | + |
| 87 | +Note that `make_iceflow_parquet` creates a parquet datastore for the data in the |
| 88 | +provided `data_dir` with the data transformed into a common |
| 89 | +[ITRF](https://itrf.ign.fr/) to facilitate analysis. Only datetime, lat, lon, |
| 90 | +and elevation fields are preserved in the parquet datastore. |
| 91 | + |
| 92 | +To access and analyze the full data record in the source files, use |
| 93 | +[`read_iceflow_datafiles`](nsidc.iceflow.read_iceflow_datafiles): |
| 94 | + |
| 95 | +``` |
| 96 | +from nsidc.iceflow import read_iceflow_datafiles |
| 97 | +
|
| 98 | +# Read all of the data in the source files - not just lat/lon/elev. |
| 99 | +df = read_iceflow_datafiles(downloaded_files) |
| 100 | +
|
| 101 | +# Optional: transform lat/lon/elev to common ITRF: |
| 102 | +from nsidc.iceflow import transform_itrf |
| 103 | +df = transform_itrf( |
| 104 | + data=df, |
| 105 | + target_itrf="ITRF2014", |
| 106 | +) |
| 107 | +``` |
| 108 | + |
| 109 | +Note that `read_iceflow_datafiles` reads all of the data from the given |
| 110 | +filepaths. This could be a large amount of data, and could cause your program to |
| 111 | +crash if physical memory limits are exceeded. |
0 commit comments