MISR Toolkit  1.5.1
Data Structures | Macros | Functions
MisrRegression.h File Reference
#include "MisrUtil.h"
#include "MisrError.h"
#include "MisrProjParam.h"
#include "MisrMapQuery.h"

Go to the source code of this file.

Data Structures

struct  MTKt_RegressionCoeff
 

Macros

#define MTKT_REGRESSION_COEFF_INIT
 

Functions

MTKt_status MtkRegressionCoeffAllocate (int nline, int nsample, MTKt_RegressionCoeff *regressbuf)
 Allocate buffer to contain regression coefficients. More...
 
MTKt_status MtkRegressionCoeffFree (MTKt_RegressionCoeff *regressbuf)
 Free memory for regression coefficients. More...
 
MTKt_status MtkLinearRegressionCalc (int Size, const double *X, const double *Y, const double *YSigma, double *A, double *B, double *Correlation)
 Use linear regression to fit a set of observations (x,y) to the model: y(x) = a + b * x. The values of 'x' are assumed to be known exactly. The values of 'y' may have an associated uncertainty, 'y_sigma'. Measurements with larger uncertainty are given less weight. Uncertainty must be greater than 0. More...
 
MTKt_status MtkSmoothData (const MTKt_DataBuffer *Data, const MTKt_DataBuffer *Valid_mask, int Width_line, int Width_sample, MTKt_DataBuffer *Data_smoothed)
 Smooth the given array with a boxcar average of the specified width. The algorithm is similar to the IDL smooth routine. Smoothed data is type float. More...
 
MTKt_status MtkRegressionCoeffCalc (const MTKt_DataBuffer *Data1, const MTKt_DataBuffer *Valid_mask1, const MTKt_DataBuffer *Data2, const MTKt_DataBuffer *Data2_sigma, const MTKt_DataBuffer *Valid_mask2, const MTKt_MapInfo *Map_info, int Regression_size_factor, MTKt_RegressionCoeff *Regression_coeff, MTKt_MapInfo *Regression_map_info)
 Calculate linear regression coefficients for translating values in data buffer 1 to corresponding values in data buffer 2. More...
 
MTKt_status MtkResampleRegressionCoeff (const MTKt_RegressionCoeff *Regression_coeff, const MTKt_MapInfo *Regression_coeff_map_info, const MTKt_MapInfo *Target_map_info, MTKt_RegressionCoeff *Regression_coeff_out)
 Resample regression coefficients at each pixel in the target map. Resampling is by cubic convolution. More...
 
MTKt_status MtkApplyRegression (const MTKt_DataBuffer *Source, const MTKt_DataBuffer *Source_mask, const MTKt_MapInfo *Source_map_info, const MTKt_RegressionCoeff *Regression_coeff, const MTKt_MapInfo *Regression_coeff_map_info, MTKt_DataBuffer *Regressed, MTKt_DataBuffer *Regressed_mask)
 Apply regression to given data. Uses MtkResampleCubicConvolution to resample regression coefficients to resolution of the input data. Output data is the same size and resolution as the input data. More...
 
MTKt_status MtkDownsample (const MTKt_DataBuffer *Source, const MTKt_DataBuffer *Source_mask, int Size_factor, MTKt_DataBuffer *Result, MTKt_DataBuffer *Result_mask)
 Downsample data by averaging pixels. More...
 
MTKt_status MtkUpsampleMask (const MTKt_DataBuffer *Source_mask, int Size_factor, MTKt_DataBuffer *Result_mask)
 Upsample a mask by nearest neighbor sampling. More...
 

Macro Definition Documentation

◆ MTKT_REGRESSION_COEFF_INIT

#define MTKT_REGRESSION_COEFF_INIT
Value:
{ \
MTKT_DATABUFFER_INIT, \
MTKT_DATABUFFER_INIT, \
MTKT_DATABUFFER_INIT, \
}

Definition at line 32 of file MisrRegression.h.

Function Documentation

◆ MtkApplyRegression()

MTKt_status MtkApplyRegression ( const MTKt_DataBuffer Source,
const MTKt_DataBuffer Source_mask,
const MTKt_MapInfo Source_map_info,
const MTKt_RegressionCoeff Regression_coeff,
const MTKt_MapInfo Regression_coeff_map_info,
MTKt_DataBuffer Regressed,
MTKt_DataBuffer Regressed_mask 
)

Apply regression to given data. Uses MtkResampleCubicConvolution to resample regression coefficients to resolution of the input data. Output data is the same size and resolution as the input data.

Returns
MTK_SUCCESS if successful.
Example:
In this example we apply a regression based on the supplied source, source_mask, and source_map_info using regression_coeff and regression_coeff_map_info. The result is regressed and regressed_mask.
status = MtkApplyRegression(&source, &source_mask, &source_map_info, &regression_coeff, &regression_coeff_map_info, &regressed, &regressed_mask);
Note
Parameters
[in]SourceInput data. (float)
[in]Source_maskValid mask for input data. (uint8)
[in]Source_map_infoMap info for input data
[in]Regression_coeffRegression coefficients
[in]Regression_coeff_map_infoMap info for regression coefficients
[out]RegressedOutput data. (float)
[out]Regressed_maskValid mask for output data. (uint8)

Definition at line 36 of file MtkApplyRegression.c.

◆ MtkDownsample()

MTKt_status MtkDownsample ( const MTKt_DataBuffer Source,
const MTKt_DataBuffer Source_mask,
int  Size_factor,
MTKt_DataBuffer Result,
MTKt_DataBuffer Result_mask 
)

Downsample data by averaging pixels.

Returns
MTK_SUCCESS if successful.
Example:
In this example we downsample source with source_mask by size_factor. The result is stored in result with result_mask.
status = MtkDownsample(&source, &source_mask, size_factor, &result, &result_mask);
Note
Parameters
[in]SourceSource data. (float)
[in]Source_maskValid mask for source data. (uint8)
[in]Size_factorNumber of pixels to aggregate along each dimension.
[out]ResultDownsampled result. (float)
[out]Result_maskValid mask for result. (uint8)

Definition at line 36 of file MtkDownsample.c.

◆ MtkLinearRegressionCalc()

MTKt_status MtkLinearRegressionCalc ( int  Size,
const double *  X,
const double *  Y,
const double *  Y_Sigma,
double *  A,
double *  B,
double *  Correlation 
)

Use linear regression to fit a set of observations (x,y) to the model: y(x) = a + b * x. The values of 'x' are assumed to be known exactly. The values of 'y' may have an associated uncertainty, 'y_sigma'. Measurements with larger uncertainty are given less weight. Uncertainty must be greater than 0.

Returns
MTK_SUCCESS if successful.
Example:
double x[4] = {1,5,7,8};
double y[4] = {12,14,19,21};
double y_sigma[4] = {0.1,0.2,0.2,0.3};
double a, b;
status = MtkLinearRegressionCalc(4, x, y, y_sigma, &a, &b)
Note
Parameters
[in]SizeSize of X and Y arrays
[in]XX array
[in]YY array
[in]Y_SigmaUncertainty in Y
[out]AA
[out]BB
[out]CorrelationCorrelation

Definition at line 39 of file MtkLinearRegressionCalc.c.

◆ MtkRegressionCoeffAllocate()

MTKt_status MtkRegressionCoeffAllocate ( int  nline,
int  nsample,
MTKt_RegressionCoeff regressbuf 
)

Allocate buffer to contain regression coefficients.

Returns
MTK_SUCCESS if successful.
Example:
In this example, we allocate a buffer with a size of 5 lines by 10 samples of type MTKe_int16
status = MtkRegressionCoeffAllocate(5, 10, &regressbuf);
Note
The caller is responsible for using MtkRegressionCoeffFree() to free the memory used by regressbuf
Parameters
[in]nlineNumber of lines
[in]nsampleNumber of samples
[out]regressbufData Buffer

Definition at line 36 of file MtkRegressionCoeffAllocate.c.

◆ MtkRegressionCoeffCalc()

MTKt_status MtkRegressionCoeffCalc ( const MTKt_DataBuffer Data1,
const MTKt_DataBuffer Valid_mask1,
const MTKt_DataBuffer Data2,
const MTKt_DataBuffer Data2_sigma,
const MTKt_DataBuffer Valid_mask2,
const MTKt_MapInfo Map_info,
int  Regression_size_factor,
MTKt_RegressionCoeff Regression_coeff,
MTKt_MapInfo Regression_coeff_map_info 
)

Calculate linear regression coefficients for translating values in data buffer 1 to corresponding values in data buffer 2.

Returns
MTK_SUCCESS if successful.
Example:
In this example we determine coefficients to map values in data1 with mask valid_mask1 to data2 having mask valid_mask2 and uncertainty data2_sigma. Linear regression will use pixel neighborhood size specified by regression_size_factor and output the results to regression_coeff with regression_coeff_map_info.
status = MtkRegressionCoeffCalc(&data1, &valid_mask1, &data2, &data2_sigma, &valid_mask2, &map_info, regression_size_factor, &regression_coeff, &regression_coeff_map_info);
Note
Parameters
[in]Data1Data buffer 1
[in]Valid_mask1Valid mask for data buffer 1
[in]Data2Data buffer 2
[in]Data2_sigmaUncertainty for data buffer 2
[in]Valid_mask2Valid mask for data buffer 2
[in]Map_infoMap info for input data.
[in]Regression_size_factorNumber of pixels to aggregate along each axis when generating regression coefficients.
[out]Regression_coeffRegression coefficients.
[out]Regression_coeff_map_infoMap info for regression coefficients

Definition at line 36 of file MtkRegressionCoeffCalc.c.

◆ MtkRegressionCoeffFree()

MTKt_status MtkRegressionCoeffFree ( MTKt_RegressionCoeff regressbuf)

Free memory for regression coefficients.

Returns
MTK_SUCCESS
Example:
In this example, we have a MTKt_RegressionCoeff called regressbuf that was previously allocated with MtkRegressionCoeffAllocate() and we wish to free it.
status = MtkRegressionCoeffFree(&regressbuf);
Parameters
[in,out]regressbufData Buffer

Definition at line 33 of file MtkRegressionCoeffFree.c.

◆ MtkResampleRegressionCoeff()

MTKt_status MtkResampleRegressionCoeff ( const MTKt_RegressionCoeff Regression_coeff,
const MTKt_MapInfo Regression_coeff_map_info,
const MTKt_MapInfo Target_map_info,
MTKt_RegressionCoeff Regression_coeff_out 
)

Resample regression coefficients at each pixel in the target map. Resampling is by cubic convolution.

Returns
MTK_SUCCESS if successful.
Example:
In this example we use cubic convolution to resample regression_coeff with regression_coeff_map_info to target_map_info. Output is at regression_coeff_out.
status = MtkResampleRegressionCoeff(&regression_coeff, &regression_coeff_map_info, &target_map_info, &regression_coeff_out);
Note
MtkRegressionCoeffCalc() can be used to generate regression_coeff and regression_coeff_map_info from 2 data sets and masks.
Parameters
[in]Regression_coeffRegression coefficients.
[in]Regression_coeff_map_infoMap info for regression coefficients.
[in]Target_map_infoMap info for target grid.
[out]Regression_coeff_outRegression coefficients resampled to target grid.

Definition at line 38 of file MtkResampleRegressionCoeff.c.

◆ MtkSmoothData()

MTKt_status MtkSmoothData ( const MTKt_DataBuffer Data,
const MTKt_DataBuffer Valid_mask,
int  Width_line,
int  Width_sample,
MTKt_DataBuffer Data_smoothed 
)

Smooth the given array with a boxcar average of the specified width. The algorithm is similar to the IDL smooth routine. Smoothed data is type float.

Returns
MTK_SUCCESS if successful.
Example:
In this example we smooth data with mask valid_mask and smoothing window widths width_line and width_sample. Output is data_smoothed.
status = MtkSmoothData(&data, &valid_mask, width_line, width_sample, &data_smoothed);
Note
Parameters
[in]DataData. (float)
[in]Valid_maskMask inidicating where data is valid. (uint8)
[in]Width_lineWidth of smoothing window along line dimension. Must be and odd number.
[in]Width_sampleWidth of smoothing window along sample dimension. Must be an odd number.
[out]Data_smoothedSmoothed data. (float)

Definition at line 36 of file MtkSmoothData.c.

◆ MtkUpsampleMask()

MTKt_status MtkUpsampleMask ( const MTKt_DataBuffer Source_mask,
int  Size_factor,
MTKt_DataBuffer Result_mask 
)

Upsample a mask by nearest neighbor sampling.

Returns
MTK_SUCCESS if successful.
Example:
In this example we upsample source_mask by a factor of size_factor. The output is result_mask.
status = MtkUpsampleMask(&source_mask, size_factor, &result_mask);
Note
Parameters
[in]Source_maskSource mask. (uint8)
[in]Size_factorNumber of pixels to expand along each dimension.
[out]Result_maskUpsampled result. (uint8)

Definition at line 36 of file MtkUpsampleMask.c.


MISR Toolkit - Copyright © 2005 - 2020 Jet Propulsion Laboratory
Generated on Fri Jun 19 2020 22:49:53