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;
129 "N_get_gradient_2d: calculate N_gradient_2d NC %g SC %g WC %g EC %g",
189 double EC,
double TC,
double BC)
193 G_debug(5,
"N_create_gradient_3d: create N_gradient_3d");
217 G_debug(5,
"N_copy_gradient_3d: copy N_gradient_3d");
219 if (!source || !target)
222 target->
NC = source->
NC;
223 target->
SC = source->
SC;
224 target->
WC = source->
WC;
225 target->
EC = source->
EC;
226 target->
TC = source->
TC;
227 target->
BC = source->
BC;
253 double NC,
SC, WC, EC, TC, BC;
265 "N_get_gradient_3d: calculate N_gradient_3d NC %g SC %g WC %g EC %g TC %g BC %g",
266 NC, SC, WC, EC, TC, BC);
332 double NEN,
double WC,
333 double EC,
double SWS,
339 "N_create_gradient_neighbours_x: create N_gradient_neighbours_x");
365 G_debug(6,
"N_copy_gradient_neighbours_x: copy N_gradient_neighbours_x");
367 if (!source || !target)
370 target->
NWN = source->
NWN;
371 target->
NEN = source->
NEN;
372 target->
WC = source->
WC;
373 target->
EC = source->
EC;
374 target->
SWS = source->
SWS;
375 target->
SES = source->
SES;
427 double NEE,
double NC,
428 double SC,
double SWW,
434 "N_create_gradient_neighbours_y: create N_gradient_neighbours_y");
460 G_debug(6,
"N_copy_gradient_neighbours_y: copy N_gradient_neighbours_y");
462 if (!source || !target)
465 target->
NWW = source->
NWW;
466 target->
NEE = source->
NEE;
467 target->
NC = source->
NC;
468 target->
SC = source->
SC;
469 target->
SWW = source->
SWW;
470 target->
SEE = source->
SEE;
525 double NEZ,
double WZ,
526 double CZ,
double EZ,
527 double SWZ,
double SZ,
533 "N_create_gradient_neighbours_z: create N_gradient_neighbours_z");
562 G_debug(6,
"N_copy_gradient_neighbours_z: copy N_gradient_neighbours_z");
564 if (!source || !target)
567 target->
NWZ = source->
NWZ;
568 target->
NZ = source->
NZ;
569 target->
NEZ = source->
NEZ;
570 target->
WZ = source->
WZ;
571 target->
CZ = source->
CZ;
572 target->
EZ = source->
EZ;
573 target->
SWZ = source->
SWZ;
574 target->
SZ = source->
SZ;
575 target->
SEZ = source->
SEZ;
640 "N_create_gradient_neighbours_2d: create N_gradient_neighbours_2d");
672 "N_copy_gradient_neighbours_2d: copy N_gradient_neighbours_2d");
674 if (!source || !target)
711 double NWN, NEN, WC, EC, SWS, SES;
713 double NWW, NEE, NC,
SC, SWW, SEE;
741 "N_get_gradient_neighbours_2d: calculate N_gradient_neighbours_x NWN %g NEN %g WC %g EC %g SWS %g SES %g",
742 NWN, NEN, WC, EC, SWS, SES);
745 "N_get_gradient_neighbours_2d: calculate N_gradient_neighbours_y NWW %g NEE %g NC %g SC %g SWW %g SEE %g",
746 NWW, NEE, NC, SC, SWW, SEE);
846 "N_create_gradient_neighbours_3d: create N_gradient_neighbours_3d");
889 "N_copy_gradient_neighbours_3d: copy N_gradient_neighbours_3d");
891 if (!source || !target)
933 "N_alloc_gradient_field_2d: allocate a N_gradient_field_2d struct");
977 G_debug(3,
"N_copy_gradient_field_2d: copy N_gradient_field_2d");
979 if (!source || !target)
996 fprintf(stdout,
"N_gradient_field_2d \n");
997 fprintf(stdout,
"Cols %i\n", field->
cols);
998 fprintf(stdout,
"Rows: %i\n", field->
rows);
999 fprintf(stdout,
"X array pointer: %p\n", field->
x_array);
1000 fprintf(stdout,
"Y array pointer: %p\n", field->
y_array);
1001 fprintf(stdout,
"Min %g\n", field->
min);
1002 fprintf(stdout,
"Max %g\n", field->
max);
1003 fprintf(stdout,
"Sum %g\n", field->
sum);
1004 fprintf(stdout,
"Mean %g\n", field->
mean);
1005 fprintf(stdout,
"Nonull %i\n", field->
nonull);
1006 fprintf(stdout,
"X array info \n");
1008 fprintf(stdout,
"Y array info \n");
1031 "N_alloc_gradient_field_3d: allocate a N_gradient_field_3d struct");
1080 G_debug(3,
"N_copy_gradient_field_3d: copy N_gradient_field_3d");
1082 if (!source || !target)
1101 fprintf(stdout,
"N_gradient_field_3d \n");
1102 fprintf(stdout,
"Cols %i\n", field->
cols);
1103 fprintf(stdout,
"Rows: %i\n", field->
rows);
1104 fprintf(stdout,
"Depths %i\n", field->
depths);
1105 fprintf(stdout,
"X array pointer: %p\n", field->
x_array);
1106 fprintf(stdout,
"Y array pointer: %p\n", field->
y_array);
1107 fprintf(stdout,
"Z array pointer: %p\n", field->
z_array);
1108 fprintf(stdout,
"Min %g\n", field->
min);
1109 fprintf(stdout,
"Max %g\n", field->
max);
1110 fprintf(stdout,
"Sum %g\n", field->
sum);
1111 fprintf(stdout,
"Mean %g\n", field->
mean);
1112 fprintf(stdout,
"Nonull %i\n", field->
nonull);
1113 fprintf(stdout,
"X array info \n");
1115 fprintf(stdout,
"Y array info \n");
1117 fprintf(stdout,
"Z array info \n");
void N_free_array_2d(N_array_2d *data)
Release the memory of a N_array_2d structure.
N_gradient_neighbours_x * xt
N_gradient_neighbours_z * zt
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.
void N_free_gradient_neighbours_z(N_gradient_neighbours_z *grad)
Free's a N_gradient_neighbours_z structure.
void G_free(void *buf)
Free allocated memory.
void N_free_gradient_2d(N_gradient_2d *grad)
Free's a N_gradient_2d structure.
Gradient between the cell neighbours in X and Y direction.
void N_free_gradient_field_3d(N_gradient_field_3d *field)
Free's a N_gradient_neighbours_3d structure.
Gradient between the cell neighbours in Z direction.
void N_print_gradient_field_3d_info(N_gradient_field_3d *field)
Print gradient field information to stdout.
void N_free_gradient_neighbours_x(N_gradient_neighbours_x *grad)
Free's a N_gradient_neighbours_x structure.
void N_free_array_3d(N_array_3d *data)
Release the memory of a N_array_3d.
Gradient between the cells in X and Y direction.
N_gradient_neighbours_y * y
int N_copy_gradient_3d(N_gradient_3d *source, N_gradient_3d *target)
copy a N_gradient_3d structure
int N_copy_gradient_neighbours_2d(N_gradient_neighbours_2d *source, N_gradient_neighbours_2d *target)
copy a N_gradient_neighbours_2d structure
N_array_2d * N_alloc_array_2d(int cols, int rows, int offset, int type)
Allocate memory for a N_array_2d data structure.
int N_copy_gradient_neighbours_x(N_gradient_neighbours_x *source, N_gradient_neighbours_x *target)
copy a N_gradient_neighbours_x structure
N_gradient_3d * N_alloc_gradient_3d(void)
Allocate a N_gradient_3d structure.
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.
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.
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_z * zb
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...
void N_print_array_2d_info(N_array_2d *data)
This function writes the data info of the array data to stdout.
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_field_2d * N_alloc_gradient_field_2d(int cols, int rows)
Allocate a N_gradient_field_2d.
N_gradient_neighbours_x * xb
N_gradient_neighbours_y * yb
void N_print_array_3d_info(N_array_3d *data)
Write the info of the array to stdout.
Gradient between the cell neighbours in X, Y and Z direction.
Gradient between the cell neighbours in X direction.
N_gradient_neighbours_y * yt
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.
N_gradient_neighbours_z * N_alloc_gradient_neighbours_z(void)
Allocate a N_gradient_neighbours_z structure.
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
void N_print_gradient_field_2d_info(N_gradient_field_2d *field)
Print gradient field information to stdout.
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.
N_gradient_neighbours_2d * N_alloc_gradient_neighbours_2d(void)
Allocate a N_gradient_neighbours_2d structure.
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.
Gradient between the cells in X, Y and Z direction.
void N_free_gradient_neighbours_2d(N_gradient_neighbours_2d *grad)
Free's a N_gradient_neighbours_2d structure.
N_gradient_neighbours_x * N_alloc_gradient_neighbours_x(void)
Allocate a N_gradient_neighbours_x structure.
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_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]...
int G_debug(int level, const char *msg,...)
Print debugging message.
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_field_3d * N_alloc_gradient_field_3d(int cols, int rows, int depths)
Allocate a N_gradient_field_3d.
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.
void N_free_gradient_3d(N_gradient_3d *grad)
Free's a N_gradient_3d structure.
N_gradient_neighbours_x * xc
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 * yc
int N_copy_gradient_neighbours_3d(N_gradient_neighbours_3d *source, N_gradient_neighbours_3d *target)
copy a N_gradient_neighbours_3d structure
void N_free_gradient_neighbours_3d(N_gradient_neighbours_3d *grad)
Free's a N_gradient_neighbours_3d structure.
N_gradient_2d * N_alloc_gradient_2d(void)
Allocate a N_gradient_2d structure.
Gradient between the cell neighbours in Y direction.
N_gradient_neighbours_x * x
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.
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.
N_gradient_neighbours_y * N_alloc_gradient_neighbours_y(void)
Allocate a N_gradient_neighbours_y structure.
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.
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.