8000 Allow read_tmy3 to handle 00:00 timestamps by AdamRJensen · Pull Request #1494 · pvlib/pvlib-python · GitHub
[go: up one dir, main page]

Skip to content

Allow read_tmy3 to handle 00:00 timestamps #1494

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

Merged
merged 19 commits into from
Aug 16, 2022
Merged
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Add fbuf.close and first within try/except
  • Loading branch information
AdamRJensen committed Jul 27, 2022
commit e812daebd8a0cbb9cf693d30c4ff937f497b93b1
6 changes: 3 additions & 3 deletions pvlib/iotools/tmy.py
Original file line number Diff line number Diff line change
Expand Up @@ -160,13 +160,13 @@ def read_tmy3(filename, coerce_year=None, recolumn=True):
head = ['USAF', 'Name', 'State', 'TZ', 'latitude', 'longitude', 'altitude']
try:
fbuf = open(str(filename), 'r')
firstline = fbuf.readline() # first line contains the metadata
# SolarAnywhere files contain non-UTF8 characters and require
# encoding='iso-8859-1' on Linux in order to be parsed
except UnicodeDecodeError:
fbuf = open(str(filename), 'r', encoding='iso-8859-1')
firstline = fbuf.readline() # first line contains the metadata

# read in file metadata, advance buffer to second line
firstline = fbuf.readline()
# use pandas to read the csv file buffer
# header is actually the second line, but tell pandas to look for
# header information on the 1st line (0 indexing) because we've already
Expand Down Expand Up @@ -208,7 +208,7 @@ def read_tmy3(filename, coerce_year=None, recolumn=True):
data = _recolumn(data) # rename to standard column names

data = data.tz_localize(int(meta['TZ'] * 3600))

fbuf.close()
return data, meta


Expand Down
0