RAVE
|
Represents a 2-dimensional data array. More...
Go to the source code of this file.
Typedefs | |
typedef struct _RaveData2D_t | RaveData2D_t |
Defines a Rave 2-dimensional data array. | |
Functions | |
void | RaveData2D_useNodata (RaveData2D_t *self, int use) |
Sets if the operations should take into account nodata value or not. | |
int | RaveData2D_usingNodata (RaveData2D_t *self) |
Returns if the calculations are taking into account the nodata value. | |
void | RaveData2D_setNodata (RaveData2D_t *self, double nodata) |
double | RaveData2D_getNodata (RaveData2D_t *self) |
long | RaveData2D_getXsize (RaveData2D_t *self) |
Returns the xsize. | |
long | RaveData2D_getYsize (RaveData2D_t *self) |
Returns the ysize. | |
RaveDataType | RaveData2D_getType (RaveData2D_t *self) |
Returns the data type. | |
void * | RaveData2D_getData (RaveData2D_t *self) |
Returns a pointer to the internal data storage. | |
int | RaveData2D_setData (RaveData2D_t *self, long xsize, long ysize, void *data, RaveDataType type) |
Sets the data. | |
int | RaveData2D_createData (RaveData2D_t *self, long xsize, long ysize, RaveDataType type, double value) |
Creates a data field with the specified size and type. | |
int | RaveData2D_fill (RaveData2D_t *self, double v) |
Fills the field with the specified value. | |
int | RaveData2D_setValue (RaveData2D_t *self, long x, long y, double v) |
Sets the value at the specified coordinates. | |
int | RaveData2D_setValueUnchecked (RaveData2D_t *self, long x, long y, double v) |
Same as RaveData2D_setValue but there is no boundary checking performed. | |
int | RaveData2D_getValue (RaveData2D_t *self, long x, long y, double *v) |
Returns the value at the specified x and y position. | |
int | RaveData2D_getValueUnchecked (RaveData2D_t *self, long x, long y, double *v) |
Same as RaveData2D_getValue but there is no boundary checking performed. | |
int | RaveData2D_hasData (RaveData2D_t *self) |
Returns if this object contains data and a xsize and ysize > 0. | |
double | RaveData2D_min (RaveData2D_t *self) |
Returns min in self. | |
double | RaveData2D_max (RaveData2D_t *self) |
Returns max in self. | |
RaveData2D_t * | RaveData2D_concatX (RaveData2D_t *field, RaveData2D_t *other) |
Concatenates field with other horizontally and returns the new field. | |
RaveData2D_t * | RaveData2D_concatY (RaveData2D_t *field, RaveData2D_t *other) |
Concatenates field with other vertically and returns the new field. | |
RaveData2D_t * | RaveData2D_circshift (RaveData2D_t *field, int nx, int ny) |
Circular shift of the field in x & y dimension. | |
int | RaveData2D_circshiftData (RaveData2D_t *field, int nx, int ny) |
Circular shift of the internal field in x & y dimension. | |
RaveData2D_t * | RaveData2D_addNumber (RaveData2D_t *field, double v) |
Adds the specified value to field and returns a new field. | |
RaveData2D_t * | RaveData2D_add (RaveData2D_t *field, RaveData2D_t *other) |
Adds the array value to field and returns a new field. | |
RaveData2D_t * | RaveData2D_subNumber (RaveData2D_t *field, double v) |
Substracts the specified value from field and returns a new field. | |
RaveData2D_t * | RaveData2D_sub (RaveData2D_t *field, RaveData2D_t *other) |
Substracts the array value from field and returns a new field. | |
RaveData2D_t * | RaveData2D_mulNumber (RaveData2D_t *field, double v) |
Multiplicates all values in field with v and returns a new field. | |
RaveData2D_t * | RaveData2D_emul (RaveData2D_t *field, RaveData2D_t *other) |
Element wise multiplication. | |
RaveData2D_t * | RaveData2D_powNumber (RaveData2D_t *field, double v) |
Element wise pow on a matrix. | |
RaveData2D_t * | RaveData2D_epow (RaveData2D_t *field, RaveData2D_t *other) |
Element wise pow on a matrix This means that others x&y size must either be 1 or the same as selfs xsize/ysize. | |
RaveData2D_t * | RaveData2D_medfilt2 (RaveData2D_t *field, long winXsize, long winYsize) |
Executes a median filtering in 2D. | |
RaveData2D_t * | RaveData2D_cumsum (RaveData2D_t *field, int dir) |
Runs a cummulative sum of either columns or rows. | |
RaveData2D_t * | RaveData2D_movingstd (RaveData2D_t *field, long nx, long ny) |
Computes the standard deviation over a given number of pixels (nx * ny). | |
long * | RaveData2D_hist (RaveData2D_t *field, int bins, long *nnodata) |
Creates a histogram of field with bins number of bins. | |
int | RaveData2D_entropy (RaveData2D_t *field, int bins, double *entropy) |
Calculate the entropy value for the field. | |
void | RaveData2D_disp (RaveData2D_t *field) |
Helper function to print field to stdout. | |
const char * | RaveData2D_str (RaveData2D_t *field) |
Helper function that returns the matrix as a string. | |
void | RaveData2D_replace (RaveData2D_t *field, double v, double v2) |
Replaces all occurances of v with v2 in the provided data field. | |
RaveData2D_t * | RaveData2D_zeros (long xsize, long ysize, RaveDataType type) |
Utility function for creating a new rave data 2d object filled with zeros. | |
RaveData2D_t * | RaveData2D_ones (long xsize, long ysize, RaveDataType type) |
Utility function for creating a new rave data 2d object filled with ones. | |
RaveData2D_t * | RaveData2D_createObject (long xsize, long ysize, RaveDataType type) |
Utility function for creating a new rave data 2d object. | |
Variables | |
RaveCoreObjectType | RaveData2D_TYPE |
Type definition to use when creating a rave object. | |
typedef struct _RaveData2D_t RaveData2D_t |
Defines a Rave 2-dimensional data array.
RaveData2D_t * RaveData2D_add | ( | RaveData2D_t * | field, |
RaveData2D_t * | other ) |
Adds the array value to field and returns a new field.
Other's x&y size must either be 1 or the same as selfs xsize/ysize.
[in] | field | - self |
[in] | other | - the other array to add |
RaveData2D_t * RaveData2D_addNumber | ( | RaveData2D_t * | field, |
double | v ) |
Adds the specified value to field and returns a new field.
[in] | field | - self |
[in] | v | - the value to add |
RaveData2D_t * RaveData2D_circshift | ( | RaveData2D_t * | field, |
int | nx, | ||
int | ny ) |
Circular shift of the field in x & y dimension.
[in] | field | - the field to be shifted |
[in] | nx | - the number of steps to be shifted in x-direction. Can be both positive and negative |
[in] | ny | - the number of steps to be shifted in y-direction. Can be both positive and negative |
int RaveData2D_circshiftData | ( | RaveData2D_t * | field, |
int | nx, | ||
int | ny ) |
Circular shift of the internal field in x & y dimension.
[in] | field | - the field to be shifted |
[in] | nx | - the number of steps to be shifted in x-direction. Can be both positive and negative |
[in] | ny | - the number of steps to be shifted in y-direction. Can be both positive and negative |
RaveData2D_t * RaveData2D_concatX | ( | RaveData2D_t * | field, |
RaveData2D_t * | other ) |
Concatenates field with other horizontally and returns the new field.
The field's and other's y-dimensions must be the same as well as the data type.
[in] | field | - self |
[in] | other | - the field to contatenate |
RaveData2D_t * RaveData2D_concatY | ( | RaveData2D_t * | field, |
RaveData2D_t * | other ) |
Concatenates field with other vertically and returns the new field.
The field's and other's x-dimensions must be the same as well as the data type.
[in] | field | - self |
[in] | other | - the field to contatenate |
int RaveData2D_createData | ( | RaveData2D_t * | self, |
long | xsize, | ||
long | ysize, | ||
RaveDataType | type, | ||
double | value ) |
Creates a data field with the specified size and type.
[in] | self | - self |
[in] | xsize | - x-size |
[in] | ysize | - y-size |
[in] | type | - the data type |
[in] | value | - initial value to set for all positions in the data field |
RaveData2D_t * RaveData2D_createObject | ( | long | xsize, |
long | ysize, | ||
RaveDataType | type ) |
Utility function for creating a new rave data 2d object.
[in] | xsize | - x-size |
[in] | ysize | - y-size |
[in] | type | - the data type |
RaveData2D_t * RaveData2D_cumsum | ( | RaveData2D_t * | field, |
int | dir ) |
Runs a cummulative sum of either columns or rows.
If dir == 1, then it's columnwise sum. Else if dir == 2, then it's row based cummulative sum.
[in] | field | - self |
[in] | if | it's goind to be column (1) or row (2) based cummulation. |
void RaveData2D_disp | ( | RaveData2D_t * | field | ) |
Helper function to print field to stdout.
[in] | field | - field |
RaveData2D_t * RaveData2D_emul | ( | RaveData2D_t * | field, |
RaveData2D_t * | other ) |
Element wise multiplication.
I.e. not a real matrix multiplication but instead it atempts to perform item wise multiplication row or columnwise. This means that others x&y size must either be 1 or the same as selfs xsize/ysize.
[in] | field | - self |
[in] | other | - the other array to use for multiplication |
int RaveData2D_entropy | ( | RaveData2D_t * | field, |
int | bins, | ||
double * | entropy ) |
Calculate the entropy value for the field.
Entropy is a statistical measure of randomness.
[in] | field | - self |
[in] | bins | - the number of bins |
[in,out] | entropy | - the calculated entropy |
RaveData2D_t * RaveData2D_epow | ( | RaveData2D_t * | field, |
RaveData2D_t * | other ) |
Element wise pow on a matrix This means that others x&y size must either be 1 or the same as selfs xsize/ysize.
[in] | field | - self |
[in] | other | - the other array to use for multiplication |
int RaveData2D_fill | ( | RaveData2D_t * | self, |
double | v ) |
Fills the field with the specified value.
[in] | self | - self |
[in] | v | - the value to fill with |
void * RaveData2D_getData | ( | RaveData2D_t * | self | ) |
Returns a pointer to the internal data storage.
[in] | self | - self |
double RaveData2D_getNodata | ( | RaveData2D_t * | self | ) |
[in] | self | - self |
RaveDataType RaveData2D_getType | ( | RaveData2D_t * | self | ) |
Returns the data type.
[in] | self | - self |
int RaveData2D_getValue | ( | RaveData2D_t * | self, |
long | x, | ||
long | y, | ||
double * | v ) |
Returns the value at the specified x and y position.
If coordinates is outside the boundaries, v will be left as is so initialize it before calling this function.
[in] | self | - self |
[in] | x | - the x index |
[in] | y | - the y index |
[out] | v | - the data at the specified index |
int RaveData2D_getValueUnchecked | ( | RaveData2D_t * | self, |
long | x, | ||
long | y, | ||
double * | v ) |
Same as RaveData2D_getValue but there is no boundary checking performed.
I.e. unless you know what you are doing you might be accessing unreserved memory.
[in] | self | - self |
[in] | x | - the x index |
[in] | y | - the y index |
[out] | v | - the data at the specified index |
long RaveData2D_getXsize | ( | RaveData2D_t * | self | ) |
Returns the xsize.
[in] | self | - self |
long RaveData2D_getYsize | ( | RaveData2D_t * | self | ) |
Returns the ysize.
[in] | self | - self |
int RaveData2D_hasData | ( | RaveData2D_t * | self | ) |
Returns if this object contains data and a xsize and ysize > 0.
[in] | self | - self |
long * RaveData2D_hist | ( | RaveData2D_t * | field, |
int | bins, | ||
long * | nnodata ) |
Creates a histogram of field with bins number of bins.
The histogram will be determined as Calculate bin ranges as scale = (max - min) / nbins Bin1: max >= x <= max + scale Bin2: max + scale > x <= max + 2*scale Bin3: max + 2*scale > x <= max + 3*scale and so on.....
Example: y=[-7 -5 -3 -2 -2 -1 0 1 2 3 3 4 5 5 6 7] nbins = 4
scale = (7 - (-7)) / 4 = 3.5 => b1 = -7 => -3.5 b2 = -3.49 => 0 b3 = 0.01 => 3.5 b4 = 3.51 => 7
[in] | field | - self |
[in] | bins | - number of bins |
[in,out] | nnodata | - If using nodata, this will be number of nodata values since they won't be in the histogram counts. |
Calculate bin ranges as scale = (max - min) / nbins Bin1: max >= x <= max + scale Bin2: max + scale > x <= max + 2*scale Bin3: max + 2*scale > x <= max + 3*scale and so on.....
Example: y=[-7 -5 -3 -2 -2 -1 0 1 2 3 3 4 5 5 6 7] nbins = 4
scale = (7 - (-7)) / 4 = 3.5 => b1 = -7 => -3.5 b2 = -3.49 => 0 b3 = 0.01 => 3.5 b4 = 3.51 => 7
double RaveData2D_max | ( | RaveData2D_t * | self | ) |
Returns max in self.
[in] | self | - self |
RaveData2D_t * RaveData2D_medfilt2 | ( | RaveData2D_t * | field, |
long | winXsize, | ||
long | winYsize ) |
Executes a median filtering in 2D.
I.e. takes surrounding pixels in winXsize, winYsize and determines the median value for each pixel in the field. I.e. box will be x +/- winXsize/2, y +/- winYsize/2
[in] | field | - self |
[in] | winXsize | - the number of pixels in x-direction |
[in] | winYsize | - the number of pixels in y-direction |
double RaveData2D_min | ( | RaveData2D_t * | self | ) |
Returns min in self.
[in] | self | - self |
RaveData2D_t * RaveData2D_movingstd | ( | RaveData2D_t * | field, |
long | nx, | ||
long | ny ) |
Computes the standard deviation over a given number of pixels (nx * ny).
If nx or ny = 0, it will be row or col wise std.
[in] | field | - self |
[in] | nx | - number of pixels in x-dim |
[in] | ny | - number of pixels in y-dim |
RaveData2D_t * RaveData2D_mulNumber | ( | RaveData2D_t * | field, |
double | v ) |
Multiplicates all values in field with v and returns a new field.
[in] | field | - self |
[in] | v | - the value to multply with |
RaveData2D_t * RaveData2D_ones | ( | long | xsize, |
long | ysize, | ||
RaveDataType | type ) |
Utility function for creating a new rave data 2d object filled with ones.
[in] | xsize | - x-size |
[in] | ysize | - y-size |
[in] | type | - the data type |
RaveData2D_t * RaveData2D_powNumber | ( | RaveData2D_t * | field, |
double | v ) |
Element wise pow on a matrix.
[in] | field | - self |
[in] | v | - the pow value |
void RaveData2D_replace | ( | RaveData2D_t * | field, |
double | v, | ||
double | v2 ) |
Replaces all occurances of v with v2 in the provided data field.
[in] | field | - self |
[in] | v | - the value to search for |
[in] | v2 | - the value that should be used as replacement |
int RaveData2D_setData | ( | RaveData2D_t * | self, |
long | xsize, | ||
long | ysize, | ||
void * | data, | ||
RaveDataType | type ) |
Sets the data.
[in] | self | - self |
[in] | xsize | - x-size |
[in] | ysize | - y-size |
[in] | data | - the data |
[in] | type | - the data type |
void RaveData2D_setNodata | ( | RaveData2D_t * | self, |
double | nodata ) |
[in] | self | - self |
[in] | nodata | - the nodata value to use. |
int RaveData2D_setValue | ( | RaveData2D_t * | self, |
long | x, | ||
long | y, | ||
double | v ) |
Sets the value at the specified coordinates.
[in] | self | - self |
[in] | x | - the x-position |
[in] | y | - the y-position |
[in] | v | - the value to set |
int RaveData2D_setValueUnchecked | ( | RaveData2D_t * | self, |
long | x, | ||
long | y, | ||
double | v ) |
Same as RaveData2D_setValue but there is no boundary checking performed.
I.e. unless you know what you are doing you might be accessing unreserved memory.
[in] | self | - self |
[in] | x | - the x-position |
[in] | y | - the y-position |
[in] | v | - the value to set |
const char * RaveData2D_str | ( | RaveData2D_t * | field | ) |
Helper function that returns the matrix as a string.
Note, this is not reentrant since it's using a static buffer.
[in] | field | - self |
RaveData2D_t * RaveData2D_sub | ( | RaveData2D_t * | field, |
RaveData2D_t * | other ) |
Substracts the array value from field and returns a new field.
Other's x&y size must either be 1 or the same as selfs xsize/ysize.
[in] | field | - self |
[in] | other | - the other array to substract |
RaveData2D_t * RaveData2D_subNumber | ( | RaveData2D_t * | field, |
double | v ) |
Substracts the specified value from field and returns a new field.
[in] | field | - self |
[in] | v | - the value to substract |
void RaveData2D_useNodata | ( | RaveData2D_t * | self, |
int | use ) |
Sets if the operations should take into account nodata value or not.
Default is turned off
[in] | self | - self |
[in] | use | - 1 if nodata controls should be performed, otherwise it's turned off |
int RaveData2D_usingNodata | ( | RaveData2D_t * | self | ) |
Returns if the calculations are taking into account the nodata value.
[in] | self | - self |
RaveData2D_t * RaveData2D_zeros | ( | long | xsize, |
long | ysize, | ||
RaveDataType | type ) |
Utility function for creating a new rave data 2d object filled with zeros.
[in] | xsize | - x-size |
[in] | ysize | - y-size |
[in] | type | - the data type |
|
extern |
Type definition to use when creating a rave object.