- Home
- Documentation
- API reference
- Archive
- hyperproc.archive.neon
hyperproc.archive.neon¶
Source-derived reference
Generated from the current hyperproc 0.1.2 checkout.
Implementation: hyperproc/archive/neon.py. Signatures, defaults, docstrings, and expandable source are extracted statically; the module is not imported or executed. Names beginning with _ are implementation details, not a stable public API.
Use the function signature as the authority for individual parameter defaults and return annotations. Original docstrings sometimes group parameter names or wrap return descriptions across lines; these descriptions are preserved rather than inferred or rewritten.
The NEON-backed part of :mod:hyperproc.archive, over the NEON Data API v0.
NEON does not publish granules the way a satellite mission does. It publishes deliveries: one per site and month, holding every flightline flown in that window - for the AOP spectrometer, often a hundred files and several hundred gigabytes. So finding data here is two steps rather than one::
>>> hits = hp.search("NEON", "L1", bbox=(-71.4, 44.0, -71.2, 44.2))
>>> hits # deliveries, anonymous
3 granules, size not published
>>> lines = hp.archive.files(hits[0]) # the flightlines inside one
>>> hp.download(lines[:2], "data/")
Searching is anonymous: site coordinates and the months each site was flown
come from /sites, which is open. Listing and downloading files is not.
Since June 2026 the NEON data endpoint requires an API token - NEON's own
client says so in as many words - which is free from your account page at
https://data.neonscience.org/myaccount . Put it in NEON_TOKEN or pass
token=.
One caveat worth stating plainly: NEON publishes the site's coordinates but
not the flight box, so a delivery's footprint here is a point, and bbox=
matches a site whose coordinates fall within site_radius_km of the box.
An AOP flight box is roughly 10 km across, so the default tolerance is 15 km.
_SITES: dict[str, dict] | None = None
module-attribute
¶
BASE = os.environ.get('NEON_API_URL', 'https://data.neonscience.org/api/v0/')
module-attribute
¶
ACCOUNT = 'https://data.neonscience.org/myaccount'
module-attribute
¶
NEEDS_TOKEN = f'As of June 2026 the NEON API requires a token to list or download data files. Searching does not. Get a free token from your account page at {ACCOUNT}, then set NEON_TOKEN=... or pass token=...'
module-attribute
¶
DEFAULT_PATTERN = {'DP1.30006.001': '*_reflectance.h5'}
module-attribute
¶
_FLIGHTLINE = re.compile('_(?P<date>\\d{8})_(?P<time>\\d{6})_')
module-attribute
¶
_requests()
¶
_get(path: str, token: str | None = None, **params) -> dict
¶
One NEON API call, with the token where there is one.
Source code in hyperproc/archive/neon.py
token_from(token: str | None = None) -> str | None
¶
sites(refresh: bool = False) -> dict[str, dict]
¶
Every NEON site, keyed by code, with coordinates and what was flown there.
One anonymous call answers both halves of a search, which is why the module
uses it rather than /products: each site carries siteLatitude,
siteLongitude and a dataProducts list whose entries name the months
available. Cached for the process.
Source code in hyperproc/archive/neon.py
_months(date) -> tuple[str, str] | None
¶
date= as an inclusive ("YYYY-MM", "YYYY-MM") pair.
A day is accepted and truncated to its month, because a delivery is monthly and pretending otherwise would drop the flight you asked for.
Source code in hyperproc/archive/neon.py
_hit(lat: float, lon: float, bbox, radius_km: float) -> bool
¶
Is the site within radius_km of the box?
Source code in hyperproc/archive/neon.py
search(sensor: str, level: str | None = None, *, bbox=None, date=None, site: str | Sequence | None = None, count: int = 100, site_radius_km: float = 15.0, verbose: bool = True, **kwargs) -> Results
¶
Find NEON AOP deliveries: one per site and month.
| PARAMETER | DESCRIPTION |
|---|---|
sensor
|
TYPE:
|
level
|
TYPE:
|
bbox
|
DEFAULT:
|
date
|
DEFAULT:
|
site
|
a four-letter site code, or several, instead of (or as well as)
a box -
TYPE:
|
count
|
cap on deliveries returned.
TYPE:
|
site_radius_km
|
how far outside
TYPE:
|
verbose
|
print the query and the total.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
Results
|
class: |
links
|
both need the file list, which needs a token. Pass one to
TYPE:
|
Results
|
func: |
Source code in hyperproc/archive/neon.py
133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 | |
files(results, *, token: str | None = None, pattern: str | None = None, verbose: bool = True) -> Results
¶
List the files inside one or more deliveries.
NEON has required a token for this since June 2026. One is sent when there
is one; the request goes out either way, and a refusal comes back as a
:class:PermissionError quoting the address a token comes from.
| PARAMETER | DESCRIPTION |
|---|---|
results
|
what :func:
|
token
|
the NEON API token. Defaults to
TYPE:
|
pattern
|
a shell glob over file names. The default keeps only what
:func:
TYPE:
|
verbose
|
print what was found.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
Results
|
class: |
The links NEON returns are signed and expire within the hour, so list and download in one sitting rather than pickling the result.
Source code in hyperproc/archive/neon.py
_flight_time(name: str) -> datetime | None
¶
Source code in hyperproc/archive/neon.py
download(results, out_dir: str | Path = 'data', workers: int = 4, token: str | None = None, pattern: str | None = None, verbose: bool = True) -> list[Path]
¶
Fetch NEON files into out_dir. NEON requires a token for this.
Deliveries are expanded to their files first, so passing what
:func:search returned downloads a whole site-month - often hundreds of
gigabytes. The total is printed before anything is fetched; narrow it with
:func:files and a slice, or with pattern=.