19 #include <grass/N_pde.h> 65 G_debug(5,
"N_create_gradient_2d: create N_gradient_2d");
87 G_debug(5,
"N_copy_gradient_2d: copy N_gradient_2d");
89 if (!source || !target)
92 target->
NC = source->
NC;
93 target->
SC = source->
SC;
94 target->
WC = source->
WC;
95 target->
EC = source->
EC;
118 double NC = 0, SC = 0, WC = 0, EC = 0;
128 "N_get_gradient_2d: calculate N_gradient_2d NC %g SC %g WC %g EC %g",
188 double EC,
double TC,
double BC)
192 G_debug(5,
"N_create_gradient_3d: create N_gradient_3d");
216 G_debug(5,
"N_copy_gradient_3d: copy N_gradient_3d");
218 if (!source || !target)
221 target->
NC = source->
NC;
222 target->
SC = source->
SC;
223 target->
WC = source->
WC;
224 target->
EC = source->
EC;
225 target->
TC = source->
TC;
226 target->
BC = source->
BC;
252 double NC, SC, WC, EC, TC, BC;
263 "N_get_gradient_3d: calculate N_gradient_3d NC %g SC %g WC %g EC %g TC %g BC %g",
264 NC, SC, WC, EC, TC, BC);
330 double NEN,
double WC,
331 double EC,
double SWS,
337 "N_create_gradient_neighbours_x: create N_gradient_neighbours_x");
363 G_debug(6,
"N_copy_gradient_neighbours_x: copy N_gradient_neighbours_x");
365 if (!source || !target)
368 target->
NWN = source->
NWN;
369 target->
NEN = source->
NEN;
370 target->
WC = source->
WC;
371 target->
EC = source->
EC;
372 target->
SWS = source->
SWS;
373 target->
SES = source->
SES;
425 double NEE,
double NC,
426 double SC,
double SWW,
432 "N_create_gradient_neighbours_y: create N_gradient_neighbours_y");
458 G_debug(6,
"N_copy_gradient_neighbours_y: copy N_gradient_neighbours_y");
460 if (!source || !target)
463 target->
NWW = source->
NWW;
464 target->
NEE = source->
NEE;
465 target->
NC = source->
NC;
466 target->
SC = source->
SC;
467 target->
SWW = source->
SWW;
468 target->
SEE = source->
SEE;
523 double NEZ,
double WZ,
524 double CZ,
double EZ,
525 double SWZ,
double SZ,
531 "N_create_gradient_neighbours_z: create N_gradient_neighbours_z");
560 G_debug(6,
"N_copy_gradient_neighbours_z: copy N_gradient_neighbours_z");
562 if (!source || !target)
565 target->
NWZ = source->
NWZ;
566 target->
NZ = source->
NZ;
567 target->
NEZ = source->
NEZ;
568 target->
WZ = source->
WZ;
569 target->
CZ = source->
CZ;
570 target->
EZ = source->
EZ;
571 target->
SWZ = source->
SWZ;
572 target->
SZ = source->
SZ;
573 target->
SEZ = source->
SEZ;
637 "N_create_gradient_neighbours_2d: create N_gradient_neighbours_2d");
669 "N_copy_gradient_neighbours_2d: copy N_gradient_neighbours_2d");
671 if (!source || !target)
708 double NWN, NEN, WC, EC, SWS, SES;
709 double NWW, NEE, NC, SC, SWW, SEE;
734 "N_get_gradient_neighbours_2d: calculate N_gradient_neighbours_x NWN %g NEN %g WC %g EC %g SWS %g SES %g",
735 NWN, NEN, WC, EC, SWS, SES);
738 "N_get_gradient_neighbours_2d: calculate N_gradient_neighbours_y NWW %g NEE %g NC %g SC %g SWW %g SEE %g",
739 NWW, NEE, NC, SC, SWW, SEE);
838 "N_create_gradient_neighbours_3d: create N_gradient_neighbours_3d");
881 "N_copy_gradient_neighbours_3d: copy N_gradient_neighbours_3d");
883 if (!source || !target)
925 "N_alloc_gradient_field_2d: allocate a N_gradient_field_2d struct");
969 G_debug(3,
"N_copy_gradient_field_2d: copy N_gradient_field_2d");
971 if (!source || !target)
988 fprintf(stdout,
"N_gradient_field_2d \n");
989 fprintf(stdout,
"Cols %i\n", field->
cols);
990 fprintf(stdout,
"Rows: %i\n", field->
rows);
991 fprintf(stdout,
"X array pointer: %p\n", field->
x_array);
992 fprintf(stdout,
"Y array pointer: %p\n", field->
y_array);
993 fprintf(stdout,
"Min %g\n", field->
min);
994 fprintf(stdout,
"Max %g\n", field->
max);
995 fprintf(stdout,
"Sum %g\n", field->
sum);
996 fprintf(stdout,
"Mean %g\n", field->
mean);
997 fprintf(stdout,
"Nonull %i\n", field->
nonull);
998 fprintf(stdout,
"X array info \n");
1000 fprintf(stdout,
"Y array info \n");
1023 "N_alloc_gradient_field_3d: allocate a N_gradient_field_3d struct");
1072 G_debug(3,
"N_copy_gradient_field_3d: copy N_gradient_field_3d");
1074 if (!source || !target)
1093 fprintf(stdout,
"N_gradient_field_3d \n");
1094 fprintf(stdout,
"Cols %i\n", field->
cols);
1095 fprintf(stdout,
"Rows: %i\n", field->
rows);
1096 fprintf(stdout,
"Depths %i\n", field->
depths);
1097 fprintf(stdout,
"X array pointer: %p\n", field->
x_array);
1098 fprintf(stdout,
"Y array pointer: %p\n", field->
y_array);
1099 fprintf(stdout,
"Z array pointer: %p\n", field->
z_array);
1100 fprintf(stdout,
"Min %g\n", field->
min);
1101 fprintf(stdout,
"Max %g\n", field->
max);
1102 fprintf(stdout,
"Sum %g\n", field->
sum);
1103 fprintf(stdout,
"Mean %g\n", field->
mean);
1104 fprintf(stdout,
"Nonull %i\n", field->
nonull);
1105 fprintf(stdout,
"X array info \n");
1107 fprintf(stdout,
"Y array info \n");
1109 fprintf(stdout,
"Z array info \n");
N_gradient_2d * N_get_gradient_2d(N_gradient_field_2d *field, N_gradient_2d *gradient, int col, int row)
Return a N_gradient_2d structure calculated from the input gradient field at position [row][col]...
N_gradient_neighbours_x * xt
N_gradient_neighbours_z * zt
N_gradient_3d * N_alloc_gradient_3d(void)
Allocate a N_gradient_3d structure.
Gradient between the cell neighbours in X and Y direction.
Gradient between the cell neighbours in Z direction.
N_gradient_neighbours_z * N_alloc_gradient_neighbours_z(void)
Allocate a N_gradient_neighbours_z structure.
N_gradient_neighbours_x * N_alloc_gradient_neighbours_x(void)
Allocate a N_gradient_neighbours_x structure.
void N_print_gradient_field_2d_info(N_gradient_field_2d *field)
Print gradient field information to stdout.
void N_copy_array_3d(N_array_3d *source, N_array_3d *target)
Copy the source N_array_3d struct to the target N_array_3d struct.
double N_get_array_3d_d_value(N_array_3d *data, int col, int row, int depth)
This function returns the value of type float at position col, row, depth.
N_array_3d * N_alloc_array_3d(int cols, int rows, int depths, int offset, int type)
Allocate memory for a N_array_3d data structure.
Gradient between the cells in X and Y direction.
N_gradient_neighbours_y * y
N_array_2d * N_alloc_array_2d(int cols, int rows, int offset, int type)
Allocate memory for a N_array_2d data structure.
N_gradient_field_3d * N_alloc_gradient_field_3d(int cols, int rows, int depths)
Allocate a N_gradient_field_3d.
int N_copy_gradient_field_2d(N_gradient_field_2d *source, N_gradient_field_2d *target)
Copy N_gradient_field_2d structure from source to target.
void G_free(void *)
Free allocated memory.
N_gradient_neighbours_x * N_create_gradient_neighbours_x(double NWN, double NEN, double WC, double EC, double SWS, double SES)
Allocate and initialize a N_gradient_neighbours_x structure.
void N_free_gradient_neighbours_2d(N_gradient_neighbours_2d *grad)
Free's a N_gradient_neighbours_2d structure.
int N_copy_gradient_neighbours_3d(N_gradient_neighbours_3d *source, N_gradient_neighbours_3d *target)
copy a N_gradient_neighbours_3d structure
int N_copy_gradient_neighbours_y(N_gradient_neighbours_y *source, N_gradient_neighbours_y *target)
copy a N_gradient_neighbours_y structure
void N_free_gradient_neighbours_y(N_gradient_neighbours_y *grad)
Free's a N_gradient_neighbours_y structure.
N_gradient_2d * N_alloc_gradient_2d(void)
Allocate a N_gradient_2d structure.
N_gradient_neighbours_2d * N_alloc_gradient_neighbours_2d(void)
Allocate a N_gradient_neighbours_2d structure.
void N_print_array_3d_info(N_array_3d *data)
Write the info of the array to stdout.
N_gradient_neighbours_3d * N_create_gradient_neighbours_3d(N_gradient_neighbours_x *xt, N_gradient_neighbours_x *xc, N_gradient_neighbours_x *xb, N_gradient_neighbours_y *yt, N_gradient_neighbours_y *yc, N_gradient_neighbours_y *yb, N_gradient_neighbours_z *zt, N_gradient_neighbours_z *zb)
Allocate and initialize a N_gradient_neighbours_3d structure.
void N_free_gradient_field_3d(N_gradient_field_3d *field)
Free's a N_gradient_neighbours_3d structure.
void N_free_gradient_3d(N_gradient_3d *grad)
Free's a N_gradient_3d structure.
N_gradient_neighbours_z * zb
int N_copy_gradient_field_3d(N_gradient_field_3d *source, N_gradient_field_3d *target)
Copy N_gradient_field_3d structure from source to target.
void N_copy_array_2d(N_array_2d *source, N_array_2d *target)
Copy the source N_array_2d struct to the target N_array_2d struct.
void N_print_gradient_field_3d_info(N_gradient_field_3d *field)
Print gradient field information to stdout.
N_gradient_neighbours_3d * N_alloc_gradient_neighbours_3d(void)
Allocate a N_gradient_neighbours_3d structure.
N_gradient_neighbours_z * N_create_gradient_neighbours_z(double NWZ, double NZ, double NEZ, double WZ, double CZ, double EZ, double SWZ, double SZ, double SEZ)
Allocate and initialize a N_gradient_neighbours_z structure.
N_gradient_neighbours_x * xb
void N_free_array_2d(N_array_2d *data)
Release the memory of a N_array_2d structure.
int N_copy_gradient_neighbours_z(N_gradient_neighbours_z *source, N_gradient_neighbours_z *target)
copy a N_gradient_neighbours_z structure
N_gradient_neighbours_y * yb
int N_copy_gradient_3d(N_gradient_3d *source, N_gradient_3d *target)
copy a N_gradient_3d structure
Gradient between the cell neighbours in X, Y and Z direction.
Gradient between the cell neighbours in X direction.
N_gradient_neighbours_y * N_create_gradient_neighbours_y(double NWW, double NEE, double NC, double SC, double SWW, double SEE)
Allocate and initialize a N_gradient_neighbours_y structure.
N_gradient_neighbours_y * yt
void N_free_gradient_neighbours_3d(N_gradient_neighbours_3d *grad)
Free's a N_gradient_neighbours_3d structure.
void N_print_array_2d_info(N_array_2d *data)
This function writes the data info of the array data to stdout.
void N_free_gradient_neighbours_x(N_gradient_neighbours_x *grad)
Free's a N_gradient_neighbours_x structure.
int depths
number of depths for 3D data
int N_copy_gradient_neighbours_x(N_gradient_neighbours_x *source, N_gradient_neighbours_x *target)
copy a N_gradient_neighbours_x structure
Gradient between the cells in X, Y and Z direction.
N_gradient_neighbours_2d * N_create_gradient_neighbours_2d(N_gradient_neighbours_x *x, N_gradient_neighbours_y *y)
Allocate and initialize a N_gradient_neighbours_2d structure.
N_gradient_neighbours_y * N_alloc_gradient_neighbours_y(void)
Allocate a N_gradient_neighbours_y structure.
N_gradient_neighbours_2d * N_get_gradient_neighbours_2d(N_gradient_field_2d *field, N_gradient_neighbours_2d *gradient, int col, int row)
Return a N_gradient_neighbours_2d structure calculated from the input gradient field at position [row...
int cols
Number of columns for 2D data.
N_gradient_field_2d * N_alloc_gradient_field_2d(int cols, int rows)
Allocate a N_gradient_field_2d.
void N_free_gradient_neighbours_z(N_gradient_neighbours_z *grad)
Free's a N_gradient_neighbours_z structure.
void N_free_gradient_2d(N_gradient_2d *grad)
Free's a N_gradient_2d structure.
N_gradient_neighbours_x * xc
int N_copy_gradient_neighbours_2d(N_gradient_neighbours_2d *source, N_gradient_neighbours_2d *target)
copy a N_gradient_neighbours_2d structure
N_gradient_neighbours_y * yc
DCELL N_get_array_2d_d_value(N_array_2d *data, int col, int row)
Returns the value of type DCELL at position col, row.
Gradient between the cell neighbours in Y direction.
N_gradient_neighbours_x * x
void N_free_array_3d(N_array_3d *data)
Release the memory of a N_array_3d.
int N_copy_gradient_2d(N_gradient_2d *source, N_gradient_2d *target)
copy a N_gradient_2d structure
N_gradient_2d * N_create_gradient_2d(double NC, double SC, double WC, double EC)
allocate and initialize a N_gradient_2d structure
void N_free_gradient_field_2d(N_gradient_field_2d *field)
Free's a N_gradient_neighbours_2d structure.
int rows
Number of rows for 2D data.
int G_debug(int, const char *,...) __attribute__((format(printf
N_gradient_3d * N_get_gradient_3d(N_gradient_field_3d *field, N_gradient_3d *gradient, int col, int row, int depth)
Return a N_gradient_3d structure calculated from the input gradient field at position [depth][row][co...
N_gradient_3d * N_create_gradient_3d(double NC, double SC, double WC, double EC, double TC, double BC)
allocate and initialize a N_gradient_3d structure