init2d.c 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  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. #include <stdio.h>
  22. #include <math.h>
  23. #include <unistd.h>
  24. #include <grass/gis.h>
  25. #include <grass/interpf.h>
  26. /*! Initializes parameters used by the library */
  27. void IL_init_params_2d(struct interp_params *params,
  28. FILE * inp, /*!< input stream */
  29. int elatt, /*!< which fp att in sites file? 1 = first */
  30. int smatt, /*!< which fp att in sites file to use for
  31. * smoothing? (if zero use sm) 1 = first */
  32. double zm, /*!< multiplier for z-values */
  33. int k1, /*!< min number of points per segment for interpolation */
  34. int k2, /*!< max number of points per segment */
  35. char *msk, /*!< name of mask */
  36. int rows, int cols, /*!< number of rows and columns */
  37. DCELL * ar1, DCELL * ar2, DCELL * ar3, DCELL * ar4, DCELL * ar5,
  38. DCELL * ar6, /*!< arrays for interpolated values (ar1-ar6) */
  39. double tension, /*!< tension */
  40. int k3, /*!< max number of points for interpolation */
  41. int sc1, int sc2, int sc3, /*!< multipliers for interpolation values */
  42. double sm, /*!< smoothing */
  43. char *f1, char *f2, char *f3, char *f4, char *f5,
  44. char *f6, /*!< output files (f1-f6) */
  45. double dm, /*!< min distance between points */
  46. double x_or, /*!< x of origin */
  47. double y_or, /*!< y of origin */
  48. int der, /*!< 1 if compute partial derivatives */
  49. double tet, /*!< anisotropy angle (0 is East, counter-clockwise) */
  50. double scl, /*!< anisotropy scaling factor */
  51. FILE * t1, FILE * t2, FILE * t3, FILE * t4, FILE * t5,
  52. FILE * t6, /*!< temp files for writing interp. values (t1-t6) */
  53. FILE * dev, /*!< pointer to deviations file */
  54. struct TimeStamp *ts,
  55. int c, /*!< cross validation */
  56. const char *wheresql /*!< SQL WHERE statement */
  57. )
  58. {
  59. params->fdinp = inp;
  60. params->elatt = elatt;
  61. params->smatt = smatt;
  62. params->zmult = zm;
  63. params->kmin = k1;
  64. params->kmax = k2;
  65. params->maskmap = msk;
  66. params->nsizr = rows;
  67. params->nsizc = cols;
  68. params->az = ar1;
  69. params->adx = ar2;
  70. params->ady = ar3;
  71. params->adxx = ar4;
  72. params->adyy = ar5;
  73. params->adxy = ar6;
  74. params->fi = tension;
  75. params->KMAX2 = k3;
  76. params->scik1 = sc1;
  77. params->scik2 = sc2;
  78. params->scik3 = sc3;
  79. params->rsm = sm;
  80. params->elev = f1;
  81. params->slope = f2;
  82. params->aspect = f3;
  83. params->pcurv = f4;
  84. params->tcurv = f5;
  85. params->mcurv = f6;
  86. params->dmin = dm;
  87. params->x_orig = x_or;
  88. params->y_orig = y_or;
  89. params->deriv = der;
  90. params->theta = tet;
  91. params->scalex = scl;
  92. params->Tmp_fd_z = t1;
  93. params->Tmp_fd_dx = t2;
  94. params->Tmp_fd_dy = t3;
  95. params->Tmp_fd_xx = t4;
  96. params->Tmp_fd_yy = t5;
  97. params->Tmp_fd_xy = t6;
  98. params->fddevi = dev;
  99. params->ts = ts;
  100. params->cv = c;
  101. params->wheresql = wheresql;
  102. }
  103. /*! Initializes functions used by the library */
  104. void IL_init_func_2d(struct interp_params *params,
  105. grid_calc_fn * grid_f, /*!< calculates grid for given segment */
  106. matrix_create_fn * matr_f, /*!< creates matrix for a given segment */
  107. check_points_fn * point_f, /*!< checks interpolation function at points */
  108. secpar_fn * secp_f, /*!< calculates aspect, slope, curvature */
  109. interp_fn * interp_f, /*!< radial basis function */
  110. interpder_fn * interpder_f, /*!< derivatives of radial basis function */
  111. wr_temp_fn * temp_f /*!< writes temp files */
  112. )
  113. {
  114. params->grid_calc = grid_f;
  115. params->matrix_create = matr_f;
  116. params->check_points = point_f;
  117. params->secpar = secp_f;
  118. params->interp = interp_f;
  119. params->interpder = interpder_f;
  120. params->wr_temp = temp_f;
  121. }