Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
9d80c28
remove non-reporting sites
lboeman May 12, 2020
4be09a7
temp commit for rebase
lboeman May 12, 2020
5990695
add reference obs json files to gitignore
lboeman May 12, 2020
5098c74
declare pv srml sites and obs in json
lboeman May 13, 2020
03d5d35
add description of reference_observation system
lboeman May 13, 2020
97b55ce
edits, add note about API keys
lboeman May 13, 2020
c3f5b1d
add tests for new code
lboeman May 13, 2020
8778278
add missing timezone field in json, differentiate between 15 and 30 d…
lboeman May 14, 2020
3d49fce
more test coverage
lboeman May 14, 2020
1d41714
Update docs/source/reference-observations.rst
lboeman May 15, 2020
23b59ab
Update docs/source/reference-observations.rst
lboeman May 15, 2020
e635af5
Update docs/source/reference-observations.rst
lboeman May 15, 2020
709cde3
Update docs/source/whatsnew/1.0.0rc1.rst
lboeman May 15, 2020
ccd603b
Update docs/source/whatsnew/1.0.0rc1.rst
lboeman May 15, 2020
c1bbd58
Update docs/source/reference-observations.rst
lboeman May 15, 2020
f4e82cb
update reference obs docs, fix build warnings, reference classes in s…
lboeman May 15, 2020
4e5ce66
fix mislabeled and broken tests
lboeman May 20, 2020
00806ad
flake8
lboeman May 20, 2020
5059a65
factor out json modeling params loading to common
lboeman May 27, 2020
24ea737
fix rebase error
lboeman May 27, 2020
dd4c693
use inspect to specify file relative to executing test
lboeman May 27, 2020
4604136
exclude reference obs test data from gitignore
lboeman May 27, 2020
d024d51
change name of non-plant test
lboeman May 27, 2020
647c88a
replace extra_parameters update in parameter update function
lboeman May 27, 2020
ab34a16
flake8
lboeman May 27, 2020
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 .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,9 @@ venv.bak/
.vscode/

*.json
!solarforecastarbiter/io/reference_observations/*.json
!solarforecastarbiter/io/reference_observations/tests/data/*.json

*.html
!solarforecastarbiter/reports/templates/*.html
*.md
Expand Down
1 change: 1 addition & 0 deletions docs/source/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ for more information about the Solar Forecast Arbiter project.

installation
contributing
reference-observations
reference-forecasts
api
cli
Expand Down
149 changes: 149 additions & 0 deletions docs/source/reference-observations.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,149 @@
.. curentmodule: solarforecastarbiter.io.reference_observations

######################
Reference Observations
######################

Overview
========

The Solar Forecast Arbiter imports reference observation data from multiple
measurement networks. All of the logic for creating the appropriate Solar
Forecast Arbiter sites and observations and updating observations with new data
from the network can be found in the
:py:mod:`solarforecastarbiter.io.reference_observations` subpackage. Code for
retrieving data from the network's APIs are spread between the
:py:mod:`solarforecastarbiter.io.fetch` subpackage, and the
`pvlib python <https://pvlib-python.readthedocs.io/en/stable/index.html>`_ *iotools*
module.

A list of these networks and their Solar Forecast Arbiter modules can be found
in the `Available Network Handlers`_ section. A map of all of the sites
available in the reference dataset can be found on the
`Solar Forecast Arbiter project website <https://solarforecastarbiter.org/referencedata/>`_.


Structure
=========
The :py:mod:`solarforecastarbiter.io.reference_observations` subpackage
contains python modules and data files in JSON and CSV format.

Data Files
----------
* `sfa_reference_sites.csv`
The master list of reference sites. See the comment at the top of this file
for descriptions of its fields. The file contains extra fields that are not
found in the Solar Forecast Arbiter API schema for Sites. These fields are
for use with the source network's API and are stored in the
`extra_parameters` field when the site is created for use in subsequent
updates.

* `<network>_reference_sites.json`
Network-specific files containing site and observation metadata in the Solar
Forecast Arbiter API's JSON format. These are used when the master CSV does
not contain all of the columns needed to accurately define a site or
observation.

Modules
-------
* :py:mod:`solarforecastarbiter.io.reference_observations.reference_data`
This module coordinates the initialization and update process. It also
contains the `NETWORKHANDLER_MAP` dictionary, which maps network names to
the correct `Network Handlers`_. The functions in the module are utilized by
the CLI `referencedata` command.

* :py:mod:`solarforecastarbiter.io.reference_observations.common`
The `common` module contains utility functions for use throughout the
`reference_data` subpackage. It has useful functions for converting
external data into Solar Forecast Arbiter Datamodel objects and
network-agnostic utilities for preparing and posting data to the Solar
Forecast Arbiter API. Most `Network Handlers`_ rely heavily on these
functions.

Network Handlers
****************
Network Handlers are network specific modules that implement a handful of
functions with a common interface. See
:py:mod:`solarforecastarbiter.io.reference_observations.surfrad` for an
example.

The required network handler functions are:

* `initialize_site_observations(api, site)`
Create an observation at the site for each variable available from the
network.

* api: :py:class:`solarforecastarbiter.io.api.APISession`
* site: :py:class:`solarforecastarbiter.datamodel.Site`


* `initialize_site_forecasts(api, site)`
Create a forecast for each observation at the site.

* api: :py:class:`solarforecastarbiter.io.api.APISession`
* site: :py:class:`solarforecastarbiter.datamodel.Site`


* `update_observation_data(api, sites, observations, start, end)`
Retrieve data from the network then format and post it to each observation
at the site.

* api: :py:class:`solarforecastarbiter.io.api.APISession`
* sites: list of :py:class:`solarforecastarbiter.datamodel.Site`
* observations: list of :py:class:`solarforecastarbiter.datamodel.Observation`
* start: datetime
* end: datetime


* (optional) `adjust_site_parameters(site)`
In instances where the master site CSV does not contain enough metadata about
the site, (e.g. when a PV plant requires `modeling_parameters`) this function
may be used to update the site metadata before it is posted to the API.

* site: dict


Available Network Handlers
^^^^^^^^^^^^^^^^^^^^^^^^^^
* SURFRAD: NOAA Surface Radiation Budget Network
https://www.esrl.noaa.gov/gmd/grad/surfrad/

:py:mod:`solarforecastarbiter.io.reference_observations.surfrad`

* SOLRAD: NOAA SOLRAD Network
https://www.esrl.noaa.gov/gmd/grad/solrad/index.html

:py:mod:`solarforecastarbiter.io.reference_observations.solrad`

* CRN: NOAA U.S. Climate Reference Network
https://www.ncdc.noaa.gov/crn/

:py:mod:`solarforecastarbiter.io.reference_observations.crn`

* NREL MIDC: National Renewable Energy Laboratory Measurement and Instrumentation Data Center
https://midcdmz.nrel.gov/

:py:mod:`solarforecastarbiter.io.reference_observations.midc`

* UO SRML: University of Oregon Solar Radiation Monitoring Laboratory
http://solardat.uoregon.edu/

:py:mod:`solarforecastarbiter.io.reference_observations.srml`

* DOE RTC: DOE Regional Test Centers for Solar Technologies\*
https://pv-dashboard.sandia.gov/

:py:mod:`solarforecastarbiter.io.reference_observations.rtc`

* DOE ARM: DOE Atmospheric Radiation Measurement\*
https://www.arm.gov/

:py:mod:`solarforecastarbiter.io.reference_observations.arm`

* NREL PVDAQ: National Renewable Energy Laboratory PV Data Acquisition\*
https://developer.nrel.gov/docs/solar/pvdaq-v3/

:py:mod:`solarforecastarbiter.io.reference_observations.pvdaq`

\* Requesting data from these networks requires a valid api key for their
associated api.
4 changes: 4 additions & 0 deletions docs/source/whatsnew/1.0.0rc1.rst
Original file line number Diff line number Diff line change
Expand Up @@ -49,13 +49,17 @@ Enhancements
'DAYTIME INTERPOLATED VALUES'``. (:issue:`124`)
* A public Docker image is available, and Github Actions use this image for
continuous integration tests (:pull:`446`)
* Adjusted University of Oregon Solar Radiation Measurment Laboratory (UO SRML)
to include available PV power data. (:pull:`442`)

Bug fixes
~~~~~~~~~
* Fix incorrect ordering of months and weekdays in metrics plots.
(:issue:`428`) (:pull:`430`)
* Ensure data is sorted from reference data sources before slicing and
posting to the API (:pull:`435`)
* Remove UO SMRL sites from reference dataset that have not reported recent
data. (:issue:`436`) (:pull:`442`)


Contributors
Expand Down
29 changes: 29 additions & 0 deletions solarforecastarbiter/io/reference_observations/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -629,3 +629,32 @@ def create_forecasts(api, site, variables, templates):
persist_created = create_persistence_forecasts(
api, site, variables, nwp_templates)
return nwp_created + persist_created


def apply_json_site_parameters(json_sitefile, site):
"""Updates site metadata with modeling parameters found in a json file.

Parameters
----------
json_sitefile: str
Absolute path of a json file with a 'sites' key containing a list of
sites in the Solar Forecast Arbiter JSON format.
site: dict

Returns
-------
dict
Copy of inputs plus a new key 'modeling_parameters'.
"""
with open(json_sitefile) as fp:
sites_metadata = json.load(fp)['sites']
site_api_id = str(site['extra_parameters']['network_api_id'])
for site_metadata in sites_metadata:
site_extra_params = json.loads(site_metadata['extra_parameters'])
if str(site_extra_params['network_api_id']) == site_api_id:
site_out = site.copy()
site_out['modeling_parameters'] = site_metadata[
'modeling_parameters']
site_out['extra_parameters'].update(site_extra_params)
return site_out
return site
12 changes: 1 addition & 11 deletions solarforecastarbiter/io/reference_observations/pvdaq.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,17 +41,7 @@ def adjust_site_parameters(site):
--------
solarforecastarbiter.io.reference_observations.site_df_to_dicts
"""
with open(DEFAULT_SITEFILE) as fp:
sites_metadata = json.load(fp)['sites']
site_api_id = int(site['extra_parameters']['network_api_id'])
for site_metadata in sites_metadata:
site_extra_params = json.loads(site_metadata['extra_parameters'])
if site_extra_params['network_api_id'] == site_api_id:
site_out = site.copy()
site_out['modeling_parameters'] = site_metadata[
'modeling_parameters']
site_out['extra_parameters'].update(site_extra_params)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

missing from the combined function

return site_out
return common.apply_json_site_parameters(DEFAULT_SITEFILE, site)


def initialize_site_observations(api, site):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,25 +26,22 @@
#
interval_length,name,latitude,longitude,elevation,network_api_id,network_api_abbreviation,timezone,attribution,network
1,Seattle UW WA,47.653999999999996,-122.309,70,94291.0,ST,Etc/GMT+5,"Peterson, J., and Vignola, F., 2017: Structure of a Comprehensive Solar Radiation Dataset. Proceedings of the ASES National Solar Conference 2017. doi: 10.18086/solar.2017.07.02",UO SRML
1,Ashland OR,42.19,-122.7,595,94040.0,AS,Etc/GMT+8,"Peterson, J., and Vignola, F., 2017: Structure of a Comprehensive Solar Radiation Dataset. Proceedings of the ASES National Solar Conference 2017. doi: 10.18086/solar.2017.07.02",UO SRML
1,Ashland OR PV,42.19,-122.7,595,94040.0,AS,Etc/GMT+8,"Peterson, J., and Vignola, F., 2017: Structure of a Comprehensive Solar Radiation Dataset. Proceedings of the ASES National Solar Conference 2017. doi: 10.18086/solar.2017.07.02",UO SRML
1,UO Solar Awning Eugene OR,44.05,-123.07,150,94255.0,AW,Etc/GMT+8,"Peterson, J., and Vignola, F., 2017: Structure of a Comprehensive Solar Radiation Dataset. Proceedings of the ASES National Solar Conference 2017. doi: 10.18086/solar.2017.07.02",UO SRML
1,Kalapuya High School OR,45.0,-120.0,0,94259.0,KA,Etc/GMT+8,"Peterson, J., and Vignola, F., 2017: Structure of a Comprehensive Solar Radiation Dataset. Proceedings of the ASES National Solar Conference 2017. doi: 10.18086/solar.2017.07.02",UO SRML
1,Kalapuya High School OR PV,45.0,-120.0,0,94259.0,KA,Etc/GMT+8,"Peterson, J., and Vignola, F., 2017: Structure of a Comprehensive Solar Radiation Dataset. Proceedings of the ASES National Solar Conference 2017. doi: 10.18086/solar.2017.07.02",UO SRML
1,Salem OR,44.92100000000001,-123.01799999999999,62,94806.0,SA,Etc/GMT+8,"Peterson, J., and Vignola, F., 2017: Structure of a Comprehensive Solar Radiation Dataset. Proceedings of the ASES National Solar Conference 2017. doi: 10.18086/solar.2017.07.02",UO SRML
1,Portland OR PV,45.51,-122.69,70,94808.0,PS,Etc/GMT+8,"Peterson, J., and Vignola, F., 2017: Structure of a Comprehensive Solar Radiation Dataset. Proceedings of the ASES National Solar Conference 2017. doi: 10.18086/solar.2017.07.02",UO SRML
1,Portland OR PV 15 deg tilt,45.51,-122.69,70,94808.0(15),PS,Etc/GMT+8,"Peterson, J., and Vignola, F., 2017: Structure of a Comprehensive Solar Radiation Dataset. Proceedings of the ASES National Solar Conference 2017. doi: 10.18086/solar.2017.07.02",UO SRML
1,Portland OR PV 30 deg tilt,45.51,-122.69,70,94808.0,PS,Etc/GMT+8,"Peterson, J., and Vignola, F., 2017: Structure of a Comprehensive Solar Radiation Dataset. Proceedings of the ASES National Solar Conference 2017. doi: 10.18086/solar.2017.07.02",UO SRML
1,Cheney WA,47.49,-117.589,777,94158.0,CY,Etc/GMT+8,"Peterson, J., and Vignola, F., 2017: Structure of a Comprehensive Solar Radiation Dataset. Proceedings of the ASES National Solar Conference 2017. doi: 10.18086/solar.2017.07.02",UO SRML
1,Dillon MT,45.21,-112.64,1590,94145.0,DI,Etc/GMT+8,"Peterson, J., and Vignola, F., 2017: Structure of a Comprehensive Solar Radiation Dataset. Proceedings of the ASES National Solar Conference 2017. doi: 10.18086/solar.2017.07.02",UO SRML
1,Eugene OR,44.05,-123.07,150,94255.0,EU,Etc/GMT+8,"Peterson, J., and Vignola, F., 2017: Structure of a Comprehensive Solar Radiation Dataset. Proceedings of the ASES National Solar Conference 2017. doi: 10.18086/solar.2017.07.02",UO SRML
1,Burns OR,43.52,-119.02,1265,94170.0,BU,Etc/GMT+8,"Peterson, J., and Vignola, F., 2017: Structure of a Comprehensive Solar Radiation Dataset. Proceedings of the ASES National Solar Conference 2017. doi: 10.18086/solar.2017.07.02",UO SRML
5,Aberdeen ID,42.95,-112.78,1433,94174.0,AB,Etc/GMT+8,"Peterson, J., and Vignola, F., 2017: Structure of a Comprehensive Solar Radiation Dataset. Proceedings of the ASES National Solar Conference 2017. doi: 10.18086/solar.2017.07.02",UO SRML
1,Silver Lake OR,43.12,-121.06,1355,94249.0,SL,Etc/GMT+8,"Peterson, J., and Vignola, F., 2017: Structure of a Comprehensive Solar Radiation Dataset. Proceedings of the ASES National Solar Conference 2017. doi: 10.18086/solar.2017.07.02",UO SRML
1,Bend OR,44.06,-121.31,1124,94807.0,BD,Etc/GMT+8,"Peterson, J., and Vignola, F., 2017: Structure of a Comprehensive Solar Radiation Dataset. Proceedings of the ASES National Solar Conference 2017. doi: 10.18086/solar.2017.07.02",UO SRML
15,Moab UT,38.58,-109.54,1000,94102.0,MO,Etc/GMT+8,"Peterson, J., and Vignola, F., 2017: Structure of a Comprehensive Solar Radiation Dataset. Proceedings of the ASES National Solar Conference 2017. doi: 10.18086/solar.2017.07.02",UO SRML
15,Green River WY,41.46,-109.44,1000,94101.0,GR,Etc/GMT+8,"Peterson, J., and Vignola, F., 2017: Structure of a Comprehensive Solar Radiation Dataset. Proceedings of the ASES National Solar Conference 2017. doi: 10.18086/solar.2017.07.02",UO SRML
1,Bend OR PV,44.06,-121.31,1124,94807.0,BD,Etc/GMT+8,"Peterson, J., and Vignola, F., 2017: Structure of a Comprehensive Solar Radiation Dataset. Proceedings of the ASES National Solar Conference 2017. doi: 10.18086/solar.2017.07.02",UO SRML
15,Seattle WA,47.68,-122.25,20,94290.0,SE,Etc/GMT+8,"Peterson, J., and Vignola, F., 2017: Structure of a Comprehensive Solar Radiation Dataset. Proceedings of the ASES National Solar Conference 2017. doi: 10.18086/solar.2017.07.02",UO SRML
15,Forest Grove OR,45.55,-123.08,55,94008.0,FG,Etc/GMT+8,"Peterson, J., and Vignola, F., 2017: Structure of a Comprehensive Solar Radiation Dataset. Proceedings of the ASES National Solar Conference 2017. doi: 10.18086/solar.2017.07.02",UO SRML
15,Picabo ID,43.31,-114.17,1472,94172.0,PI,Etc/GMT+8,"Peterson, J., and Vignola, F., 2017: Structure of a Comprehensive Solar Radiation Dataset. Proceedings of the ASES National Solar Conference 2017. doi: 10.18086/solar.2017.07.02",UO SRML
15,Twin Falls ID,42.55,-114.35,1200,94171.0,TW,Etc/GMT+8,"Peterson, J., and Vignola, F., 2017: Structure of a Comprehensive Solar Radiation Dataset. Proceedings of the ASES National Solar Conference 2017. doi: 10.18086/solar.2017.07.02",UO SRML
15,Boise ID,43.62,-116.21,701,94182.0,BO,Etc/GMT+8,"Peterson, J., and Vignola, F., 2017: Structure of a Comprehensive Solar Radiation Dataset. Proceedings of the ASES National Solar Conference 2017. doi: 10.18086/solar.2017.07.02",UO SRML
15,Parma ID,43.8,-116.94,678,94173.0,PA,Etc/GMT+8,"Peterson, J., and Vignola, F., 2017: Structure of a Comprehensive Solar Radiation Dataset. Proceedings of the ASES National Solar Conference 2017. doi: 10.18086/solar.2017.07.02",UO SRML
15,Christmas Valley OR,43.24,-120.88,1325,94251.0,CH,Etc/GMT+8,"Peterson, J., and Vignola, F., 2017: Structure of a Comprehensive Solar Radiation Dataset. Proceedings of the ASES National Solar Conference 2017. doi: 10.18086/solar.2017.07.02",UO SRML
15,Bend OR,43.99,-121.35,1100,94256.0,BE,Etc/GMT+8,"Peterson, J., and Vignola, F., 2017: Structure of a Comprehensive Solar Radiation Dataset. Proceedings of the ASES National Solar Conference 2017. doi: 10.18086/solar.2017.07.02",UO SRML
Expand Down
Loading