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)
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
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)
If the date is not specified, the data are averaged over the entire time range.
hypercoast.viz_pace_chla(array, cmap="jet", size=6)
To visualize the data interactively, we can select either a single date or aggregate the data over a time range.
First, let's select a single date from the data array:
single_array = array.sel(date="2024-06-01")
single_array
Convert the data array to an image that can be displayed on an interactive map.
single_image = hypercoast.pace_chla_to_image(single_array)
Create an interactive map and display the image on the map.
m = hypercoast.Map(center=[40, -100], zoom=4)
m.add_basemap("Hybrid")
m.add_raster(
single_image,
cmap="jet",
vmin=-1,
vmax=2,
layer_name="Chlorophyll a",
zoom_to_layer=False,
)
label = "Chlorophyll Concentration [lg(lg(mg m^-3))]"
m.add_colormap(cmap="jet", vmin=-1, vmax=2, label=label)
m
The daily image does not have a global coverage. To visualize the data globally, we can aggregate the data over a time range.
mean_array = array.mean(dim="date")
Convert the aggregated data array to an image that can be displayed on an interactive map.
image = hypercoast.pace_chla_to_image(mean_array)
Create an interactive map and display the image on the map.
m = hypercoast.Map(center=[40, -100], zoom=4)
m.add_basemap("Hybrid")
m.add_raster(
image, cmap="jet", vmin=-1, vmax=2, layer_name="Chlorophyll a", zoom_to_layer=False
)
label = "Chlorophyll Concentration [lg(lg(mg m^-3))]"
m.add_colormap(cmap="jet", vmin=-1, vmax=2, label=label)
m