The 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 Statistics.xml -p StatisticsEx01.par -Ssource=A2010283180500.L2_LAC_OC.nc -PoutputAsciiFile=A2010283180500.L2_LAC_OC_stats.txt

File = Statistics.xml

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

    <node id="StatisticsOpNode">
      <operator>StatisticsOp</operator>
      <sources>
        <source>${source}</source>
      </sources>
      <parameters>
        <bandConfigurations>
          <bandConfiguration>
            <sourceBandName>${band1}</sourceBandName>
          </bandConfiguration>
          <bandConfiguration>
            <sourceBandName>${band2}</sourceBandName>
          </bandConfiguration>
        </bandConfigurations>
        <outputAsciiFile>${outputAsciiFile}</outputAsciiFile>
        <percentiles>${percentiles}</percentiles>
        <numBins>${numBins}</numBins>
        <calculateMedian>${calculateMedian}</calculateMedian>
      </parameters>
    </node>

</graph>

File = StatisticsEx01.par

band1=chlor_a
band2=Kd_490
percentiles=80,85,90
numBins=1000
calculateMedian=true




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 StatisticsValidPixel.xml -p StatisticsEx02.par -Ssource=A2010283180500.L2_LAC_OC.nc -PoutputAsciiFile=A2010283180500.L2_LAC_OC_stats.txt

File = StatisticsValidPixel.xml

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

    <node id="StatisticsOpNode">
      <operator>StatisticsOp</operator>
      <sources>
        <source>${source}</source>
      </sources>
      <parameters>
        <bandConfigurations>
          <bandConfiguration>
            <sourceBandName>${band1}</sourceBandName>
            <validPixelExpression>${band1ValidPixelExpression}</validPixelExpression>
          </bandConfiguration>
          <bandConfiguration>
            <sourceBandName>${band2}</sourceBandName>
            <validPixelExpression>${band2ValidPixelExpression}</validPixelExpression>
          </bandConfiguration>
        </bandConfigurations>
        <outputAsciiFile>${outputAsciiFile}</outputAsciiFile>
        <percentiles>${percentiles}</percentiles>
        <numBins>${numBins}</numBins>
        <calculateMedian>${calculateMedian}</calculateMedian>
      </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
numBins=1000
calculateMedian=true




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 StatisticsShapefile.xml -p StatisticsEx03.par -Ssource=A2010283180500.L2_LAC_OC.nc -PoutputAsciiFile=A2010283180500.L2_LAC_OC_stats.txt

File = StatisticsShapefile.xml

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

    <node id="StatisticsOpNode">
      <operator>StatisticsOp</operator>
      <sources>
        <source>${source}</source>
      </sources>
      <parameters>
        <shapefile>${shapefile}</shapefile>
        <bandConfigurations>
          <bandConfiguration>
            <sourceBandName>${band1}</sourceBandName>
          </bandConfiguration>
          <bandConfiguration>
            <sourceBandName>${band2}</sourceBandName>
          </bandConfiguration>
        </bandConfigurations>
        <outputAsciiFile>${outputAsciiFile}</outputAsciiFile>
        <percentiles>${percentiles}</percentiles>
        <numBins>${numBins}</numBins>
        <calculateMedian>${calculateMedian}</calculateMedian>
      </parameters>
    </node>

</graph>

File = StatisticsEx03.par

band1=chlor_a
band2=Kd_490
shapefile=geometry_Polygon.shp
percentiles=80,85,90
numBins=1000
calculateMedian=true




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 StatisticsMathBand.xml -p StatisticsEx04.par -Ssource=A2010283180500.L2_LAC_OC.nc -PoutputAsciiFile=A2010283180500.L2_LAC_OC_stats.txt

File = StatisticsMathBand.xml

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

    <node id="StatisticsOpNode">
      <operator>StatisticsOp</operator>
      <sources>
        <source>${source}</source>
      </sources>
      <parameters>
        <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>
        <numBins>${numBins}</numBins>
        <calculateMedian>${calculateMedian}</calculateMedian>
      </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
numBins=1000
calculateMedian=true