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

TimeseriesObjectiveFunction fails because of missing year argument #27

Open
MatthewSteen opened this issue Mar 14, 2021 · 6 comments
Open
Assignees

Comments

@MatthewSteen
Copy link
Member

The year from the CSV file needs to be added as an argument to the MonthOfYear call in line 546 (or use line 544 instead).

mon = csv[row][0].split(' ')[0].split('/')[0].to_i
day = csv[row][0].split(' ')[0].split('/')[1].to_i
year = csv[row][0].split(' ')[0].split('/')[2]&.to_i
hou = csv[row][0].split(' ')[1].split(':')[0].to_i
min = csv[row][0].split(' ')[1].split(':')[1].to_i
sec = csv[row][0].split(' ')[1].split(':')[2]&.to_i
if year.nil?
dat = OpenStudio::Date.new(OpenStudio::MonthOfYear.new(cal[mon]), day)
else
# dat = OpenStudio::Date.new(OpenStudio::MonthOfYear.new(cal[mon]),day,year)
# hack since year is not in the sql file correctly
dat = OpenStudio::Date.new(OpenStudio::MonthOfYear.new(cal[mon]), day)
end

Without it, OpenStudio assumes 2009, which fails the >= conditional below for timestamps after 2009.

unless dtm >= first_date && dtm <= last_date
if warning_messages
runner.registerWarning("CSV DateTime #{dtm} is not in SQL Timeseries Dates")
end
next
end

Experienced this issue with timeseries data in the following format.

datetime,occ_zone_temp_ave,plm_zone_temp_ave,
10/30/2020 0:00,25.61841766,23.6810688,
10/30/2020 0:01,25.61639483,23.692894,
10/30/2020 0:02,25.62348463,23.70474212,
10/30/2020 0:03,25.62786781,23.69617423,
10/30/2020 0:04,25.62711445,23.69417523,
10/30/2020 0:05,25.63245887,23.69228997,

@MatthewSteen
Copy link
Member Author

Another useful update for this measure would be to remove " from the path argument, which should be added to all measures that have a path as an user argument.

# remove leading and trailing double quotes
# windows users can shift + right click a file to copy as path, which has double quotes
csv_name.gsub!('"', '')

@DavidGoldwasser
Copy link
Collaborator

@brianlball and @lgentile in addition to writing documentation we should also add a test to this measures. Could try to use FRP for test which might be the quickest, or could make a simple purpose made sample model for the test and documentation. Maybe there is another project we are working on that would be good for test and documentation.

@MatthewSteen
Copy link
Member Author

MatthewSteen commented Apr 3, 2021

Another comment/improvement to this measure (and all other measures in general) is to break up the run method into short functions that the run method calls, i.e. apply best coding practices of functions/methods with a single purpose, which would make them more readable, allow for easier debugging, and simplify unit testing.

@MatthewSteen
Copy link
Member Author

MatthewSteen commented Apr 12, 2021

Another improvement is to use a standardized time format (ISO 8601) so that users don't have to reformat data after using other tools (e.g. Python Pandas). Maybe that's an EnergyPlus issue though.

Additionally, the measure failed when using the mm/dd/yy format that the arguments suggest because it actually requires mm/dd/yyyy format.

image

@kongkun-om
Copy link

Hi,
I am interested in using this measure for a time-series calibration. I have monitored data from the building. I tried to find a csv example in the resources folder but it's not available. Could you please advise on the csv formatting? Should I follow ISO 8601 as mentioned above, for example, "07-10 15:00" if "mm:dd hh:mm" is used? Or, will "07/10 15:00" work too? Does the date/time stamp have to be in one column?

If possible, could you please share a csv file example so I can use it as a template?

Thank you.

@kongkun-om
Copy link

kongkun-om commented Aug 10, 2023

I encounter these warning and error. Is it because the SQL table does not contain year and second data as shown in the screenshot? Thank you.

[12:57:55.024073 WARN] CSV DateTime 2009-Apr-22 23:00:00 is not in SQL Timeseries Dates
[12:57:55.024174 ERROR] no implicit conversion from nil to integer

Capture

@brianlball brianlball mentioned this issue Oct 9, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants