def test_generate_observation_figure_components(
        validated_observation_values, ac_power_observation_metadata_label):
    out = timeseries.generate_observation_figure(
        ac_power_observation_metadata_label,
        validated_observation_values,
        return_components=True)
    assert '<script' in out[0]
    assert '<div' in out[1]
Example #2
0
def timeseries_adapter(type_, metadata, json_value_response):
    metadata = deepcopy(metadata)
    # ignores any modeling parameters as they aren't need for this
    if 'site' in metadata:
        site = datamodel.Site.from_dict(metadata['site'], raise_on_extra=False)
        metadata['site'] = site
    elif 'aggregate' in metadata:
        # Patch aggregates so data model doesn't throw an error. We don't
        # need to load all of the observations when plotting forecasts.
        metadata['aggregate']['observations'] = []
    if type_ == 'forecast':
        obj = datamodel.Forecast.from_dict(metadata)
        data = io_utils.json_payload_to_forecast_series(json_value_response)
        return timeseries.generate_forecast_figure(obj,
                                                   data,
                                                   return_components=True,
                                                   limit=None)
    elif type_ == 'observation':
        obj = datamodel.Observation.from_dict(metadata)
        data = io_utils.json_payload_to_observation_df(json_value_response)
        return timeseries.generate_observation_figure(obj,
                                                      data,
                                                      return_components=True,
                                                      limit=None)
    elif type_ == 'probabilistic_forecast':
        cvs = []
        for constant_value in metadata['constant_values']:
            cv_dict = metadata.copy()
            cv_dict.update(constant_value)
            cvs.append(
                datamodel.ProbabilisticForecastConstantValue.from_dict(
                    cv_dict))
        metadata['constant_values'] = cvs
        obj = datamodel.ProbabilisticForecast.from_dict(metadata,
                                                        raise_on_extra=False)
        return timeseries.generate_probabilistic_forecast_figure(
            obj, json_value_response)
    else:
        # remove observations, we aren't using them for plotting aggregates
        metadata['observations'] = []
        obj = datamodel.Aggregate.from_dict(metadata, raise_on_extra=False)
        data = io_utils.json_payload_to_observation_df(json_value_response)
        return timeseries.generate_observation_figure(obj,
                                                      data,
                                                      return_components=True,
                                                      limit=None)
def test_generate_observation_figure_missing_data(
        validated_observation_values, ac_power_observation_metadata):
    validated_observation_values.iloc[1] = [None, None]
    out = timeseries.generate_observation_figure(ac_power_observation_metadata,
                                                 validated_observation_values,
                                                 return_components=True)
    assert '<script' in out[0]
    assert 'MISSING' in out[0]
    assert '<div' in out[1]
Example #4
0
def timeseries_adapter(type_, metadata, json_value_response):
    metadata = deepcopy(metadata)
    # ignores any modeling parameters as they aren't need for this
    site = datamodel.Site.from_dict(metadata['site'], raise_on_extra=False)
    metadata['site'] = site
    if type_ == 'forecast':
        obj = datamodel.Forecast.from_dict(metadata)
        data = io_utils.json_payload_to_forecast_series(json_value_response)
        return timeseries.generate_forecast_figure(obj,
                                                   data,
                                                   return_components=True)
    else:
        obj = datamodel.Observation.from_dict(metadata)
        data = io_utils.json_payload_to_observation_df(json_value_response)
        return timeseries.generate_observation_figure(obj,
                                                      data,
                                                      return_components=True)
def test_generate_observation_figure_empty(ghi_observation_metadata, rc):
    assert timeseries.generate_observation_figure(
        ghi_observation_metadata, pd.DataFrame(), return_components=rc) is None
def test_generate_observation_figure(validated_observation_values,
                                     ac_power_observation_metadata_label):
    out = timeseries.generate_observation_figure(
        ac_power_observation_metadata_label, validated_observation_values)
    assert isinstance(out, bokeh.models.Column)