Python

Installation

Install with pip:

pip install skywise-model

Configuration

You have two options for configuration. First, you can set environment variables:

export SKYWISE_MODEL_APP_ID='your-app-id'
export SKYWISE_MODEL_APP_KEY='your-app-key'

You can also directly configure the base resource:

from skywisemodel import ModelApiResource

ModelApiResource.set_user('your-app-id')
ModelApiResource.set_password('your-app-key')

Try It Out

To test out the library, try querying the latest list of models:

from skywisemodel import Model

models = Model.find()
for model in models:
    print "%s - %s" % (model.name, model.description)

Resources

The library consists of several resources that have methods that correspond to queries to the API.

Models

The base resource for querying the API is the Model class.

Available class methods:

Available instance methods:

Model.find (id_=None)

Returns a single Model object if a model ID or name is passed, or a list of all Models otherwise.

Request Syntax

from skywisemodel import Model

weatherops_global = Model.find('weatherops-global')
all_models = Model.find()

Parameters

  • id_ (String:optional) – the id or name of the Model.

get_forecasts ()

Returns a current list of Forecasts for the Model.

Request Syntax

from skywisemodel import Model

weatherops_global = Model.find('weatherops-global')
forecasts = weatherops_global.get_forecasts()

get_forecast_by_id (id_)

Returns a single Forecast object for the given ID.

Request Syntax

from skywisemodel import Model

weatherops_global = Model.find('weatherops-global')
forecast = weatherops_global.get_forecast_by_id('my-known-forecast-id')

print forecast.id, forecast.initTime

Parameters

  • id_ (String:required) – the id of the Forecast.

Variables

Available methods:

get_timeseries (latitude, longitude)

Returns the Timeseries for the given latitude and longitude of the Variable.

Request Syntax

from skywisemodel import Model

weatherops_global = Model.find('weatherops-global')
latest_forecast = weatherops_global.get_forecasts().pop()
variable = latest_forecast.get_variables().pop()
timeseries = variable.get_timeseries(35.0, -97.0)

for item in timeseries.series:
    print item.value, item.validTime, timeseries.unit['label']

Parameters

  • latitude (float:required) – the latitude of your time series request.
  • longitude (float:required) – the longitude of your time series request.