gphys 1.1.1a

Sign up to get free protection for your applications and to get access to all the features.
Files changed (428) hide show
  1. data/ChangeLog +1777 -0
  2. data/LICENSE.txt +34 -0
  3. data/README +33 -0
  4. data/Rakefile +57 -0
  5. data/TODO_ep_flux +6 -0
  6. data/bin/gdir_client +27 -0
  7. data/bin/gdir_server +129 -0
  8. data/bin/gpaop +146 -0
  9. data/bin/gpcat +148 -0
  10. data/bin/gpcut +102 -0
  11. data/bin/gpedit +228 -0
  12. data/bin/gplist +68 -0
  13. data/bin/gpmath +120 -0
  14. data/bin/gpmaxmin +128 -0
  15. data/bin/gpprint +60 -0
  16. data/bin/gpvect +706 -0
  17. data/bin/gpview +704 -0
  18. data/bin/grads2nc_with_gphys +61 -0
  19. data/doc/attribute.html +19 -0
  20. data/doc/attributenetcdf.html +15 -0
  21. data/doc/axis.html +376 -0
  22. data/doc/coordmapping.html +111 -0
  23. data/doc/coordtransform.html +36 -0
  24. data/doc/derivative/gphys-derivative.html +80 -0
  25. data/doc/derivative/index.html +21 -0
  26. data/doc/derivative/index.rd +14 -0
  27. data/doc/derivative/math-doc/document/document.css +30 -0
  28. data/doc/derivative/math-doc/document/document.html +57 -0
  29. data/doc/derivative/math-doc/document/images.aux +1 -0
  30. data/doc/derivative/math-doc/document/images.log +385 -0
  31. data/doc/derivative/math-doc/document/images.pl +186 -0
  32. data/doc/derivative/math-doc/document/images.tex +364 -0
  33. data/doc/derivative/math-doc/document/img1.png +0 -0
  34. data/doc/derivative/math-doc/document/img10.png +0 -0
  35. data/doc/derivative/math-doc/document/img11.png +0 -0
  36. data/doc/derivative/math-doc/document/img12.png +0 -0
  37. data/doc/derivative/math-doc/document/img13.png +0 -0
  38. data/doc/derivative/math-doc/document/img14.png +0 -0
  39. data/doc/derivative/math-doc/document/img15.png +0 -0
  40. data/doc/derivative/math-doc/document/img16.png +0 -0
  41. data/doc/derivative/math-doc/document/img17.png +0 -0
  42. data/doc/derivative/math-doc/document/img18.png +0 -0
  43. data/doc/derivative/math-doc/document/img19.png +0 -0
  44. data/doc/derivative/math-doc/document/img2.png +0 -0
  45. data/doc/derivative/math-doc/document/img20.png +0 -0
  46. data/doc/derivative/math-doc/document/img21.png +0 -0
  47. data/doc/derivative/math-doc/document/img22.png +0 -0
  48. data/doc/derivative/math-doc/document/img23.png +0 -0
  49. data/doc/derivative/math-doc/document/img24.png +0 -0
  50. data/doc/derivative/math-doc/document/img25.png +0 -0
  51. data/doc/derivative/math-doc/document/img26.png +0 -0
  52. data/doc/derivative/math-doc/document/img27.png +0 -0
  53. data/doc/derivative/math-doc/document/img28.png +0 -0
  54. data/doc/derivative/math-doc/document/img29.png +0 -0
  55. data/doc/derivative/math-doc/document/img3.png +0 -0
  56. data/doc/derivative/math-doc/document/img30.png +0 -0
  57. data/doc/derivative/math-doc/document/img4.png +0 -0
  58. data/doc/derivative/math-doc/document/img5.png +0 -0
  59. data/doc/derivative/math-doc/document/img6.png +0 -0
  60. data/doc/derivative/math-doc/document/img7.png +0 -0
  61. data/doc/derivative/math-doc/document/img8.png +0 -0
  62. data/doc/derivative/math-doc/document/img9.png +0 -0
  63. data/doc/derivative/math-doc/document/index.html +57 -0
  64. data/doc/derivative/math-doc/document/labels.pl +13 -0
  65. data/doc/derivative/math-doc/document/next.png +0 -0
  66. data/doc/derivative/math-doc/document/next_g.png +0 -0
  67. data/doc/derivative/math-doc/document/node1.html +238 -0
  68. data/doc/derivative/math-doc/document/node2.html +75 -0
  69. data/doc/derivative/math-doc/document/prev.png +0 -0
  70. data/doc/derivative/math-doc/document/prev_g.png +0 -0
  71. data/doc/derivative/math-doc/document/up.png +0 -0
  72. data/doc/derivative/math-doc/document/up_g.png +0 -0
  73. data/doc/derivative/math-doc/document.pdf +0 -0
  74. data/doc/derivative/math-doc/document.tex +158 -0
  75. data/doc/derivative/numru-derivative.html +129 -0
  76. data/doc/ep_flux/ep_flux.html +469 -0
  77. data/doc/ep_flux/ggraph_on_merdional_section.html +71 -0
  78. data/doc/ep_flux/index.html +31 -0
  79. data/doc/ep_flux/index.rd +24 -0
  80. data/doc/ep_flux/math-doc/document/WARNINGS +1 -0
  81. data/doc/ep_flux/math-doc/document/contents.png +0 -0
  82. data/doc/ep_flux/math-doc/document/crossref.png +0 -0
  83. data/doc/ep_flux/math-doc/document/document.css +30 -0
  84. data/doc/ep_flux/math-doc/document/document.html +101 -0
  85. data/doc/ep_flux/math-doc/document/images.aux +1 -0
  86. data/doc/ep_flux/math-doc/document/images.log +1375 -0
  87. data/doc/ep_flux/math-doc/document/images.pl +1328 -0
  88. data/doc/ep_flux/math-doc/document/images.tex +1471 -0
  89. data/doc/ep_flux/math-doc/document/img1.png +0 -0
  90. data/doc/ep_flux/math-doc/document/img10.png +0 -0
  91. data/doc/ep_flux/math-doc/document/img100.png +0 -0
  92. data/doc/ep_flux/math-doc/document/img101.png +0 -0
  93. data/doc/ep_flux/math-doc/document/img102.png +0 -0
  94. data/doc/ep_flux/math-doc/document/img103.png +0 -0
  95. data/doc/ep_flux/math-doc/document/img104.png +0 -0
  96. data/doc/ep_flux/math-doc/document/img105.png +0 -0
  97. data/doc/ep_flux/math-doc/document/img106.png +0 -0
  98. data/doc/ep_flux/math-doc/document/img107.png +0 -0
  99. data/doc/ep_flux/math-doc/document/img108.png +0 -0
  100. data/doc/ep_flux/math-doc/document/img109.png +0 -0
  101. data/doc/ep_flux/math-doc/document/img11.png +0 -0
  102. data/doc/ep_flux/math-doc/document/img110.png +0 -0
  103. data/doc/ep_flux/math-doc/document/img111.png +0 -0
  104. data/doc/ep_flux/math-doc/document/img112.png +0 -0
  105. data/doc/ep_flux/math-doc/document/img113.png +0 -0
  106. data/doc/ep_flux/math-doc/document/img114.png +0 -0
  107. data/doc/ep_flux/math-doc/document/img115.png +0 -0
  108. data/doc/ep_flux/math-doc/document/img116.png +0 -0
  109. data/doc/ep_flux/math-doc/document/img117.png +0 -0
  110. data/doc/ep_flux/math-doc/document/img118.png +0 -0
  111. data/doc/ep_flux/math-doc/document/img119.png +0 -0
  112. data/doc/ep_flux/math-doc/document/img12.png +0 -0
  113. data/doc/ep_flux/math-doc/document/img120.png +0 -0
  114. data/doc/ep_flux/math-doc/document/img121.png +0 -0
  115. data/doc/ep_flux/math-doc/document/img122.png +0 -0
  116. data/doc/ep_flux/math-doc/document/img123.png +0 -0
  117. data/doc/ep_flux/math-doc/document/img124.png +0 -0
  118. data/doc/ep_flux/math-doc/document/img125.png +0 -0
  119. data/doc/ep_flux/math-doc/document/img126.png +0 -0
  120. data/doc/ep_flux/math-doc/document/img127.png +0 -0
  121. data/doc/ep_flux/math-doc/document/img128.png +0 -0
  122. data/doc/ep_flux/math-doc/document/img129.png +0 -0
  123. data/doc/ep_flux/math-doc/document/img13.png +0 -0
  124. data/doc/ep_flux/math-doc/document/img130.png +0 -0
  125. data/doc/ep_flux/math-doc/document/img131.png +0 -0
  126. data/doc/ep_flux/math-doc/document/img132.png +0 -0
  127. data/doc/ep_flux/math-doc/document/img133.png +0 -0
  128. data/doc/ep_flux/math-doc/document/img134.png +0 -0
  129. data/doc/ep_flux/math-doc/document/img135.png +0 -0
  130. data/doc/ep_flux/math-doc/document/img136.png +0 -0
  131. data/doc/ep_flux/math-doc/document/img137.png +0 -0
  132. data/doc/ep_flux/math-doc/document/img138.png +0 -0
  133. data/doc/ep_flux/math-doc/document/img139.png +0 -0
  134. data/doc/ep_flux/math-doc/document/img14.png +0 -0
  135. data/doc/ep_flux/math-doc/document/img140.png +0 -0
  136. data/doc/ep_flux/math-doc/document/img141.png +0 -0
  137. data/doc/ep_flux/math-doc/document/img142.png +0 -0
  138. data/doc/ep_flux/math-doc/document/img143.png +0 -0
  139. data/doc/ep_flux/math-doc/document/img144.png +0 -0
  140. data/doc/ep_flux/math-doc/document/img145.png +0 -0
  141. data/doc/ep_flux/math-doc/document/img146.png +0 -0
  142. data/doc/ep_flux/math-doc/document/img147.png +0 -0
  143. data/doc/ep_flux/math-doc/document/img148.png +0 -0
  144. data/doc/ep_flux/math-doc/document/img149.png +0 -0
  145. data/doc/ep_flux/math-doc/document/img15.png +0 -0
  146. data/doc/ep_flux/math-doc/document/img150.png +0 -0
  147. data/doc/ep_flux/math-doc/document/img151.png +0 -0
  148. data/doc/ep_flux/math-doc/document/img152.png +0 -0
  149. data/doc/ep_flux/math-doc/document/img153.png +0 -0
  150. data/doc/ep_flux/math-doc/document/img154.png +0 -0
  151. data/doc/ep_flux/math-doc/document/img155.png +0 -0
  152. data/doc/ep_flux/math-doc/document/img156.png +0 -0
  153. data/doc/ep_flux/math-doc/document/img157.png +0 -0
  154. data/doc/ep_flux/math-doc/document/img158.png +0 -0
  155. data/doc/ep_flux/math-doc/document/img159.png +0 -0
  156. data/doc/ep_flux/math-doc/document/img16.png +0 -0
  157. data/doc/ep_flux/math-doc/document/img160.png +0 -0
  158. data/doc/ep_flux/math-doc/document/img161.png +0 -0
  159. data/doc/ep_flux/math-doc/document/img162.png +0 -0
  160. data/doc/ep_flux/math-doc/document/img163.png +0 -0
  161. data/doc/ep_flux/math-doc/document/img164.png +0 -0
  162. data/doc/ep_flux/math-doc/document/img165.png +0 -0
  163. data/doc/ep_flux/math-doc/document/img166.png +0 -0
  164. data/doc/ep_flux/math-doc/document/img167.png +0 -0
  165. data/doc/ep_flux/math-doc/document/img168.png +0 -0
  166. data/doc/ep_flux/math-doc/document/img169.png +0 -0
  167. data/doc/ep_flux/math-doc/document/img17.png +0 -0
  168. data/doc/ep_flux/math-doc/document/img170.png +0 -0
  169. data/doc/ep_flux/math-doc/document/img171.png +0 -0
  170. data/doc/ep_flux/math-doc/document/img172.png +0 -0
  171. data/doc/ep_flux/math-doc/document/img173.png +0 -0
  172. data/doc/ep_flux/math-doc/document/img174.png +0 -0
  173. data/doc/ep_flux/math-doc/document/img175.png +0 -0
  174. data/doc/ep_flux/math-doc/document/img176.png +0 -0
  175. data/doc/ep_flux/math-doc/document/img177.png +0 -0
  176. data/doc/ep_flux/math-doc/document/img178.png +0 -0
  177. data/doc/ep_flux/math-doc/document/img179.png +0 -0
  178. data/doc/ep_flux/math-doc/document/img18.png +0 -0
  179. data/doc/ep_flux/math-doc/document/img180.png +0 -0
  180. data/doc/ep_flux/math-doc/document/img181.png +0 -0
  181. data/doc/ep_flux/math-doc/document/img182.png +0 -0
  182. data/doc/ep_flux/math-doc/document/img183.png +0 -0
  183. data/doc/ep_flux/math-doc/document/img184.png +0 -0
  184. data/doc/ep_flux/math-doc/document/img185.png +0 -0
  185. data/doc/ep_flux/math-doc/document/img186.png +0 -0
  186. data/doc/ep_flux/math-doc/document/img187.png +0 -0
  187. data/doc/ep_flux/math-doc/document/img188.png +0 -0
  188. data/doc/ep_flux/math-doc/document/img189.png +0 -0
  189. data/doc/ep_flux/math-doc/document/img19.png +0 -0
  190. data/doc/ep_flux/math-doc/document/img190.png +0 -0
  191. data/doc/ep_flux/math-doc/document/img191.png +0 -0
  192. data/doc/ep_flux/math-doc/document/img192.png +0 -0
  193. data/doc/ep_flux/math-doc/document/img193.png +0 -0
  194. data/doc/ep_flux/math-doc/document/img194.png +0 -0
  195. data/doc/ep_flux/math-doc/document/img195.png +0 -0
  196. data/doc/ep_flux/math-doc/document/img196.png +0 -0
  197. data/doc/ep_flux/math-doc/document/img197.png +0 -0
  198. data/doc/ep_flux/math-doc/document/img198.png +0 -0
  199. data/doc/ep_flux/math-doc/document/img199.png +0 -0
  200. data/doc/ep_flux/math-doc/document/img2.png +0 -0
  201. data/doc/ep_flux/math-doc/document/img20.png +0 -0
  202. data/doc/ep_flux/math-doc/document/img200.png +0 -0
  203. data/doc/ep_flux/math-doc/document/img21.png +0 -0
  204. data/doc/ep_flux/math-doc/document/img22.png +0 -0
  205. data/doc/ep_flux/math-doc/document/img23.png +0 -0
  206. data/doc/ep_flux/math-doc/document/img24.png +0 -0
  207. data/doc/ep_flux/math-doc/document/img25.png +0 -0
  208. data/doc/ep_flux/math-doc/document/img26.png +0 -0
  209. data/doc/ep_flux/math-doc/document/img27.png +0 -0
  210. data/doc/ep_flux/math-doc/document/img28.png +0 -0
  211. data/doc/ep_flux/math-doc/document/img29.png +0 -0
  212. data/doc/ep_flux/math-doc/document/img3.png +0 -0
  213. data/doc/ep_flux/math-doc/document/img30.png +0 -0
  214. data/doc/ep_flux/math-doc/document/img31.png +0 -0
  215. data/doc/ep_flux/math-doc/document/img32.png +0 -0
  216. data/doc/ep_flux/math-doc/document/img33.png +0 -0
  217. data/doc/ep_flux/math-doc/document/img34.png +0 -0
  218. data/doc/ep_flux/math-doc/document/img35.png +0 -0
  219. data/doc/ep_flux/math-doc/document/img36.png +0 -0
  220. data/doc/ep_flux/math-doc/document/img37.png +0 -0
  221. data/doc/ep_flux/math-doc/document/img38.png +0 -0
  222. data/doc/ep_flux/math-doc/document/img39.png +0 -0
  223. data/doc/ep_flux/math-doc/document/img4.png +0 -0
  224. data/doc/ep_flux/math-doc/document/img40.png +0 -0
  225. data/doc/ep_flux/math-doc/document/img41.png +0 -0
  226. data/doc/ep_flux/math-doc/document/img42.png +0 -0
  227. data/doc/ep_flux/math-doc/document/img43.png +0 -0
  228. data/doc/ep_flux/math-doc/document/img44.png +0 -0
  229. data/doc/ep_flux/math-doc/document/img45.png +0 -0
  230. data/doc/ep_flux/math-doc/document/img46.png +0 -0
  231. data/doc/ep_flux/math-doc/document/img47.png +0 -0
  232. data/doc/ep_flux/math-doc/document/img48.png +0 -0
  233. data/doc/ep_flux/math-doc/document/img49.png +0 -0
  234. data/doc/ep_flux/math-doc/document/img5.png +0 -0
  235. data/doc/ep_flux/math-doc/document/img50.png +0 -0
  236. data/doc/ep_flux/math-doc/document/img51.png +0 -0
  237. data/doc/ep_flux/math-doc/document/img52.png +0 -0
  238. data/doc/ep_flux/math-doc/document/img53.png +0 -0
  239. data/doc/ep_flux/math-doc/document/img54.png +0 -0
  240. data/doc/ep_flux/math-doc/document/img55.png +0 -0
  241. data/doc/ep_flux/math-doc/document/img56.png +0 -0
  242. data/doc/ep_flux/math-doc/document/img57.png +0 -0
  243. data/doc/ep_flux/math-doc/document/img58.png +0 -0
  244. data/doc/ep_flux/math-doc/document/img59.png +0 -0
  245. data/doc/ep_flux/math-doc/document/img6.png +0 -0
  246. data/doc/ep_flux/math-doc/document/img60.png +0 -0
  247. data/doc/ep_flux/math-doc/document/img61.png +0 -0
  248. data/doc/ep_flux/math-doc/document/img62.png +0 -0
  249. data/doc/ep_flux/math-doc/document/img63.png +0 -0
  250. data/doc/ep_flux/math-doc/document/img64.png +0 -0
  251. data/doc/ep_flux/math-doc/document/img65.png +0 -0
  252. data/doc/ep_flux/math-doc/document/img66.png +0 -0
  253. data/doc/ep_flux/math-doc/document/img67.png +0 -0
  254. data/doc/ep_flux/math-doc/document/img68.png +0 -0
  255. data/doc/ep_flux/math-doc/document/img69.png +0 -0
  256. data/doc/ep_flux/math-doc/document/img7.png +0 -0
  257. data/doc/ep_flux/math-doc/document/img70.png +0 -0
  258. data/doc/ep_flux/math-doc/document/img71.png +0 -0
  259. data/doc/ep_flux/math-doc/document/img72.png +0 -0
  260. data/doc/ep_flux/math-doc/document/img73.png +0 -0
  261. data/doc/ep_flux/math-doc/document/img74.png +0 -0
  262. data/doc/ep_flux/math-doc/document/img75.png +0 -0
  263. data/doc/ep_flux/math-doc/document/img76.png +0 -0
  264. data/doc/ep_flux/math-doc/document/img77.png +0 -0
  265. data/doc/ep_flux/math-doc/document/img78.png +0 -0
  266. data/doc/ep_flux/math-doc/document/img79.png +0 -0
  267. data/doc/ep_flux/math-doc/document/img8.png +0 -0
  268. data/doc/ep_flux/math-doc/document/img80.png +0 -0
  269. data/doc/ep_flux/math-doc/document/img81.png +0 -0
  270. data/doc/ep_flux/math-doc/document/img82.png +0 -0
  271. data/doc/ep_flux/math-doc/document/img83.png +0 -0
  272. data/doc/ep_flux/math-doc/document/img84.png +0 -0
  273. data/doc/ep_flux/math-doc/document/img85.png +0 -0
  274. data/doc/ep_flux/math-doc/document/img86.png +0 -0
  275. data/doc/ep_flux/math-doc/document/img87.png +0 -0
  276. data/doc/ep_flux/math-doc/document/img88.png +0 -0
  277. data/doc/ep_flux/math-doc/document/img89.png +0 -0
  278. data/doc/ep_flux/math-doc/document/img9.png +0 -0
  279. data/doc/ep_flux/math-doc/document/img90.png +0 -0
  280. data/doc/ep_flux/math-doc/document/img91.png +0 -0
  281. data/doc/ep_flux/math-doc/document/img92.png +0 -0
  282. data/doc/ep_flux/math-doc/document/img93.png +0 -0
  283. data/doc/ep_flux/math-doc/document/img94.png +0 -0
  284. data/doc/ep_flux/math-doc/document/img95.png +0 -0
  285. data/doc/ep_flux/math-doc/document/img96.png +0 -0
  286. data/doc/ep_flux/math-doc/document/img97.png +0 -0
  287. data/doc/ep_flux/math-doc/document/img98.png +0 -0
  288. data/doc/ep_flux/math-doc/document/img99.png +0 -0
  289. data/doc/ep_flux/math-doc/document/index.html +101 -0
  290. data/doc/ep_flux/math-doc/document/internals.pl +258 -0
  291. data/doc/ep_flux/math-doc/document/labels.pl +265 -0
  292. data/doc/ep_flux/math-doc/document/next.png +0 -0
  293. data/doc/ep_flux/math-doc/document/next_g.png +0 -0
  294. data/doc/ep_flux/math-doc/document/node1.html +104 -0
  295. data/doc/ep_flux/math-doc/document/node10.html +164 -0
  296. data/doc/ep_flux/math-doc/document/node11.html +86 -0
  297. data/doc/ep_flux/math-doc/document/node12.html +166 -0
  298. data/doc/ep_flux/math-doc/document/node13.html +897 -0
  299. data/doc/ep_flux/math-doc/document/node14.html +1065 -0
  300. data/doc/ep_flux/math-doc/document/node15.html +72 -0
  301. data/doc/ep_flux/math-doc/document/node16.html +81 -0
  302. data/doc/ep_flux/math-doc/document/node2.html +82 -0
  303. data/doc/ep_flux/math-doc/document/node3.html +91 -0
  304. data/doc/ep_flux/math-doc/document/node4.html +149 -0
  305. data/doc/ep_flux/math-doc/document/node5.html +330 -0
  306. data/doc/ep_flux/math-doc/document/node6.html +99 -0
  307. data/doc/ep_flux/math-doc/document/node7.html +98 -0
  308. data/doc/ep_flux/math-doc/document/node8.html +83 -0
  309. data/doc/ep_flux/math-doc/document/node9.html +140 -0
  310. data/doc/ep_flux/math-doc/document/prev.png +0 -0
  311. data/doc/ep_flux/math-doc/document/prev_g.png +0 -0
  312. data/doc/ep_flux/math-doc/document/up.png +0 -0
  313. data/doc/ep_flux/math-doc/document/up_g.png +0 -0
  314. data/doc/ep_flux/math-doc/document.pdf +0 -0
  315. data/doc/ep_flux/math-doc/document.tex +2018 -0
  316. data/doc/gdir.html +412 -0
  317. data/doc/gdir_client.html +16 -0
  318. data/doc/gdir_connect_ftp-like.html +61 -0
  319. data/doc/gdir_server.html +45 -0
  320. data/doc/ggraph.html +1615 -0
  321. data/doc/gpcat.html +44 -0
  322. data/doc/gpcut.html +41 -0
  323. data/doc/gphys.html +532 -0
  324. data/doc/gphys_fft.html +324 -0
  325. data/doc/gphys_grads_io.html +69 -0
  326. data/doc/gphys_grib_io.html +82 -0
  327. data/doc/gphys_io.html +120 -0
  328. data/doc/gphys_io_common.html +18 -0
  329. data/doc/gphys_netcdf_io.html +283 -0
  330. data/doc/gplist.html +24 -0
  331. data/doc/gpmath.html +51 -0
  332. data/doc/gpmaxmin.html +31 -0
  333. data/doc/gpprint.html +34 -0
  334. data/doc/gpview.html +270 -0
  335. data/doc/grads2nc_with_gphys.html +21 -0
  336. data/doc/grads_gridded.html +307 -0
  337. data/doc/grib.html +144 -0
  338. data/doc/grid.html +212 -0
  339. data/doc/index.html +133 -0
  340. data/doc/index.rd +127 -0
  341. data/doc/netcdf_convention.html +136 -0
  342. data/doc/unumeric.html +176 -0
  343. data/doc/update +64 -0
  344. data/doc/varray.html +299 -0
  345. data/doc/varraycomposite.html +67 -0
  346. data/ext_coord.c +209 -0
  347. data/ext_init.c +7 -0
  348. data/extconf.rb +42 -0
  349. data/install.rb +130 -0
  350. data/interpo.c +497 -0
  351. data/lib/numru/dcl_mouse.rb +71 -0
  352. data/lib/numru/dclext_datetime_ax.rb +220 -0
  353. data/lib/numru/derivative.rb +348 -0
  354. data/lib/numru/ganalysis/covariance.rb +154 -0
  355. data/lib/numru/ganalysis/eof.rb +298 -0
  356. data/lib/numru/ganalysis/histogram.rb +252 -0
  357. data/lib/numru/ganalysis/met.rb +317 -0
  358. data/lib/numru/ganalysis/planet.rb +182 -0
  359. data/lib/numru/ganalysis.rb +7 -0
  360. data/lib/numru/gdir.rb +1038 -0
  361. data/lib/numru/gdir_connect_ftp-like.rb +149 -0
  362. data/lib/numru/ggraph.rb +5838 -0
  363. data/lib/numru/ggraph_on_merdional_section.rb +178 -0
  364. data/lib/numru/gphys/assoccoords.rb +359 -0
  365. data/lib/numru/gphys/attribute.rb +129 -0
  366. data/lib/numru/gphys/attributenetcdf.rb +80 -0
  367. data/lib/numru/gphys/axis.rb +963 -0
  368. data/lib/numru/gphys/coordmapping.rb +286 -0
  369. data/lib/numru/gphys/coordtransform.rb +209 -0
  370. data/lib/numru/gphys/derivative.rb +314 -0
  371. data/lib/numru/gphys/ep_flux.rb +868 -0
  372. data/lib/numru/gphys/gpcommon.rb +52 -0
  373. data/lib/numru/gphys/gphys.rb +1207 -0
  374. data/lib/numru/gphys/gphys_fft.rb +886 -0
  375. data/lib/numru/gphys/gphys_grads_io.rb +212 -0
  376. data/lib/numru/gphys/gphys_grib_io.rb +214 -0
  377. data/lib/numru/gphys/gphys_gtool3_io.rb +162 -0
  378. data/lib/numru/gphys/gphys_hdfeos5_io.rb +672 -0
  379. data/lib/numru/gphys/gphys_io.rb +452 -0
  380. data/lib/numru/gphys/gphys_io_common.rb +126 -0
  381. data/lib/numru/gphys/gphys_netcdf_io.rb +800 -0
  382. data/lib/numru/gphys/gphys_nusdas_io.rb +132 -0
  383. data/lib/numru/gphys/grads_gridded.rb +1638 -0
  384. data/lib/numru/gphys/grib.rb +2049 -0
  385. data/lib/numru/gphys/grib_params.rb +1465 -0
  386. data/lib/numru/gphys/grid.rb +723 -0
  387. data/lib/numru/gphys/gtool3.rb +771 -0
  388. data/lib/numru/gphys/interpolate.rb +854 -0
  389. data/lib/numru/gphys/narray_ext.rb +34 -0
  390. data/lib/numru/gphys/netcdf_convention.rb +406 -0
  391. data/lib/numru/gphys/subsetmapping.rb +332 -0
  392. data/lib/numru/gphys/unumeric.rb +522 -0
  393. data/lib/numru/gphys/varray.rb +1109 -0
  394. data/lib/numru/gphys/varraycomposite.rb +415 -0
  395. data/lib/numru/gphys/varraygrads.rb +225 -0
  396. data/lib/numru/gphys/varraygrib.rb +177 -0
  397. data/lib/numru/gphys/varraygtool3.rb +226 -0
  398. data/lib/numru/gphys/varrayhdfeos5.rb +451 -0
  399. data/lib/numru/gphys/varraynetcdf.rb +350 -0
  400. data/lib/numru/gphys/varraynusdas.rb +59 -0
  401. data/lib/numru/gphys.rb +9 -0
  402. data/lib/numru/htdir.rb +170 -0
  403. data/multibitIO.c +567 -0
  404. data/sample/cira86_to_nc.rb +122 -0
  405. data/sample/druby_cli1.rb +21 -0
  406. data/sample/druby_cli2.rb +34 -0
  407. data/sample/druby_serv1.rb +30 -0
  408. data/sample/druby_serv2.rb +64 -0
  409. data/sample/ep_flux/demo_NCEP_1.rb +48 -0
  410. data/sample/ep_flux/demo_NCEP_2.rb +57 -0
  411. data/sample/ep_flux/demo_NCEP_3.rb +81 -0
  412. data/sample/ggraph_latlon_labelling_dr002690.rb +159 -0
  413. data/sample/ggraph_mapfit-axes_dr002687.rb +131 -0
  414. data/sample/map_projection.rb +121 -0
  415. data/sample/ncep_theta_coord.rb +79 -0
  416. data/test/eof_slp.rb +28 -0
  417. data/test/mltbit.dat +0 -0
  418. data/test/test_ep_flux.rb +533 -0
  419. data/test/test_multibitIO.rb +19 -0
  420. data/testdata/T.jan.ctl +12 -0
  421. data/testdata/T.jan.dat +0 -0
  422. data/testdata/T.jan.grib +0 -0
  423. data/testdata/T.jan.nc +0 -0
  424. data/testdata/T.jan.packed.withmiss.nc +0 -0
  425. data/testdata/UV.jan.nc +0 -0
  426. data/testdata/assoc_crds.nc +0 -0
  427. data/testdata/cira86.dat +1332 -0
  428. metadata +621 -0
@@ -0,0 +1,854 @@
1
+ require "numru/gphys/gphys"
2
+ require "numru/dcl" # math1/gt2dlib is used for pure-2D interpolation
3
+ require "numru/dcl_mouse" # for mouse_cut, mouse_cut_repeat
4
+ require "narray_miss"
5
+
6
+ if $0 == __FILE__
7
+ require "numru/gphys" # for test
8
+ end
9
+
10
+ module NumRu
11
+ class GPhys
12
+
13
+
14
+ @@interpo_previous_cutter = nil
15
+ @@interpo_previous_modifier = nil
16
+ @@interpo_missval = -1e30
17
+
18
+ # = Makes a subset interactively by specifying a (poly-)line on the DCL viewport
19
+ #
20
+ # ARGUMENTS
21
+ # * dimx {String] : name of number (0,1,..) of the dimension
22
+ # corresponding to the X coordinate in the current window of DCL
23
+ # * dimy {String] : name of number (0,1,..) of the dimension
24
+ # corresponding to the Y coordinate in the current window of DCL
25
+ # * num {Integer] : the number of points along the (poly-)line
26
+ # (2 or greater -- if 2, a single line segment; if 3 or more, a
27
+ # poly-line)
28
+ #
29
+ # RETURN VALUE
30
+ # * a GPhys
31
+ def mouse_cut(dimx, dimy, num=2)
32
+
33
+ # < preparation >
34
+
35
+ dimx = dim_index(dimx)
36
+ dimy = dim_index(dimy)
37
+
38
+ rundef = DCL.glpget("rundef")
39
+ line = nil
40
+ while(true)
41
+ puts "\n*** Waiting for mouse click. Click #{num} points in the current viewport."
42
+ line = DCLMouseLine.new(num)
43
+ if line.ux.include?(rundef)
44
+ puts "** The points specified include one(s) outside the U window. Do it again."
45
+ else
46
+ break
47
+ end
48
+ end
49
+ line.draw
50
+ vx = line.vx
51
+ vy = line.vy
52
+ ux = line.ux
53
+ uy = line.uy
54
+ len = ux.length
55
+ kx = Array.new
56
+ ky = Array.new
57
+ cut = [true]*rank
58
+ for i in 0...len
59
+ cut[dimx] = ux[i]
60
+ cut[dimy] = uy[i]
61
+ dummy, sl = grid.cut(*cut)
62
+ kx[i] = sl[dimx]
63
+ ky[i] = sl[dimy]
64
+ end
65
+ ndiv = Array.new
66
+ ndsum = [0]
67
+ for i in 0...len-1
68
+ ndiv[i] = Math.sqrt( (kx[i+1]-kx[i])**2 + (ky[i+1]-ky[i])**2).to_i
69
+ ndsum.push ndsum[-1] + ndiv[i] # 0, ndiv[0], ndiv[0]+ndiv[1], ...
70
+ end
71
+ ndtot = ndsum[-1]
72
+ vxdiv = NArray.float(ndtot)
73
+ vydiv = NArray.float(ndtot)
74
+ for i in 0...len-1
75
+ a = NArray.float(ndiv[i]).indgen / ndiv[i]
76
+ vxdiv[ndsum[i]...ndsum[i+1]] = (1.0-a)*vx[i] + a*vx[i+1]
77
+ vydiv[ndsum[i]...ndsum[i+1]] = (1.0-a)*vy[i] + a*vy[i+1]
78
+ end
79
+ uxdiv = NArray.float(ndtot)
80
+ uydiv = NArray.float(ndtot)
81
+ for i in 0...ndtot
82
+ uxdiv[i], uydiv[i] = DCL.stitrf(vxdiv[i], vydiv[i])
83
+ end
84
+ cx = coord(dimx)
85
+ xcrd = VArray.new(uxdiv, cx, cx.name)
86
+ cy = coord(dimy)
87
+ ycrd = VArray.new(uydiv, cy, cy.name)
88
+ if (vxdiv[-1]-vxdiv[0]).abs > (vydiv[-1]-vydiv[0]).abs
89
+ cutter = [xcrd,ycrd] # x will be the main coord var if not map proj
90
+ crd = xcrd
91
+ else
92
+ cutter = [ycrd,xcrd] # x will be the main coord var if not map proj
93
+ crd = ycrd
94
+ end
95
+ axnm = crd.name
96
+ itr = DCL.sgqtrn
97
+ if itr>=10 and itr<=40
98
+ newcrd = __sp_dist(xcrd,ycrd)
99
+ modifier = Proc.new{|gp|
100
+ newax = Axis.new.set_pos(newcrd)
101
+ gp.grid.set_axis(axnm,newax)
102
+ g = Grid.new( newax )
103
+ gxcrd = GPhys.new(g,xcrd)
104
+ gycrd = GPhys.new(g,ycrd)
105
+ gp.set_assoc_coords([gxcrd, gycrd])
106
+ gp
107
+ }
108
+ else
109
+ modifier = nil
110
+ end
111
+ @@interpo_previous_cutter = cutter
112
+ @@interpo_previous_modifier = modifier
113
+
114
+ # < do the job >
115
+
116
+ gpnew = interpolate(cutter)
117
+ gpnew = modifier[gpnew] if modifier
118
+ [gpnew, line]
119
+ end
120
+
121
+ # = Interpolation onto grid points specified by the previous call of GPhys#mouse_cut
122
+ def mouse_cut_repeat
123
+ if @@interpo_previous_cutter.nil?
124
+ raise("You must first use GPhys#mouse_cut. This method repeats it")
125
+ end
126
+ gpnew = interpolate(@@interpo_previous_cutter)
127
+ gpnew = @@interpo_previous_modifier[gpnew] if @@interpo_previous_modifier
128
+ gpnew
129
+ end
130
+
131
+ def __sp_dist(lon,lat)
132
+ x = lon.val * (Math::PI/180.0) # lon in rad
133
+ y = Math::PI/2 - lat.val*(Math::PI/180.0) # rad from a pole
134
+ cos_a = NMath::cos(y[1..-1])
135
+ sin_a = NMath::sin(y[1..-1])
136
+ cos_b = NMath::cos(y[0..-2])
137
+ sin_b = NMath::sin(y[0..-2])
138
+ cos_C = NMath::cos(x[1..-1]-x[0..-2])
139
+ cos_c= cos_a*cos_b + sin_a*sin_b*cos_C # from Spherical trigonometry
140
+ mask = cos_c.gt(1.0)
141
+ cos_c[mask] = 1.0 # to deal with round error
142
+ c = NMath::acos(cos_c)
143
+ cs = c.cumsum * (180.0/Math::PI)
144
+ cumdist = NArray.float(lon.length)
145
+ cumdist[1..-1] = cs
146
+
147
+ VArray.new(cumdist,
148
+ {"long_name"=>"distance along great circle","units"=>"degrees"},
149
+ "dist")
150
+ end
151
+ private :__sp_dist
152
+
153
+ # = Interpolate to conform the grid to a target GPhys object
154
+ #
155
+ # ARGUMENTS
156
+ # * to [GPhys] : the target gphys
157
+ #
158
+ # RETURN VALUE
159
+ # * a GPhys
160
+ #
161
+ def regrid(to)
162
+ coords = to.axnames.collect{|nm| to.coord(nm)}
163
+ interpolate(*coords)
164
+ end
165
+
166
+ # = Wide-purpose multi-dimensional linear interpolation
167
+ #
168
+ # This method supports interpolation regarding combinations of
169
+ # 1D and 2D coordinate variables. For instance, suppose self is
170
+ # 4D with coordinates named ["x", "y", "z", "t"] and associated
171
+ # coordinates "sigma"["z"] ("sigma" is 1D and its axis is "z"),
172
+ # "p"["x","y"], "q"["x","y"] ("p" and "q" are 2D having the
173
+ # coordinates "x" and "y"). You can make interpolation by
174
+ # specifying 1D VArrays whose names are among "x", "y", "z", "t",
175
+ # "sigma", "p", "q". You can also use a Hash like {"z" => 1.0}
176
+ # to specify a single point along the "x" coordinate.
177
+ #
178
+ # If the units of the target coordinate and the current coordinate
179
+ # are different, a converstion was made so that slicing is
180
+ # made correctly, as long as the two units are comvertible;
181
+ # if the units are not convertible, it is just warned.
182
+ #
183
+ # If you specify only "x", "y", and "t" coordinates
184
+ # for interpolation, the remaining coordinates "z" is simply
185
+ # retained. So the result will be 4 dimensional
186
+ # with coordinates named ["x", "y", "z", "t"], but the
187
+ # lengths of "x", "y", and "t" dimensions are changed according
188
+ # to the specification. Note that the result could
189
+ # be 3-or-smaller dimensional -- see below.
190
+ #
191
+ # Suppose you have two 1D VArrays, xnew and ynew, having
192
+ # names "x" and "y", respectively, and the lengths of xnew and
193
+ # the ynew are the same. Then, you can give an array of
194
+ # the two, [xnew, ynew], for coord0 as
195
+ #
196
+ # gp_int = gp_org.interpolate( [xnew, ynew] )
197
+ #
198
+ # (Here, gp_org represents a GPhys object, and the return value
199
+ # pointed by gp_int is also a GPhys.) In this case,
200
+ # the 1st dimension of the result (gp_int) will be sampled
201
+ # at the points [xnew[0],ynew[0]], [xnew[1],ynew[1]], [xnew[2],ynew[2]],
202
+ # ..., while the 2nd and the third dimensions are "z" and "t" (no
203
+ # interpolation). This way, the rank of the result will be reduced
204
+ # from that of self.
205
+ #
206
+ # If you instead give xnew to coord0 and ynew to coord1 as
207
+ #
208
+ # gp_int = gp_org.interpolate( xnew, ynew )
209
+ #
210
+ # The result will be 4-dimensional with the first coordinate
211
+ # sampled at xnew[0], xnew[1], xnew[2],... and the second
212
+ # coordinate sampled at ynew[0], ynew[1], ynew[2],...
213
+ #
214
+ # You can also cut regarding 2D coordinate variable as
215
+ #
216
+ # gp_int = gp_org.interpolate( pnew, qnew )
217
+ # gp_int = gp_org.interpolate( xnew, qnew )
218
+ # gp_int = gp_org.interpolate( [pnew, qnew] )
219
+ # gp_int = gp_org.interpolate( [xnew, qnew] )
220
+ #
221
+ # In any case, the desitination VArrays such as xnew ynew pnew qnew
222
+ # must be one-dimensional.
223
+ #
224
+ # Note that
225
+ #
226
+ # gp_int = gp_org.interpolate( qnew )
227
+ #
228
+ # fails (exception raised), since it is ambiguous. If you tempted to
229
+ # do so, perhaps what you want is covered by the following special
230
+ # form:
231
+ #
232
+ # As a special form, you can specify a particular dimension
233
+ # like this:
234
+ #
235
+ # gp_int = gp_org.interpolate( "x"=>pnew )
236
+ #
237
+ # Here, interpolation along "x" is made, while other axes are
238
+ # retained. This is useful if pnew corresponds to a multi-D
239
+ # coordinate variable where there are two or more corresponding axes
240
+ # (otherwise, this special form is not needed.)
241
+ #
242
+ # See the test part at the end of this file for more examples.
243
+ #
244
+ # LIMITATION
245
+ #
246
+ # Currently associated coordinates expressed by 3D or greater
247
+ # dimensional arrays are not supported.
248
+ #
249
+ # Computational efficiency of pure two-dimensional coordinate
250
+ # support should be improved by letting C extensions cover deeper
251
+ # and improving the search algorithm for grid (which is usually
252
+ # ordered quasi-regularly).
253
+ #
254
+ # COVERAGE
255
+ #
256
+ # Extrapolation is covered for 1D coordinates, but only
257
+ # interpolation is covered for 2D coordinates (which is
258
+ # limited by gt2dlib in DCL -- exception will be raised
259
+ # if you specify a grid point outside the original 2D grid points.).
260
+ #
261
+ # MATHEMATICAL SPECIFICATION
262
+ #
263
+ # The multi-dimensional linear interpolation is done by
264
+ # supposing a (hyper-) "rectangular" grid, where each
265
+ # dimension is independently sampled one-dimensionally. In case
266
+ # of interpolation along two dimensional coordinates such as "p"
267
+ # and "q" in the example above, a mapping from a rectangular grid
268
+ # is assumed, and the corresponding points in the rectangular grid
269
+ # is solved inversely (currently by using gt2dlib in DCL).
270
+ #
271
+ # For 1D and 2D cases, linear interpolations may be expressed as
272
+ #
273
+ # 1D: zi = (1-a)*z0 + a*z1
274
+ # 2D: zi = (1-a)*(1-b)*z00 + a*(1-b)*z10 + (1-a)*b*z01 + a*b*z11
275
+ #
276
+ # This method is extended to arbitrary number of dimensions. Thus,
277
+ # if the number of dimensions to interpolate is S, then 2**S grid
278
+ # points are used for each interpolation (8 points for 3D, 16 points
279
+ # for 4D,...). Thus, the linearity of this interpolation is only along
280
+ # each dimension, not over the whole dimensionality.
281
+ #
282
+ # USAGE
283
+ # interpolate(coord0, coord1, ...)
284
+ #
285
+ # ARGUMENTS
286
+ # * coord0, coord1,... [ 1D VArray, or Array of 1D VArray,
287
+ # or a 1-element Hash as
288
+ # {coordinate_name(String) => slice_loc_value(Numeric)} ] :
289
+ # locations to which interpolation is made. Names of
290
+ # all the VArray's in the arguments must exist among
291
+ # the names of the coordinates of self (including associated
292
+ # coordinates), since the dimension
293
+ # finding is made in terms of coordinate names.
294
+ # If an argument is an Array of VArray's, the first
295
+ # VArray will become the main coordinate variable,
296
+ # and the rest will be associated coordinates.
297
+ # * [SPECIAL CASE]
298
+ # You can specfify a one-element Hash as the only argument
299
+ # such as
300
+ # gphys.interpolate("x"=>varray)
301
+ # where varray is a coordinate onto which interpolation is made.
302
+ # This is espcially useful if varray is multi-D. If varray's
303
+ # name "p" (name of a 2D coordnate var), for example,
304
+ # you can interpolate only regarding "x" by retaining other
305
+ # axes. If varray is 1-diemnsional, the same thing can
306
+ # be done simply by
307
+ # gphys.interpolate(varray)
308
+ # since the corresponding 1D coordinate is found aotomatically.
309
+ #
310
+ # RETURN VALUE
311
+ # * a GPhys
312
+ #
313
+ def interpolate(*coords)
314
+ coords, org_coords, org_dims, newgrid = _interpo_match_coords(coords)
315
+ crdmap = _interpo_reorder_2crdmap(coords, org_coords, org_dims)
316
+ idxmap = _interpo_find_position(crdmap)
317
+
318
+ z = val
319
+ if z.is_a?(NArrayMiss)
320
+ missval = ( (a=get_att('_FillValue')) ? a[0] : nil ) ||
321
+ ( (a=get_att('missing_value')) ? a[0] : nil ) ||
322
+ @@interpo_missval
323
+ z = z.to_na(missval)
324
+ else
325
+ missval = nil
326
+ end
327
+
328
+ na = c_interpo_do(newgrid.shape, idxmap, z, missval) # [C-extension]
329
+
330
+ if missval
331
+ mask = na.ne(missval)
332
+ na = NArrayMiss.to_nam_no_dup(na,mask)
333
+ end
334
+
335
+ va = VArray.new(na, data, name)
336
+
337
+ ret = GPhys.new(newgrid, va)
338
+ ret.grid.set_lost_axes(self.lost_axes)
339
+ ret
340
+ end
341
+
342
+ private
343
+
344
+ def _interpo_find_position(crdmap)
345
+ idxmap = Array.new
346
+ crdmap.each do|m|
347
+ od = m[0] # original dim(s): can be a Numeric or an Array of Numerics
348
+ if od.is_a?(Numeric)
349
+ mp = m[1]
350
+ cd = mp[0] # current dimension to be treated in the new grid
351
+ if mp.length==1
352
+ idxmap.push( [m[0], cd] ) # simple copying
353
+ elsif cd.is_a?(Numeric) && mp[1].is_a?(NArray)
354
+ xto = mp[1] # 1-D new coordinate var
355
+ xfrom = mp[2] # 1-D original coordinate var
356
+ ids, f = c_interpo_find_loc_1D(xto,xfrom) # [C-extension]
357
+ idxmap.push( [ m[0], cd, nil, ids, f ] ) # mapping from 1D
358
+ else
359
+ # partially 2D case
360
+ cdims = mp[2]
361
+ xto = mp[3] # 1-D new coordinate var
362
+ xfrom = mp[4] # multi-D original coordinate var
363
+ dimc = nil
364
+ for i in 0...cdims.length
365
+ if cdims[i] == od
366
+ dimc = i
367
+ break
368
+ end
369
+ end
370
+ ids, f = c_interpo_find_loc_1D_MD(xto,xfrom,dimc) # [C-extension]
371
+
372
+ dims_covd = mp[1] #dimensions covered by the coordinate variable(orig)
373
+ idxmap.push( [ od, cd, dims_covd, ids, f ] ) # mapping from 2D
374
+ #^^
375
+ #will be removed : see (***) below
376
+ end
377
+ else
378
+ # Full 2D mapping
379
+ txi = m[1][0][1].to_type(NArray::SFLOAT)
380
+ txg = m[1][0][2].to_type(NArray::SFLOAT)
381
+ tyi = m[1][1][1].to_type(NArray::SFLOAT)
382
+ tyg = m[1][1][2].to_type(NArray::SFLOAT)
383
+ uxg = NArray.sfloat(txg.shape[0]).indgen!
384
+ uyg = NArray.sfloat(txg.shape[1]).indgen!
385
+ DCL.g2sctr(uxg,uyg, txg,tyg)
386
+ if m[1][0][0] == m[1][1][0]
387
+ len = txi.length
388
+ ids1 = NArray.int(len)
389
+ f1 = NArray.float(len)
390
+ ids2 = NArray.int(len)
391
+ f2 = NArray.float(len)
392
+ for j in 0...len
393
+ ## [�J������] (������) ���̃��[�v��C�ɂ����ق��������i1D�Ȃ̂ł܂��������ǁC����2D�̂�����Ȃ�ꏏ�Ɂj�D���̍ہCg2ictr �͒T�������������ĂȂ��̂ŁCinterpo_find_loc_1D ��2D�ł̒T����������� g2ibl2 �𒼐ڌĂԕ��������D
394
+ uxi, uyi = DCL.g2ictr(txi[j], tyi[j])
395
+ ids1[j] = [ [uxi.floor,0].max, uxg.length-2 ].min
396
+ ids2[j] = [ [uyi.floor,0].max, uyg.length-2 ].min
397
+ f1[j] = uxi - ids1[j]
398
+ f2[j] = uyi - ids2[j]
399
+ end
400
+ idxmap.push( [ od[0], m[1][0][0], nil, ids1, f1] ) # mapping from 1D
401
+ idxmap.push( [ od[1], m[1][0][0], nil, ids2, f2] ) # mapping from 1D
402
+ #^^^^
403
+ #will be removed : see (***) below
404
+ else
405
+ lenx = txi.length
406
+ leny = tyi.length
407
+ ids1 = NArray.int(lenx,leny)
408
+ f1 = NArray.float(lenx,leny)
409
+ ids2 = NArray.int(lenx,leny)
410
+ f2 = NArray.float(lenx,leny)
411
+ for k in 0...leny
412
+ for j in 0...lenx
413
+ ## [�J������] (������) ���̃��[�v��C�ɂ����ق�������(2D��������)�D���̍ہCg2ictr �͒T�������������ĂȂ��̂ŁCinterpo_find_loc_1D ��2D�ł̒T����������� g2ibl2 �𒼐ڌĂԕ��������D
414
+ uxi, uyi = DCL.g2ictr(txi[j], tyi[k])
415
+ ids1[j,k] = [ [uxi.floor,0].max, uxg.length-2 ].min
416
+ ids2[j,k] = [ [uyi.floor,0].max, uyg.length-2 ].min
417
+ f1[j,k] = uxi - ids1[j,k]
418
+ f2[j,k] = uyi - ids2[j,k]
419
+ end
420
+ end
421
+ idxmap.push( [ od[0], m[1][0][0], [m[1][1][0]], ids1, f1] ) # mapping from 2D
422
+ idxmap.push( [ od[1], m[1][0][0], [m[1][1][0]], ids2, f2] ) # mapping from 2D
423
+ #^^^^
424
+ #will be removed : see (***) below
425
+ end
426
+ end
427
+ end
428
+
429
+ if idxmap.length != rank
430
+ raise "Something is wrong: a BUG, or possibly overly specified?"
431
+ end
432
+
433
+ idxmap.sort!
434
+
435
+ idxmap.each_with_index do |m,i|
436
+ d = m.shift # the first element is removed (***)
437
+ if d!=i
438
+ raise "Something is wrong: a BUG, or possibly overly specified? #{d}"
439
+ end
440
+ end
441
+
442
+ idxmap
443
+ end
444
+
445
+ # put the coorinate mapping into a data structure good for
446
+ # algorithm implementation
447
+ #
448
+ # RETURN VALUE
449
+ # * crdmap : info regarding mapping from dimensions of self
450
+ # to those of the new grid. Ordered as [ pure 1D interpolations..,
451
+ # multi-D interpolations that can be reduced to 1D interpolations,...
452
+ # pure multi-D (actually 2D) interpolations,...]
453
+ def _interpo_reorder_2crdmap(coords, org_coords, org_dims)
454
+ cids = Array.new # array (whose length is the rank of newgrid) of ids
455
+ cf = Array.new # array (whose length is the rank of newgrid) of f
456
+ crdmap1D = Array.new
457
+ crdmap2D = Array.new
458
+ for ic in 0...org_coords.length
459
+ if coords[ic].nil? # simple copying
460
+ crdmap1D.push( [ org_dims[ic], ic ] )
461
+ else
462
+ for j in 0...coords[ic].length
463
+ xto = coords[ic][j].val
464
+ xfrom = org_coords[ic][j].val
465
+ xto = xto.to_na if !xto.is_a?(NArray)
466
+ # missing in the coordinate, if any, is ignored
467
+ xfrom = xfrom.to_na if !xfrom.is_a?(NArray)
468
+ # missing in the coordinate, if any, is ignored
469
+ if org_dims[ic][j].length == 1
470
+ crdmap1D.push( [ org_dims[ic][j][0], ic, xto,
471
+ xfrom] )
472
+ else
473
+ crdmap2D.push( [ org_dims[ic][j], ic, xto,
474
+ xfrom, coords[ic][j].name] )
475
+ end
476
+ end
477
+ end
478
+ end
479
+
480
+ crdmap1D.sort! # sort by the original dimension ids
481
+ for i in 0...(crdmap1D.length-1)
482
+ d = crdmap1D[i][0]
483
+ if (d == crdmap1D[i+1][0])
484
+ raise("Coordinates to interpolate are overly specified for #{axis(d).name}(#{d})")
485
+ end
486
+ end
487
+
488
+ odim_covrd = crdmap1D.collect{|m| m[0]}
489
+
490
+ crdmapH = Hash.new
491
+ crdmap1D.each do |m|
492
+ crdmapH[m[0]] = m[1..-1]
493
+ end
494
+
495
+ crdmap = crdmapH.to_a.sort!
496
+
497
+ pure2D = Array.new
498
+ crdmap2D.each do |m|
499
+ indep = m[0] - odim_covrd
500
+ if indep.length == 0 # over-determined
501
+ raise("Coordinates to interpolate are overly specified: Unnecesary 2D spec exists")
502
+ elsif indep.length == 1 # partially determined (except for one dim)
503
+ od = indep[0]
504
+ odcov = (m[0] - indep)#[0]
505
+ dims_covd = odcov.collect{|d| crdmapH[d][0]}
506
+ oc_covd_int_needed = Array.new
507
+ ocrd = m[3]
508
+ odcov.each do |d|
509
+ a = crdmapH[d]
510
+ if a[2]
511
+ va = coords[d][0]
512
+ oc_covd_int_needed.push(va)
513
+ end
514
+ end
515
+ if oc_covd_int_needed.length > 0
516
+ cname = m[4]
517
+ cmd = self.assoc_coord_gphys(cname)
518
+ ocrd = cmd.interpolate(*oc_covd_int_needed).val # interpolate the multi-D coord first
519
+ end
520
+ crdmap.push(xxx=[od, [ m[1], dims_covd, m[0], m[2], ocrd ] ])
521
+ odim_covrd.push(od) # covered this time
522
+ else
523
+ if m[0].length >= 3
524
+ raise(ArgumentError,"Pure multi-D interpolation is limited upto 2D #{m[0]}")
525
+ end
526
+ pure2D.push(m)
527
+ end
528
+ end
529
+
530
+ pure2D.sort!
531
+ while (pure2D.length > 0)
532
+ m1 = pure2D.shift
533
+ m2 = pure2D.shift
534
+ if ( m2.nil? || m1[0] != m2[0] )
535
+ raise("Insufficient specification of 2D slicing: Pair needed")
536
+ end
537
+ crdmap.push( [m1[0], [m1[1..-1],m2[1..-1]]] )
538
+ m1[0].each{|x| odim_covrd.push(x)}
539
+ end
540
+
541
+ if odim_covrd.length != rank
542
+ raise("[BUG] Sorry. Something is wrong. Should be a bug.")
543
+ end
544
+
545
+ crdmap
546
+ end
547
+
548
+ def _interpo_match_coords(coords)
549
+
550
+ if coords[0].is_a?(Hash) && coords[0].length==1 # a special case
551
+ dimname, varray = coords[0].to_a[0]
552
+ coords = [ varray ]
553
+ dim = dim_index(dimname) or raise("dimension #{dimname} does not exist")
554
+ nochange_dims = Array.new
555
+ (rank-1).downto(0){|i| nochange_dims.push(i) if i!=dim}
556
+ else
557
+ nochange_dims = nil
558
+ end
559
+
560
+ #< to Array of Arrays if not for easiness of treatment >
561
+
562
+ coords.collect! do |x|
563
+ x.is_a?(Array) ? x : [x]
564
+ end
565
+
566
+ #< check the array contents and modify them if desirable >
567
+
568
+ coords.each do |a|
569
+ a.collect! do |x|
570
+ if x.is_a?(Hash) and
571
+ ( k,v = x.to_a[0]; k.is_a?(String) && v.is_a?(Numeric) )
572
+ na = NArray[v]
573
+ x = VArray.new( na, coord(k), k )
574
+ elsif !(x.is_a?(VArray) and x.rank==1)
575
+ raise(ArgumentError, "Arguments must consist only of 1D VArrays or 1-element Hashs to specify coordinate name (String) and slicing location (Numeric).")
576
+ end
577
+ x
578
+ end
579
+ end
580
+
581
+ #< investigate the correspondence >
582
+ org_dims = coords.collect do |a|
583
+ a.collect do |va|
584
+ ids = grid.coord_dim_indices(va.name)
585
+ if ids.nil?
586
+ raise(ArgumentError, "'#{va.name}' is not in the coordiantes #{coordnames.inspect}")
587
+ end
588
+ if ids.length > 4
589
+ raise(ArgumentError, "coord whose rank is greater than 4 is not supported : #{va.name} mapped to dims: #{ids.inspect}")
590
+ end
591
+ ids
592
+ end
593
+ end
594
+
595
+ if !nochange_dims
596
+ nochange_dims = (0...rank).collect{|i| i}.reverse - org_dims.flatten
597
+ end
598
+
599
+ #< corresponding original coordinates >
600
+ org_coords = Array.new
601
+ coords.each do |a|
602
+ oa = Array.new
603
+ org_coords.push(oa)
604
+ a.each do |va|
605
+ crd = coord(va.name)
606
+ units_to = va.units
607
+ units_orig = crd.units
608
+ if ( units_to =~ units_orig )
609
+ crd = crd.convert_units(units_to)
610
+ else
611
+ $stderr.print("WARNING: incompatible units (#{va.name}): #{units_orig} - #{units_to}\n")
612
+ end
613
+ oa.push( crd )
614
+ end
615
+ end
616
+
617
+ #< prepare the new grid >
618
+
619
+ axes = coords.collect do |a|
620
+ Axis.new().set_pos(a.first)
621
+ end
622
+
623
+ #insdims = Array.new
624
+ gaxes = axes.dup
625
+ irank = org_dims.length
626
+ nochange_dims.each do |nd|
627
+ (org_dims.length-1).downto(0) do |id|
628
+ x = org_dims[id]
629
+ d = x.is_a?(Integer) ? x : (x.flatten - nochange_dims).max
630
+ if d < nd
631
+ gaxes.insert(id+1, axis(nd)) # insert after id
632
+ coords.insert(id+1, nil)
633
+ org_coords.insert(id+1, nil)
634
+ org_dims.insert(id+1, nd)
635
+ break
636
+ elsif id==0
637
+ gaxes.insert(id, axis(nd)) # unshift
638
+ coords.insert(id, nil)
639
+ org_coords.insert(id, nil)
640
+ org_dims.insert(id, nd)
641
+ end
642
+ end
643
+ end
644
+
645
+ newgrid = Grid.new(*gaxes)
646
+
647
+ assoc = Array.new
648
+ coords.each_with_index do |a,i|
649
+ if !a.nil? && a.length > 1
650
+ ax = axes[i]
651
+ axgrd = Grid.new(ax)
652
+ a[1..-1].each do |va|
653
+ if va.length != ax.length
654
+ raise("coord size mismatch: #{va.inspect} - #{ax.pos.inspect}")
655
+ end
656
+ assoc.push( GPhys.new(axgrd, va) )
657
+ end
658
+ end
659
+ end
660
+
661
+ if assoc.length > 0
662
+ newgrid.set_assoc_coords(assoc)
663
+ end
664
+
665
+ [coords, org_coords, org_dims, newgrid]
666
+ end
667
+ end
668
+ end
669
+
670
+ #######################################
671
+ ## < test >
672
+ if $0 == __FILE__
673
+ require "numru/ggraph"
674
+ include NumRu
675
+ include NMath
676
+
677
+ module NumRu
678
+ class VArray
679
+ def to_g1D
680
+ ax = Axis.new().set_pos(self)
681
+ grid = Grid.new(ax)
682
+ GPhys.new(grid,self)
683
+ end
684
+ end
685
+ end
686
+
687
+ #< prepare a GPhys object with associated coordinates >
688
+
689
+ nx = 10
690
+ ny = 8
691
+ # nx = 20
692
+ # ny = 16
693
+ nz = 2
694
+ x = (NArray.sfloat(nx).indgen! + 0.5) * (2*PI/nx)
695
+ y = NArray.sfloat(ny).indgen! * (2*PI/(ny-1))
696
+
697
+ z = NArray.sfloat(nz).indgen!
698
+ vx = VArray.new( x, {"units"=>"m"}, "x")
699
+ vy = VArray.new( y, {"units"=>"m"}, "y")
700
+ vz = VArray.new( z, {"units"=>"m"}, "z")
701
+ xax = Axis.new().set_pos(vx)
702
+ yax = Axis.new().set_pos(vy)
703
+ zax = Axis.new().set_pos(vz)
704
+ xygrid = Grid.new(xax, yax)
705
+ xyzgrid = Grid.new(xax, yax, zax)
706
+
707
+ sqrt2 = sqrt(2.0)
708
+
709
+ p = NArray.sfloat(nx,ny)
710
+ q = NArray.sfloat(nx,ny)
711
+ for j in 0...ny
712
+ p[true,j] = NArray.sfloat(nx).indgen!(2*j,1)*sqrt2
713
+ q[true,j] = NArray.sfloat(nx).indgen!(2*j,-1)*sqrt2
714
+ end
715
+ vp = VArray.new( p, {"units"=>"mm"}, "p")
716
+ vq = VArray.new( q, {"units"=>"mm"}, "q")
717
+ gp = GPhys.new(xygrid, vp)
718
+ gq = GPhys.new(xygrid, vq)
719
+
720
+ r = NArray.sfloat(nz).indgen! * 2
721
+ vr = VArray.new( r ).rename("r")
722
+ gr = GPhys.new( Grid.new(zax), vr )
723
+
724
+ d = sin(x.newdim(1,1)) * cos(y.newdim(0,1)) + z.newdim(0,0)
725
+ vd = VArray.new( d ).rename("d")
726
+ gd = GPhys.new(xyzgrid, vd)
727
+
728
+ gx = vx.to_g1D
729
+ ga = gd + gx
730
+ ga.name = "a"
731
+
732
+ gd.set_assoc_coords([gp,gq,gr,ga])
733
+
734
+ print "GPhys with associated coordinates:\n"
735
+ p gd
736
+
737
+
738
+ DCL.swpset('iwidth',700)
739
+ DCL.swpset('iheight',700)
740
+ #DCL.sgscmn(4) # set colomap
741
+ DCL.gropn(1)
742
+ DCL.glpset("lmiss",true)
743
+ DCL.sldiv("y",2,2)
744
+ GGraph::set_fig "viewport"=>[0.15,0.85,0.15,0.85]
745
+ GGraph::tone gd
746
+ GGraph::color_bar
747
+ GGraph::tone gd[true,ny/2,true]
748
+ GGraph::color_bar
749
+
750
+ #< prepare coordinates to interpolate >
751
+
752
+ xi = NArray[1.0, 2.0, 3.0, 4.0, 5.0]
753
+ # yi = NArray[1.0, 4.0, 5.0]
754
+ yi = NArray[-0.1, 2.5, 4.0, 5.5, 6.8] # test of extrapolation
755
+ vxi = VArray.new( xi, {"units"=>"m"}, "x") # "0.5m" to test unit conversion
756
+ vyi = VArray.new( yi, {"units"=>"m"}, "y") # "0.5m" to test unit conversion
757
+
758
+ # pi = NArray[10.0, 13.0, 15.0, 17.0, 20.0]
759
+ # qi = NArray[0.0, 3.0, 5.0, 7.0, 10.0]
760
+ # pi = NArray.float(23).indgen!*0.5+8
761
+ # qi = NArray.float(23).indgen!*0.5-3
762
+ pi = NArray.float(6).indgen!*2+10
763
+ qi = NArray.float(6).indgen!*2
764
+ vpi = VArray.new( pi, {"units"=>"mm"}, "p")
765
+ vqi = VArray.new( qi, {"units"=>"mm"}, "q")
766
+
767
+ ai = NArray[2.0, 4.0]
768
+ vai = VArray.new( ai ).rename("a")
769
+
770
+ #< test of interpolate >
771
+
772
+ gxi = vxi.to_g1D
773
+ gyi = vyi.to_g1D
774
+ gp = GPhys.new(xygrid,vp)
775
+ gq = GPhys.new(xygrid,vq)
776
+
777
+ gi = gd.interpolate(vxi,vyi,{"z"=>0.5})
778
+ GGraph::tone gi,true,"color_bar"=>true
779
+
780
+ ###gd.interpolate(vxi,vyi,vr,vz) # nust fail by over-determination
781
+
782
+ gi = gd.interpolate([vxi,vyi])
783
+ #p gi.max, gi.min
784
+ GGraph::tone gd,true,"min"=>-1.2,"max"=>1.2,"int"=>0.1
785
+ GGraph::scatter gxi, gyi, false,"type"=>4,"size"=>0.027,"index"=>3
786
+ GGraph::color_scatter gxi, gyi, gi, false,"min"=>-1.2,"max"=>1.2,"int"=>0.1,"type"=>10,"size"=>0.029
787
+ GGraph::color_bar
788
+
789
+ gi = gd.interpolate(vyi,vxi)
790
+ GGraph::tone gi,true,"color_bar"=>true
791
+
792
+ #GGraph::tone gp,true,"color_bar"=>true
793
+
794
+ GGraph::tone gq,true
795
+ GGraph::contour gq,false
796
+ GGraph::color_bar
797
+
798
+ gi = gd.interpolate(vxi,vqi)
799
+ GGraph::tone gi,true,"color_bar"=>true
800
+ ##gi = gd.interpolate(vx,vqi)
801
+
802
+ gi = gd.interpolate("y"=>vqi)
803
+ #GGraph::tone gi,true,"color_bar"=>true
804
+
805
+ #p "###",gd.coordnames
806
+ #gi = gd.interpolate(vxi,vyi,vai)
807
+ gi = gd.interpolate("y"=>vai)
808
+ GGraph::tone gi[2,false],true,"color_bar"=>true
809
+
810
+ GGraph::tone gp,true
811
+ GGraph::contour gp,false
812
+ GGraph::color_bar
813
+ gi = gd.interpolate("x"=>vpi)
814
+ GGraph::tone gd
815
+ GGraph::tone gi,true,"color_bar"=>true,"exchange"=>true,"min"=>-1,"max"=>1
816
+
817
+ gi = gd.interpolate([vpi,vqi])
818
+ GGraph::tone gi,true,"color_bar"=>true
819
+
820
+ GGraph::tone gd
821
+ GGraph::tone gd.cut("p"=>vpi.min.to_f..vpi.max.to_f,"q"=>vqi.min.to_f..vqi.max.to_f),true
822
+
823
+ gi = gd.interpolate(vpi,vqi)
824
+ GGraph::tone gi,true,"color_bar"=>true
825
+
826
+ gi = gd.interpolate(vqi,vpi)
827
+ GGraph::tone gi,true,"color_bar"=>true
828
+
829
+ gi2 = gd.regrid(gi[false,0])
830
+ p "regriding test (should be true):", gi.val == gi2.val
831
+
832
+ gi = gd.interpolate(vqi,vpi,{"z"=>0.5})
833
+ GGraph::tone gi,true,"color_bar"=>true
834
+
835
+ ###gd.interpolate(vpi) # must fail by insufficient specification
836
+ =begin
837
+ =end
838
+
839
+
840
+ mask=d.lt(0.7)
841
+ missv = -999.0
842
+ d[mask.not] = missv
843
+ p d[false,0]
844
+ dm = NArrayMiss.to_nam(d, mask )
845
+ vdm = VArray.new( dm, {"missing_value"=>NArray[missv]}, "d")
846
+ gdm = GPhys.new(xyzgrid, vdm)
847
+ gi = gdm.interpolate(vpi,vqi)
848
+ # gi = gdm.interpolate(vxi,vyi)
849
+ GGraph::tone gi,true,"color_bar"=>true
850
+
851
+
852
+ #< finish >
853
+ DCL.grcls
854
+ end