Visualizing PACE chlorophyll-a data interactively with HyperCoast¶
This notebook demonstrates how to visualize Plankton, Aerosol, Cloud, ocean Ecosystem (PACE) data interactively with HyperCoast.
# %pip install "hypercoast[extra]"
import hypercoast
To download PACE 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, you can uncomment the code below to search and download the data.
# hypercoast.nasa_earth_login()
# temporal = ("2024-06-01", "2024-07-01")
# results= hypercoast.search_pace_chla(temporal=temporal)
# hypercoast.download_nasa_data(results, "chla")
Alternatively, you can download some sample data from here.
url = "https://github.com/opengeos/datasets/releases/download/hypercoast/pace_chla.zip"
hypercoast.download_file(url)
'/home/runner/work/HyperCoast/HyperCoast/docs/examples/pace_chla.zip'
The downloaded zip file is automatically extracted and saved in the chla
directory, which contains 17 daily files of chlorophyll-a concentration data in the netCDF format. The date range of the data is from 2024-06-01 to 2024-06-17.
files = "chla/*nc"
Load all the data files in the chla
directory as an xarray DataArray
array = hypercoast.read_pace_chla(files)
array
<xarray.DataArray 'chlor_a' (lat: 1800, lon: 3600, date: 17)> Size: 441MB dask.array<transpose, shape=(1800, 3600, 17), dtype=float32, chunksize=(512, 1024, 1), chunktype=numpy.ndarray> Coordinates: * lat (lat) float32 7kB 89.95 89.85 89.75 ... -89.75 -89.85 -89.95 * lon (lon) float32 14kB -179.9 -179.9 -179.8 ... 179.8 179.9 180.0 * date (date) <U10 680B '2024-06-01' '2024-06-02' ... '2024-06-17' spatial_ref int64 8B 0 Attributes: long_name: Chlorophyll Concentration, OCI Algorithm units: lg(mg m^-3) standard_name: mass_concentration_of_chlorophyll_in_sea_water valid_min: 0.001 valid_max: 100.0 reference: Hu, C., Lee Z., and Franz, B.A. (2012). Chlorophyll-a alg... display_scale: log display_min: 0.01 display_max: 20.0 date: ['2024-06-01', '2024-06-02', '2024-06-03', '2024-06-04', ...
Select a date and visualize the chlorophyll-a concentration data with Matplotlib.
hypercoast.viz_pace_chla(array, date="2024-06-01", cmap="jet", size=6)
<matplotlib.collections.QuadMesh at 0x7fc64a6f7ef0>
If the date is not specified, the data are averaged over the entire time range.
hypercoast.viz_pace_chla(array, cmap="jet", size=6)
<matplotlib.collections.QuadMesh at 0x7fc64a5f9ee0>