5 Replies Latest reply on Aug 1, 2017 2:15 AM by skwan

    AF SDK Plot Values

    Sreeni13

      Hello,

           I have a question regarding if we reduce the number of count for the interpolated values in a graph from the actual number of values within a given time stamp will it alter the meaningful data from the graph or will there be any loss of data.

      Thanks in advance.

      R.Sreenivas

        • Re: AF SDK Plot Values
          Rick Davin

          A comforting notion is that no matter how you fetch data for a trend - be it actual archive values or interpolated values or using PlotValues method - that you do not have a loss of data in your archives.  The big question is does a trend visually represent the processes in a relatively accurate manner.  Some may demand it be exactly accurate but there are many practical factors at play that prevent that: the pixel resolution of the plot area versus the display capabilities of the output medium (monitor, 4K monitor, printer, etc).

           

          If you have sparse values within the time range, then the actual archive values may suffice.  Fetching interpolated values in this case may produce lots more data points, but have absolutely no effect on the resulting trend.  In this case, interpolated values adds more work but has 0 benefit.

           

          If you have very dense data within the time range, then the actual archives would be overkill and may not be fully displayed.  That is many of the data points won't be displayed because they just can't be displayed.  If you have 100K values to display across a 1200 pixel time axis, then you can only show 1200 values.  That means the time and effort to retrieve 98,800 values has been wasted.  Fetching interpolated values in this case may reduce the number data points.  Still if the interpolated values call returns 3600 values, you spent time fetching 2400 values that you don't need.

           

          For trends, graphs, plots, etc., the best recommendation is to use the PIPoint.PlotValues or the AFAttribute.Data.PlotValues methods.

          1 of 1 people found this helpful
          • Re: AF SDK Plot Values
            GreenTech

            One of the issues that you have with fetching interpolated data is Nyquist theorem (that is you must fetch samples at <1/2 the period of the highest frequency that you wish to recover (or view).

            I.e. if you fetch interpolated values for Sinusoid, across a 10 years with 1 value per day (e.g.) what will appear on a chart is a flat line (as the value of Sinusoid is the same every day at the same time).

             

            (try adding sinusoid to an AF attribute, select Time Series Data and view 'Sampled' for a few hundred days - set interval to 12h

             

            According to that the value of Sinusoid is always 12... must be broken

             

            PlotValues is specifically engineered to avoid this - even if you select few data points, by giving you the best 'zoomed out' interpretation of the values _for a chart_

            100 points plot values - it's a bit 'grainy' but you can see that it is a periodic waveform!

            Without PlotValues, if you wanted to 'down-sample' your wave, you'd have to first analyse it and decide what was the highest frequency that you wanted to preserve. (FFT?)

             

            Don't underestimate it's value when showing trends on a screen, it's a massive improvement on just fetching all of the points.

            Cheers,

            Rob

            4 of 4 people found this helpful
              • Re: AF SDK Plot Values
                Sreeni13

                Hello Rob,

                     I have a doubt, while using plotvalues method for plotting a graph what will be the desired ratio of interval and time range in it so i can achieve the most accurate data as output.

                  • Re: AF SDK Plot Values
                    GreenTech

                    Hi Sreenivas,

                    Short answer, with plot values - use maximum resolution of screen (for a chart that is going to go across the whole screen) so let's say 2000.

                     

                    When you are talking about accurate output, it's important to understand the main purpose of PlotValues is where you wish to _display_ a chart where the medium (a computer terminal or printed report) is physically unable to display more points than it's native resolution. This then typically becomes the requested number of points for that call to plot values.

                    If what you want to do is display a chart, but then provide the user with an option to _download_, I'd suggest you use that action to fetch either archive or sampled values otherwise you will always lose some accuracy in the output.

                    Does that make sense?

                     

                    Cheers,
                    Rob

                    1 of 1 people found this helpful
                      • Re: AF SDK Plot Values
                        skwan

                        Sreenivas:

                        Rob is 100% correct.  I will attempt to clarify a bit more.  From your post, you are most interested in "accurate data".  That is actually a problem when you try to display a plot on a computer screen in some situations.  Let's say you have a 1080p computer screen.  At most, you can display 1920 pixels across the screen - so 1920 dots.  Now let's say your plot has 5760 data points (time stamp/values).  That means each pixel or dot on your screen must represent 3 values (1920 pixels, 5760 data points) if you get all 5760 values.  So which one of these 3 values do you put on each dot on your screen?  I hope that further explains the reasoning behind the PlotValues call.

                        --

                        Steve Kwan

                        2 of 2 people found this helpful