GRASS GIS 8 Programmer's Manual  8.2.2dev(2023)-3d2c704037
init2d.c
Go to the documentation of this file.
1 
2 /*!
3  * \file init2d.c
4  *
5  * \brief Initialization of interpolation library data structures
6  *
7  * \author H. Mitasova, I. Kosinovsky, D. Gerdes Fall 1993 (original authors)
8  * \author modified by McCauley in August 1995
9  * \author modified by Mitasova in August 1995
10  * \author modified by Brown in June 1999 - added elatt & smatt
11  *
12  * \copyright
13  * (C) 1993-1999 by Helena Mitasova and the GRASS Development Team
14  *
15  * \copyright
16  * This program is free software under the
17  * GNU General Public License (>=v2).
18  * Read the file COPYING that comes with GRASS
19  * for details.
20  *
21  */
22 
23 #include <stdio.h>
24 #include <math.h>
25 #include <unistd.h>
26 #include <grass/gis.h>
27 #include <grass/interpf.h>
28 
29 
30 /*! Initializes parameters used by the library */
31 void IL_init_params_2d(struct interp_params *params,
32  FILE * inp, /*!< input stream */
33  int elatt, /*!< which fp att in sites file? 1 = first */
34  int smatt, /*!< which fp att in sites file to use for
35  * smoothing? (if zero use sm) 1 = first */
36  double zm, /*!< multiplier for z-values */
37  int k1, /*!< min number of points per segment for interpolation */
38  int k2, /*!< max number of points per segment */
39  char *msk, /*!< name of mask */
40  int rows, int cols, /*!< number of rows and columns */
41  DCELL * ar1, DCELL * ar2, DCELL * ar3, DCELL * ar4, DCELL * ar5,
42  DCELL * ar6, /*!< arrays for interpolated values (ar1-ar6) */
43  double tension, /*!< tension */
44  int k3, /*!< max number of points for interpolation */
45  int sc1, int sc2, int sc3, /*!< multipliers for interpolation values */
46  double sm, /*!< smoothing */
47  char *f1, char *f2, char *f3, char *f4, char *f5,
48  char *f6, /*!< output files (f1-f6) */
49  double dm, /*!< min distance between points */
50  double x_or, /*!< x of origin */
51  double y_or, /*!< y of origin */
52  int der, /*!< 1 if compute partial derivatives */
53  double tet, /*!< anisotropy angle (0 is East, counter-clockwise) */
54  double scl, /*!< anisotropy scaling factor */
55  FILE * t1, FILE * t2, FILE * t3, FILE * t4, FILE * t5,
56  FILE * t6, /*!< temp files for writing interp. values (t1-t6) */
57  bool create_devi, /*!< create deviations file? */
58  struct TimeStamp *ts,
59  int c, /*!< cross validation */
60  const char *wheresql /*!< SQL WHERE statement */
61  )
62 {
63  params->fdinp = inp;
64  params->elatt = elatt;
65  params->smatt = smatt;
66  params->zmult = zm;
67  params->kmin = k1;
68  params->kmax = k2;
69  params->maskmap = msk;
70  params->nsizr = rows;
71  params->nsizc = cols;
72  params->az = ar1;
73  params->adx = ar2;
74  params->ady = ar3;
75  params->adxx = ar4;
76  params->adyy = ar5;
77  params->adxy = ar6;
78  params->fi = tension;
79  params->KMAX2 = k3;
80  params->scik1 = sc1;
81  params->scik2 = sc2;
82  params->scik3 = sc3;
83  params->rsm = sm;
84  params->elev = f1;
85  params->slope = f2;
86  params->aspect = f3;
87  params->pcurv = f4;
88  params->tcurv = f5;
89  params->mcurv = f6;
90  params->dmin = dm;
91  params->x_orig = x_or;
92  params->y_orig = y_or;
93  params->deriv = der;
94  params->theta = tet;
95  params->scalex = scl;
96  params->Tmp_fd_z = t1;
97  params->Tmp_fd_dx = t2;
98  params->Tmp_fd_dy = t3;
99  params->Tmp_fd_xx = t4;
100  params->Tmp_fd_yy = t5;
101  params->Tmp_fd_xy = t6;
102  params->create_devi = create_devi;
103  params->ts = ts;
104  params->cv = c;
105  params->wheresql = wheresql;
106 }
107 
108 /*! Initializes functions used by the library */
109 void IL_init_func_2d(struct interp_params *params,
110  grid_calc_fn * grid_f, /*!< calculates grid for given segment */
111  matrix_create_fn * matr_f, /*!< creates matrix for a given segment */
112  check_points_fn * point_f, /*!< checks interpolation function at points */
113  secpar_fn * secp_f, /*!< calculates aspect, slope, curvature */
114  interp_fn * interp_f, /*!< radial basis function */
115  interpder_fn * interpder_f, /*!< derivatives of radial basis function */
116  wr_temp_fn * temp_f /*!< writes temp files */
117  )
118 {
119  params->grid_calc = grid_f;
120  params->matrix_create = matr_f;
121  params->check_points = point_f;
122  params->secpar = secp_f;
123  params->interp = interp_f;
124  params->interpder = interpder_f;
125  params->wr_temp = temp_f;
126 
127 }
interp_fn * interp
Definition: interpf.h:101
int interpder_fn(double, double, double *, double *)
Definition: interpf.h:64
double rsm
Definition: interpf.h:83
interpder_fn * interpder
Definition: interpf.h:102
double scalex
Definition: interpf.h:90
char * mcurv
Definition: interpf.h:84
double DCELL
Definition: gis.h:614
FILE * Tmp_fd_xy
Definition: interpf.h:92
FILE * Tmp_fd_yy
Definition: interpf.h:92
void IL_init_func_2d(struct interp_params *params, grid_calc_fn *grid_f, matrix_create_fn *matr_f, check_points_fn *point_f, secpar_fn *secp_f, interp_fn *interp_f, interpder_fn *interpder_f, wr_temp_fn *temp_f)
Definition: init2d.c:109
double theta
Definition: interpf.h:89
matrix_create_fn * matrix_create
Definition: interpf.h:98
DCELL * adxx
Definition: interpf.h:78
double y_orig
Definition: interpf.h:87
char * elev
Definition: interpf.h:84
char * pcurv
Definition: interpf.h:84
FILE * Tmp_fd_xx
Definition: interpf.h:92
DCELL * adx
Definition: interpf.h:78
const char * wheresql
Definition: interpf.h:104
int wr_temp_fn(struct interp_params *, int, int, off_t)
Definition: interpf.h:66
secpar_fn * secpar
Definition: interpf.h:100
int check_points_fn(struct interp_params *, struct quaddata *, double *, double *, double, double, struct triple)
Definition: interpf.h:53
grid_calc_fn * grid_calc
Definition: interpf.h:97
FILE * Tmp_fd_dx
Definition: interpf.h:92
check_points_fn * check_points
Definition: interpf.h:99
int grid_calc_fn(struct interp_params *, struct quaddata *, struct BM *, double, double, double *, double *, double *, double *, double *, double *, double *, double *, double *, double *, off_t, double)
Definition: interpf.h:44
char * aspect
Definition: interpf.h:84
DCELL * az
Definition: interpf.h:78
double fi
Definition: interpf.h:80
int secpar_fn(struct interp_params *, int, int, int, struct BM *, double *, double *, double *, double *, double *, double *, int, int)
Definition: interpf.h:57
double x_orig
Definition: interpf.h:87
int matrix_create_fn(struct interp_params *, struct triple *, int, double **, int *)
Definition: interpf.h:50
char * tcurv
Definition: interpf.h:84
DCELL * ady
Definition: interpf.h:78
FILE * Tmp_fd_dy
Definition: interpf.h:92
char * maskmap
Definition: interpf.h:76
double dmin
Definition: interpf.h:86
FILE * fdinp
Definition: interpf.h:71
wr_temp_fn * wr_temp
Definition: interpf.h:103
FILE * Tmp_fd_z
Definition: interpf.h:92
void IL_init_params_2d(struct interp_params *params, FILE *inp, int elatt, int smatt, double zm, int k1, int k2, char *msk, int rows, int cols, DCELL *ar1, DCELL *ar2, DCELL *ar3, DCELL *ar4, DCELL *ar5, DCELL *ar6, double tension, int k3, int sc1, int sc2, int sc3, double sm, char *f1, char *f2, char *f3, char *f4, char *f5, char *f6, double dm, double x_or, double y_or, int der, double tet, double scl, FILE *t1, FILE *t2, FILE *t3, FILE *t4, FILE *t5, FILE *t6, bool create_devi, struct TimeStamp *ts, int c, const char *wheresql)
Definition: init2d.c:31
double zmult
Definition: interpf.h:70
Definition: gis.h:598
DCELL * adxy
Definition: interpf.h:78
struct TimeStamp * ts
Definition: interpf.h:91
bool create_devi
Definition: interpf.h:95
double interp_fn(double, double)
Definition: interpf.h:62
char * slope
Definition: interpf.h:84
DCELL * adyy
Definition: interpf.h:78