Class cwstats
The statistics utility calculates a number of statistics for each variable in an earth data file.
Name
cwstats - calculates earth data file statistics.
Synopsis
cwstats [OPTIONS] input
Options:
-h, --help
-i, --region=LAT/LON/RADIUS
-l, --limit=STARTROW/STARTCOL/ENDROW/ENDCOL
-m, --match=PATTERN
-p, --polygon=FILE
-s, --stride=N
-S, --sample=FACTOR
--version
Description
The statistics utility calculates a number of statistics for each variable in an earth data file:
- Count - the count of total data values sampled
- Valid - the number of valid (not missing) data values
- Min - the minimum data value
- Max - the maximum data value
- Mean - the average data value
- Stdev - the standard deviation from the mean
- Median - the median data value
To speed up the statistics calculations, a subset of the data values in each variable may be specified using either the --stride or --sample options, and one of the --limit, --region, or --polygon options. The --match option may also be used to limit the statistics calculations to a subset of the variables.
Parameters
Main parameters:
- input
- The input data file name.
Options:
- -h, --help
- Prints a brief help message.
- -i, --region=LAT/LON/RADIUS
- The sampling region for each two-dimensional variable. The region is specified by the center latitude and longitude in degrees, and the radius from the center in kilometers. Only data within the rectangle specified by the center and radius is sampled. By default, all data is sampled. Only one of the --region, --limit, or --polygon options may be specified.
- -l, --limit=STARTROW/ENDROW/STARTCOL/ENDCOL
- The sampling limits for each two-dimensional variable in image coordinates. Only data between the limits is sampled. By default, all data is sampled. Only one of the --region, --limit, or --polygon options may be specified.
- -m, --match=PATTERN
- The variable name matching pattern. If specified, the pattern is used as a regular expression to match variable names. Only variables matching the pattern are included in the calculations. By default, no pattern matching is performed and all variables are included.
- -p, --polygon=FILE
- The file name containing a list of polygon vertex points to use for constraining the statistics calculation. The file must be an ASCII text file containing vertex points as latitude / longitude pairs, one pair per line, with values separated by spaces or tabs. The points are specified in terms of earth location latitude and longitude in the range [-90..90] and [-180..180] with a datum matching that of the input file. Only data inside the polygon is sampled. By default, all data is sampled. Only one of the --region, --limit, or --polygon options may be specified.
- -s, --stride=N
- The sampling frequency for each variable dimension. The default is to sample all data values (stride = 1).
- -S, --sample=FACTOR
- The sampling factor for each variable. The sampling factor is a value in the range [0..1] that specifies the number of data values sampled as a fraction of the total number of data values. Optionally, the sample value can be specified in percent, eg: 50%. To sample 1 percent of all data values, the sample factor would be specified as 0.01 or 1%. The default is to sample all data values (factor = 1).
- --version
- Prints the software version.
Exit status
0 on success, > 0 on failure. Possible causes of errors:
- Invalid command line option
- Invalid input file name
- Unsupported input file format
- Error reading input data values
Examples
The following shows a statistics calculation on a CoastWatch HDF file from the Great Lakes:
phollema$ cwstats 2002_197_1719_n16_gr.hdf Variable Count Valid Min Max Mean Stdev avhrr_ch1 1048576 483728 3.49 74.36 13.059646 11.371605 avhrr_ch2 1048576 483728 1.97 71.35 18.520041 9.844144 avhrr_ch3a 1048576 483728 0.53 52.84 14.664213 8.88201 avhrr_ch4 1048576 483728 -44.8 31.55 11.052207 13.683309 avhrr_ch5 1048576 483728 -45.48 27.05 7.978351 13.185983 sst 1048576 483728 -44.51 51.43 20.166333 16.714169 cloud 1048576 1048576 0 127 23.24175 37.179013 sat_zenith 1048576 483728 0.36 0.7 0.466376 0.077153 sun_zenith 1048576 483728 0.87 0.95 0.907019 0.022209 rel_azimuth 1048576 483728 -0.58 -0.33 -0.465731 0.058149 graphics 1048576 1048576 0 14 6.84576 2.931459
- Since:
- 3.1.0
- Author:
- Peter Hollemans
-
Method Summary
Modifier and TypeMethodDescriptionstatic void
Performs the main function.static void
printStats
(EarthDataReader reader, DataLocation start, DataLocation end, Shape polygon, int stride, double sample, String match) Prints the variable statistics information.
-
Method Details
-
main
Performs the main function.- Parameters:
argv
- the list of command line parameters.
-
printStats
public static void printStats(EarthDataReader reader, DataLocation start, DataLocation end, Shape polygon, int stride, double sample, String match) Prints the variable statistics information.- Parameters:
reader
- the earth data reader object to use.start
- the starting data location, or null for the beginning of the data.end
- the ending data location, or null for the end of the data.polygon
- the polygon to use for constraining the statistics calculation, or null to use the values of start and end.stride
- the sampling stride for each variable.sample
- the sampling factor for each variable, orDouble.NaN
if the sampling stride should be used.match
- the variable name matching pattern, or null for all variables.- See Also:
-