Indy500 Posted November 26, 2009 Share Posted November 26, 2009 I have a channel "tempbioreactor2" that is measured once a second and has a history and persistance of 86400. When I execute debug statements like: ? formattime(gettime(tempbioreactor2[10000])) 22:45:55 ? formattime(gettime(tempbioreactor2[20000])) 19:59:22 ? formattime(gettime(tempbioreactor2[30000])) 17:12:51 You can see that there is a time associated with the data. But, when I execute a debug statement like: ? formattime(gettime(tempbioreactor2[19h59m22s])) ? formattime(gettime(tempbioreactor2[19h20m])) I get nothing. Here's another example: ? tempbioreactor2[10000] 64.30170862295 ? formattime(gettime(tempbioreactor2[10000])) 23:00:34 ? formattime(gettime(tempbioreactor2[23h00m34s])) ? min(tempbioreactor2[18h,19h]) You can see that I get nothing using the 23h00m34s format like it shows on page 64 of the manual (or the [18h,19h] format like it shows at the top of the page. What am I doing wrong? Link to comment Share on other sites More sharing options...
AzeoTech Posted November 26, 2009 Share Posted November 26, 2009 First, you can't really subset by time with only one time value. The reason is that the time stamp is stored with millisecond precision, so unless your data point is at exactly 23h00m34.000000 it won't match with 23h00m34s (also, you don't need the "s"). Second, I'm guessing the [18h,19h] doesn't work because you are calling it earlier in the day than 6pm since [10000] is 11pm. If you don't specify the date portion it will automatically use today, even if its in the future. Try fully specifying the date/time instead of just the time. Or, do [18h - 86400, 19h - 86400] which gives you 6pm to 7pm yesterday. Link to comment Share on other sites More sharing options...
Indy500 Posted November 27, 2009 Author Share Posted November 27, 2009 First, thanks for answering on Thanksgiving! What great support! Second, your post clarified a lot however, I'm still having some problems: ? FormatDateTime("%c", SysTime()) 11/26/09 23:44:03 ? "riseHour = "+riseHour riseHour = 7 ? "riseMinute = "+riseMinute riseMinute = 40 ? "first = "+mean(ambientTemperature[evaluate("00h00m01, "+riseHour+"h"+riseMinute+"m")]) first = 64.68837490247 ? "second = "+mean(ambientTemperature[00h00m01, evaluate(riseHour+"h"+riseMinute+"m")]) second = 61.28498523042 ? "third = "+mean(ambientTemperature[00h00m01, riseHour+"h"+riseMinute+"m"]) third = 63.80443275164 Obviously, the "first", "second", and "third" statements are very close to each other, but different. They each give a different value, so only one of them is the right way to do it (or maybe they are all wrong!) and I can't figure out which is the correct way. I'm guessing it's "second" since I looked at the dataset and the number seemed correct. Link to comment Share on other sites More sharing options...
AzeoTech Posted November 27, 2009 Share Posted November 27, 2009 Thanksgiving is only a holiday in the US and DF is used around the world. And even then, many DF applications don't stop at 5pm or on holidays! The second one is correct. For the first one, think about what the string is inside the evaluate, its becomes: "00h00m01,7h40m" you can't really evaluate that string properly, or at least it won't be what you want. Its not a single expression as the comma is not an operator. The third is incorrect because the hms parser is in the compiler. The string: "7h40m", which is what the second argument becomes, will reduce to simply 7 because DF will convert it from a string to a number, so you are actually getting all the data up until midnight today since 7 is 7 seconds into Jan 1st 1970. The second should work, but truthfully, I prefer to simply use math: 0h0m + riseHour*3600 + riseMinute * 60 In fact, I typically find midnight using math too: floor(systime() / 86400) * 86400 BTW: The best way to test this is to hand type it: ? mean(ambientTemperature[00h00m01, 07h40m]) and I think you'll find you'll get 61.28498523042 Link to comment Share on other sites More sharing options...
Indy500 Posted November 27, 2009 Author Share Posted November 27, 2009 Thanks! I've got everything working now. I also love your tip about just using math to do the calculations. Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.