Python ====== Installation ------------ Install with pip: .. code-block:: bash pip install skywise-model Configuration ------------- You have two options for configuration. First, you can set environment variables: .. code-block:: bash export SKYWISE_MODEL_APP_ID='your-app-id' export SKYWISE_MODEL_APP_KEY='your-app-key' You can also directly configure the base resource: .. code-block:: python 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: .. code-block:: python 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: - `Model.find`_ () Available instance methods: - `get_forecasts`_ () - `get_forecast_by_id`_ () .. _`Model.find`: **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** .. code-block:: python 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`: **get_forecasts** () Returns a current list of Forecasts for the Model. **Request Syntax** .. code-block:: python from skywisemodel import Model weatherops_global = Model.find('weatherops-global') forecasts = weatherops_global.get_forecasts() .. _`get_forecast_by_id`: **get_forecast_by_id** (*id_*) Returns a single Forecast object for the given ID. **Request Syntax** .. code-block:: python 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`_ () .. _`get_timeseries`: **get_timeseries** (*latitude, longitude*) Returns the Timeseries for the given latitude and longitude of the Variable. **Request Syntax** .. code-block:: python 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.