graphchartstime-seriesaxibase

Axibase Time Series Database - filter out negative values on time chart


I am using Axibase Time Series Database Community Edition, version 10552, to store my photovoltaic and sun altitude data. Sun altitude values are negative during the night time and I don't want to see them on my graphs.

How can I view only the positive values? Anyone know a setting or a trick that can acheive this?

Here is my current Time Chart widget configuration:

[widget]
  type = chart
  title = PV power
  timespan = 3 day
  entity = pvout.25630

[series]
  label = Sun Altitude at (-35.3089, 149.2004)
  metric = sun_altitude
  color = orange
   [tags]
    lat = -35.3089 
    lon = 149.2004

Here is a screenshot of what I am actually seeing at the moment:

enter image description here

Here is an example in Chart Lab:

https://axibase.com/chartlab/3170e35d/2/


Solution

  • Good question.

    There are several ways to hide or filter out the negative values:

    1. replace-value setting uses an expression to modify or filter series values:

      [widget]
        type = chart
        title = PV power
        timespan = 3 day
        entity = pvout.25630
      
      [series]
        label = Sun Altitude at (-35.3089, 149.2004)
        metric = sun_altitude
        color = orange
      
        replace-value = value < 0 ? null : value
      
        [tags]
         lat=-35.3089 
         lon=149.2004
      

    This expression will filter out all values that are less than 0 from the series.

    Results: https://axibase.com/chartlab/3170e35d/3/

    replace-value

    1. min-range-force setting can be used to set the minimum range of the y-axis:

      [widget]
        type = chart
        title = PV power
        timespan = 3 day
        entity = pvout.25630
      
        min-range-force = 0
      
      [series]
        label = Sun Altitude at (-35.3089, 149.2004)
        metric = sun_altitude
        color = orange
      
        [tags]
         lat=-35.3089 
         lon=149.2004
      

    Results: https://axibase.com/chartlab/3170e35d/4/

    enter image description here

    1. If you are using a script to calculate the Sun Altitude, then you can use the Math.max function:

      [widget]
        type = chart
        title = PV power
        timespan = 3 day
      
      [series]
        label = Altitude
        #API: SunCalc.getPosition = function (date, lat, lng)
        value = var pos = SunCalc.getPosition(new Date(time), -35.3089, 149.2004);
        value = return Math.max(0, pos.altitude)
        frequency = 30 minute
        color = orange
      

    Results: https://axibase.com/chartlab/3170e35d/5/

    enter image description here

    1. value equation can be used to create a computed series, excluding the negative values:

      [widget]
        type = chart
        title = PV power
        timespan = 3 day
        entity = pvout.25630
      
      [series]
        metric = sun_altitude
        display = false
        alias = sun_alt
      
       [tags]
        lat=-35.3089 
        lon=149.2004
      
      [series]
        label = Sun Altitude at (-35.3089, 149.2004)
        value = Math.max(0, value('sun_alt'))
        color = orange
      

    In this case, we hide the original series and assign an alias, then we use the value = Math.max(0, value('sun_alt')) equation to create a new computed series without the negative values.

    Results: https://axibase.com/chartlab/3170e35d/6/

    enter image description here