24 #include "CUnit/Basic.h" 30 double bin_width[] = {100};
31 double quantiles[] = {0.1, 0.3, 0.5, 0.7, 0.9};
32 double quantiles2[] = {0.66666667};
45 uint32_t values[] = {0, 91, 55, 86, 76, 41, 36, 97, 25, 63, 68, 2, 78, 15, 82, 47};
50 CU_ASSERT(raster != NULL);
52 CU_ASSERT(band != NULL);
54 for (x = 0; x < xmax; x++) {
55 for (y = 0; y < ymax; y++) {
61 CU_ASSERT_DOUBLE_EQUAL(nodata, 0, DBL_EPSILON);
64 CU_ASSERT(stats != NULL);
65 CU_ASSERT_DOUBLE_EQUAL(stats->
min, 1, DBL_EPSILON);
66 CU_ASSERT_DOUBLE_EQUAL(stats->
max, 198, DBL_EPSILON);
69 CU_ASSERT(quantile != NULL);
73 CU_ASSERT(histogram != NULL);
77 CU_ASSERT(histogram != NULL);
81 CU_ASSERT(histogram != NULL);
88 CU_ASSERT(stats != NULL);
91 CU_ASSERT(quantile != NULL);
95 CU_ASSERT(quantile != NULL);
96 CU_ASSERT_EQUAL(count, 5);
100 CU_ASSERT(histogram != NULL);
107 CU_ASSERT(stats != NULL);
111 CU_ASSERT(stats != NULL);
115 CU_ASSERT(stats != NULL);
119 CU_ASSERT(stats != NULL);
120 CU_ASSERT_DOUBLE_EQUAL(stats->
min, 0, DBL_EPSILON);
121 CU_ASSERT_DOUBLE_EQUAL(stats->
max, 198, DBL_EPSILON);
124 CU_ASSERT(quantile != NULL);
131 CU_ASSERT(stats != NULL);
134 CU_ASSERT(quantile != NULL);
145 CU_ASSERT(raster != NULL);
147 CU_ASSERT(band != NULL);
150 for (x = 0; x < xmax; x++) {
151 for (y = 0; y < ymax; y++) {
157 CU_ASSERT_DOUBLE_EQUAL(nodata, 0, DBL_EPSILON);
164 CU_ASSERT(quantile != NULL);
165 CU_ASSERT_NOT_EQUAL(count, 0);
166 CU_ASSERT_NOT_EQUAL(qlls_count, 0);
167 CU_ASSERT_DOUBLE_EQUAL(quantile[0].
value, 78, DBL_EPSILON);
178 CU_ASSERT(raster != NULL);
180 CU_ASSERT(band != NULL);
183 for (x = 0; x < xmax; x++) {
184 for (y = 0; y < ymax; y++) {
185 rt_band_set_pixel(band, x, y, (((
double) x * y) + (x + y) + (x + y * x)) / (x + y + 1), NULL);
190 CU_ASSERT_DOUBLE_EQUAL(nodata, 0, DBL_EPSILON);
193 for (x = 0; x < max_run; x++) {
195 band, 1, 1, xmax * ymax * max_run,
199 CU_ASSERT(quantile != NULL);
200 CU_ASSERT_NOT_EQUAL(count, 0);
201 CU_ASSERT_NOT_EQUAL(qlls_count, 0);
223 double count[] = {3, 4, 5};
226 CU_ASSERT(raster != NULL);
228 CU_ASSERT(band != NULL);
231 for (x = 0; x < xmax; x++) {
232 for (y = 0; y < ymax; y++) {
233 rt_band_set_pixel(band, x, y, (((
double) x * y) + (x + y) + (x + y * x)) / (x + y + 1), NULL);
237 CU_ASSERT(vcnts != NULL);
238 CU_ASSERT_NOT_EQUAL(rtn, 0);
242 CU_ASSERT(vcnts != NULL);
243 CU_ASSERT_NOT_EQUAL(rtn, 0);
247 CU_ASSERT(vcnts != NULL);
248 CU_ASSERT_NOT_EQUAL(rtn, 0);
252 CU_ASSERT(vcnts != NULL);
253 CU_ASSERT_NOT_EQUAL(rtn, 0);
257 CU_ASSERT(vcnts != NULL);
258 CU_ASSERT_NOT_EQUAL(rtn, 0);
262 CU_ASSERT(vcnts != NULL);
263 CU_ASSERT_NOT_EQUAL(rtn, 0);
273 CU_pSuite suite = CU_add_suite(
"band_stats", NULL, NULL);
int quantile_llist_destroy(struct quantile_llist **list, uint32_t list_count)
raster
Be careful!! Zeros function's input parameter can be a (height x width) array, not (width x height): ...
rt_errorstate rt_band_set_nodata(rt_band band, double val, int *converted)
Set nodata value.
static void test_band_value_count()
static void test_band_stats()
struct rt_quantile_t * rt_quantile
rt_quantile rt_band_get_quantiles_stream(rt_band band, int exclude_nodata_value, double sample, uint64_t cov_count, struct quantile_llist **qlls, uint32_t *qlls_count, double *quantiles, int quantiles_count, uint32_t *rtn_count)
Compute the default set of or requested quantiles for a coverage.
rt_errorstate rt_band_get_nodata(rt_band band, double *nodata)
Get NODATA value.
void cu_free_raster(rt_raster raster)
rt_band cu_add_band(rt_raster raster, rt_pixtype pixtype, int hasnodata, double nodataval)
rt_quantile rt_band_get_quantiles(rt_bandstats stats, double *quantiles, int quantiles_count, uint32_t *rtn_count)
Compute the default set of or requested quantiles for a set of data the quantile formula used is same...
#define PG_ADD_TEST(suite, testfunc)
rt_bandstats rt_band_get_summary_stats(rt_band band, int exclude_nodata_value, double sample, int inc_vals, uint64_t *cK, double *cM, double *cQ)
Compute summary statistics for a band.
rt_raster rt_raster_new(uint32_t width, uint32_t height)
Construct a raster with given dimensions.
void band_stats_suite_setup(void)
struct rt_histogram_t * rt_histogram
struct rt_bandstats_t * rt_bandstats
rt_valuecount rt_band_get_value_count(rt_band band, int exclude_nodata_value, double *search_values, uint32_t search_values_count, double roundto, uint32_t *rtn_total, uint32_t *rtn_count)
Count the number of times provided value(s) occur in the band.
void rtdealloc(void *mem)
rt_histogram rt_band_get_histogram(rt_bandstats stats, int bin_count, double *bin_widths, int bin_widths_count, int right, double min, double max, uint32_t *rtn_count)
Count the distribution of data.
rt_errorstate rt_band_set_pixel(rt_band band, int x, int y, double val, int *converted)
Set single pixel's value.