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)
'/home/runner/work/HyperCoast/HyperCoast/docs/examples/data/PACE_OCI.20240615T182549.L2.OC_BGC.V1_0_0.NRT.nc'
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
Frozen({'chlor_a': <xarray.Variable (latitude: 1710, longitude: 1272)> Size: 9MB [2175120 values with dtype=float32] Attributes: long_name: Chlorophyll Concentration, OCI Algorithm units: 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..., 'carbon_phyto': <xarray.Variable (latitude: 1710, longitude: 1272)> Size: 9MB [2175120 values with dtype=float32] Attributes: long_name: Phytoplankton Carbon units: mg m^-3 valid_min: 0.0 valid_max: 1000.0 reference: Graff, J.R., Westberry, T.K., Milligan, A.J., Brown, M.B., Da..., 'poc': <xarray.Variable (latitude: 1710, longitude: 1272)> Size: 9MB [2175120 values with dtype=float32] Attributes: long_name: Particulate Organic Carbon, D. Stramski, 2022 (hybrid version) units: mg m^-3 valid_min: -32000 valid_max: -22000 reference: Stramski, D., et al. "Ocean color algorithms to estimate the ..., 'chlor_a_unc': <xarray.Variable (latitude: 1710, longitude: 1272)> Size: 9MB [2175120 values with dtype=float32] Attributes: long_name: Uncertainty in chlorophyll a concentration units: mg m^-3 standard_name: chlorophyll_concentration_in_sea_water standard_error valid_min: 0.001 valid_max: 100.0, 'carbon_phyto_unc': <xarray.Variable (latitude: 1710, longitude: 1272)> Size: 9MB [2175120 values with dtype=float32] Attributes: long_name: Phytoplankton Carbon standard uncertainty units: mg m^-3 valid_min: 0.0 valid_max: 1000.0 reference: Graff, J.R., Westberry, T.K., Milligan, A.J., Brown, M.B., Da..., 'l2_flags': <xarray.Variable (latitude: 1710, longitude: 1272)> Size: 9MB [2175120 values with dtype=int32] Attributes: long_name: Level-2 Processing Flags valid_min: -2147483648 valid_max: 2147483647 flag_masks: [ 1 2 4 8 ... flag_meanings: ATMFAIL LAND PRODWARN HIGLINT HILT HISATZEN COASTZ SPARE ..., 'longitude': <xarray.Variable (latitude: 1710, longitude: 1272)> Size: 9MB [2175120 values with dtype=float32] Attributes: long_name: Longitude units: degrees_east standard_name: longitude valid_min: -180.0 valid_max: 180.0, 'latitude': <xarray.Variable (latitude: 1710, longitude: 1272)> Size: 9MB [2175120 values with dtype=float32] Attributes: long_name: Latitude units: degrees_north standard_name: latitude valid_min: -90.0 valid_max: 90.0})
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)
<matplotlib.collections.QuadMesh at 0x7f55a30f2450>
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)
<matplotlib.collections.QuadMesh at 0x7f55a24f0950>
Particulate Organic Carbon.
poc = hypercoast.grid_pace_bgc(dataset, variable="poc", method="linear")
poc.plot(vmin=0, vmax=1000, cmap="jet")
<matplotlib.collections.QuadMesh at 0x7f55a2550560>
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