Usage¶
Import library¶
To use HyperCoast in a project:
1 |
|
Search for datasets¶
To download and access NASA hyperspectral data, you will need to create an Earthdata login. You can register for an account at urs.earthdata.nasa.gov. Once you have an account, run the following code to log in:
1 |
|
Collections on NASA Earthdata are discovered with the search_datasets function, which accepts an instrument filter as an easy way to get started. Each of the items in the list of collections returned has a "short-name". For example, to search for all datasets with the instrument "oci":
1 2 3 4 5 6 7 8 9 |
|
Search for data by short name¶
Next, we use the search_nasa_data
function to find granules within a collection.
Let's use the short_name for the PACE/OCI Level-2 data product for bio-optical
and biogeochemical properties.
1 2 3 4 |
|
We can refine our search by passing more parameters that describe the spatiotemporal domain of our use case. Here, we use the temporal parameter to request a date range and the bounding_box parameter to request granules that intersect with a bounding box. We can even provide a cloud_cover threshold to limit files that have a lower percentage of cloud cover. We do not provide a count, so we'll get all granules that satisfy the constraints.
1 2 3 4 5 6 7 8 9 10 11 |
|
Display the footprints of the granules that match the search criteria.
1 |
|
We can also download all the results with one command.
1 |
|
Search for PACE data¶
To search for PACE data, we can use the search_pace
function:
1 2 3 4 5 6 |
|
To download the PACE data, we can use the download_pace
function:
1 |
|
Search for EMIT data¶
To search for EMIT data, we can use the search_emit
function:
1 2 3 4 5 6 |
|
To download the EMIT data, we can use the download_emit
function:
1 |
|
Visualize PACE data¶
Load the dataset as a xarray.Dataset
object:
1 |
|
Visualize selected bands of the dataset:
1 |
|
Visualize the dataset on an interactive map:
1 2 3 4 5 6 7 |
|
Visualize EMIT data¶
To visualize EMIT data, we can use the read_emit
function:
1 |
|
Visualize the dataset on an interactive map:
1 2 3 4 5 |
|
Create an image cube¶
First , load the dataset as a xarray.Dataset
object. Select a region of interest (ROI) using the sel
method:
1 2 |
|
Create an image cube using the image_cube
function:
1 2 3 4 5 6 7 8 9 10 |
|
Interactive slicing and thresholding¶
First , load the dataset as a xarray.Dataset
object. Select a region of interest (ROI) using the sel
method:
1 2 |
|
Interactive slicing along the z-axis (band):
1 2 3 4 5 6 7 8 9 10 11 12 |
|
Interactive thresholding:
1 2 3 4 5 6 7 8 9 10 11 12 |
|
Visualizing PACE chlorophyll-a concentration data¶
Load all the data files in a directory as an xarray.DataArray
:
1 2 |
|
Select a date and visualize the chlorophyll-a concentration data with Matplotlib.
1 |
|
If the date is not specified, the data are averaged over the entire time range.
1 |
|
Convert the data array to an image that can be displayed on an interactive map.
1 |
|
Create an interactive map and display the image on the map.
1 2 3 4 5 6 7 8 9 10 11 12 13 |
|