15 Replies Latest reply on Jul 7, 2017 4:21 AM by skwan

    Understand o/p of AFData.PlotValues

    Paurav Joshi

      Hello Folks,

       

      I am trying to understand o/p of PlotValues method. As per Live library document, each interval can produce up to 5 values which may have at most one exceptional point (bad status or digital state).

       

      I have got values of recorded v/s plot of cdt158 for 1 day (i.e. "y" to "t"), and I am unable to understand why some values stored in the output of plot values although they are not max, min, start, end, and bad value.

       

      Following is the code I used for plotvalues function:

      AFTimeRange tr = new AFTimeRange("y","t");
      AFValues plottedValues = myTag.PlotValues(tr, 24);// 24 intervals, 1 interval per hour
      
      

       

      Please find attach excel-sheet contains recorded and plotted with some highlighted values.

       

      Edit: No value is questionable or substituted.

      Recorded Values:

      Plot Values:

       

      Thanks,

      Paurav Joshi

        • Re: Understand o/p of AFData.PlotValues
          Rick Davin

          Hi Paurav,

           

          Very interesting question.  I'm going to have to refer to some internal sources to get a qualified answer.  Meanwhile, I have reworked most of your workbook to be on a single sheet for both RecordedValues and PlotValues, along with comments at bottom of this reply.  A snippet:

           

          2017-06-27 11_38_37-PlotValues Formatted.xlsx - Excel.png

           

          Any shaded area shows a PlotValue.  A bold font is a special value of some sort.  Red fonts indicate questions.

           

          UPDATED SPREADSHEET WITH PRETTY FORMATTING:

            • Re: Understand o/p of AFData.PlotValues
              Paurav Joshi

              Hi Rick,

               

              Thanks for taking so much efforts .

              One point to note here regarding screenshot you share, second last value should not be included because it is not the minimum value of that interval.And rightly last value of the interval as well as minimum is included.

               

              Thanks,

              Paurav Joshi

                • Re: Understand o/p of AFData.PlotValues
                  Rick Davin

                  What I can tell so far is that for a given intervals PlotValues will:

                   

                  Grab the First Value in the interval

                  Grab the Last Value in the interval

                  Compute the Min & Max between the First and Last excluding the First and Last

                   

                  So I have labeled some cells Incl Min versus Excl Min.  Sometimes, the Excl Min or Excl Max is included in PlotValues, particularly when the First or Last is special by being the Incl Min or Incl Max.  My question would be: what's the reasoning why sometimes the Excl Min/Max is included, but sometimes it is not.

                    • Re: Understand o/p of AFData.PlotValues
                      Paurav Joshi

                      Hi Rick,

                      What I can tell so far is that for a given intervals PlotValues will:

                       

                      Grab the First Value in the interval

                      Grab the Last Value in the interval

                      Compute the Min & Max between the First and Last excluding the First and Last

                      Adding into it following para from livelibrary, which led me to think otherwise related to last point:

                      Yes, would love to have more clarity so that we can add a suggestion to modify the document.

                       

                      Thanks,

                      Paurav Joshi

                        • Re: Understand o/p of AFData.PlotValues
                          arosenthal

                          I would be interested to see how the result of PlotValues changes if you give an absolute timestamp range of "6/26/2017 12:02:17" to "6/26/2017 11:57:47". I wonder if there is some strange behavior occurring because PlotValues has to return values at the extremes, which happen to be timestamps that don't exist in RecordedValues.

                            • Re: Understand o/p of AFData.PlotValues
                              Rick Davin

                              At the extremes of the overall time range, interpolated values are returned.

                                • Re: Understand o/p of AFData.PlotValues
                                  arosenthal

                                  That's true. Maybe what's happening is that the "intervals" can overlap, but PlotValues won't return two values in a row that are based on the same archived value.

                                   

                                  In the OP's data, the value at 1:01:17 AM is not actually the start of the 2nd interval; it's the minimum value of the interval occurring between 1:00 AM and 2:00 AM. The start value of the 2nd interval actually comes from the recorded value at 12:56:17 AM. But, this value is already represented as the end value of the 1st interval, so PlotValues doesn't repeat it.

                                   

                                  Update: Actually, this logic still doesn't hold for other intervals. I still don't know what's really going on...

                                    • Re: Understand o/p of AFData.PlotValues
                                      Rick Davin

                                      The value at 1:01:17 AM is the first value within the interval occurring from 1:00 AM - 2:00 AM.  You are correct that it is not the start of the interval, but it is the first value within the interval.

                                       

                                      For the time range passed to PlotValues, the time range StartTime and EndTIme will have values, recorded if found, interpolated if not.  Other than the overall time range's StartTime and EndTime, interpolation is not done for any of the intermediate intervals.

                                       

                                      I have been told that interpolation on the StartTime and EndTime can be problematic.  I leave it to Stephen Kwan to explain more.

                          • Re: Understand o/p of AFData.PlotValues
                            Rick Davin

                            Hi Paurav,

                             

                            I have confirmed that much of our thinking is on the right track.  Putting aside the exceptional digital state value, here are the 4 numeric values that are returned, if unique:

                             

                            • First within the interval.  Not necessarily the exact start of interval.
                            • Last within the interval.  Not necessarily the exact end of the interval.
                            • The Maximum and Minimum between the First and Last, excluding the First and Last.

                             

                            From your original post, the value at 2:26:17 AM is correctly included because it is the Minimum between the First and Last, excluding the First and Last.  That appears as row 31 in my earlier post.

                             

                            We are confused as to the value in your original post at 3:13:47 AM.  That is row 40 in my earlier post.  By the previous stated reasoning, 3:13:47 AM should not be returned with PlotValues BUT the value at 3:51:47 AM (my row 45) should be included since it is the Minimum between the First and Last, excluding the First and Last.

                             

                            We have a team researching this. It may take some time to get the full answer.  Your patience is appreciated.

                             

                            PS - I really like this conversation because it helps promote a better understanding of some of the lesser documented methods.

                            2 of 2 people found this helpful
                          • Re: Understand o/p of AFData.PlotValues
                            Rick Davin

                            This question has led to a Work Item 175669.  Note this is merely a confirmation that the WI has been entered into the work queue.  I am unable to provide an estimated date as to when the fix for the WI will be completed.  Any previous statements I made about Lowest (minimum) or Highest (maximum) exclusively between the First and Last are incorrect.  If the First or Last coincide with the Lowest or Highest, fewer values should be returned.  We occasionally observe a returned value that is not the First, Last, Lowest or Highest; WI 175669 should correct those occurrences.

                            2 of 2 people found this helpful