First time here? Check our help page!
2

TimeSeries alternative

Hi, Sometimes SQLlite doesn't give back data when we call .TimeSeries and return an empty value for an array. I want to create directly when value empty returned, so which syntax and should input here when i know start date, end date and frequency ? Regards

ngkhanh's avatar
2.2k
ngkhanh
asked 2016-02-10 16:06:03 -0500
__AmirRoth__'s avatar
4.4k
__AmirRoth__
updated 2016-02-11 07:33:34 -0500
edit flag offensive 0 remove flag close merge delete

Comments

Are you referring to SqlFile::timeseries. The arguments to that function are envPeriod, reportingFrequency, timeSeriesName, and keyValue. If you are not getting an initialized TimeSeries object back then you are either passing in bad values for those arguments or you did not request that EnergyPlus output the desired data.

macumber's avatar macumber (2016-02-10 21:45:18 -0500) edit

Sorry for my wrong syntax. It's .timeSeries method. It's a space without infiltration or outdoor rate, so they would not get recorded in .sql. The value can be zero but the timedate data still should input

ngkhanh's avatar ngkhanh (2016-02-10 22:55:52 -0500) edit

Are you asking how to create a TimeSeries?

Jason DeGraw's avatar Jason DeGraw (2016-02-11 10:22:02 -0500) edit

So in some cases you do your query and get back a result, is that right? In other cases, you do your query and get back an empty result, what do you want to do in that case? Create a timeseries with all zero values? Why do you want to do that?

macumber's avatar macumber (2016-02-11 10:25:36 -0500) edit

Yes, I want to get a times series with all zero value - that all time data have zero value (1/1/2009 0h:0m:0s, 0) 0 . I got time duration by sqlFile.hoursSimulated and RunPeriods , OpenStudio::Date for begin and and end day but have problem to create a TimeSeries with all zero array. I read here but still have problems with time creating and modifying in case of month or year frequency

ngkhanh's avatar ngkhanh (2016-02-11 10:49:09 -0500) edit
add a comment see more comments

1 Answer

4

You should be able to create a time series with zero values, though the tricky parts may be getting the right Vector object and the right first report time. Here's Ruby code to do it for a complete year:

require 'openstudio'
values = OpenStudio::Vector.new(8760, 0.0)
date = OpenStudio::Date.new(OpenStudio::MonthOfYear.new("Jan"), 1, 2009)
time = OpenStudio::Time.new(0,1,0,0)
timeSeries = OpenStudio::TimeSeries.new(date, time, values, "")

Note that in the documentation the firstReportDateTime arguments are going to be the date and time of the first value in the time series, so if I had used one of those constructors I would be passing in 1/1/2009 01:00.

There are more examples here on creating time series. Unfortunately, the Ruby tests are gone now, only the C++ tests remain.

Jason DeGraw's avatar
2.2k
Jason DeGraw
answered 2016-02-11 11:24:15 -0500, updated 2017-11-15 21:21:26 -0500
edit flag offensive 0 remove flag delete link

Comments

Thank your syntaxs are very clear. I tried Time method in ruby console and saw that : OpenStudio::Time.new(1,1) = OpenStudio::Time.new(0,25) = 25:00:00. How i need to understand time value in Openstudio for checking purpose ? for example OpenStudio::Time.new(0,24) = 24:00:00 should be midnight moment to 1 am of day 1 or this is the 24th hour of day 0 (from 23 to 24:00) ? sometime i get confusing between time format between : 00:00:00 to 23:00:00 and 1:00:00 to 24 :00:00 in result viewer ? how to determine them ?

ngkhanh's avatar ngkhanh (2016-02-11 12:05:12 -0500) edit

Yes, you do need to be careful about time. The time series associates the value with the time at the end of the interval. So the value attached to 1/1/2009 01:00 in the time series covers the interval from 1/1/2009 00:00 to 1/1/2009 01:00. The value attached to 1/1/2009 24:00 (which is the same as 1/2/2009 00:00) covers 1/1/2009 23:00 to 1/2/2009 00:00. Does that help?

Jason DeGraw's avatar Jason DeGraw (2016-02-11 12:34:45 -0500) edit

My answer originally linked to Ruby tests that are no longer available.

Jason DeGraw's avatar Jason DeGraw (2017-11-15 21:23:14 -0500) edit
add a comment see more comments