Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions docs/sphinx/source/whatsnew/v0.4.5.txt
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@ Enhancements

* Added irradiance.dni method that determines DNI from GHI and DHI and corrects
unreasonable DNI values during sunrise/sunset transitions
* ForecastModel will now only connect to the Unidata server when necessary,
rather than when the object is created. This supports offline work
and speeds up analysis of previously downloaded data.


Contributors
Expand Down
13 changes: 11 additions & 2 deletions pvlib/forecast.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,12 +118,16 @@ def __init__(self, model_type, model_name, set_type):
self.model_type = model_type
self.model_name = model_name
self.set_type = set_type
self.connected = False

def connect_to_catalog(self):
self.catalog = TDSCatalog(self.catalog_url)
self.fm_models = TDSCatalog(self.catalog.catalog_refs[model_type].href)
self.fm_models = TDSCatalog(
self.catalog.catalog_refs[self.model_type].href)
self.fm_models_list = sorted(list(self.fm_models.catalog_refs.keys()))

try:
model_url = self.fm_models.catalog_refs[model_name].href
model_url = self.fm_models.catalog_refs[self.model_name].href
except ParseError:
raise ParseError(self.model_name + ' model may be unavailable.')

Expand All @@ -137,6 +141,7 @@ def __init__(self, model_type, model_name, set_type):

self.datasets_list = list(self.model.datasets.keys())
self.set_dataset()
self.connected = True

def __repr__(self):
return '{}, {}'.format(self.model_name, self.set_type)
Expand Down Expand Up @@ -224,6 +229,10 @@ def get_data(self, latitude, longitude, start, end,
forecast_data : DataFrame
column names are the weather model's variable names.
"""

if not self.connected:
self.connect_to_catalog()

if vert_level is not None:
self.vert_level = vert_level

Expand Down