MPCPy
MPCPy copied to clipboard
EPW radiation data final timestep timeseries value changes in next timestep.
WeatherFromEPW._read_timeseries_from_epw gives changing values for final hour radiation variables. This is because after resampling the values, interpolating, and shifting 30 minutes backwards (as mentioned in Buildings.BoundaryConditions.WeatherData.ReaderTMY3) the original unshifted uninterpolated value is appended as the final value in the timeseries (see exodata.py line 956).
This value for the hourly radiation will then change if it is not the final hour in the timeseries (see reproducing code). There is a simple fix to read one timestep further for radiation data then do the resampling, interpolation, and time shift - without appending the original value at the end. I would happily send a pull request implementing this if it is sufficient. Although, perhaps there are already some rewrites to EPW time interval handling already in the works (https://github.com/lbl-srg/MPCPy/issues/143)? Please let me know - thanks!
minimal reproducing code (have to add local .epw file path):
from mpcpy import exodata
import datetime
weather = exodata.WeatherFromEPW(
'/root/data/CHE_Geneva.067000_IWEC.epw',
standard_time=True
)
start_time = datetime.datetime.strptime('4/2/2017 01:00:00', '%m/%d/%Y %H:%M:%S')
final_time = datetime.datetime.strptime('4/2/2017 07:00:00', '%m/%d/%Y %H:%M:%S')
weather.collect_data(start_time, final_time)
weather.data['weaHGloHor'].display_data()
start_time += datetime.timedelta(hours=1)
final_time += datetime.timedelta(hours=1)
weather.collect_data(start_time, final_time)
weather.data['weaHGloHor'].display_data()
Hey Tom, thanks for reporting the issue. I will have a look at it in the coming days.
Great thanks, I implemented the fix mentioned locally and it appears to give the expected behaviour.
Hey Tom, thanks for implementing a suggested fix. Can you please send the pull request?
Sure, adding the pull request for information - it's nothing fancy but gets around having to append an uninterpolated final value in the timeseries.