# /// script
# requires-python = ">=3.12"
# dependencies = [
# "earthaccess-auth>=0.4.0",
# "icechunk>=2.2.2",
# "matplotlib>=3.11.2",
# "xarray>=2026.7.0",
# ]
# ///
Quickstart: reading a store from anywhere¶
The first quickstart reads chunks from ASDC's S3 bucket, which works only in AWS us-west-2. This one reads the same chunks over HTTPS from NASA's distribution endpoint, so it runs on a laptop.
It relies on the store's references being relative, as
vcc://asdc/TEMPO/.... Icechunk resolves such a reference through
whichever container is named asdc. This notebook replaces that container
with one that points at https://data.asdc.earthdata.nasa.gov/ and sends
an Earthdata Login bearer token with each request. The HTTPS endpoint
serves the same keys as the bucket. It sits behind CloudFront, which
rate-limits it, so expect it to be slower than reading in-region.
Run it with juv:
juv run docs/examples/quickstart-https.ipynb.
Authenticate¶
login() looks for EARTHDATA_TOKEN (or EARTHDATA_USERNAME and
EARTHDATA_PASSWORD), then ~/.netrc, then prompts. Only the bearer token
is used here, so the base package is enough.
import earthaccess_auth
token = earthaccess_auth.login().token["access_token"]
Open the store¶
Icechunk opens the repository on Source Cooperative anonymously. The
repository's own config points the asdc container at S3. Swapping in an
HTTPS container with the same name sends every relative reference to
the HTTPS endpoint instead. HttpAccess authorizes the container to be
read. The token travels in the container's headers.
The token is a static header. Open the store again when it expires.
import icechunk
import xarray as xr
storage = icechunk.s3_storage(
bucket="us-west-2.opendata.source.coop",
prefix="pangeo/tempo-virtual-icechunk/tempo/no2/v04",
region="us-west-2",
anonymous=True,
)
repo = icechunk.Repository.open(storage)
https_prefix = "https://data.asdc.earthdata.nasa.gov/asdc-prod-protected/"
config = repo.config
config.set_virtual_chunk_container(
icechunk.VirtualChunkContainer(
https_prefix,
icechunk.http_store(headers={"Authorization": f"Bearer {token}"}),
name="asdc",
)
)
repo = repo.reopen(
config=config,
authorize_virtual_chunk_access=icechunk.containers_credentials(
{https_prefix: icechunk.credentials.HttpAccess}
),
)
ds = xr.open_zarr(repo.readonly_session("main").store, consolidated=False, chunks=None)
ds
<xarray.Dataset> Size: 88TB
Dimensions: (time: 17418,
latitude: 2950,
longitude: 7750)
Coordinates:
* time (time) datetime64[ns] 139kB ...
* latitude (latitude) float32 12kB ...
* longitude (longitude) float32 31kB ...
Data variables: (12/39)
albedo (time, latitude, longitude) float32 2TB ...
amf_cloud_fraction (time, latitude, longitude) float32 2TB ...
amf_troposphere (time, latitude, longitude) float32 2TB ...
amf_cloud_pressure (time, latitude, longitude) float32 2TB ...
eff_cloud_fraction (time, latitude, longitude) float32 2TB ...
amf_stratosphere (time, latitude, longitude) float32 2TB ...
... ...
vertical_column_troposphere_uncertainty (time, latitude, longitude) float64 3TB ...
viewing_zenith_angle (time, latitude, longitude) float32 2TB ...
tropopause_pressure (time, latitude, longitude) float32 2TB ...
vertical_column_total (time, latitude, longitude) float64 3TB ...
snow_ice_fraction (time, latitude, longitude) float32 2TB ...
vertical_column_troposphere (time, latitude, longitude) float64 3TB ...
Attributes: (12/22)
product_type: NO2
processing_level: 3
processing_version: 4
sdpc_version: TEMPO_SDPC_v4.8.4
version_id: 4
pge_version: 1.0.0
... ...
collection_shortname: TEMPO_NO2_L3
collection_version: 1
keywords: EARTH SCIENCE>ATMOSPHERE>AIR QUALITY>NITROGEN OXI...
summary: Nitrogen dioxide Level 3 files provide trace gas ...
tempo_store: {'schema': 'tempo-backfill-inventory/1', 'collect...
pending_ledger: []Load a single point¶
Selecting a point and a time, then asking for the value, reads the one
chunk that holds it, over HTTPS. main_data_quality_flag is 0 for normal
retrievals.
nyc = dict(latitude=40.7, longitude=-74.0, method="nearest")
scan = ds.sel(time="2026-09-03T18:00", method="nearest")
no2 = scan.vertical_column_troposphere.sel(**nyc)
flag = scan.main_data_quality_flag.sel(**nyc)
when = scan.time.values.astype("datetime64[m]")
print(f"{when}: {float(no2):.3g} {no2.units}, quality flag {int(flag)}")
2026-09-03T17:37: 7.57e+15 molecules/cm^2, quality flag 0
Plot a map¶
The same scan over the Northeast, keeping only normal-quality retrievals. One scan spans a few chunks per variable, so this reads a few tens of MB.
northeast = scan.sel(latitude=slice(36, 46), longitude=slice(-82, -66))
good = northeast.vertical_column_troposphere.where(
(northeast.main_data_quality_flag == 0)
& (northeast.eff_cloud_fraction < 0.5)
& (northeast.solar_zenith_angle < 80)
)
good.plot(robust=True, figsize=(9, 5));