Rnpn
This module contains functionality to download and load data from NPN. It uses rnpn as client.
Could use https://data.usanpn.org/observations/get-started to figure out which species/phenophases combis are available.
Example
from springtime.datasets.insitu.npn.rnpn import (
RNPN,
npn_species,
npn_phenophases
)
# List IDs and names for available species, phenophases
species = npn_species()
phenophases = npn_phenophases()
# Load dataset
dataset = RNPN(
# Syringa vulgaris / common lilac
species_ids={'name': 'lilac', 'items': [36]},
phenophase_ids={'name': 'Leaves', 'items': [483]},
years=[2010, 2012],
)
dataset.download()
gdf = dataset.load()
# or with area bounds
dataset = RNPN(
years = [2010, 2011],
area = {'name':'some', 'bbox':[-112, 30, -108, 35.0]}
)
Requires rnpn R package. Install with
install.packages("rnpn")
SpeciesByFunctionalType
Bases: BaseModel
Species by functional type.
PhenophasesByName
Bases: BaseModel
Phenophases by name.
RNPN
Bases: Dataset
Download and load data from NPN.
Attributes:
Name | Type | Description |
---|---|---|
years |
timerange. For example years=[2000, 2002] downloads data for three years. |
|
resample |
Resample the dataset to a different time resolution. If None, no resampling. |
|
species_ids |
Optional[Union[NamedIdentifiers, SpeciesByFunctionalType]]
|
formatted as a dictionary of the form |
phenophase_ids |
Union[NamedIdentifiers, PhenophasesByName]
|
formatted as a dictionary of the form |
area |
Optional[NamedArea]
|
A dictionary of the form
|
use_first |
bool
|
When true uses first_yes columns as value, otherwise the last "_yes"-columns. |
aggregation_operator |
Literal['min', 'max', 'mean', 'median']
|
"min", "max", "mean", or "median" |
load()
Load the dataset into memory.
download(timeout=30)
Download the data.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
timeout |
int
|
time in seconds to wait for a response of the npn server. |
30
|
Raises:
Type | Description |
---|---|
TimeoutError
|
If requests still fails after 3 attempts. |
npn_species()
npn_phenophases()
npn_stations()
Get available stations on npn.
Returns:
Type | Description |
---|---|
gpd.GeoDataFrame
|
Dataframe with station_id and other station related fields. |
npn_species_ids_by_functional_type(functional_type)
Lookup species ids by functional type.
npn_phenophase_ids_by_name(phenophase_name)
Lookup phenophase ids by name.