-
Notifications
You must be signed in to change notification settings - Fork 1.1k
add SOLRAD data parser to iotools #667
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
Conversation
pvlib/test/test_solrad.py
Outdated
|
||
test_dir = os.path.dirname( | ||
os.path.abspath(inspect.getfile(inspect.currentframe()))) | ||
testfile = os.path.join(test_dir, '../data/abq19056.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.
should be testfile = os.path.join(test_dir, 'data', '703165TY.csv')
for cross-platform compatibility
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 path you've specified would be pvlib/test/data/703165TY.csv
, but the data is in pvlib/data/abq19056.dat
. I am pretty sure that os.path
handles the ..
specification as needed for the platform. The appveyor builds do not object to this pattern.
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.
Of course. I substituted a file I have to test. Doesn't work on Windows. C:\python\pvlib-dev\pvlib-python\pvlib\../data/abq19056.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.
Hm... Appveyor tests run on Windows so I am quite confused.
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.
Hmmm... the string is interpreted correctly when a file operation is performed, so it's OK as coded. I still think my suggestion is an improvement.
import os
import inspect
test_dir = os.path.dirname(
os.path.abspath(inspect.getfile(inspect.currentframe())))
print(test_dir)
testfile = os.path.join(test_dir, '../data/703165TY.csv')
print(testfile)
with open(testfile) as infile:
r = infile.readline()
print(r)
produces
C:\python\pvlib-dev\pvlib-python\pvlib\test
C:\python\pvlib-dev\pvlib-python\pvlib\test\../data/703165TY.csv
703165,"SAND POINT",AK,-9.0,55.317,-160.517,7
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.
Is '..' acceptable? testfile = os.path.join(test_dir, '..', 'data', '703165TY.csv')
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 see it's called pardir
: https://docs.python.org/3/library/os.html#os.pardir
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.
that would maintain the OS-specific separator so the string doesn't have a mix of \ and /
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.
or use os.pardir
to avoid the ..
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. I thought os.path.join
was smarter than it was because the tests have never complained about that pattern in the past. Looking forward to the Python 3 only days and using pathlib.
pvlib/test/test_solrad.py
Outdated
test_dir = os.path.dirname( | ||
os.path.abspath(inspect.getfile(inspect.currentframe()))) | ||
testfile = os.path.join(test_dir, '../data/abq19056.dat') | ||
testfile_mad = os.path.join(test_dir, '../data/msn19056.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.
see above comment
https://www.esrl.noaa.gov/gmd/grad/solrad/index.html
docs/sphinx/source/api.rst
for API changes.docs/sphinx/source/whatsnew
file for all changes.Needs tests.