Visualizing PACE OCI L2 data products with HyperCoast¶
This notebook demonstrates how to visualize Plankton, Aerosol, Cloud, ocean Ecosystem (PACE) OCI L2 data products, including the concentration of chlorophyll-a, concentration of phytoplankton carbon, and concentration of particulate organic carbon.
# %pip install "hypercoast[extra]"
import hypercoast
To download and access the 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 and run the following cell to search and download PACE OCI L2 data products.
# hypercoast.nasa_earth_login()
# short_name = "PACE_OCI_L2_BGC_NRT"
# results, gdf = hypercoast.search_nasa_data(
# short_name=short_name,
# bbox=(-90.5642, 29.9749, -89.7143, 30.42),
# temporal=("2024-06-15", "2024-06-16"),
# return_gdf=True
# )
# hypercoast.download_nasa_data(results, out_dir="bgc")
Alternatively, use the following code block to download a sample dataset from here.
url = "https://github.com/opengeos/datasets/releases/download/hypercoast/PACE_OCI.20240615T182549.L2.OC_BGC.V1_0_0.NRT.nc"
filepath = "data/PACE_OCI.20240615T182549.L2.OC_BGC.V1_0_0.NRT.nc"
hypercoast.download_file(url, filepath)
Load the downloaded dataset as an xarray.Dataset
:
dataset = hypercoast.read_pace_bgc(filepath)
Let's inspect the data variables contained in the dataset:
dataset.variables
We can see that the dataset contains the following variables:
Transform the xarray dataset into gridded data.
Plot the Chlorophyll Concentration.
chlor_a = hypercoast.grid_pace_bgc(dataset, variable="chlor_a", method="linear")
chlor_a.plot(vmin=0, vmax=20, cmap="jet", size=6)
Plot the Phytoplankton Carbon.
carbon_phyto = hypercoast.grid_pace_bgc(
dataset, variable="carbon_phyto", method="linear"
)
carbon_phyto.plot(vmin=0, vmax=120, cmap="jet", size=6)
Particulate Organic Carbon.
poc = hypercoast.grid_pace_bgc(dataset, variable="poc", method="linear")
poc.plot(vmin=0, vmax=1000, cmap="jet")
Plot the data on an interactive map.
m = hypercoast.Map()
m.add_basemap("Hybrid")
m.add_raster(chlor_a, layer_name="Chlorophyll-a", colormap="jet", vmin=0, vmax=20)
m.add_raster(
carbon_phyto, layer_name="Phytoplankton Carbon", colormap="plasma", vmin=0, vmax=120
)
m.add_raster(
poc, layer_name="Particulate Organic Carbon", colormap="coolwarm", vmin=0, vmax=1000
)
m.add_layer_manager()
m.add_colormap(cmap="jet", vmin=0, vmax=20, label="Chlorophyll-a (mg/m3)")
m.add_colormap(cmap="plasma", vmin=0, vmax=120, label="Phytoplankton Carbon (mg/m3)")
m.add_colormap(
cmap="coolwarm", vmin=0, vmax=1000, label="Particulate Organic Carbon (mg/m3)"
)
m