GPT Cookbook: StatisticsOp


Generates statistics for an input source file and writes results to a text file.


Example 1  Statistics for 2 Bands

Example 2  Statistics for 2 Bands with Modified Valid Pixel Expression

Example 3  Statistics for 2 Bands with Shapefile

Example 4  Statistics for 2 Bands and 2 Math Bands








Example 1    Statistics for 2 Bands


This generates statistics for two bands (chlor_a and Kd_490).


Command Line Entry

gpt StatisticsGraphEx01.xml -p StatisticsEx01.par -Pifile=A2010283180500.L2_LAC_OC.nc -PoutputAsciiFile=A2010283180500.L2_LAC_OC_statsEx01.txt

File = StatisticsGraphEx01.xml

<graph id="StatisticsGraph">
  <version>1.0</version>

  <node id="Read">
    <operator>Read</operator>
    <sources/>
    <parameters class="com.bc.ceres.binding.dom.XppDomElement">
       <file>${ifile}</file>
       <formatName>SeaDAS-L2</formatName>
    </parameters>
  </node>

  <node id="StatisticsOp">
    <operator>StatisticsOp</operator>
    <sources>
       <sourceProduct refid="Read"/>
    </sources>
    <parameters class="com.bc.ceres.binding.dom.XppDomElement">
       <bandConfigurations>
          <bandConfiguration>
            <sourceBandName>${band1}</sourceBandName>
          </bandConfiguration>
          <bandConfiguration>
            <sourceBandName>${band2}</sourceBandName>
          </bandConfiguration>
       </bandConfigurations>
       <outputAsciiFile>${outputAsciiFile}</outputAsciiFile>
       <percentiles>${percentiles}</percentiles>
    </parameters>
  </node>

</graph>

File = StatisticsEx01.par

band1=chlor_a
band2=Kd_490
percentiles=80,85,90




Example 2    Statistics for 2 Bands with Modified Valid Pixel Expression


This generates statistics for two bands (chlor_a and Kd_490) with a custom defined valid pixel expression.


Command Line Entry

gpt StatisticsGraphEx02.xml -p StatisticsEx02.par -Pifile=A2010283180500.L2_LAC_OC.nc -PoutputAsciiFile=A2010283180500.L2_LAC_OC_statsEx02.txt

File = StatisticsGraphEx02.xml

<graph id="StatisticsValidPixelGraph">
  <version>1.0</version>
  <node id="Read">
    <operator>Read</operator>
    <sources/>
    <parameters class="com.bc.ceres.binding.dom.XppDomElement">
       <file>${ifile}</file>
       <formatName>SeaDAS-L2</formatName>
    </parameters>
  </node>

  <node id="StatisticsOp">
    <operator>StatisticsOp</operator>
    <sources>
       <sourceProduct refid="Read"/>
    </sources>
    <parameters class="com.bc.ceres.binding.dom.XppDomElement">
       <bandConfigurations>
          <bandConfiguration>
            <sourceBandName>${band1}</sourceBandName>
            <validPixelExpression>${band1ValidPixelExpression}</validPixelExpression>
          </bandConfiguration>
          <bandConfiguration>
            <sourceBandName>${band2}</sourceBandName>
            <validPixelExpression>${band2ValidPixelExpression}</validPixelExpression>
          </bandConfiguration>
       </bandConfigurations>
       <outputAsciiFile>${outputAsciiFile}</outputAsciiFile>
       <percentiles>${percentiles}</percentiles>
    </parameters>
  </node>

</graph>

File = StatisticsEx02.par

band1=chlor_a
band1ValidPixelExpression=chlor_a &gt; 0.001 and chlor_a &lt; 100 and !l2_flags.HIGLINT and !l2_flags.HISATZEN and !l2_flags.LOWLW and !l2_flags.HILT
band2=Kd_490
band2ValidPixelExpression=Kd_490 &gt;= 0.01000 and Kd_490 &lt;= 6.00000 and !l2_flags.HIGLINT and !l2_flags.HISATZEN and !l2_flags.LOWLW and !l2_flags.HILT
percentiles=80,85,90




Example 3    Statistics for 2 Bands with Shapefile


This generates statistics for two bands (chlor_a and Kd_490) within a region defined by a loaded shapefile.


Command Line Entry

gpt StatisticsGraphEx03.xml -p StatisticsEx03.par -Pifile=A2010283180500.L2_LAC_OC.nc -PoutputAsciiFile=A2010283180500.L2_LAC_OC_statsEx03.txt

File = StatisticsGraphEx03.xml

<graph id="StatisticsShapeFileGraph">
  <version>1.0</version>

  <node id="Read">
    <operator>Read</operator>
    <sources/>
    <parameters class="com.bc.ceres.binding.dom.XppDomElement">
       <file>${ifile}</file>
       <formatName>SeaDAS-L2</formatName>
    </parameters>
  </node>

  <node id="StatisticsOp">
    <operator>StatisticsOp</operator>
    <sources>
       <sourceProduct refid="Read"/>
    </sources>
    <parameters class="com.bc.ceres.binding.dom.XppDomElement">
       <shapefile>${shapefile}</shapefile>
       <bandConfigurations>
          <bandConfiguration>
            <sourceBandName>${band1}</sourceBandName>
          </bandConfiguration>
          <bandConfiguration>
            <sourceBandName>${band2}</sourceBandName>
          </bandConfiguration>
       </bandConfigurations>
       <outputAsciiFile>${outputAsciiFile}</outputAsciiFile>
       <percentiles>${percentiles}</percentiles>
    </parameters>
  </node>

</graph>

File = StatisticsEx03.par

band1=chlor_a
band2=Kd_490
shapefile=geometry_Polygon.shp
percentiles=80,85,90




Example 4    Statistics for 2 Bands and 2 Math Bands


This generates statistics for two bands (chlor_a and Kd_490) and two Math bands:

Math Band 1. apparent optical depth derived from Kd_490.

Math Band 2. pic in units of kmol m^-3.

Note: when adding a math band in the StatisticsOp, if you want a validPixelExpression you must specifically define it because it is not automatically derived from the constituent source bands


Command Line Entry

gpt StatisticsGraphEx04.xml -p StatisticsEx04.par -Pifile=A2010283180500.L2_LAC_OC.nc -PoutputAsciiFile=A2010283180500.L2_LAC_OC_statsEx04.txt

File = StatisticsGraphEx04.xml

<graph id="StatisticsMathBandGraph">
  <version>1.0</version>

  <node id="Read">
    <operator>Read</operator>
    <sources/>
    <parameters class="com.bc.ceres.binding.dom.XppDomElement">
       <file>${ifile}</file>
       <formatName>SeaDAS-L2</formatName>
    </parameters>
  </node>

  <node id="StatisticsOp">
    <operator>StatisticsOp</operator>
    <sources>
       <sourceProduct refid="Read"/>
    </sources>
    <parameters class="com.bc.ceres.binding.dom.XppDomElement">
       <bandConfigurations>
          <bandConfiguration>
            <sourceBandName>${band1}</sourceBandName>
          </bandConfiguration>
          <bandConfiguration>
            <sourceBandName>${band2}</sourceBandName>
          </bandConfiguration>
              <bandConfiguration>
            <expression>${mathBand1Expression}</expression>
            <validPixelExpression>${mathBand1ValidPixelExpression}</validPixelExpression>
          </bandConfiguration>
          <bandConfiguration>
            <expression>${mathBand2Expression}</expression>
            <validPixelExpression>${mathBand2ValidPixelExpression}</validPixelExpression>
          </bandConfiguration>
       </bandConfigurations>
       <outputAsciiFile>${outputAsciiFile}</outputAsciiFile>
       <percentiles>${percentiles}</percentiles>
    </parameters>
  </node>

</graph>

File = StatisticsEx04.par

band1=chlor_a
band2=Kd_490
mathBand1Expression=if (Kd_490 != 0) then 1.3/Kd_490 else NaN
mathBand1ValidPixelExpression=Kd_490 &gt;= 0.01000 and Kd_490 &lt;= 6.00000
mathBand2Expression=1000*pic
mathBand2ValidPixelExpression=pic &gt;= -0.00000 and pic &lt;= 0.12500
percentiles=80,85,90