Visualizing PACE data interactively with HyperCoast¶
This notebook demonstrates how to visualize Plankton, Aerosol, Cloud, ocean Ecosystem (PACE) data interactively with HyperCoast.
In [1]:
Copied!
# %pip install "hypercoast[extra]"
# %pip install "hypercoast[extra]"
In [2]:
Copied!
import hypercoast
import hypercoast
Download a sample PACE data file from here.
In [3]:
Copied!
url = "https://github.com/opengeos/datasets/releases/download/hypercoast/PACE_OCI.20240730T181157.L2.OC_AOP.V2_0.NRT.nc"
url = "https://github.com/opengeos/datasets/releases/download/hypercoast/PACE_OCI.20240730T181157.L2.OC_AOP.V2_0.NRT.nc"
In [4]:
Copied!
filepath = "data/PACE_OCI.20240730T181157.L2.OC_AOP.V2_0.NRT.nc"
hypercoast.download_file(url, filepath)
filepath = "data/PACE_OCI.20240730T181157.L2.OC_AOP.V2_0.NRT.nc"
hypercoast.download_file(url, filepath)
data/PACE_OCI.20240730T181157.L2.OC_AOP.V2_0.NRT.nc already exists. Skip downloading. Set overwrite=True to overwrite.
Out[4]:
'/home/runner/work/HyperCoast/HyperCoast/docs/examples/data/PACE_OCI.20240730T181157.L2.OC_AOP.V2_0.NRT.nc'
Let's make a scatter plot of the pixel locations so we can see the irregular spacing.
In [5]:
Copied!
plot = hypercoast.view_pace_pixel_locations(filepath, step=20)
plot = hypercoast.view_pace_pixel_locations(filepath, step=20)
Load the dataset as a xarray.Dataset
object.
In [6]:
Copied!
dataset = hypercoast.read_pace(filepath)
dataset = hypercoast.read_pace(filepath)
Visualize selected bands of the dataset.
In [7]:
Copied!
hypercoast.viz_pace(dataset, wavelengths=[500, 510, 520, 530], ncols=2)
hypercoast.viz_pace(dataset, wavelengths=[500, 510, 520, 530], ncols=2)
Add projection.
In [8]:
Copied!
hypercoast.viz_pace(dataset, wavelengths=[500, 510, 520, 530], ncols=2, crs="default")
hypercoast.viz_pace(dataset, wavelengths=[500, 510, 520, 530], ncols=2, crs="default")
Plot a spectral signature.
In [9]:
Copied!
latitude = 29.9307
longitude = -87.9106
hypercoast.extract_pace(dataset, latitude, longitude, return_plot=True)
latitude = 29.9307
longitude = -87.9106
hypercoast.extract_pace(dataset, latitude, longitude, return_plot=True)
Out[9]:
[<matplotlib.lines.Line2D at 0x7fdc1c2f9790>]
Plot multiple spectral signatures.
In [10]:
Copied!
latitude = (29.49, 29.50)
longitude = (-88.10, -88.00)
hypercoast.filter_pace(dataset, latitude, longitude, return_plot=True)
latitude = (29.49, 29.50)
longitude = (-88.10, -88.00)
hypercoast.filter_pace(dataset, latitude, longitude, return_plot=True)
Single-band visualization.
In [11]:
Copied!
m = hypercoast.Map()
m.add_basemap("Hybrid")
wavelengths = [450]
m.add_pace(dataset, wavelengths, colormap="jet", vmin=0, vmax=0.02, layer_name="PACE")
m.add_colormap(cmap="jet", vmin=0, vmax=0.02, label="Reflectance")
m.add("spectral")
m
m = hypercoast.Map()
m.add_basemap("Hybrid")
wavelengths = [450]
m.add_pace(dataset, wavelengths, colormap="jet", vmin=0, vmax=0.02, layer_name="PACE")
m.add_colormap(cmap="jet", vmin=0, vmax=0.02, label="Reflectance")
m.add("spectral")
m
Out[11]:
Multiple-band visualization.
In [12]:
Copied!
m = hypercoast.Map()
m.add_basemap("Hybrid")
wavelengths = [450, 550, 650]
m.add_pace(
dataset, wavelengths, indexes=[3, 2, 1], vmin=0, vmax=0.02, layer_name="PACE"
)
m.add("spectral")
m
m = hypercoast.Map()
m.add_basemap("Hybrid")
wavelengths = [450, 550, 650]
m.add_pace(
dataset, wavelengths, indexes=[3, 2, 1], vmin=0, vmax=0.02, layer_name="PACE"
)
m.add("spectral")
m
Out[12]: