OpenZGY/C++ API and Internals (ALPHA)
Access seismic data stored in ZGY format.
Public Types | Public Member Functions | List of all members
InternalZGY::StatisticData Class Reference

Holds the result of computing statistics. More...

#include <statisticdata.h>

Public Types

typedef std::int64_t count_type
 

Public Member Functions

 StatisticData ()
 
 StatisticData (count_type cnt, count_type inf, double sum, double ssq, double min, double max)
 
 StatisticData (const count_type *bins, int nbins, double range_min, double range_max, bool is_int8)
 
void add (double value)
 
StatisticDataoperator+= (const StatisticData &other)
 
StatisticDataoperator-= (const StatisticData &other)
 
StatisticDataoperator*= (count_type factor)
 
void scale (double oldmin, double oldmax, double newmin, double newmax)
 
void trimRange (const count_type *bins, int nbins, double range_min, double range_max)
 

Detailed Description

Holds the result of computing statistics.

Constructor & Destructor Documentation

◆ StatisticData() [1/3]

InternalZGY::StatisticData::StatisticData ( )

Initialize a StatisticData to empty. min/max are by definition irrelevant when count is zero, but they will be set to 0 here just to have a consistent value.

◆ StatisticData() [2/3]

InternalZGY::StatisticData::StatisticData ( count_type  cnt,
count_type  inf,
double  sum,
double  ssq,
double  min,
double  max 
)

Initialize a StatisticData from discrete values.

◆ StatisticData() [3/3]

InternalZGY::StatisticData::StatisticData ( const count_type *  bins,
int  nbins,
double  range_min,
double  range_max,
bool  is_int8 
)

Create a StatisticData from histogram information.

If is_int8 is true, the histogram was populated from 8-bit data and the histogram has 256 bins. In this case the result will be precise. The method needs to be told about this. Otherwise it would have to add 1/2 bin width slop, not knowing that there can only be a single value in each bin. That value might not be integral any longer due to scaling, buit there can still only be one.

If is_int8 is false, this isn't as accurate as the actual statistics since each sample will be rounded to the center of the bin it falls in. Also, Inf will always be 0 since the histogram doesn't count outliers. The result is still useful as a consistency check. And also to update the min/max range in the real statistics after subtracting samples.

Member Function Documentation

◆ add()

void InternalZGY::StatisticData::add ( double  value)

Add a single sample to the statistics.

◆ operator*=()

StatisticData & InternalZGY::StatisticData::operator*= ( count_type  factor)

Multiply StatisticData with a constant N, equivalent to creating a new instance and adding the old one to it N times. N can also be negative. The min/max range is not affected.

◆ operator+=()

StatisticData & InternalZGY::StatisticData::operator+= ( const StatisticData other)

Add more samples to an existing StatisticData. other is also allowed to hold negative counts, this will cause samples to be removed. But the min/max range will still be expanded.

◆ operator-=()

StatisticData & InternalZGY::StatisticData::operator-= ( const StatisticData other)

Remove samples from an existing StatisticData. The resulting min/max range will be the union of the two classes, not the intersection. Could also have chosen to leave the min/max uncanged. But it is more consistent to do a union, because -a+b will then work like b-a. Either way, you can call trimRange() afterwards if you know what the range ought to be.

◆ scale()

void InternalZGY::StatisticData::scale ( double  oldmin,
double  oldmax,
double  newmin,
double  newmax 
)

Calculate the linear transform needed to convert from one range (typically the natural data range of the integral storage type) to the data range that the application wants to see. Then update the statistics so they look like the transform had been done on every single data point before adding it.

Note: If caler has (slope, intercept) instead of the 4 factors, pass oldmin=0, oldmax=1, newmin=intercept, newmax=intercept+slope.

◆ trimRange()

void InternalZGY::StatisticData::trimRange ( const count_type *  bins,
int  nbins,
double  range_min,
double  range_max 
)

Try to narrow the range found in the statistics based on the information we have in the histogram. This is particularly useful after subtracting something from the histogram.

The range found in the histogram is normally wider than or equal to the statistics range. If this is not the case, we know the min/max in the statistics are incorrect. We cannot know the precise new range without rescanning all the data, but we can approximate it using the histogram. There is no point in doing any of this if the histogram is empty. In that case min/max are irrelevant, and will be reset once data has been added. If any of the overflow bins are in use, these are ignored. That should not happen in normal circumstances, but could occur if stats are calculated from application provided data, but maintained in a fixed histogram because that is what the file format dictates.


The documentation for this class was generated from the following files: