ekanderson Posted January 12, 2009 Share Posted January 12, 2009 I am collecting channel data at 6 minute HISTORY intervals. Channel timing ranges from 10 sec with Average so history is at 6 minute interval. I am logging and exporting at 6 minute, 1 hour, and 24 hour intervals. Is there a QUICK or Easy way to. At DFexpress loading of the *.ctl file Check time of last data collection, i.e, basetime=channelx.Time[0] Based on that value AND current system time Fill ALL channel's histories with nAn values upto the current time mod 360. i.e., from channelx.time[0] to current time at 360 sec increments Some of the hourly files do mean, max, min. The 24 hour file dumps a days worth of data. The only way I can think of doing it is do a loop FOR EACH channel, channelx.addvalue(????) nAn Then do channelx.TIME[0] =channelx.TIME[1] +360 and loop til completed Which leads to question, will nAn, be correctly recognized by mean, max, min???? Link to comment Share on other sites More sharing options...
AzeoTech Posted January 12, 2009 Share Posted January 12, 2009 That's the right approach, but use execute() inside your loop so you don't have to type out every channel name. This assumes that your channels are numbered in order. Execute might read something like this: for (private x = 0, x < 10, x++) execute("channel" + doubletostr(x) + ".AddValue(y)") endfor Now, you can't do channelx.time, but addvalue will use the time of whatever you pass, so create another variable, say y in my case and set it to NaN then set its time: y = Nan() y.time = channelx.time[0] + 360 Link to comment Share on other sites More sharing options...
ekanderson Posted January 14, 2009 Author Share Posted January 14, 2009 I wasn't clear about NaN. Don't want to set the time to NaN, but channel value. That said, again the question. Will mean(chan[]), etc. correctly ignore chan[] data that is NaN??? Regretably, chan.s are NOT numbered, but will work around that someway. Thanks Link to comment Share on other sites More sharing options...
ekanderson Posted January 14, 2009 Author Share Posted January 14, 2009 I found Channel.ListALL() function ListAll([group]): returns an array of strings containing the names of all the channels. If group is provided, only those channels in the given group are returned: Channel.ListAll("Main"). Used in conjunction with Execute() or Evaluate() you could easily apply things across groups of channels. Since this returns a csv string, I'm evidently missing the easily part. :>) Note: I didn't find this in DF help, but it works V.channel.listall() Link to comment Share on other sites More sharing options...
AzeoTech Posted January 14, 2009 Share Posted January 14, 2009 My script does set the value to NaN() and the time to 6 minutes more then channelx.time[0]. Yes, mean/sum, etc ignore nan values. Channel.ListAll() returns an array of strings, not a csv string. You can just loop through them: private string chanlist = channel.listall() for (private x = 0, x < numrows(chanlist), x++) execute(chanlist[x] + ".AddValue(y)") endfor Link to comment Share on other sites More sharing options...
ekanderson Posted February 13, 2009 Author Share Posted February 13, 2009 Got it working BUT Export sets that output the NaN data to a *.csv file with ff expression(s) Format("%4.2f",(max(v.S_kw_hrs[0,9]))) output is 100000000000000000000 "didn't count all the 0's" same but min() ditto same but mean() output is 1.#J was told that the NaN values would be ignored by above functions, max, min, mean If I output just channel[0] get inf Cannot find what "inf" is, but possibly stands for infinite??????? Link to comment Share on other sites More sharing options...
AzeoTech Posted February 13, 2009 Share Posted February 13, 2009 inf means infinite and is not ignored by mean/min, etc, and is probably the source of the other weird numbers. Link to comment Share on other sites More sharing options...
ekanderson Posted February 13, 2009 Author Share Posted February 13, 2009 Could you give me a hint on what IS ignored????????????????????????????? Link to comment Share on other sites More sharing options...
ekanderson Posted February 13, 2009 Author Share Posted February 13, 2009 the INPUT data that max, mean, min functions access is in this case is NaN data. inf is the OUTPUT in *.csv file Link to comment Share on other sites More sharing options...
AzeoTech Posted February 14, 2009 Share Posted February 14, 2009 I think perhaps you are using an older version of DAQFactory that did not properly ignore nans. Try going to the command prompt and typing this: global x = {1,2,3} ? mean(x) should display 2 x[2] = nan() ? mean(x) should display 1.5 My version, 5.79a, does this. If you get anything else you should go and get the latest release. Link to comment Share on other sites More sharing options...
ekanderson Posted February 14, 2009 Author Share Posted February 14, 2009 AOK, have 5.79a Build 1574 May have an inkling. If channel has ONLY NaN values, max, min, and mean return "values" of NaN. Then format() returns the weird values, rather than NaN. Link to comment Share on other sites More sharing options...
AzeoTech Posted February 14, 2009 Share Posted February 14, 2009 well that certainly makes sense. If there is nothing but NaN's, there's nothing left to do mean/min/max on. Format displays a weird value because internally, nan is actually 1e300, which is usually easier to deal with for reasons I won't go into. Here's what you can do: iif(mychan[0] == NaN(),"NaN",Format("%.3f",mychan[0])) This will display NaN if its NaN, and a formatted value otherwise. Link to comment Share on other sites More sharing options...
ekanderson Posted February 26, 2009 Author Share Posted February 26, 2009 iif(mychan[0] == NaN(),"NaN",Format("%.3f",mychan[0])) This will display NaN if its NaN, and a formatted value otherwise. I'm using the output in an export sets with of the form of max(mychan[0,9]) so is it safe to assume that the line would be: iff(max(mychan[0,9]) ==NaN(), "NaN", format("%.3f", max(mychan[0,9]))) + or - a parentheses or two. will work???? Link to comment Share on other sites More sharing options...
AzeoTech Posted February 27, 2009 Share Posted February 27, 2009 Yup, you can substitute any valid expression that results in a scalar for mychan[0]. Link to comment Share on other sites More sharing options...
BeeHay Posted August 16, 2010 Share Posted August 16, 2010 Sorry to bump another old thread, but this is the only thread I've found with info on "NaN" values... I have a few values that depend on a counter to be running using the 2 counters on my LJ U3... I also have the counters counts per/min value in a while(1) loop because the counters turn on and off frequently... I would like to know if there is an easy way to replace "NaN" values with just a plain 'ole "0" or "1" just to keep my calced values displaying a number instead of "NaN". I tried a few iif() statements, but I don't think I quite understand yet... Any pointers would be great! Link to comment Share on other sites More sharing options...
BeeHay Posted August 17, 2010 Share Posted August 17, 2010 This is what I've ended up with - if(Strokes[0] < 10) && (Strokes2[0] < 10) PumpsOff[0] = 1 Variable1[0] = 0 Variable2[0] = 0 Variable3[0] = 0 Variable4[0] = 0 Variable5[0] = 0 Variable6[0] = 0 //ect... else PumpsOff[0] = 0 endif Seems to be a "cheater" way of doing it, but atleast I have zeros instead of NaN... Link to comment Share on other sites More sharing options...
AzeoTech Posted August 17, 2010 Share Posted August 17, 2010 Its usually better to adjust the display, as having 0 or 1 in your data might get confused for actual data. You can take it out of your display using iif. For example: iif(variable1[0] == Nan(), "---", variable1[0]) Of course you can put calcs in too. Link to comment Share on other sites More sharing options...
BeeHay Posted August 17, 2010 Share Posted August 17, 2010 Ahh, that's where I was going wrong... I thought NaN was a string, so I was trying to figure out how to use it...I thought it was like this - iif(variable1[0] == "NaN" Thanks again, very much appreciated. Link to comment Share on other sites More sharing options...
BeeHay Posted August 23, 2010 Share Posted August 23, 2010 I found another way to "hide" NaNs... I put this in the Visible Expression under the Size tab in the Variable Value Component - Variable1[0] < Nan() Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.