Skip to content
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

read_epw data shifted 1 hour back #1156

Open
shirubana opened this issue Feb 1, 2021 · 0 comments
Open

read_epw data shifted 1 hour back #1156

shirubana opened this issue Feb 1, 2021 · 0 comments
Labels

Comments

@shirubana
Copy link

Describe the bug
It seems that the EPW data being read is being shifted one hour back.

To Reproduce

epwfile = 'USA_AZ_Tucson.Intl.AP.722740_TMY3.epw'
tmyfile = '722740TYA.CSV'                           # TMY file for Tucson

import pvlib
(epwdata, metadata) = pvlib.iotools.epw.read_epw(epwfile, coerce_year=2002) #pvlib>0.6.1
(tmydata, metadata) = pvlib.iotools.tmy.read_tmy3(tmyfile, coerce_year=2002) #pvlib>0.6.1

fig, ax = plt.subplots()
ax.plot(tmydata.index[0:24], tmydata.DNI[0:24], label='TMY data read with pvlib')
ax.plot(epwdata.index[0:24], epwdata.dni[0:24], label='EPW read with pvlib')
ax.set_ylabel('DNI [W/m$^2$]')
ax.legend()
fig.autofmt_xdate()

Expected behavior
The EPW weather files follow IWEC Manual’s conventions, where the data is aggregated hourly as an average from t-1 to t, just like Typical Meteorological Year Data (TMY). From example, from IWEC Manual:

DNI: This is the Direct Normal Radiation in Wh/m2. (Amount of solar radiation in Wh/m2 received directly from the solar disk on a surface perpendicular to the sun’s rays, during the number of minutes preceding the time indicated.)

Screenshots
If applicable, add screenshots to help explain your problem.
image

Versions:

  • pvlib.__version__: '0.9.0-alpha.1+4.g750b1fa'
  • pandas.__version__: '0.24.2'
  • python: 3.7.3

Additional context
Suggested fix:

epwdata_fix = epwdata.copy()
epwdata_fix .index = epwdata_fix .index+pd.Timedelta(hours=1) 

fig, ax = plt.subplots()
ax.plot(tmydata.index[0:24], tmydata.DNI[0:24], label='TMY data read with pvlib')
ax.plot(epwdata.index[0:24], epwdata.dni[0:24], label='EPW read with pvlib ')
ax.plot(epwdata_fix.index[0:24], epwdata_fix .dni[0:24], '*', label='EPW read with pvlib (with suggested shift)')
ax.set_ylabel('DNI [W/m$^2$]')
ax.legend()
fig.autofmt_xdate()

image

However --- this creates one entry for the first day of the next year at the end of the dataframe which can cause trouble; not sure what to suggest for that, for our use of this we're going to go with deleting the last line.
epwdata_fix = epwdata_fix[:-1]

image

@AdamRJensen AdamRJensen added bug io and removed bug labels Aug 15, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants