Forecast

Configuration

You can configure the endpoint directly or utilize env variables.

export PSW_FORECAST_SITE="http://base.forecast.url"
export PSW_FORECAST_USER="3ScaleUsername"
export PSW_FORECAST_PASSWORD="3ScalePassword"

Sources

Used to create and update forecast sources.

from skywise.forecast import Source

# Create a Source
source = Source()
source.name = 'tropical-gfe'
source.description = 'WeatherOps AWIPS II GFE tropical forecast.'
source.platform_source_key = 'tropical-gfe'
source.save()

# Update a Source
source.description = 'WeatherOps GFE Tropical Forecast'
source.save()

# Find all Sources or by a platform source key
sources = Source.find()
tropical_source = Source.find(platform_source_key='tropical-gfe').pop()

# Delete a source
tropical_source.destroy()

Adding and Removing Parameters

Each Source has a set of forecast products. A forecast must include parameters for each of these to be considered ‘complete’.

from skywise.platform import Product

# Add a Forecast Product
forecast_product = Product.find('my-24-hr-forecast-product-uuid')
source.add_forecast_product(forecast_product)

# Retrieve All Forecast Products for a Source
forecast_products = source.get_forecast_products()

# Delete a Source's Forecast Products
[forecast_product.destroy() for forecast_product in forecast_products]

Forecasts

A Forecast is a collection of parameters for which we have forecast data. Forecasts can be created from Sources.

import arrow

init_time = arrow.get().datetime
forecasts = source.get_forecasts(initTime=init_time)
if len(forecasts) is 0:
    forecast = source.create_forecast(init_time)

# Find Forecasts by Status
from skywise.forecast import STATUS_INCOMPLETE
pending_forecasts = source.get_forecasts(status=STATUS_INCOMPLETE)

Adding and Removing Forecast Parameters

Forecast Parameters allow us to link a Forecast in the Forecast API to a particular forecast in Platform.

from skywise.platform import Product

product = product.find('my-24-hr-forecast-product-uuid')
platform_forecast = product.get_forecast('platform-forecast-uuid')
forecast.add_parameter(platform_forecast)

Delete a Forecast

Deleting a forecast will also delete all of its associated forecast parameters.

forecast.destroy()