-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Surfrad data reader #595
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Surfrad data reader #595
Conversation
pvlib/iotools/surfrad.py
Outdated
Dataframe with the fields found in SURFRAD_COLUMNS. | ||
metadata: dict | ||
Site metadata included in the file. | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
W293 blank line contains whitespace
pvlib/test/test_surfrad.py
Outdated
import inspect | ||
import os | ||
|
||
from numpy import isnan |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
F401 'numpy.isnan' imported but unused
pvlib/test/test_surfrad.py
Outdated
test_dir = os.path.dirname( | ||
os.path.abspath(inspect.getfile(inspect.currentframe()))) | ||
testfile = os.path.join(test_dir, '../data/surfrad-slv16001.dat') | ||
network_testfile ='ftp://aftp.cmdl.noaa.gov/data/radiation/surfrad/Alamosa_CO/2016/slv16001.dat' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
E225 missing whitespace around operator
E501 line too long (96 > 79 characters)
pvlib/test/test_surfrad.py
Outdated
|
||
@pytest.mark.parametrize('filename', [ | ||
testfile, | ||
network_testfile ]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
E202 whitespace before ']'
pvlib/test/test_surfrad.py
Outdated
|
||
def test_format_index(): | ||
start = pd.Timestamp('20160101 00:00') | ||
expected_index = pd.DatetimeIndex(start = start, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
E251 unexpected spaces around keyword / parameter equals
pvlib/test/test_surfrad.py
Outdated
def test_format_index(): | ||
start = pd.Timestamp('20160101 00:00') | ||
expected_index = pd.DatetimeIndex(start = start, | ||
periods = 1440, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
E251 unexpected spaces around keyword / parameter equals
pvlib/test/test_surfrad.py
Outdated
'latitude': '37.70', | ||
'longitude': '105.92', | ||
'elevation': '2317', | ||
'surfrad_version': '1' } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
E202 whitespace before '}'
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice work.
pvlib/iotools/surfrad.py
Outdated
zen float solar zenith angle (deg) | ||
**Fields below have associated qc flags labeled <field>_flag.** | ||
----------------------------------------------------------------------- | ||
dw_solar float downwelling global solar(W/m^2) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess this could be dw_solar, ghi
and you could add another **
line with a note like **raw, mapped fields are controlled by the map_variables argument**
. There's probably a better way to say that.
pvlib/test/test_surfrad.py
Outdated
'Alamosa_CO/2016/slv16001.dat') | ||
|
||
|
||
def test_read_surfrad(): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think this test is doing anything for us so we can delete it
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sorry for setting a bad example in test_tmy.py
pvlib/test/test_surfrad.py
Outdated
|
||
def test_format_index(): | ||
start = Timestamp('20160101 00:00') | ||
expected_index = DatetimeIndex(start=start, periods=1440, freq='1min') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you can supply tz='UTC'
here and skip the localize call below. Seems a little more straightforward to me. I had to look up if localize modifies in place or not.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch, thanks. This was a naive "fix" when I was reading the test failure incorrectly, I wasn't setting the timezone correctly in read_surfrad.
It looks like pandas 0.14.0 has some issues with setting the timezone the way you proposed though, so i'll have to figure that out.
pvlib/test/test_surfrad.py
Outdated
|
||
def test_read_surfrad_metadata(): | ||
expected = {'name': 'Alamosa', | ||
'latitude': '37.70', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the values here and below should be numeric. probably all floats.
Or we can update the minimum pandas requirement. Do you know what version
we’d need to bump to?
…On Thu, Oct 4, 2018 at 9:16 AM lboeman ***@***.***> wrote:
***@***.**** commented on this pull request.
------------------------------
In pvlib/test/test_surfrad.py
<#595 (comment)>:
> ***@***.***
+def test_read_surfrad_network():
+ surfrad.read_surfrad(network_testfile)
+
+
+def test_read_surfrad_columns_exist():
+ data, _ = surfrad.read_surfrad(testfile)
+ assert 'zen' in data.columns
+ assert 'temp' in data.columns
+ assert 'par' in data.columns
+ assert 'pressure' in data.columns
+
+
+def test_format_index():
+ start = Timestamp('20160101 00:00')
+ expected_index = DatetimeIndex(start=start, periods=1440, freq='1min')
Good catch, thanks. This was a naive "fix" when I was reading the test
failure incorrectly, I wasn't setting the timezone correctly in
read_surfrad.
It looks like pandas 0.14.0 has some issues with setting the timezone the
way you proposed though, so i'll have to figure that out.
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#595 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AELiRxp2sqVbP3xNDhQpg3F7d7rg4IIbks5uhjRbgaJpZM4XFCSI>
.
|
Yes. Good catch.
…On Thu, Oct 4, 2018 at 9:25 AM lboeman ***@***.***> wrote:
***@***.**** commented on this pull request.
------------------------------
In pvlib/iotools/surfrad.py
<#595 (comment)>:
> + from urllib.request import urlopen, Request
+
+import pandas as pd
+import numpy as np
+
+SURFRAD_COLUMNS = [
+ 'year', 'jday', 'month', 'day', 'hour', 'minute', 'dt', 'zen',
+ 'dw_solar', 'dw_solar_flag', 'uw_solar', 'uw_solar_flag', 'direct_n',
+ 'direct_n_flag', 'diffuse', 'diffuse_flag', 'dw_ir', 'dw_ir_flag',
+ 'dw_casetemp', 'dw_casetemp_flag', 'dw_dometemp', 'dw_dometemp_flag',
+ 'uw_ir', 'uw_ir_flag', 'uw_casetemp', 'uw_casetemp_flag', 'uw_dometemp',
+ 'uw_dometemp_flag', 'uvb', 'uvb_flag', 'par', 'par_flag', 'netsolar',
+ 'netsolar_flag', 'netir', 'netir_flag', 'totalnet', 'totalnet_flag',
+ 'temp', 'temp_flag', 'rh', 'rh_flag', 'windspd', 'windspd_flag',
+ 'winddir', 'winddir_flag', 'pressure', 'pressure_flag']
+
Is 'zen': 'solar_zenith' also a valid mapping?
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#595 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AELiR8lb6bd_N_iz17B5Oou4k3FtWM-zks5uhjZdgaJpZM4XFCSI>
.
|
@wholmgren Looks like the |
Let's bump the minimum requirements to 0.15.0. @mikofski will also appreciate the http://pandas.pydata.org/pandas-docs/stable/whatsnew.html#timezone-handling-improvements |
The bump to pandas 0.15.0 is causing other tests to fail and after testing it looks like all versions from 15-18.1 all produce errors in the tests. So it's probably best to roll this back to 0.14.0? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
a few minor comments below. I'll check out the tests.
@@ -9,6 +9,8 @@ release. | |||
**Python 2.7 support will end on June 1, 2019**. Releases made after this | |||
date will require Python 3. (:issue:`501`) | |||
|
|||
**Minimum pandas requirment bumped 0.14.0=>0.15.0** |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
requirement
pvlib/iotools/surfrad.py
Outdated
Filepath or url. | ||
map_variables: bool | ||
When true, renames columns of the Dataframe to pvlib variable names | ||
where applicable. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add: "See variable SURFRAD_COLUMNS"
The min failures are due to a couple of issues.
|
@lboeman can you merge the latest pvlib-python/master into your branch and make the changes to pvsystem.py proposed above? I think that should make the tests pass. |
@wholmgren Updated those lines and all tests are passing now. |
Just a thought, not requesting any change: the |
@cwhanse do you know of other data sources that use the SURFRAD time format? If not, I suggest we leave it as for now. |
@wholmgren not off the top of my head. I agree, leave where it is for now, but let's move it if we find another |
* Created :py:func:`pvlib.iotools.read_srml` and :py:func:`pvlib.iotools.read_srml_month_from_solardat` | ||
to read University of Oregon Solar Radiation Monitoring Laboratory data. (:issue:`589`) | ||
|
||
* Created :py:func:`pvlib.iotools.read_surfrad` to read NOAA SURFRAD data. (:issue:`590`) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@lboeman your rebase introduced duplicate entries here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks! Fixed.
pvlib python pull request guidelines
Thank you for your contribution to pvlib python! You may delete all of these instructions except for the list below.
You may submit a pull request with your code at any stage of completion.
The following items must be addressed before the code can be merged. Please don't hesitate to ask for help if you're unsure of how to accomplish any of the items below:
docs/sphinx/source/api.rst
for API changes.docs/sphinx/source/whatsnew
file for all changes.Brief description of the problem and proposed solution (if not already fully described in the issue linked to above):