Télécharger krig_01.dgibi

Retour à la liste

Numérotation des lignes :

  1. ** Test du krigeage en dimension 2
  2.  
  3. * Sur la base sur la reference suivante :
  4. * Edward H. Isaaks, R. Mohan Srivasta
  5. * Applied Geostatistics, Oxford University Press, 1989 - 561 pages
  6. *
  7. * L'exemple traite ici est situe au chapitre 12, pages 290-296
  8. * Consultable sur : https://www.geokniga.org/bookfiles/geokniga-anintroductiontoappliedgeostatistics.pdf
  9.  
  10.  
  11. ** Options generales
  12. OPTI 'ECHO' 0 ;
  13. itrac = FAUX ;
  14. SAUT 2 'LIGNE' ;
  15.  
  16.  
  17.  
  18. ************************************************************************
  19. * Donnees communes : points de mesures et points cibles *
  20. ************************************************************************
  21.  
  22. ** Valeurs des points de mesure
  23. lxm = PROG 61. 63. 64. 68. 71. 73. 75. ;
  24. lym = PROG 139. 140. 129. 128. 140. 141. 128. ;
  25. lfm = PROG 477. 696. 227. 646. 606. 791. 783. ;
  26.  
  27. ** Variogramme (modele gaussien avec pepite, palier et portee)
  28. c0 = 0. ;
  29. c1 = 10. ;
  30. a = 10. ;
  31. lh = PROG 0. 'PAS' 0.01 20. ;
  32. lg = c0 + (c1 * (1. - (EXP (-3. * lh / a)))) ;
  33. REMP lg 1 0. ;
  34. gam = EVOL 'VERT' 'MANU' lh lg ;
  35. SI itrac ;
  36. DESS gam 'TITR' 'Variogramme (modele gaussien)' ;
  37. FINSI ;
  38.  
  39. ** Valeurs des points cibles (ou l'on va kriger)
  40. xmin = 60. ;
  41. xmax = 80. ;
  42. ymin = 120. ;
  43. ymax = 145. ;
  44. dx = 0.25 ;
  45. lxc0 = PROG xmin 'PAS' dx xmax ;
  46. lyc0 = PROG ymin 'PAS' dx ymax ;
  47.  
  48. ** Valeurs au point de reference (pour tester le calcul)
  49. xref = 65. ;
  50. yref = 137. ;
  51. fref = 592.7 ;
  52. vref = 8.96 ;
  53.  
  54.  
  55.  
  56. ************************************************************************
  57. * Cas 1 : krigeage avec mesures LISTREEL et cibles LISTREEL *
  58. * et variogramme *
  59. ************************************************************************
  60.  
  61. ** Liste des coordonnes des cibles
  62. lxc = PROG ;
  63. lyc = PROG ;
  64. REPE by (DIME lyc0) ;
  65. REPE bx (DIME lxc0) ;
  66. lxc = lxc ET (EXTR lxc0 &bx) ;
  67. lyc = lyc ET (EXTR lyc0 &by) ;
  68. FIN bx ;
  69. FIN by ;
  70. ncib = DIME lxc ;
  71.  
  72. ** Krigeage au points cibles (avec le variogramme)
  73. t1 = TABL ;
  74. t1 . 'MESURES' = TABL ;
  75. t1 . 'MESURES' . 'X' = lxm ;
  76. t1 . 'MESURES' . 'Y' = lym ;
  77. t1 . 'MESURES' . 'FONC' = lfm ;
  78. t1 . 'CIBLES' = TABL ;
  79. t1 . 'CIBLES' . 'X' = lxc ;
  80. t1 . 'CIBLES' . 'Y' = lyc ;
  81. t1 . 'COORDONNEES' = MOTS 'X' 'Y' ;
  82. t1 . 'COMPOSANTE' = MOT 'FONC' ;
  83. t1 . 'VARIOGRAMME' = gam ;
  84. est1 var1 = KRIG t1;
  85. tps1 = TEMP 'HORL' ;
  86. MESS 'CAS #1' ;
  87. MESS '======' ;
  88. MESS 'Krigeage sur' ' ' ncib ' points realise en' ' ' tps1 ' ms' ;
  89.  
  90. ** Comparaison a la solution de reference
  91. ixref = POSI xref 'DANS' lxc0 ;
  92. iyref = POSI yref 'DANS' lyc0 ;
  93. iref = ixref + ((iyref - 1) * (DIME lxc0)) ;
  94. xcal1 = EXTR lxc iref ;
  95. ycal1 = EXTR lyc iref ;
  96. fcal1 = EXTR est1 iref ;
  97. vcal1 = EXTR var1 iref ;
  98. errf1 = ((FLOT (@ARR fcal1 1)) - fref) / fref ;
  99. errv1 = ((FLOT (@ARR vcal1 2)) - vref) / vref ;
  100. MESS '+--------------------------+--------------------------+' ;
  101. MESS ' Valeurs de reference | Valeurs calculees ' ;
  102. MESS '+--------------------------+--------------------------+' ;
  103. MESS ' x y | x y ' ;
  104. MESS ' ' xref ' ' yref ' |' xcal1 ' ' ycal1 ' ' ;
  105. MESS ' --------------------------+-------------------------- ' ;
  106. MESS ' Fonction Variance | Fonction Variance ' ;
  107. MESS ' ' fref ' ' vref ' |' fcal1 ' ' vcal1 ' ' ;
  108. MESS ' --------------------------+-------------------------- ' ;
  109. MESS ' | Erreur Erreur ' ;
  110. MESS ' |' errf1 ' ' errv1 ' ' ;
  111. MESS '+--------------------------+--------------------------+' ;
  112. SAUT 2 'LIGNE' ;
  113.  
  114.  
  115.  
  116. ************************************************************************
  117. * Cas 2 : krigeage avec mesures LISTREEL et cibles CHPOINT *
  118. * et covariogramme *
  119. ************************************************************************
  120.  
  121. ** Covariogramme
  122. lc = c1 * (EXP (-3. * lh / a)) ;
  123. REMP lc 1 (c0 + c1) ;
  124. cov = EVOL 'VERT' 'MANU' lh lc ;
  125.  
  126. ** Maillage de points cibles, ou l'on veut interpoler
  127. OPTI 'DIME' 2 'ELEM' 'QUA4' 'DENS' dx ;
  128. lig1 = DROI (xmin ymin) (xmax ymin) ;
  129. mail = lig1 TRAN (0. (ymax - ymin)) ;
  130. ncib = NBNO mail ;
  131. con = CONT mail ;
  132. x y = COOR mail ;
  133. cib = (NOMC 'X' x) ET (NOMC 'Y' y) ;
  134.  
  135. ** Krigeage au points cibles (avec le covariogramme)
  136. t2 = TABL ;
  137. t2 . 'MESURES' = TABL ;
  138. t2 . 'MESURES' . 'X' = lxm ;
  139. t2 . 'MESURES' . 'Y' = lym ;
  140. t2 . 'MESURES' . 'FONC' = lfm ;
  141. t2 . 'CIBLES' = cib ;
  142. t2 . 'COORDONNEES' = MOTS 'X' 'Y' ;
  143. t2 . 'COMPOSANTE' = MOT 'FONC' ;
  144. t2 . 'COVARIOGRAMME' = cov ;
  145. est2 var2 = KRIG t2 ;
  146. tps2 = TEMP 'HORL' ;
  147. MESS 'CAS #2' ;
  148. MESS '======' ;
  149. MESS 'Krigeage sur' ' ' ncib ' points realise en' ' ' tps2 ' ms' ;
  150.  
  151. ** Comparaison a la solution de reference
  152. pref = mail POIN 'PROCHE' (xref yref) ;
  153. xcal2 ycal2 = COOR pref ;
  154. fcal2 = EXTR est2 'FONC' pref ;
  155. vcal2 = EXTR var2 'FONC' pref ;
  156. errf2 = ((FLOT (@ARR fcal2 1)) - fref) / fref ;
  157. errv2 = ((FLOT (@ARR vcal2 2)) - vref) / vref ;
  158. MESS '+--------------------------+--------------------------+' ;
  159. MESS ' Valeurs de reference | Valeurs calculees ' ;
  160. MESS '+--------------------------+--------------------------+' ;
  161. MESS ' x y | x y ' ;
  162. MESS ' ' xref ' ' yref ' |' xcal2 ' ' ycal2 ' ' ;
  163. MESS ' --------------------------+-------------------------- ' ;
  164. MESS ' Fonction Variance | Fonction Variance ' ;
  165. MESS ' ' fref ' ' vref ' |' fcal2 ' ' vcal2 ' ' ;
  166. MESS ' --------------------------+-------------------------- ' ;
  167. MESS ' | Erreur Erreur ' ;
  168. MESS ' |' errf2 ' ' errv2 ' ' ;
  169. MESS '+--------------------------+--------------------------+' ;
  170. SAUT 2 'LIGNE' ;
  171.  
  172.  
  173.  
  174. ************************************************************************
  175. * Cas 3 : krigeage avec mesures CHPOINT et cibles LISTREEL *
  176. * et variogramme *
  177. ************************************************************************
  178.  
  179. ** Maillage et champs pour visualiser ces points de mesure
  180. ptm = POIN lxm lym ;
  181. xm ym = COOR ptm ;
  182. mes = (NOMC 'X' xm) ET (NOMC 'Y' ym) ET
  183. (MANU 'CHPO' ptm 1 'FONC' lfm 'NATURE' 'DIFFUS') ;
  184.  
  185. ** Krigeage au points cibles (avec le variogramme)
  186. t3 = TABL ;
  187. t3 . 'MESURES' = mes ;
  188. t3 . 'CIBLES' = TABL ;
  189. t3 . 'CIBLES' . 'X' = lxc ;
  190. t3 . 'CIBLES' . 'Y' = lyc ;
  191. t3 . 'COORDONNEES' = MOTS 'X' 'Y' ;
  192. t3 . 'COMPOSANTE' = MOT 'FONC' ;
  193. t3 . 'VARIOGRAMME' = gam ;
  194. est3 var3 = KRIG t3 ;
  195. tps3 = TEMP 'HORL' ;
  196. MESS 'CAS #3' ;
  197. MESS '======' ;
  198. MESS 'Krigeage sur' ' ' ncib ' points realise en' ' ' tps3 ' ms' ;
  199.  
  200. ** Comparaison a la solution de reference
  201. xcal3 = xcal1 ;
  202. ycal3 = xcal1 ;
  203. fcal3 = EXTR est3 iref ;
  204. vcal3 = EXTR var3 iref ;
  205. errf3 = ((FLOT (@ARR fcal3 1)) - fref) / fref ;
  206. errv3 = ((FLOT (@ARR vcal3 2)) - vref) / vref ;
  207. MESS '+--------------------------+--------------------------+' ;
  208. MESS ' Valeurs de reference | Valeurs calculees ' ;
  209. MESS '+--------------------------+--------------------------+' ;
  210. MESS ' x y | x y ' ;
  211. MESS ' ' xref ' ' yref ' |' xcal3 ' ' ycal3 ' ' ;
  212. MESS ' --------------------------+-------------------------- ' ;
  213. MESS ' Fonction Variance | Fonction Variance ' ;
  214. MESS ' ' fref ' ' vref ' |' fcal3 ' ' vcal3 ' ' ;
  215. MESS ' --------------------------+-------------------------- ' ;
  216. MESS ' | Erreur Erreur ' ;
  217. MESS ' |' errf3 ' ' errv3 ' ' ;
  218. MESS '+--------------------------+--------------------------+' ;
  219. SAUT 2 'LIGNE' ;
  220.  
  221.  
  222.  
  223. ************************************************************************
  224. * Cas 4 : krigeage avec mesures CHPOINT et cibles CHPOINT *
  225. * et covariogramme *
  226. ************************************************************************
  227.  
  228. ** Krigeage au points cibles (avec le covariogramme)
  229. t4 = TABL ;
  230. t4 . 'MESURES' = mes ;
  231. t4 . 'CIBLES' = cib ;
  232. t4 . 'COORDONNEES' = MOTS 'X' 'Y' ;
  233. t4 . 'COMPOSANTE' = MOT 'FONC' ;
  234. t4 . 'COVARIOGRAMME' = cov ;
  235. est4 var4 = KRIG t4 ;
  236. tps4 = TEMP 'HORL' ;
  237. MESS 'CAS #4' ;
  238. MESS '======' ;
  239. MESS 'Krigeage sur' ' ' ncib ' points realise en' ' ' tps4 ' ms' ;
  240.  
  241. ** Comparaison a la solution de reference
  242. xcal4 = xcal2 ;
  243. ycal4 = ycal2 ;
  244. fcal4 = EXTR est4 'FONC' pref ;
  245. vcal4 = EXTR var4 'FONC' pref ;
  246. errf4 = ((FLOT (@ARR fcal4 1)) - fref) / fref ;
  247. errv4 = ((FLOT (@ARR vcal4 2)) - vref) / vref ;
  248. MESS '+--------------------------+--------------------------+' ;
  249. MESS ' Valeurs de reference | Valeurs calculees ' ;
  250. MESS '+--------------------------+--------------------------+' ;
  251. MESS ' x y | x y ' ;
  252. MESS ' ' xref ' ' yref ' |' xcal4 ' ' ycal4 ' ' ;
  253. MESS ' --------------------------+-------------------------- ' ;
  254. MESS ' Fonction Variance | Fonction Variance ' ;
  255. MESS ' ' fref ' ' vref ' |' fcal4 ' ' vcal4 ' ' ;
  256. MESS ' --------------------------+-------------------------- ' ;
  257. MESS ' | Erreur Erreur ' ;
  258. MESS ' |' errf4 ' ' errv4 ' ' ;
  259. MESS '+--------------------------+--------------------------+' ;
  260. SAUT 2 'LIGNE' ;
  261.  
  262. ** Trace des champs
  263. SI itrac ;
  264. TRAC est4 mail con 'TITR' 'Interpolation de la fonction par Krigeage' ;
  265. TRAC var4 mail con 'TITR' 'Variance de l''estimation par Krigeage' ;
  266. FINSI ;
  267.  
  268.  
  269. ** Sortie en erreur si ecart trop grand
  270. errmax = MAXI 'ABS' errf1 errf2 errf3 errf4
  271. errv1 errv2 errv3 errv4 ;
  272. MESS 'Erreur max. =' errmax ;
  273. SI (errmax > 1.E-10) ;
  274. ERRE '--> Mauvaise interpolation :-(' ;
  275. FINSI ;
  276.  
  277.  
  278. FIN ;
  279.  
  280.  
  281.  

© Cast3M 2003 - Tous droits réservés.
Mentions légales