API Reference
Core API Functions
salientsdk.forecast_timeseries(loc, date='-default', debias=False, field='anom', format='nc', model='blend', reference_clim='salient', timescale='all', variable='temp', version='-default', destination='-default', force=False, session=None, apikey=None, verify=None, verbose=False, strict=True, **kwargs)
Get time series of S2S meteorological forecasts.
This function is a convenience wrapper to the Salient API.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
loc |
Location
|
The location to query |
required |
date |
str | list[str]
|
The date the forecast was generated.
Defaults to find the most recent forecast.
Can be a specific date in the format |
'-default'
|
debias |
bool
|
If True, debias the data to local observations.
Valid only for |
False
|
field |
str
|
The field to query, defaults to |
'anom'
|
format |
str
|
The file format of the response.
Defaults to |
'nc'
|
model |
str | list[str]
|
The model to query.
Defaults to |
'blend'
|
reference_clim |
str
|
Reference climatology for calculating anomalies.
Ignored when |
'salient'
|
timescale |
str
|
Forecast look-ahead.
- |
'all'
|
variable |
str
|
The variable to query, defaults to |
'temp'
|
version |
str
|
The model version of the Salient |
'-default'
|
destination |
str
|
The destination directory for downloaded files.
|
'-default'
|
force |
bool
|
If False (default), don't download the data if it already exists |
False
|
session |
Session
|
The session object to use for the request |
None
|
apikey |
str | None
|
The API key to use for the request.
In most cases, this is not needed if a |
None
|
verify |
bool
|
If True (default), verify the SSL certificate.
Defaults to use the value returned by |
None
|
verbose |
bool
|
If True (default False) print status messages |
False
|
strict |
bool
|
If True (default) error if query is invalid. If False,
return |
True
|
**kwargs |
Additional arguments to pass to the API |
{}
|
Other Parameters:
Name | Type | Description |
---|---|---|
units |
str
|
|
Returns:
Type | Description |
---|---|
str | DataFrame
|
str | pd.DataFrame: the file name(s) of the downloaded data.
File names are a hash of the query parameters.
When |
salientsdk.downscale(loc, variables='temp,precip', date='-today', members=50, debias=False, frequency='daily', reference_clim='salient', version='-default', weights=None, destination='-default', force=False, session=None, apikey=None, verify=None, verbose=False, **kwargs)
Temporal downscale of forecasts.
Convert temporally coarse probabilistic forecasts into granular daily ensembles. For more detail, see the api doc.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
loc |
Location
|
The location to query.
If using a |
required |
variables |
str | list[str]
|
The variables to query, separated by commas or as a |
'temp,precip'
|
date |
str
|
The start date of the time series.
If |
'-today'
|
members |
int
|
The number of ensemble members to download |
50
|
frequency |
str
|
The temporal resolution of the time series, |
'daily'
|
reference_clim |
str
|
Reference period to calculate anomalies |
'salient'
|
debias |
bool
|
If True, debias the data |
False
|
version |
str
|
The model version of the Salient |
'-default'
|
weights |
str
|
The variable that will be used to weight each grid point within a
|
None
|
destination |
str
|
The destination directory for downloaded files. |
'-default'
|
force |
bool
|
If False (default), don't download the data if it already exists |
False
|
session |
Session
|
The session object to use for the request |
None
|
apikey |
str | None
|
The API key to use for the request.
In most cases, this is not needed if a |
None
|
verify |
bool
|
If True (default), verify the SSL certificate |
None
|
verbose |
bool
|
If True (default False) print status messages |
False
|
**kwargs |
Additional arguments to pass to the API |
{}
|
Other Parameters:
Name | Type | Description |
---|---|---|
gdd_base |
int
|
The base temperature for growing degree days |
units |
str
|
US or SI |
Returns:
Type | Description |
---|---|
str | DataFrame
|
str | pd.DataFrame : If only one file was downloaded, return the name of the file.
If multiple files were downloaded, return a table with column |
salientsdk.data_timeseries(loc, variable='temp', field='anom', debias=False, start='1950-01-01', end='-today', format='nc', frequency='daily', destination='-default', force=False, session=None, apikey=None, verify=None, verbose=False, **kwargs)
Get a historical time series of ERA5 data.
This function is a convenience wrapper to the Salient API.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
loc |
Location
|
The location to query.
If using a |
required |
variable |
str | list[str]
|
The variable to query, defaults to |
'temp'
|
field |
str
|
The field to query, defaults to "anom" |
'anom'
|
debias |
bool
|
If True, debias the data to local observations.
Disabled for |
False
|
start |
str
|
The start date of the time series |
'1950-01-01'
|
end |
str
|
The end date of the time series |
'-today'
|
format |
str
|
The format of the response |
'nc'
|
frequency |
str
|
The frequency of the time series |
'daily'
|
destination |
str
|
The directory to download the data to |
'-default'
|
force |
bool
|
If False (default), don't download the data if it already exists |
False
|
session |
Session
|
The session object to use for the request.
If |
None
|
apikey |
str | None
|
The API key to use for the request.
In most cases, this is not needed if a |
None
|
verify |
bool
|
If True (default), verify the SSL certificate |
None
|
verbose |
bool
|
If True (default False) print status messages |
False
|
**kwargs |
Additional arguments to pass to the API |
{}
|
Other Parameters:
Name | Type | Description |
---|---|---|
units |
str
|
|
Returns:
Type | Description |
---|---|
str | DataFrame
|
str | pd.DataFrame:
the file name of the downloaded data. File names are a hash of the query parameters.
When |
salientsdk.hindcast_summary(loc, metric='crps', reference='-auto', season='all', split_set='all', timescale='all', variable='temp', version='-default', interp_method='nearest', destination='-default', force=False, session=None, apikey=None, verify=None, verbose=False, **kwargs)
Get summary of accuracy metrics.
This function is a convenience wrapper to the Salient API.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
loc |
Location
|
The location to query |
required |
metric |
str
|
The accuracy metric to calculate. Defaults to "crps". |
'crps'
|
interp_method |
str
|
The interpolation method to use.
- |
'nearest'
|
reference |
str
|
The reference dataset to compare against. Defaults to "-auto". |
'-auto'
|
season |
str | list[str]
|
Meteorological season to consider. Defaults to "all". May also be a list of strings or a comma-separated string to vectorize the query. Also valid: DJF, MAM, JJA, SON. |
'all'
|
split_set |
str
|
The date range over which to calculate scores.
|
'all'
|
timescale |
str
|
Forecast look-ahead.
- |
'all'
|
variable |
str | list[str]
|
The variable to query, defaults to |
'temp'
|
version |
str | list[str]
|
The model version of the Salient |
'-default'
|
destination |
str
|
The destination directory for downloaded files.
|
'-default'
|
force |
bool
|
If False (default), don't download the data if it already exists |
False
|
session |
Session
|
The |
None
|
apikey |
str | None
|
The API key to use for the request.
In most cases, this is not needed if a |
None
|
verify |
bool
|
Verify the SSL certificate.
Defaults to use get_verify_ssl(), typically set during |
None
|
verbose |
bool
|
If True (default False) print status messages. |
False
|
**kwargs |
Additional arguments to pass to the API |
{}
|
Other Parameters:
Name | Type | Description |
---|---|---|
units |
str
|
|
Returns:
Name | Type | Description |
---|---|---|
str |
str
|
the file name of the downloaded data.
File names are a hash of the query parameters.
When |
salientsdk.geo(loc, variables='elevation', resolution=0.25, format='nc', destination='-default', force=False, session=None, apikey=None, verify=None, verbose=False, **kwargs)
Get static geo-data.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
loc |
Location
|
The location to query.
If using a |
required |
variables |
str
|
The variables to query, defaults to "elevation". Supports a comma separated list or list of variables. |
'elevation'
|
resolution |
float
|
The spatial resolution of the data in degrees. |
0.25
|
format |
str
|
The file format of the response.
Defaults to |
'nc'
|
destination |
str
|
The destination directory for downloaded files. |
'-default'
|
force |
bool
|
If False (default), don't download the data if it already exists |
False
|
session |
Session
|
The session object to use for the request |
None
|
apikey |
str | None
|
The API key to use for the request.
In most cases, this is not needed if a |
None
|
verify |
bool
|
If True (default), verify the SSL certificate |
None
|
verbose |
bool
|
If True (default False) print status messages |
False
|
**kwargs |
Additional arguments to pass to the API |
{}
|
Returns:
Type | Description |
---|---|
str | list[str]
|
str | pd.DataFrame : If only one file was downloaded, return the name of the file.
If multiple files were downloaded, return a table with column |
salientsdk.login(username='username', password='password', apikey=None, verify=None, verbose=False)
Login to the Salient API.
This function is a local convenience wrapper around the Salient API login endpoint. It will use your credentials to create a persistent session you can use to execute API calls.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
username |
str
|
The username to login with |
'username'
|
password |
str
|
The password to login with |
'password'
|
apikey |
str | None
|
The API key to use instead of a login.
If |
None
|
verify |
bool
|
Whether to verify the SSL certificate.
If |
None
|
verbose |
bool
|
Whether to print the response status |
False
|
Returns:
Type | Description |
---|---|
Session | None
|
Session | None: Session object to pass to other API calls.
As a side effect, will also set the default session for
use with |
Geo-Inputs
salientsdk.Location
Define geographical parameters for an API query.
The Salient API defines location by a single latitude/longitude, multiple latitude/longitude pairs in a single location_file, or a polygon defined in a shapefile. This class manages these options.
__init__(lat=None, lon=None, location_file=None, shapefile=None, region=None)
Initialize a Location object.
Only one of the following 4 options should be used at a time: lat/lon, location_file, shapefile, or region.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
lat |
float
|
Latitude in degrees, -90 to 90. |
None
|
lon |
float
|
Longitude in degrees, -180 to 180. |
None
|
location_file |
str | list[str]
|
Path(s) to CSV file(s) with latitude and longitude columns. |
None
|
shapefile |
str | list[str]
|
Path(s) to a shapefile(s) with a polygon defining the location. |
None
|
region |
str | list[str]
|
Accepts continents, countries, or U.S. states (e.g. "usa")
Only available for |
None
|
load_location_file(destination='-default')
Load the location file(s) into a DataFrame.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
destination |
str
|
The directory where the file is located.
Defaults to the default directory via |
'-default'
|
Returns:
Type | Description |
---|---|
GeoDataFrame
|
gpd.GeoDataFrame: The location data in a DataFrame. If multiple files are loaded,
the DataFrames will be concatenated into a single DataFrame with an
additional column location_file suports a variety of column names for latitude and longitude.
This method standardizes them to |
_as_geoframe(geo)
staticmethod
Normalize column names on a DataFrame and convert to a GeoDataFrame.
Regardless of the column names in the input DataFrame, this method
will return a GeoDataFrame with columns lat
,lon
, and name
plot_locations(title=None, weight=None, pad=1.0)
Show location points on a map.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
title |
str
|
The title of the plot. |
None
|
weight |
str
|
The column name in the location file to use to weight the points. |
None
|
pad |
float
|
Adds extent to the lat/lon bounding boxon the map. |
1.0
|
salientsdk.upload_file(file, verbose=True, session=None)
Uploads a geography file to the Salient API.
An interface to to the Salient upload_file API endpoint.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
file |
str
|
the file to upload (e.g. a shapefile or CSV). |
required |
verbose |
bool
|
whether to print status messages. |
True
|
session |
Session
|
the session to use for the upload. |
None
|
salientsdk.upload_bounding_box(north, south, east, west, geoname, destination='-default', force=False, verbose=False, session=None)
Upload a bounding box.
Create and upload a GeoJSON shapefile with a rectangular bounding box
for later use with the shapefile
location argument.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
north |
float
|
Northern extent decimal latitude |
required |
south |
float
|
Southern extent decimal latitude |
required |
east |
float
|
Eastern extent decimal longitude |
required |
west |
float
|
Western extent decimal longitude |
required |
geoname |
str
|
Name of the GeoJSON file and object to create |
required |
destination |
str
|
The destination directory for the generated file |
'-default'
|
force |
bool
|
If the file already exists, don't upload it |
False
|
verbose |
bool
|
Whether to print status messages |
False
|
session |
Session
|
The session object to use for the request |
None
|
Returns:
Name | Type | Description |
---|---|---|
str |
str
|
File name of the GeoJSON file |
salientsdk.upload_shapefile(coords, geoname, destination='-default', force=False, verbose=False, session=None)
Upload a custom shapefile defined by a a list of lat/lon pairs.
This will often be used with Location(shapefile...)
Parameters:
Name | Type | Description | Default |
---|---|---|---|
coords |
list[tuple]
|
List of (longitude, latitude) pairs defining the polygon. |
required |
geoname |
str
|
Name of the GeoJSON file and object to create. |
required |
destination |
str
|
The destination directory for the generated file. |
'-default'
|
force |
bool
|
If True, overwrite the existing file if it exists. |
False
|
verbose |
bool
|
Whether to print status messages. |
False
|
session |
Session
|
The session object to use for the request. |
None
|
Returns:
Name | Type | Description |
---|---|---|
str |
File name of the GeoJSON file. |
salientsdk.upload_location_file(lats, lons, names, geoname, destination='-default', force=False, verbose=False, session=None, **kwargs)
Upload a vector of locations.
Create and upload a CSV file with a list of locations for
later use with the location_file
location argument.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
lats |
list[float] | Series
|
List of decimal latitudes |
required |
lons |
list[float] | Series
|
List of decimal longitudes |
required |
names |
list[str] | Series
|
List of names for the locations |
required |
geoname |
str
|
Name of the CSV file and object to create |
required |
destination |
str
|
The destination directory for the generated file |
'-default'
|
force |
bool
|
When False, if the file already exists don't upload it |
False
|
verbose |
bool
|
If True, print status messages |
False
|
session |
Session
|
The session object to use for the request |
None
|
**kwargs |
Additional columns to include in the CSV file |
{}
|
Returns:
Name | Type | Description |
---|---|---|
str |
str
|
File name of the CSV file |
salientsdk.user_files(destination='-default', session=None, verify=None, verbose=False)
List the location and shape files uploaded by the user.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
destination |
str
|
The destination directory for the resulting JSON file |
'-default'
|
session |
Session
|
The session object to use for the request |
None
|
verify |
bool
|
Whether to verify the SSL certificate.
Defaults to use the value returned by |
None
|
verbose |
bool
|
If True, print the full contents of the file. |
False
|
Returns:
Name | Type | Description |
---|---|---|
str |
str
|
the location of the JSON file containing top-level entries
|
salientsdk.merge_location_data(ds, loc_file)
Merge additional data columns from a location_file into a dataset.
Will add any additional columns from loc_file
to ds
.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
ds |
Dataset
|
A |
required |
loc_file |
str | Location
|
Path to a CSV file containing location data
or a |
required |
Returns:
Type | Description |
---|---|
xr.Dataset: A new |
Utilities
Data Utilities
salientsdk.load_multihistory(files, fields=['vals'])
Load multiple .nc history files and merge them into a single dataset.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
files |
DataFramme
|
Table of the type returned by
|
required |
fields |
list[str]
|
List of fields to extract from the history files.
Useful if when calling |
['vals']
|
Returns:
Type | Description |
---|---|
Dataset
|
xr.Dataset: The merged dataset, where each field and variable is renamed
to |
salientsdk.transpose_hindcast_summary(scores, min_score=0.0, weight_weeks=1.0, weight_months=0.5, weight_quarters=0.25)
Transpose hindcast_summary long to wide, preserving groups.
Transposes the hindcast summary data from a long format to a wide format
where each 'Lead' row becomes a column. Adds a column mean
with a
weighted average of the scores.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
scores |
str | DataFrame
|
The hindcast scores data.
This can be either a file path as a string or a pre-loaded DataFrame
of the type returned by |
required |
min_score |
float
|
Render any scores below this threshold as NA |
0.0
|
weight_weeks |
float
|
Weight for weeks 3-5, defaults to 1.0 |
1.0
|
weight_months |
float
|
Weight for months 2-3, defaults to 0.5 |
0.5
|
weight_quarters |
float
|
Weight for quarters 2-4, defaults to 0.25 |
0.25
|
Returns:
Type | Description |
---|---|
DataFrame
|
pd.DataFrame: The transposed DataFrame with 'Lead' categories as columns. |
Wind Utilities
salientsdk.wind.calc_wind_power_all(met, wspd='wspd', wspd100='wspd100', temp='temp', turbine_model='turbine_model', hub_height='hub_height', elevation='elevation')
Calculate wind power from meteorological data.
This is a convenience function that shears wind to hub height, density-corrects it, then calculates wind power. It operates on a single dataset as a source of the necessary data.
The arguments wspd
, wspd100
, temp
, turbine_model
, hub_height
, and elevation
can be either strings or xr.DataArray
objects. If they are strings, they are assumed
to be keys in the met
dataset.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
met |
Dataset
|
Meteorological data. |
required |
wspd |
str | DataArray
|
Wind speed at hub height. |
'wspd'
|
wspd100 |
str | DataArray
|
Wind speed at 100m. |
'wspd100'
|
temp |
str | DataArray
|
Temperature |
'temp'
|
turbine_model |
str | DataArray
|
Turbine model. |
'turbine_model'
|
hub_height |
str | DataArray
|
Hub height (m). |
'hub_height'
|
elevation |
str | DataArray
|
Elevation above sea level (m). |
'elevation'
|
Returns:
Type | Description |
---|---|
Dataset
|
xr.Dataset: with fields
|
salientsdk.wind.calc_wind_power(wind_speed, turbine_model='default', keep_dims=None)
Calculate power from power curve & density-corrected hub-height wind.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
wind_speed |
DataArray
|
Wind speed at hub height. |
required |
turbine_model |
str | DataArray
|
Turbine model to use.
If a string, call |
'default'
|
keep_dims |
set | None
|
Set of coordinates to preserve in the output.
If |
None
|
Returns:
Type | Description |
---|---|
DataArray
|
xr.DataArray: Wind power in MW. |
salientsdk.wind.correct_wind_density(wspd, dens=1.225, temp=286.0, elev=0.0)
Correct wind speed for air density.
Values dens
, temp
, and elev
can be scalar numbers or DataArray
s with
coordinates compatible with wspd
.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
wspd |
DataArray
|
Wind speed at hub height. |
required |
dens |
DataArray | float
|
Target air density to correct to (kg/m^3). Corrects to sea level air density by default. |
1.225
|
temp |
DataArray | float
|
Temperature (degrees C) |
286.0
|
elev |
DataArray | float
|
Elevation above sea level (m). Corrects to sea level by default. |
0.0
|
Returns:
Type | Description |
---|---|
DataArray
|
xr.DataArray: Wind speed corrected for air density. |
salientsdk.wind.shear_wind(wnd_hi, wnd_lo, hgt_hh, hgt_hi=100.0, hgt_lo=10.0)
Shear wind speed to hub height.
Uses the Power Law to shear wind speed from two heights to a hub height. Will interpolate or extrapolate, as needed.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
wnd_hi |
DataArray
|
Wind speed at height |
required |
wnd_lo |
DataArray
|
Wind speed at height |
required |
hgt_hh |
DataArray
|
Hub height above ground level |
required |
hgt_hi |
float
|
Height above ground level of |
100.0
|
hgt_lo |
float
|
Height above ground level of |
10.0
|
Returns:
Type | Description |
---|---|
DataArray
|
xr.DataArray: Wind speed at hub height, same dimensions as |
salientsdk.wind.get_power_curve(turbine_model='default')
Get a power curve for a specific turbine model.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
turbine_model |
None | str | list[str] | DataArray
|
Turbine model to select.
If None, return all available models.
If a string, return the model with that name.
If string is |
'default'
|
Return
xr.DataArray: Power curve for the selected turbine model(s).
Coordinate wind_speed
is the wind speed at hub height.
Solar Utilities
salientsdk.solar.data_timeseries_solar(loc, start='1950-01-01', end='-today', variable=SOLAR_VARIABLES, debias=False, destination='-default', force=False, session=None, apikey=None, verify=None, verbose=False)
Get a historical time series of pvlib-compatible solar weather inputs.
A convenience wrapper around data_timeseries()
to get solar weather data.
Generates a past weather dataset suitable to pass to run_pvlib_dataset()
.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
loc |
Location
|
The location to query. |
required |
start |
str
|
The start date of the time series |
'1950-01-01'
|
end |
str
|
The end date of the time series |
'-today'
|
variable |
list[str]
|
The variables to download.
Defaults to |
SOLAR_VARIABLES
|
debias |
bool
|
If |
False
|
destination |
str
|
The directory to download the data to |
'-default'
|
force |
bool
|
If False (default), don't download the data if it already exists |
False
|
session |
Session
|
The session object to use for the request.
If |
None
|
apikey |
str | None
|
The API key to use for the request.
In most cases, this is not needed if a |
None
|
verify |
bool
|
If True (default), verify the SSL certificate |
None
|
verbose |
bool
|
If True (default False) print status messages and check for NaN. |
False
|
Returns:
Type | Description |
---|---|
Dataset
|
xr.Dataset: An hourly dataset with the following variables: - temp: temperature (C) - wspd: wind speed (m/s) - tsi: total solar irradiance, aka Global Horizontal Irradiance (W/m^2) - dhi: diffuse horizontal irradiance (W/m^2) - dni: direct normal irradiance (W/m^2) - elevation: elevation (m) |
salientsdk.solar.downscale_solar(loc, date='-today', members=50, variables=SOLAR_VARIABLES, destination='-default', force=False, session=None, apikey=None, verify=None, verbose=False, **kwargs)
Get a forecast time series of pvlib-compatible solar weather inputs.
A convenience wrapper around downscale()
to get solar weather data.
Generates a future weather dataset suitable to pass to run_pvlib_dataset()
.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
loc |
Location
|
The location to query. |
required |
date |
str
|
The start date of the time series.
If |
'-today'
|
members |
int
|
The number of ensemble members to download |
50
|
variables |
list[str]
|
The variables to download.
Defaults to |
SOLAR_VARIABLES
|
destination |
str
|
The directory to download the data to |
'-default'
|
force |
bool
|
If False (default), don't download the data if it already exists |
False
|
session |
Session
|
The session object to use for the request.
If |
None
|
apikey |
str | None
|
The API key to use for the request.
In most cases, this is not needed if a |
None
|
verify |
bool
|
If True (default), verify the SSL certificate |
None
|
verbose |
bool
|
If True (default False) print status messages and check for NaN |
False
|
**kwargs |
Additional arguments to pass to |
{}
|
Other Parameters:
Name | Type | Description |
---|---|---|
reference_clim |
str
|
Reference period to calculate anomalies. |
version |
str
|
The model version of the Salient |
debias |
bool
|
Defaults to |
Returns:
Type | Description |
---|---|
Dataset
|
xr.Dataset: An hourly dataset with the following variables: - temp: temperature (C) - wspd: wind speed (m/s) - tsi: total solar irradiance, aka Global Horizontal Irradiance (W/m^2) - dhi: diffuse horizontal irradiance (W/m^2) - dni: direct normal irradiance (W/m^2) - elevation: elevation (m) |
salientsdk.solar.run_pvlib_dataset(weather, timedim='time', model_chain=None, nan_check=0.01)
Execute pvlib multiple times on a weather-inputs dataset.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
weather |
Dataset | str
|
Solar meteorological inputs,
of the form returned by |
required |
timedim |
str
|
The name of the time dimension |
'time'
|
model_chain |
ModelChain
|
The model chain(s) to use.
If |
None
|
nan_check |
float
|
issue a warning if any month in the dataset contains
more than this ratio of NaNs. Suppress with |
0.01
|
Returns:
Type | Description |
---|---|
Dataset
|
xr.Dataset: A dataset with matching coordinates to
|
Hydrological Utilities
salientsdk.hydro.calc_swe(met, timedim='forecast_day')
Call the snow17
model for each location and ensemble member.
Acknowledgements: Based on Anderson (2006) and Mark Raleigh's matlab code.
Primary Citations: 1. Anderson, E. A. (1973), National Weather Service River Forecast System Snow Accumulation and Ablation Model, NOAA Tech. Memo. NWS HYDro-17, 217 pp., U.S. Dep. of Commer., Silver Spring, Md. 2. Anderson, E. A. (1976), A point energy and mass balance model of a snow cover, NOAA Tech. Rep. 19, 150 pp., U.S. Dep. of Commer., Silver Spring, Md.
Written by Joe Hamman April, 2013
Parameters:
Name | Type | Description | Default |
---|---|---|---|
met |
Dataset
|
a dataset containing |
required |
timedim |
str
|
the name of the time dimension in |
'forecast_day'
|
Returns:
Type | Description |
---|---|
DataArray
|
xr.DataArray: a dataset containing snow water equivalent (mm) |
Validation Utilities
salientsdk.skill.crps(observations, forecasts, qnt_dim='quantiles')
Calculate Continuous Ranked Probability Score.
CRPS is used to calculate the skill of a probabilistic forecast. CRPS is defined as 2 times the integral of the quantile loss over the distribution. Zero CRPS indicates a perfect forecast.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
observations |
Dataset | DataArray | str
|
|
required |
forecasts |
Dataset | DataArray | str | list[str] | DataFrame
|
|
required |
qnt_dim |
str
|
Name of the quantile dimension in the forecast array.
Defaults to |
'quantiles'
|
Returns:
Type | Description |
---|---|
Dataset
|
xr.Dataset: The CRPS of the |
salientsdk.skill.align_daily_obs_to_lead(observations, forecasts, timescale='all')
Convert daily observations to match forecasts denominated by a coarse lead time.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
observations |
str | Dataset | DataArray
|
Daily observed values with coordinate |
required |
forecasts |
str | Dataset | DataArray
|
The forecasted values with coordinate |
required |
timescale |
str | Iterable[str]
|
The forecast period of the forecast, corresponding to data variables
|
'all'
|
Returns:
Type | Description |
---|---|
Dataset | DataArray
|
xr.Dataset | xr.DataArray: An aggregated version of |
Observed Data Utilities
:: salientsdk.observed.make_observed_ds
Constants and Variables
salientsdk.get_model_version(version='-default')
Get the current default model version.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
version |
str
|
If |
'-default'
|
Returns:
Name | Type | Description |
---|---|---|
str |
str
|
The current model version |
salientsdk.set_model_version(version)
Set the default model version.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
version |
str
|
The model version to set |
required |
salientsdk.get_current_session()
Get the current session.
All calls to the Salient API have a session
argument
that defaults to None
. If session is not passed to the
function, the api call will use the output of this function.
Returns:
Type | Description |
---|---|
Session
|
requests.Session: The current session if one was set via
|
salientsdk.set_current_session(session)
Set the current session.
This function is called internally as a side effect of
login()
. In most cases, users will never need
to call it explicitly.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
session |
Session | None
|
The session that will be
returned by |
required |
salientsdk.get_file_destination(destination='-default', make=True)
Get the default destination for downloaded files.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
destination |
str
|
If |
'-default'
|
make |
bool
|
If True, create the directory if it doesn't exist. |
True
|
Returns:
Name | Type | Description |
---|---|---|
str |
str
|
The destination for downloaded files. |
salientsdk.set_file_destination(destination='salient_data', force=False)
Set the default destination for downloaded files.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
destination |
str
|
The default destination for downloaded files. |
'salient_data'
|
force |
bool
|
If True (default False), clear the cached contents of the destination directory. This will force all subsequent downloads to re-download fresh versions of the files. |
False
|
Returns:
Name | Type | Description |
---|---|---|
str |
str
|
The destination that was set by the function. |
Copyright 2024 Salient Predictions