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