Different methods for working with forecasts that are currently populating the API.
Spire Weather prioritizes the quickest possible delivery of the latest global forecast data.
As a result, forecasts with the most recent issuance time in the API can be incomplete while remaining lead times are still being populated.
For an overview of Spire's forecast refresh rates and the difference between issuance times and lead times, please see here.
There are certain use-cases where it is critical to always have the most recent forecast data available at the API, which is why Spire intentionally issues forecasts while they are processing rather than waiting for them to complete.
That being said, there are other use-cases where it can be more important to always have a complete forecast issuance.
In these situations, we recommend that our clients do one of the following:
- Wait for the latest forecast to finish populating the API
- Or explicitly specify the previous issuance time through the API
For the second option, Spire APIs provide an issuance_time parameter.
Here is an example of the Weather Forecast Point API being used to specify an explicit issuance time:
https://api.wx.spire.com/forecast/point?lat=42.32717&lon=-91.62078&issuance_time=2020-04-28T00:00:00+00:00
Please note that if you would like to test this yourself, you will need to update the issuance time to a more recent one that is available in the API at the time of your request.
For users who would prefer to wait for the latest forecast to finish populating the API, they simply need to checks the size of the returned data array against the specified time bundle:
def get_expected_forecast_size(time_bundle):
if time_bundle == 'short_range_high_freq':
# The short range, high time frequency bundle
# contains data for 25 lead times (or steps)
# representing forecasts at 1 hour intervals from 0 to 24 hours.
return 25
elif time_bundle == 'medium_range_std_freq':
# The medium range, standard time frequency bundle
# contains data for 29 lead times (or steps)
# representing forecasts at six hour intervals from 0 to 168 hours.
return 29
elif time_bundle == 'medium_range_high_freq':
# The medium range, high time frequency bundle
# contains data for 49 lead times (or steps)
# representing forecasts at 1 hour intervals from 0 to 24 hours,
# as well as 6 hour intervals up to 168 hours.
return 49
Code Sample
Here is a code sample using the medium_range_std_freq time bundle with the Weather Forecast File API that will only download forecast files once the full forecast has finished populating the API.