gentooboontoo-gphys 0.6.1.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (401) hide show
  1. checksums.yaml +7 -0
  2. data/ChangeLog +1255 -0
  3. data/README +32 -0
  4. data/bin/gdir_client +9 -0
  5. data/bin/gdir_server +123 -0
  6. data/bin/gpaop +134 -0
  7. data/bin/gpcat +140 -0
  8. data/bin/gpcut +94 -0
  9. data/bin/gpedit +196 -0
  10. data/bin/gplist +67 -0
  11. data/bin/gpmath +114 -0
  12. data/bin/gpmaxmin +127 -0
  13. data/bin/gpprint +57 -0
  14. data/bin/gpvect +657 -0
  15. data/bin/gpview +603 -0
  16. data/bin/grads2nc_with_gphys +56 -0
  17. data/doc/attribute.html +19 -0
  18. data/doc/attributenetcdf.html +15 -0
  19. data/doc/axis.html +368 -0
  20. data/doc/coordmapping.html +111 -0
  21. data/doc/coordtransform.html +36 -0
  22. data/doc/derivative/gphys-derivative.html +80 -0
  23. data/doc/derivative/index.html +21 -0
  24. data/doc/derivative/index.rd +14 -0
  25. data/doc/derivative/math-doc/document/document.css +30 -0
  26. data/doc/derivative/math-doc/document/document.html +57 -0
  27. data/doc/derivative/math-doc/document/images.aux +1 -0
  28. data/doc/derivative/math-doc/document/images.log +385 -0
  29. data/doc/derivative/math-doc/document/images.pl +186 -0
  30. data/doc/derivative/math-doc/document/images.tex +364 -0
  31. data/doc/derivative/math-doc/document/img1.png +0 -0
  32. data/doc/derivative/math-doc/document/img10.png +0 -0
  33. data/doc/derivative/math-doc/document/img11.png +0 -0
  34. data/doc/derivative/math-doc/document/img12.png +0 -0
  35. data/doc/derivative/math-doc/document/img13.png +0 -0
  36. data/doc/derivative/math-doc/document/img14.png +0 -0
  37. data/doc/derivative/math-doc/document/img15.png +0 -0
  38. data/doc/derivative/math-doc/document/img16.png +0 -0
  39. data/doc/derivative/math-doc/document/img17.png +0 -0
  40. data/doc/derivative/math-doc/document/img18.png +0 -0
  41. data/doc/derivative/math-doc/document/img19.png +0 -0
  42. data/doc/derivative/math-doc/document/img2.png +0 -0
  43. data/doc/derivative/math-doc/document/img20.png +0 -0
  44. data/doc/derivative/math-doc/document/img21.png +0 -0
  45. data/doc/derivative/math-doc/document/img22.png +0 -0
  46. data/doc/derivative/math-doc/document/img23.png +0 -0
  47. data/doc/derivative/math-doc/document/img24.png +0 -0
  48. data/doc/derivative/math-doc/document/img25.png +0 -0
  49. data/doc/derivative/math-doc/document/img26.png +0 -0
  50. data/doc/derivative/math-doc/document/img27.png +0 -0
  51. data/doc/derivative/math-doc/document/img28.png +0 -0
  52. data/doc/derivative/math-doc/document/img29.png +0 -0
  53. data/doc/derivative/math-doc/document/img3.png +0 -0
  54. data/doc/derivative/math-doc/document/img30.png +0 -0
  55. data/doc/derivative/math-doc/document/img4.png +0 -0
  56. data/doc/derivative/math-doc/document/img5.png +0 -0
  57. data/doc/derivative/math-doc/document/img6.png +0 -0
  58. data/doc/derivative/math-doc/document/img7.png +0 -0
  59. data/doc/derivative/math-doc/document/img8.png +0 -0
  60. data/doc/derivative/math-doc/document/img9.png +0 -0
  61. data/doc/derivative/math-doc/document/index.html +57 -0
  62. data/doc/derivative/math-doc/document/labels.pl +13 -0
  63. data/doc/derivative/math-doc/document/next.png +0 -0
  64. data/doc/derivative/math-doc/document/next_g.png +0 -0
  65. data/doc/derivative/math-doc/document/node1.html +238 -0
  66. data/doc/derivative/math-doc/document/node2.html +75 -0
  67. data/doc/derivative/math-doc/document/prev.png +0 -0
  68. data/doc/derivative/math-doc/document/prev_g.png +0 -0
  69. data/doc/derivative/math-doc/document/up.png +0 -0
  70. data/doc/derivative/math-doc/document/up_g.png +0 -0
  71. data/doc/derivative/math-doc/document.pdf +0 -0
  72. data/doc/derivative/math-doc/document.tex +158 -0
  73. data/doc/derivative/numru-derivative.html +129 -0
  74. data/doc/ep_flux/ep_flux.html +469 -0
  75. data/doc/ep_flux/ggraph_on_merdional_section.html +71 -0
  76. data/doc/ep_flux/index.html +31 -0
  77. data/doc/ep_flux/index.rd +24 -0
  78. data/doc/ep_flux/math-doc/document/WARNINGS +1 -0
  79. data/doc/ep_flux/math-doc/document/contents.png +0 -0
  80. data/doc/ep_flux/math-doc/document/crossref.png +0 -0
  81. data/doc/ep_flux/math-doc/document/document.css +30 -0
  82. data/doc/ep_flux/math-doc/document/document.html +101 -0
  83. data/doc/ep_flux/math-doc/document/images.aux +1 -0
  84. data/doc/ep_flux/math-doc/document/images.log +1375 -0
  85. data/doc/ep_flux/math-doc/document/images.pl +1328 -0
  86. data/doc/ep_flux/math-doc/document/images.tex +1471 -0
  87. data/doc/ep_flux/math-doc/document/img1.png +0 -0
  88. data/doc/ep_flux/math-doc/document/img10.png +0 -0
  89. data/doc/ep_flux/math-doc/document/img100.png +0 -0
  90. data/doc/ep_flux/math-doc/document/img101.png +0 -0
  91. data/doc/ep_flux/math-doc/document/img102.png +0 -0
  92. data/doc/ep_flux/math-doc/document/img103.png +0 -0
  93. data/doc/ep_flux/math-doc/document/img104.png +0 -0
  94. data/doc/ep_flux/math-doc/document/img105.png +0 -0
  95. data/doc/ep_flux/math-doc/document/img106.png +0 -0
  96. data/doc/ep_flux/math-doc/document/img107.png +0 -0
  97. data/doc/ep_flux/math-doc/document/img108.png +0 -0
  98. data/doc/ep_flux/math-doc/document/img109.png +0 -0
  99. data/doc/ep_flux/math-doc/document/img11.png +0 -0
  100. data/doc/ep_flux/math-doc/document/img110.png +0 -0
  101. data/doc/ep_flux/math-doc/document/img111.png +0 -0
  102. data/doc/ep_flux/math-doc/document/img112.png +0 -0
  103. data/doc/ep_flux/math-doc/document/img113.png +0 -0
  104. data/doc/ep_flux/math-doc/document/img114.png +0 -0
  105. data/doc/ep_flux/math-doc/document/img115.png +0 -0
  106. data/doc/ep_flux/math-doc/document/img116.png +0 -0
  107. data/doc/ep_flux/math-doc/document/img117.png +0 -0
  108. data/doc/ep_flux/math-doc/document/img118.png +0 -0
  109. data/doc/ep_flux/math-doc/document/img119.png +0 -0
  110. data/doc/ep_flux/math-doc/document/img12.png +0 -0
  111. data/doc/ep_flux/math-doc/document/img120.png +0 -0
  112. data/doc/ep_flux/math-doc/document/img121.png +0 -0
  113. data/doc/ep_flux/math-doc/document/img122.png +0 -0
  114. data/doc/ep_flux/math-doc/document/img123.png +0 -0
  115. data/doc/ep_flux/math-doc/document/img124.png +0 -0
  116. data/doc/ep_flux/math-doc/document/img125.png +0 -0
  117. data/doc/ep_flux/math-doc/document/img126.png +0 -0
  118. data/doc/ep_flux/math-doc/document/img127.png +0 -0
  119. data/doc/ep_flux/math-doc/document/img128.png +0 -0
  120. data/doc/ep_flux/math-doc/document/img129.png +0 -0
  121. data/doc/ep_flux/math-doc/document/img13.png +0 -0
  122. data/doc/ep_flux/math-doc/document/img130.png +0 -0
  123. data/doc/ep_flux/math-doc/document/img131.png +0 -0
  124. data/doc/ep_flux/math-doc/document/img132.png +0 -0
  125. data/doc/ep_flux/math-doc/document/img133.png +0 -0
  126. data/doc/ep_flux/math-doc/document/img134.png +0 -0
  127. data/doc/ep_flux/math-doc/document/img135.png +0 -0
  128. data/doc/ep_flux/math-doc/document/img136.png +0 -0
  129. data/doc/ep_flux/math-doc/document/img137.png +0 -0
  130. data/doc/ep_flux/math-doc/document/img138.png +0 -0
  131. data/doc/ep_flux/math-doc/document/img139.png +0 -0
  132. data/doc/ep_flux/math-doc/document/img14.png +0 -0
  133. data/doc/ep_flux/math-doc/document/img140.png +0 -0
  134. data/doc/ep_flux/math-doc/document/img141.png +0 -0
  135. data/doc/ep_flux/math-doc/document/img142.png +0 -0
  136. data/doc/ep_flux/math-doc/document/img143.png +0 -0
  137. data/doc/ep_flux/math-doc/document/img144.png +0 -0
  138. data/doc/ep_flux/math-doc/document/img145.png +0 -0
  139. data/doc/ep_flux/math-doc/document/img146.png +0 -0
  140. data/doc/ep_flux/math-doc/document/img147.png +0 -0
  141. data/doc/ep_flux/math-doc/document/img148.png +0 -0
  142. data/doc/ep_flux/math-doc/document/img149.png +0 -0
  143. data/doc/ep_flux/math-doc/document/img15.png +0 -0
  144. data/doc/ep_flux/math-doc/document/img150.png +0 -0
  145. data/doc/ep_flux/math-doc/document/img151.png +0 -0
  146. data/doc/ep_flux/math-doc/document/img152.png +0 -0
  147. data/doc/ep_flux/math-doc/document/img153.png +0 -0
  148. data/doc/ep_flux/math-doc/document/img154.png +0 -0
  149. data/doc/ep_flux/math-doc/document/img155.png +0 -0
  150. data/doc/ep_flux/math-doc/document/img156.png +0 -0
  151. data/doc/ep_flux/math-doc/document/img157.png +0 -0
  152. data/doc/ep_flux/math-doc/document/img158.png +0 -0
  153. data/doc/ep_flux/math-doc/document/img159.png +0 -0
  154. data/doc/ep_flux/math-doc/document/img16.png +0 -0
  155. data/doc/ep_flux/math-doc/document/img160.png +0 -0
  156. data/doc/ep_flux/math-doc/document/img161.png +0 -0
  157. data/doc/ep_flux/math-doc/document/img162.png +0 -0
  158. data/doc/ep_flux/math-doc/document/img163.png +0 -0
  159. data/doc/ep_flux/math-doc/document/img164.png +0 -0
  160. data/doc/ep_flux/math-doc/document/img165.png +0 -0
  161. data/doc/ep_flux/math-doc/document/img166.png +0 -0
  162. data/doc/ep_flux/math-doc/document/img167.png +0 -0
  163. data/doc/ep_flux/math-doc/document/img168.png +0 -0
  164. data/doc/ep_flux/math-doc/document/img169.png +0 -0
  165. data/doc/ep_flux/math-doc/document/img17.png +0 -0
  166. data/doc/ep_flux/math-doc/document/img170.png +0 -0
  167. data/doc/ep_flux/math-doc/document/img171.png +0 -0
  168. data/doc/ep_flux/math-doc/document/img172.png +0 -0
  169. data/doc/ep_flux/math-doc/document/img173.png +0 -0
  170. data/doc/ep_flux/math-doc/document/img174.png +0 -0
  171. data/doc/ep_flux/math-doc/document/img175.png +0 -0
  172. data/doc/ep_flux/math-doc/document/img176.png +0 -0
  173. data/doc/ep_flux/math-doc/document/img177.png +0 -0
  174. data/doc/ep_flux/math-doc/document/img178.png +0 -0
  175. data/doc/ep_flux/math-doc/document/img179.png +0 -0
  176. data/doc/ep_flux/math-doc/document/img18.png +0 -0
  177. data/doc/ep_flux/math-doc/document/img180.png +0 -0
  178. data/doc/ep_flux/math-doc/document/img181.png +0 -0
  179. data/doc/ep_flux/math-doc/document/img182.png +0 -0
  180. data/doc/ep_flux/math-doc/document/img183.png +0 -0
  181. data/doc/ep_flux/math-doc/document/img184.png +0 -0
  182. data/doc/ep_flux/math-doc/document/img185.png +0 -0
  183. data/doc/ep_flux/math-doc/document/img186.png +0 -0
  184. data/doc/ep_flux/math-doc/document/img187.png +0 -0
  185. data/doc/ep_flux/math-doc/document/img188.png +0 -0
  186. data/doc/ep_flux/math-doc/document/img189.png +0 -0
  187. data/doc/ep_flux/math-doc/document/img19.png +0 -0
  188. data/doc/ep_flux/math-doc/document/img190.png +0 -0
  189. data/doc/ep_flux/math-doc/document/img191.png +0 -0
  190. data/doc/ep_flux/math-doc/document/img192.png +0 -0
  191. data/doc/ep_flux/math-doc/document/img193.png +0 -0
  192. data/doc/ep_flux/math-doc/document/img194.png +0 -0
  193. data/doc/ep_flux/math-doc/document/img195.png +0 -0
  194. data/doc/ep_flux/math-doc/document/img196.png +0 -0
  195. data/doc/ep_flux/math-doc/document/img197.png +0 -0
  196. data/doc/ep_flux/math-doc/document/img198.png +0 -0
  197. data/doc/ep_flux/math-doc/document/img199.png +0 -0
  198. data/doc/ep_flux/math-doc/document/img2.png +0 -0
  199. data/doc/ep_flux/math-doc/document/img20.png +0 -0
  200. data/doc/ep_flux/math-doc/document/img200.png +0 -0
  201. data/doc/ep_flux/math-doc/document/img21.png +0 -0
  202. data/doc/ep_flux/math-doc/document/img22.png +0 -0
  203. data/doc/ep_flux/math-doc/document/img23.png +0 -0
  204. data/doc/ep_flux/math-doc/document/img24.png +0 -0
  205. data/doc/ep_flux/math-doc/document/img25.png +0 -0
  206. data/doc/ep_flux/math-doc/document/img26.png +0 -0
  207. data/doc/ep_flux/math-doc/document/img27.png +0 -0
  208. data/doc/ep_flux/math-doc/document/img28.png +0 -0
  209. data/doc/ep_flux/math-doc/document/img29.png +0 -0
  210. data/doc/ep_flux/math-doc/document/img3.png +0 -0
  211. data/doc/ep_flux/math-doc/document/img30.png +0 -0
  212. data/doc/ep_flux/math-doc/document/img31.png +0 -0
  213. data/doc/ep_flux/math-doc/document/img32.png +0 -0
  214. data/doc/ep_flux/math-doc/document/img33.png +0 -0
  215. data/doc/ep_flux/math-doc/document/img34.png +0 -0
  216. data/doc/ep_flux/math-doc/document/img35.png +0 -0
  217. data/doc/ep_flux/math-doc/document/img36.png +0 -0
  218. data/doc/ep_flux/math-doc/document/img37.png +0 -0
  219. data/doc/ep_flux/math-doc/document/img38.png +0 -0
  220. data/doc/ep_flux/math-doc/document/img39.png +0 -0
  221. data/doc/ep_flux/math-doc/document/img4.png +0 -0
  222. data/doc/ep_flux/math-doc/document/img40.png +0 -0
  223. data/doc/ep_flux/math-doc/document/img41.png +0 -0
  224. data/doc/ep_flux/math-doc/document/img42.png +0 -0
  225. data/doc/ep_flux/math-doc/document/img43.png +0 -0
  226. data/doc/ep_flux/math-doc/document/img44.png +0 -0
  227. data/doc/ep_flux/math-doc/document/img45.png +0 -0
  228. data/doc/ep_flux/math-doc/document/img46.png +0 -0
  229. data/doc/ep_flux/math-doc/document/img47.png +0 -0
  230. data/doc/ep_flux/math-doc/document/img48.png +0 -0
  231. data/doc/ep_flux/math-doc/document/img49.png +0 -0
  232. data/doc/ep_flux/math-doc/document/img5.png +0 -0
  233. data/doc/ep_flux/math-doc/document/img50.png +0 -0
  234. data/doc/ep_flux/math-doc/document/img51.png +0 -0
  235. data/doc/ep_flux/math-doc/document/img52.png +0 -0
  236. data/doc/ep_flux/math-doc/document/img53.png +0 -0
  237. data/doc/ep_flux/math-doc/document/img54.png +0 -0
  238. data/doc/ep_flux/math-doc/document/img55.png +0 -0
  239. data/doc/ep_flux/math-doc/document/img56.png +0 -0
  240. data/doc/ep_flux/math-doc/document/img57.png +0 -0
  241. data/doc/ep_flux/math-doc/document/img58.png +0 -0
  242. data/doc/ep_flux/math-doc/document/img59.png +0 -0
  243. data/doc/ep_flux/math-doc/document/img6.png +0 -0
  244. data/doc/ep_flux/math-doc/document/img60.png +0 -0
  245. data/doc/ep_flux/math-doc/document/img61.png +0 -0
  246. data/doc/ep_flux/math-doc/document/img62.png +0 -0
  247. data/doc/ep_flux/math-doc/document/img63.png +0 -0
  248. data/doc/ep_flux/math-doc/document/img64.png +0 -0
  249. data/doc/ep_flux/math-doc/document/img65.png +0 -0
  250. data/doc/ep_flux/math-doc/document/img66.png +0 -0
  251. data/doc/ep_flux/math-doc/document/img67.png +0 -0
  252. data/doc/ep_flux/math-doc/document/img68.png +0 -0
  253. data/doc/ep_flux/math-doc/document/img69.png +0 -0
  254. data/doc/ep_flux/math-doc/document/img7.png +0 -0
  255. data/doc/ep_flux/math-doc/document/img70.png +0 -0
  256. data/doc/ep_flux/math-doc/document/img71.png +0 -0
  257. data/doc/ep_flux/math-doc/document/img72.png +0 -0
  258. data/doc/ep_flux/math-doc/document/img73.png +0 -0
  259. data/doc/ep_flux/math-doc/document/img74.png +0 -0
  260. data/doc/ep_flux/math-doc/document/img75.png +0 -0
  261. data/doc/ep_flux/math-doc/document/img76.png +0 -0
  262. data/doc/ep_flux/math-doc/document/img77.png +0 -0
  263. data/doc/ep_flux/math-doc/document/img78.png +0 -0
  264. data/doc/ep_flux/math-doc/document/img79.png +0 -0
  265. data/doc/ep_flux/math-doc/document/img8.png +0 -0
  266. data/doc/ep_flux/math-doc/document/img80.png +0 -0
  267. data/doc/ep_flux/math-doc/document/img81.png +0 -0
  268. data/doc/ep_flux/math-doc/document/img82.png +0 -0
  269. data/doc/ep_flux/math-doc/document/img83.png +0 -0
  270. data/doc/ep_flux/math-doc/document/img84.png +0 -0
  271. data/doc/ep_flux/math-doc/document/img85.png +0 -0
  272. data/doc/ep_flux/math-doc/document/img86.png +0 -0
  273. data/doc/ep_flux/math-doc/document/img87.png +0 -0
  274. data/doc/ep_flux/math-doc/document/img88.png +0 -0
  275. data/doc/ep_flux/math-doc/document/img89.png +0 -0
  276. data/doc/ep_flux/math-doc/document/img9.png +0 -0
  277. data/doc/ep_flux/math-doc/document/img90.png +0 -0
  278. data/doc/ep_flux/math-doc/document/img91.png +0 -0
  279. data/doc/ep_flux/math-doc/document/img92.png +0 -0
  280. data/doc/ep_flux/math-doc/document/img93.png +0 -0
  281. data/doc/ep_flux/math-doc/document/img94.png +0 -0
  282. data/doc/ep_flux/math-doc/document/img95.png +0 -0
  283. data/doc/ep_flux/math-doc/document/img96.png +0 -0
  284. data/doc/ep_flux/math-doc/document/img97.png +0 -0
  285. data/doc/ep_flux/math-doc/document/img98.png +0 -0
  286. data/doc/ep_flux/math-doc/document/img99.png +0 -0
  287. data/doc/ep_flux/math-doc/document/index.html +101 -0
  288. data/doc/ep_flux/math-doc/document/internals.pl +258 -0
  289. data/doc/ep_flux/math-doc/document/labels.pl +265 -0
  290. data/doc/ep_flux/math-doc/document/next.png +0 -0
  291. data/doc/ep_flux/math-doc/document/next_g.png +0 -0
  292. data/doc/ep_flux/math-doc/document/node1.html +104 -0
  293. data/doc/ep_flux/math-doc/document/node10.html +164 -0
  294. data/doc/ep_flux/math-doc/document/node11.html +86 -0
  295. data/doc/ep_flux/math-doc/document/node12.html +166 -0
  296. data/doc/ep_flux/math-doc/document/node13.html +897 -0
  297. data/doc/ep_flux/math-doc/document/node14.html +1065 -0
  298. data/doc/ep_flux/math-doc/document/node15.html +72 -0
  299. data/doc/ep_flux/math-doc/document/node16.html +81 -0
  300. data/doc/ep_flux/math-doc/document/node2.html +82 -0
  301. data/doc/ep_flux/math-doc/document/node3.html +91 -0
  302. data/doc/ep_flux/math-doc/document/node4.html +149 -0
  303. data/doc/ep_flux/math-doc/document/node5.html +330 -0
  304. data/doc/ep_flux/math-doc/document/node6.html +99 -0
  305. data/doc/ep_flux/math-doc/document/node7.html +98 -0
  306. data/doc/ep_flux/math-doc/document/node8.html +83 -0
  307. data/doc/ep_flux/math-doc/document/node9.html +140 -0
  308. data/doc/ep_flux/math-doc/document/prev.png +0 -0
  309. data/doc/ep_flux/math-doc/document/prev_g.png +0 -0
  310. data/doc/ep_flux/math-doc/document/up.png +0 -0
  311. data/doc/ep_flux/math-doc/document/up_g.png +0 -0
  312. data/doc/ep_flux/math-doc/document.pdf +0 -0
  313. data/doc/ep_flux/math-doc/document.tex +2018 -0
  314. data/doc/gdir.html +412 -0
  315. data/doc/gdir_client.html +16 -0
  316. data/doc/gdir_connect_ftp-like.html +61 -0
  317. data/doc/gdir_server.html +33 -0
  318. data/doc/ggraph.html +1332 -0
  319. data/doc/gpcat.html +27 -0
  320. data/doc/gpcut.html +27 -0
  321. data/doc/gphys.html +501 -0
  322. data/doc/gphys_fft.html +183 -0
  323. data/doc/gphys_grads_io.html +69 -0
  324. data/doc/gphys_grib_io.html +82 -0
  325. data/doc/gphys_io.html +96 -0
  326. data/doc/gphys_io_common.html +18 -0
  327. data/doc/gphys_netcdf_io.html +283 -0
  328. data/doc/gplist.html +23 -0
  329. data/doc/gpmath.html +34 -0
  330. data/doc/gpmaxmin.html +30 -0
  331. data/doc/gpprint.html +32 -0
  332. data/doc/gpview.html +187 -0
  333. data/doc/grads2nc_with_gphys.html +23 -0
  334. data/doc/grads_gridded.html +307 -0
  335. data/doc/grib.html +101 -0
  336. data/doc/grid.html +240 -0
  337. data/doc/index.html +125 -0
  338. data/doc/index.rd +121 -0
  339. data/doc/netcdf_convention.html +136 -0
  340. data/doc/unumeric.html +127 -0
  341. data/doc/update +64 -0
  342. data/doc/varray.html +293 -0
  343. data/doc/varraycomposite.html +67 -0
  344. data/lib/numru/dclext_datetime_ax.rb +220 -0
  345. data/lib/numru/derivative.rb +298 -0
  346. data/lib/numru/gdir.rb +1038 -0
  347. data/lib/numru/gdir_connect_ftp-like.rb +149 -0
  348. data/lib/numru/ggraph.rb +4604 -0
  349. data/lib/numru/ggraph_on_merdional_section.rb +178 -0
  350. data/lib/numru/gphys/attribute.rb +130 -0
  351. data/lib/numru/gphys/attributenetcdf.rb +80 -0
  352. data/lib/numru/gphys/axis.rb +958 -0
  353. data/lib/numru/gphys/coordmapping.rb +286 -0
  354. data/lib/numru/gphys/coordtransform.rb +209 -0
  355. data/lib/numru/gphys/derivative.rb +297 -0
  356. data/lib/numru/gphys/ep_flux.rb +868 -0
  357. data/lib/numru/gphys/gpcommon.rb +52 -0
  358. data/lib/numru/gphys/gphys.rb +1121 -0
  359. data/lib/numru/gphys/gphys_fft.rb +538 -0
  360. data/lib/numru/gphys/gphys_grads_io.rb +212 -0
  361. data/lib/numru/gphys/gphys_grib_io.rb +214 -0
  362. data/lib/numru/gphys/gphys_io.rb +363 -0
  363. data/lib/numru/gphys/gphys_io_common.rb +126 -0
  364. data/lib/numru/gphys/gphys_netcdf_io.rb +767 -0
  365. data/lib/numru/gphys/gphys_nusdas_io.rb +78 -0
  366. data/lib/numru/gphys/grads_gridded.rb +1539 -0
  367. data/lib/numru/gphys/grib.rb +2005 -0
  368. data/lib/numru/gphys/grib_params.rb +1270 -0
  369. data/lib/numru/gphys/grid.rb +602 -0
  370. data/lib/numru/gphys/netcdf_convention.rb +366 -0
  371. data/lib/numru/gphys/subsetmapping.rb +332 -0
  372. data/lib/numru/gphys/unumeric.rb +452 -0
  373. data/lib/numru/gphys/varray.rb +1079 -0
  374. data/lib/numru/gphys/varraycomposite.rb +415 -0
  375. data/lib/numru/gphys/varraygrads.rb +225 -0
  376. data/lib/numru/gphys/varraygrib.rb +177 -0
  377. data/lib/numru/gphys/varraynetcdf.rb +348 -0
  378. data/lib/numru/gphys/varraynusdas.rb +59 -0
  379. data/lib/numru/gphys.rb +7 -0
  380. data/lib/numru/htdir.rb +170 -0
  381. data/lib/numru/vizshot.rb +697 -0
  382. data/sample/cira86_to_nc.rb +122 -0
  383. data/sample/druby_cli1.rb +21 -0
  384. data/sample/druby_cli2.rb +34 -0
  385. data/sample/druby_serv1.rb +30 -0
  386. data/sample/druby_serv2.rb +64 -0
  387. data/sample/ep_flux/demo_NCEP_1.rb +48 -0
  388. data/sample/ep_flux/demo_NCEP_2.rb +57 -0
  389. data/sample/ep_flux/demo_NCEP_3.rb +81 -0
  390. data/sample/ggraph_latlon_labelling_dr002690.rb +159 -0
  391. data/sample/ggraph_mapfit-axes_dr002687.rb +131 -0
  392. data/sample/map_projection.rb +121 -0
  393. data/test/test_ep_flux.rb +533 -0
  394. data/testdata/T.jan.ctl +12 -0
  395. data/testdata/T.jan.dat +0 -0
  396. data/testdata/T.jan.grib +0 -0
  397. data/testdata/T.jan.nc +0 -0
  398. data/testdata/T.jan.packed.withmiss.nc +0 -0
  399. data/testdata/UV.jan.nc +0 -0
  400. data/testdata/cira86.dat +1332 -0
  401. metadata +527 -0
@@ -0,0 +1,958 @@
1
+ require "numru/gphys/varray"
2
+ require "numru/gphys/varraynetcdf"
3
+ require "numru/gphys/varraycomposite"
4
+ require "date"
5
+
6
+ =begin
7
+ =class NumRu::Axis
8
+
9
+ A class of to handle a descretized physical coordinate.
10
+
11
+ ==Overview
12
+
13
+ An NumRu::Axis object is meant to represent a dimension in a NumRu::Grid
14
+ object, which is used in NumRu::Grid (Hereafter, NumRu:: is omitted).
15
+ An Axis has 1-dimensional data on grid-point posisions as a VArray.
16
+ In addition, it can have supplementary data (as VArray objects).
17
+
18
+ Three types of axes are supported in this class:
19
+
20
+ 1. Simple (mostly point-sampled) axes
21
+ 2. Cell-type axes. In this case, grid points are either
22
+ at cell boundaries or within the cells (oftern at the center).
23
+ 3. Simple ("bare") indexing (without particular physical meaning)
24
+
25
+ In most applications, the 1st type would be enough, but
26
+ the 2nd type would be useful for some type of numerical
27
+ simulation. The 3rd is not physical and may not be considered as
28
+ "axes", but this could be convenient for some practical applications.
29
+
30
+ ==Class Methods
31
+ ---Axis.new(cell=false,bare_index=false,name=nil)
32
+ Constructor. The first two arguments are to specify one of the
33
+ types explained above.
34
+
35
+ ARGUMENTS
36
+ * cell (true or false)
37
+ * bare_index (true or false)
38
+ * name (String or nil): the default name (when nil) is "noname"
39
+
40
+ RETURN VALUE
41
+ * an Axis
42
+
43
+ ---Axis.defined_operations
44
+ Returns the name of the methods defined in Axis to do
45
+ some operation along the axis.
46
+
47
+ RETURN VALUE
48
+ * an Array of String. Current default value is ["integrate","average"].
49
+
50
+ ---Axis.humane_messaging = t_or_f
51
+ If false is given, the [] method is changed to return a naive
52
+ straightforward message if the axis is lost. -- By default,
53
+ it returns a fancy but sometimes unwanted message if the
54
+ axis is the time with since field in the form of yyyy-mm-dd....
55
+
56
+ ==Instance Methods
57
+ ---name=(nm)
58
+ Set a name.
59
+
60
+ ARGUMENTS
61
+ * name (String)
62
+
63
+ RETURN VALUE
64
+ * name (the argument)
65
+ ---name
66
+ Returns the name.
67
+
68
+ RETURN VALUE
69
+ * a String
70
+
71
+ ---cell?
72
+ Whether or not self is a cell-type axis.
73
+
74
+ RETURN VALUE
75
+ * true or false
76
+
77
+ ---cell_center?
78
+ Whether or not self represents data points within the cells (which is
79
+ often, but not necessarily, the centers of the cells).
80
+
81
+ RETURN VALUE
82
+ * true, false, or nil (when the axis is not cell-type)
83
+
84
+ ---cell_bounds?
85
+ Whether or not self represents data points at the cell bondaries.
86
+
87
+ RETURN VALUE
88
+ * true, false, or nil (when the axis is not cell-type)
89
+
90
+ ---bare_index?
91
+ Whether or not self is of the bare-index type.
92
+
93
+ RETURN VALUE
94
+ * true or false.
95
+
96
+ ---flatten
97
+ Returns the VArray objects in self as a flat Array. No cloning is made.
98
+
99
+ RETURN VALUE
100
+ * an Array of VArray objects.
101
+
102
+ ---each_varray
103
+ Iterator for each VArray object in self (dependent on ((<flatten>)).
104
+
105
+ RETURN VALUE
106
+ * an Array of VArray objects (same as ((<flatten>))).
107
+
108
+ ---copy
109
+ Make a deep clone onto memory.
110
+ All the VArray objects in the return value will be
111
+ of the root class of VArray.
112
+
113
+ RETURN VALUE
114
+ * an Axis
115
+
116
+ ---collect
117
+
118
+ This method is like ((<copy>)), but it is the 'collect'
119
+ iterator for each VArray in self (block required).
120
+
121
+ RETURN VALUE
122
+ * an Axis
123
+
124
+ ---pos=(pos)
125
+ Sets the grid-point positions (disretized coordinate values).
126
+
127
+ ARGUMENTS
128
+ * pos (a 1D VArray)
129
+
130
+ RETURN VALUE
131
+ * pos (the argument)
132
+
133
+ ---set_pos(pos)
134
+ Sets the grid-point positions (disretized coordinate values).
135
+
136
+ ARGUMENTS
137
+ * pos (a 1D VArray)
138
+
139
+ RETURN VALUE
140
+ * self
141
+
142
+ ---pos
143
+ Returns the grid-point positions (disretized coordinate values).
144
+
145
+ RETURN VALUE
146
+ * a VArray (no duplication is made)
147
+
148
+ ---cell_center
149
+
150
+ When cell-type, returns the positions of grid points at cell centers.
151
+
152
+ RETURN VALUE
153
+ * a VArray (no duplication is made)
154
+
155
+ ---cell_bounds
156
+
157
+ When cell-type, returns the positions of grid points at cell boundaries.
158
+
159
+ RETURN VALUE
160
+ * a VArray (no duplication is made)
161
+
162
+ ---length
163
+ Returns the length of the axis.
164
+
165
+ RETURN VALUE
166
+ * an Integer
167
+
168
+ ---set_cell(center, bounds, name=nil)
169
+ Set up cell-type axis, by giving both the cell centers and boundaries.
170
+ Completion of the set up is deferred until one of ((<set_pos_to_center>))
171
+ and ((<set_pos_to_bounds>)) is called.
172
+
173
+ ARGUMENTS
174
+ * center (a 1D VArray)
175
+ * bounds (a 1D VArray)
176
+ * name (String)
177
+
178
+ RETURN VALUE
179
+ * self
180
+
181
+ ---set_cell_guess_bounds(center, name=nil)
182
+ Set up cell-type axis, by specifing only the cell centers
183
+ and deriving bounds with a naive assumption.
184
+
185
+ ARGUMENTS
186
+ * center (a 1D VArray)
187
+ * name (String)
188
+
189
+ RETURN VALUE
190
+ * self
191
+
192
+ ---set_pos_to_center
193
+ Set the position of the current axis to the centers of the cells.
194
+ This or ((<set_pos_to_bounds>)) is needed to complete the set up
195
+ with set_cell_* methods.
196
+
197
+ ---set_pos_to_bounds
198
+ Set the position of the current axis to the cell bondaries.
199
+ This or ((<set_pos_to_center>)) is needed to complete the set up
200
+ with set_cell_* methods.
201
+
202
+ ---set_aux(name,vary)
203
+ Set auxiliary data
204
+
205
+ ARGUMENTS
206
+ * name (String) a tag to express the kind of the data
207
+ * vary (a VArray) the data
208
+
209
+ RETURN VALUE
210
+ * vary (the 2nd argument)
211
+
212
+ ---get_aux(name)
213
+
214
+ Returns auxiliary data
215
+
216
+ ARGUMENTS
217
+ * name (String) a tag to express the kind of the data (see ((<set_aux>))).
218
+
219
+ RETURN VALUE
220
+ * a VArray
221
+
222
+ ---aux_names
223
+ Returns a list of the names of auxiliary data
224
+
225
+ RETURN VALUE
226
+ * an Array of String
227
+
228
+ ---to_gphys(datavary1d=nil)
229
+ To construct a GPhys object from an Axis.
230
+
231
+ ARGUMENTS
232
+ * datavary1d (nil or VArray) :
233
+ If nil, the position object of self becomes the main data object.
234
+ If a VArray, it is used as the main data object.
235
+
236
+ RETURN VALUE
237
+ * a GPhys
238
+
239
+ ---[] (slicer)
240
+ Returns a subset. Its specification is the same as in NArray.
241
+
242
+ RETURN VALUE
243
+ * an Axis
244
+
245
+ ---cut(coord_cutter)
246
+ Similar to ((<[]>)), but is based on the physical coordinate.
247
+
248
+ RETURN VALUE
249
+ * an Axis
250
+
251
+ ---cut_rank_conserving(coord_cutter)
252
+ Similar to ((<cut>)), but is always rank-conserving. That is,
253
+ a subset specification like [i] is treated as [i..i]
254
+
255
+ RETURN VALUE
256
+ * an Axis
257
+
258
+ ---integrate(ary,dim)
259
+ Does integration along the axis
260
+
261
+ ARGUMENTS
262
+ * ary (NArray or NArray-like multi-dimensional data class)
263
+ the data, whose dim-th dimension must have the same length as the axis.
264
+ * dim (Integer) : The dimension of ary, to which the operation is applied.
265
+
266
+ RETURN VALUE
267
+ * an obejct with the same class as ary, or of a Numeric
268
+ class if ary is 1D.
269
+
270
+ ---integ_weight
271
+ Returns the integration weight (whose default is nil).
272
+
273
+ ---integ_weight=(wgt)
274
+ Sets the integration weight (whose default is nil).
275
+
276
+ ---average(ary,dim)
277
+ Similar to ((<integrate>)), but does averaging
278
+
279
+ ARGUMENTS
280
+ * see ((<integrate>))
281
+
282
+ RETURN VALUE
283
+ * see ((<integrate>))
284
+
285
+ ---average_weight
286
+ Returns the integration weight (whose default is nil).
287
+
288
+ ---average_weight=(wgt)
289
+ Sets the integration weight (whose default is nil).
290
+
291
+ ---draw_positive
292
+ Returns the direction to plot the axis, which relies on the
293
+ VArray#axis_draw_positive method.
294
+
295
+ RETURN VALUE
296
+ * one of the following:
297
+ * true: axis should be drawn in the increasing order (to right/upward)
298
+ * false: axis should be drawn in the decreasing order
299
+ * nil: not specified
300
+
301
+ ---cyclic?
302
+ Returns whether the axis is cyclic.
303
+ (Relies on the VArray#axis_cyclic? method.)
304
+
305
+ RETURN VALUE
306
+ * one of the following:
307
+ * true: cyclic
308
+ * false: not cyclic
309
+ * nil: not specified
310
+
311
+ ---modulo
312
+ Returns the modulo of a cyclic axis
313
+ (Relies on the VArray#axis_modulo method.)
314
+
315
+ RETURN VALUE
316
+ * one of the following:
317
+ * Float if the modulo is defined
318
+ * nil if modulo is not found
319
+
320
+ =end
321
+
322
+ module NumRu
323
+
324
+ class Axis
325
+
326
+ @@humane_message = true # if true, [] returns a humane message when the
327
+ # axis is lost. if false, it returns a naive one
328
+ def self.humane_message=(t_or_f)
329
+ @@humane_message = t_or_f
330
+ end
331
+
332
+ @@strftime_fmt = nil # nil, or String to explicitly specify the format
333
+ # for strftime used in []
334
+ def self.strftime_fmt=(fmt)
335
+ @@strftime_fmt = fmt
336
+ end
337
+ def self.strftime_fmt
338
+ @@strftime_fmt
339
+ end
340
+
341
+ def initialize(cell=false,bare_index=false,name=nil)
342
+ @init_fin = false # true/false (true if initializatn finished)
343
+ @name = name # String
344
+ @pos = nil # VArray (to set it can be deferred if
345
+ # @cell to support mother axes)
346
+ @cell = cell # true/false
347
+ @cell_center = nil # VArray (defined if @cell)
348
+ @cell_bounds = nil # VArray (defined if @cell)
349
+ @bare_index = bare_index # true/false(if true @cell is meaningless)
350
+ @aux = nil # Hash of VArray (auxiliary quantities)
351
+ end
352
+
353
+ def inspect
354
+ "<axis pos=#{@pos.inspect}>"
355
+ end
356
+
357
+ def name=(nm)
358
+ @name=nm
359
+ end
360
+ def name
361
+ @name || "noname"
362
+ end
363
+
364
+ def cell?
365
+ @cell
366
+ end
367
+ def cell_center?
368
+ @cell && @pos.equal?(@cell_center)
369
+ end
370
+ def cell_bounds?
371
+ @cell && @pos.equal?(@cell_bounds)
372
+ end
373
+ def bare_index?
374
+ @bare_index
375
+ end
376
+
377
+ def flatten
378
+ # return VArrays contained in a flat array
379
+ out = Array.new
380
+ out.push(@pos) if @pos
381
+ out.push(@cell_center) if @cell_center && !cell_center?
382
+ out.push(@cell_bounds) if @cell_bounds && !cell_bounds?
383
+ if @aux
384
+ @aux.each{|k,v|
385
+ out.push(v)
386
+ }
387
+ end
388
+ out
389
+ end
390
+
391
+ def each_varray
392
+ self.flatten.each{|x| yield x}
393
+ end
394
+
395
+ def copy
396
+ # deep clone onto memory
397
+ out = Axis.new(cell?, bare_index?, name)
398
+ if cell?
399
+ out.set_cell( @cell_center.copy, @cell_bounds.copy )
400
+ if cell_center?
401
+ out.set_pos_to_center
402
+ elsif cell_bounds?
403
+ out.set_pos_to_bounds
404
+ end
405
+ else
406
+ out.set_pos( @pos.copy )
407
+ end
408
+ if @aux
409
+ @aux.each{|k,v|
410
+ out.set_aux(k, v.copy)
411
+ }
412
+ end
413
+ out
414
+ end
415
+
416
+ def collect
417
+ # This method is like ((<copy>)), but it is the 'collect'
418
+ # iterator for each VArray in self (block required).
419
+ out = Axis.new(cell?, bare_index?, name)
420
+ if cell?
421
+ out.set_cell( yield(@cell_center), yield(@cell_bounds) )
422
+ if cell_center?
423
+ out.set_pos_to_center
424
+ elsif cell_bounds?
425
+ out.set_pos_to_bounds
426
+ end
427
+ else
428
+ out.set_pos( yield(@pos) )
429
+ end
430
+ if @aux
431
+ @aux.each{|k,v|
432
+ out.set_aux(k, yield(v))
433
+ }
434
+ end
435
+ out
436
+ end
437
+
438
+ def pos=(pos)
439
+ if !@cell
440
+ if ! pos.is_a?(VArray)
441
+ raise ArgumentError,"arg not a VArray: #{pos.class}"
442
+ end
443
+ if pos.rank != 1
444
+ raise ArgumentError,"rank of #{pos.name} (#{pos.rank}) is not 1"
445
+ end
446
+
447
+ @pos=pos
448
+ @init_fin = true
449
+ if ! @name
450
+ @name = pos.name
451
+ end
452
+ else
453
+ raise "This method is not available for a cell axis. "+
454
+ "Use set_pos_to_center or set_pos_to_bounds instead."
455
+ end
456
+ pos
457
+ end
458
+
459
+ def set_pos(pos)
460
+ self.pos= pos
461
+ @name = pos.name
462
+ self
463
+ end
464
+
465
+ def pos
466
+ raise "pos has not been set" if !@pos
467
+ @pos
468
+ end
469
+ def cell_center
470
+ @cell_center
471
+ end
472
+ def cell_bounds
473
+ @cell_bounds
474
+ end
475
+
476
+ def length
477
+ if @pos
478
+ @pos.length
479
+ else
480
+ raise "length is not determined until pos is set"
481
+ end
482
+ end
483
+
484
+ def set_cell(center, bounds, name=nil)
485
+ # it is the user's obligation to ensure that center and bounds
486
+ # have the same units etc.
487
+
488
+ # < error check >
489
+
490
+ if ! @cell; raise "method not available for a non-cell axis"; end
491
+
492
+ if ! center.is_a?(VArray)
493
+ raise ArgumentError,"1st arg not a VArray: #{center.class}"
494
+ end
495
+ if center.rank != 1
496
+ raise ArgumentError,"center: rank of #{center.name} (#{center.rank}) is not 1"
497
+ end
498
+
499
+ if ! bounds.is_a?(VArray)
500
+ raise ArgumentError,"2nd arg not a VArray: #{bounds.class}"
501
+ end
502
+ if bounds.rank != 1
503
+ raise ArgumentError,"bounds: rank of #{bounds.name} (#{bounds.rank}) is not 1"
504
+ end
505
+
506
+ if( center.length != bounds.length-1 )
507
+ raise "center.length != bounds.length-1"
508
+ end
509
+
510
+ # < do the job >
511
+
512
+ @cell_center = center
513
+ @cell_bounds = bounds
514
+ if name
515
+ @name=name
516
+ end
517
+ @init_fin = true # To set @pos is deferred at this moment.
518
+ # use set_pos_to_(bounds|center) to make
519
+ # the object fully available
520
+ self
521
+ end
522
+
523
+ def set_aux(name,vary)
524
+ if !name.is_a?(String)
525
+ raise ArgumentError,"1nd arg: not a String"
526
+ end
527
+
528
+ if ! vary.is_a?(VArray)
529
+ raise ArgumentError,"2nd arg not a VArray: #{vary.class}"
530
+ end
531
+ if vary.rank != 1
532
+ raise ArgumentError,"rank of #{vary.name} (#{vary.rank}) is not 1"
533
+ end
534
+
535
+ if !@aux; @aux = Hash.new; end
536
+
537
+ @aux[name] = vary
538
+ self
539
+ end
540
+ def get_aux(name)
541
+ @aux[name]
542
+ end
543
+ def aux_names
544
+ @aux ? @aux.keys : []
545
+ end
546
+
547
+ def to_gphys(datavary1d=nil)
548
+ # To form a 1-dimensional GPhys
549
+ # (Dependent on GPhys&Grid, unlike other methods Axis,
550
+ # so the test program is in gphys.rb)
551
+ # Arguments
552
+ # * datavary1d (nil or VArray): 1D VArray with the same
553
+ # size as the axis. If omitted, @pos (coordinate variable
554
+ # of the variable) is used.
555
+ if !datavary1d
556
+ datavary1d = @pos.copy
557
+ else
558
+ if datavary1d.rank != 1 || datavary1d.length != length
559
+ raise ArgumentError, "Must be 1D and same size"
560
+ end
561
+ end
562
+ GPhys.new( Grid.new(self), datavary1d )
563
+ end
564
+
565
+ def [] (slicer)
566
+ if ! @pos
567
+ raise "pos has not been set. Forgot set_pos_to_(center|bounds)?"
568
+ end
569
+
570
+ case slicer
571
+ when Fixnum
572
+ pos=@pos[slicer]
573
+ cval = ( pos.val.is_a?(Numeric) ? pos.val : pos.val[0] )
574
+ units = pos.get_att('units')
575
+ info_lost = false
576
+ if @@humane_message
577
+ if units && /(.*) *since *(.*)/ =~ units
578
+ stun = $1
579
+ tun = Units[stun]
580
+ since = DateTime.parse($2)
581
+ if Units[units] =~ Units['days since 1-1-1'] # s,hour,day,..
582
+ sec = tun.convert( cval, Units['seconds'] ).round + 1e-1
583
+ # ^ take "round" to avoid round error in sec
584
+ # (Note that %S below takes floor of seconds).
585
+ datetime = since + (sec/86400.0)
586
+ info_lost = datetime.strftime(@@strftime_fmt || '%Y-%m-%d %H:%M:%S%z')
587
+ info_lost_set = true
588
+ elsif Units[units] =~ Units['months since 1-1-1'] # year,month,pentad,..
589
+ monun = Units['months']
590
+ if /mon/ =~ stun || /year/ =~ stun
591
+ datetime = since >> tun.convert( cval, monun ).round
592
+ info_lost = datetime.strftime(@@strftime_fmt || '%Y-%m')
593
+ else # maybe pentad
594
+ datetime = since >> tun.convert( cval, monun )
595
+ info_lost = datetime.strftime(@@strftime_fmt || '%Y-%m-%d')
596
+ end
597
+ info_lost_set = true
598
+ end
599
+ end
600
+ end
601
+ if !info_lost_set
602
+ sval = sprintf("%g",cval)
603
+ info_lost = "#{self.name}=#{sval}"
604
+ if (units) # substitution
605
+ info_lost += " "+units
606
+ end
607
+ end
608
+ return info_lost
609
+ when Range, true
610
+ # re-organize the range to support slicing of variables
611
+ # with a 1 larger / smaller length.
612
+ if true===slicer
613
+ range=0..-1
614
+ else
615
+ range = slicer
616
+ end
617
+ first = range.first
618
+ last = range.exclude_end? ? range.last-1 : range.last
619
+ if first < 0
620
+ first += self.length # first will be counted from the beginning
621
+ end
622
+ if last >= 0
623
+ last -= self.length # last will be counted from the end
624
+ end
625
+ slicer = first..last
626
+ newax=Axis.new(@cell,@bare_index)
627
+ when Hash
628
+ range = slicer.keys[0]
629
+ step = slicer[range]
630
+ range = 0..-1 if range==true
631
+ first = range.first
632
+ last = range.exclude_end? ? range.last-1 : range.last
633
+ if first < 0
634
+ first += self.length # first will be counted from the beginning
635
+ end
636
+ if last >= 0
637
+ last -= self.length # last will be counted from the end
638
+ end
639
+ slicer = { (first..last) => step }
640
+ newax=Axis.new(false,@bare_index) # always not a cell axis
641
+ when NArray, Array
642
+ newax=Axis.new(false,@bare_index) # always not a cell axis
643
+ else
644
+ raise ArgumentError, "Axis slicing with #{slicer.inspect} is not available"
645
+ end
646
+
647
+ if newax.bare_index? || !newax.cell?
648
+ pos=@pos[slicer]
649
+ newax.set_pos( pos )
650
+ elsif newax.cell?
651
+ center=@cell_center[slicer]
652
+ bounds=@cell_bounds[slicer]
653
+ newax.set_cell( center, bounds )
654
+ if self.cell_center?
655
+ newax.set_pos_to_center
656
+ elsif self.cell_bounds?
657
+ newax.set_pos_to_bounds
658
+ end
659
+ end
660
+ if @aux
661
+ @aux.each{ |name, vary|
662
+ # if (aux=vary[slicer]).rank != 0
663
+ newax.set_aux(name, vary[slicer])
664
+ # else
665
+ # print "WARNING #{__FILE__}:#{__LINE__} auxiliary VArray #{name} is eliminated\n"
666
+ # end
667
+ }
668
+ end
669
+ newax
670
+ end
671
+
672
+ def cut(coord_cutter)
673
+ _cut_(false, coord_cutter)
674
+ end
675
+ def cut_rank_conserving(coord_cutter)
676
+ _cut_(true, coord_cutter)
677
+ end
678
+
679
+ def _cut_(conserve_rank, coord_cutter)
680
+
681
+ # assume that the coordinates are monotonic (without checking)
682
+
683
+ slicer = Array.new
684
+ ax = self.pos.val
685
+
686
+ units = self.pos.get_att('units')
687
+
688
+ case coord_cutter
689
+ when true
690
+ slicer=true
691
+ when Range
692
+ # find the grid points included in the range
693
+ range = coord_cutter
694
+ range_ary = [range.first, range.last]
695
+ xmin = range_ary.min
696
+ xmax = range_ary.max
697
+ xmin = UNumeric.from_date(xmin,units).val if xmin.class <= Date
698
+ xmax = UNumeric.from_date(xmax,units).val if xmax.class <= Date
699
+ wh = ( (ax >= xmin) & (ax <= xmax) ).where
700
+ if wh.length == 0
701
+ raise "Range #{range} does not include any grid point in the axis '#{name}'"
702
+ end
703
+ idmin = wh.min
704
+ idmax = wh.max
705
+ slicer=idmin..idmax
706
+ when Numeric, Date, DateTime
707
+ # find the nearst point
708
+ pt = coord_cutter
709
+ pt = UNumeric.from_date(pt,units).val if pt.class <= Date
710
+ dx = (ax-pt).abs
711
+ minloc = _minloc_(dx)
712
+ if conserve_rank
713
+ slicer=minloc..minloc
714
+ else
715
+ slicer=minloc
716
+ end
717
+ when Array, NArray
718
+ # find the nearst points
719
+ ary = coord_cutter
720
+ slicer = ary.collect{ |pt|
721
+ pt = UNumeric.from_date(pt,units).val if pt.class <= Date
722
+ dx = (ax-pt).abs
723
+ minloc = _minloc_(dx)
724
+ }
725
+ else
726
+ raise TypeError, "(#{coord_cutter.inspect}) is not accepted as a coordinate selector"
727
+ end
728
+
729
+ [ self[slicer], slicer ]
730
+ end
731
+ private :_cut_
732
+
733
+ def _minloc_(a) # private to be used in _cut_
734
+ # Developper's MEMO: Such a method should be supported in NArray
735
+ minloc = 0 # initialization
736
+ for i in 0...(a.length-1) # here, do not assume monotonic
737
+ minloc = i+1 if a[i+1]<a[i]
738
+ end
739
+ minloc
740
+ end
741
+ private :_minloc_
742
+
743
+ def set_cell_guess_bounds(center, name=nil)
744
+ # derive bounds with a naive assumption (should be OK for
745
+ # an equally separated axis).
746
+ if ! center.is_a?(VArray) || center.rank != 1
747
+ raise ArgumentError, "1st arg: not a VArray, or its rank != 1"
748
+ end
749
+ vc = center.val
750
+ vb = NArray.float( vc.length + 1 )
751
+ vb[0] = vc[0] - (vc[1]-vc[0])/2 # Assume this!!
752
+ for i in 1...vb.length
753
+ vb[i] = 2*vc[i-1] - vb[i-1] # from vc[i-1] = (vb[i-1]+vb[i])/2
754
+ end
755
+ bounds = VArray.new(vb, center) # borrow attributes from center
756
+ set_cell(center, bounds, name)
757
+ end
758
+
759
+ def set_pos_to_center
760
+ raise "The method is not available for a non-cell axis" if ! @cell
761
+ @pos = @cell_center
762
+ if !@name
763
+ @name = @cell_center.name
764
+ end
765
+ self
766
+ end
767
+
768
+ def set_pos_to_bounds
769
+ raise "The method is not available for a non-cell axis" if ! @cell
770
+ @pos = @cell_bounds
771
+ if !@name
772
+ @name = @cell_bounds.name
773
+ end
774
+ self
775
+ end
776
+
777
+ def Axis.defined_operations
778
+ @@operations
779
+ end
780
+
781
+ @@operations = ["integrate","average"]
782
+
783
+ def integrate(ary,dim)
784
+ if !@integ_weight; _set_default_integ_weight; end
785
+ sh = (0...ary.rank).collect{|i| (i==dim) ? @integ_weight.length : 1 }
786
+ mn = sprintf("%g", ( UNumeric===(a=@pos.min) ? a.val : a) )
787
+ mx = sprintf("%g", ( UNumeric===(a=@pos.max) ? a.val : a) )
788
+ return [ ( ary * @integ_weight.reshape(*sh) ).sum(dim),
789
+ "integrated "+@name+":#{mn}..#{mx}" ]
790
+ end
791
+
792
+ def integ_weight; @integ_weight; end
793
+ def integ_weight=(wgt); @integ_weight=wgt; end
794
+
795
+ def average(ary,dim)
796
+ if !@avg_weight; _set_default_avg_weight; end
797
+ sh = (0...ary.rank).collect{|i| (i==dim) ? @avg_weight.length : 1 }
798
+ mn = sprintf("%g", ( UNumeric===(a=@pos.min) ? a.val : a) )
799
+ mx = sprintf("%g", ( UNumeric===(a=@pos.max) ? a.val : a) )
800
+ return [ ( ary * @avg_weight.reshape(*sh) ).sum(dim),
801
+ "averaged "+@name+":#{mn}..#{mx}" ]
802
+ end
803
+
804
+ def average_weight; @avg_weight; end
805
+ def average_weight=(wgt); @avg_weight=wgt; end
806
+
807
+ def draw_positive
808
+ # Returns the direction to plot the axis
809
+ # * true: axis should be drawn in the increasing order(to right/upward)
810
+ # * false: axis should be drawn in the decreasing order
811
+ # * nil: not specified (VArray's default if not overridden in
812
+ # subclasses)
813
+ @pos.axis_draw_positive
814
+ end
815
+
816
+ def cyclic?
817
+ @pos.axis_cyclic?
818
+ end
819
+
820
+ def modulo
821
+ @pos.axis_modulo
822
+ end
823
+
824
+ ######### private methods ####################################
825
+
826
+ private
827
+
828
+ def _set_default_integ_weight
829
+
830
+ raise "Initialization is not completed" if ! @init_fin
831
+ if ! @pos
832
+ raise "pos has not been set. Call set_pos_to_(center|bounds)."
833
+ end
834
+
835
+ # < define numerical integration / averaging >
836
+
837
+ ## 2005/09/12 DEVLOPMENT MEMO by horinout
838
+ ## cyclic �ł��傤�ǂP�O���b�h�L�΂����� modulo �ɒB����ꍇ
839
+ ## �_�T���v����Z�������^�C�v�ł��T�C�N���b�N�p�d�݂��‚���
840
+ ## �悤�ɂ������D
841
+
842
+ if( @bare_index )
843
+ @integ_weight = NArray.int(@pos.length).fill!(1)
844
+ #dist = weight.length
845
+ elsif ( !@cell || (@cell && @pos.equal?(@cell_bounds)) )
846
+ # --- use trapezoidal formula ---
847
+ posv = @pos.val
848
+ if posv.length == 1
849
+ raise "cannot define the default integration when length==1 and non-cell"
850
+ end
851
+ #dist = (posv[-1]-posv[0]).abs
852
+ @integ_weight = posv.dup
853
+ @integ_weight[0] = (posv[1]-posv[0]).abs/2
854
+ @integ_weight[-1] = (posv[-1]-posv[-2]).abs/2
855
+ @integ_weight[1..-2] = (posv[2..-1] - posv[0..-3]).abs/2
856
+ else
857
+ # --- assume that the center values represents the averages ---
858
+ bd = @cell_bounds.val
859
+ @integ_weight = (bd[1..-1] - bd[0..-2]).abs
860
+ #dist = (bd[-1]-bd[0]).abs
861
+ end
862
+
863
+ end
864
+
865
+ def _set_default_avg_weight
866
+
867
+ raise "Initialization is not completed" if ! @init_fin
868
+ if ! @pos
869
+ raise "pos has not been set. Call set_pos_to_(center|bounds)."
870
+ end
871
+
872
+ # < define numerical integration / averaging >
873
+
874
+ if( @bare_index )
875
+ @avg_weight = NArray.int(@pos.length).fill!(1)
876
+ dist = @avg_weight.length
877
+ @avg_weight /= dist
878
+ elsif ( !@cell || (@cell && @pos.equal?(@cell_bounds)) )
879
+ # --- use trapezoidal formula ---
880
+ posv = @pos.val
881
+ if posv.length == 1
882
+ @avg_weight = NArray[1]
883
+ else
884
+ dist = (posv[-1]-posv[0]).abs
885
+ @avg_weight = posv.dup
886
+ @avg_weight[0] = (posv[1]-posv[0]).abs/2
887
+ @avg_weight[-1] = (posv[-1]-posv[-2]).abs/2
888
+ @avg_weight[1..-2] = (posv[2..-1] - posv[0..-3]).abs/2
889
+ @avg_weight /= dist
890
+ end
891
+ else
892
+ # --- assume that the center values represents the averages ---
893
+ bd = @cell_bounds.val
894
+ @avg_weight = (bd[1..-1] - bd[0..-2]).abs
895
+ dist = (bd[-1]-bd[0]).abs
896
+ @avg_weight /= dist
897
+ end
898
+
899
+ end
900
+
901
+ #######
902
+
903
+ end
904
+ end
905
+
906
+ ###################################################
907
+ ## < test >
908
+
909
+ if $0 == __FILE__
910
+ include NumRu
911
+ xc = VArray.new( NArray.float(10).indgen! + 0.5 ).rename("x")
912
+ xb = VArray.new( NArray.float(11).indgen! ).rename("xb")
913
+ axpt = Axis.new().set_pos(xc)
914
+ axcel = Axis.new(true).set_cell(xc,xb)
915
+ axcel_c = axcel.dup.set_pos_to_center
916
+ axcel_b = axcel.dup.set_pos_to_bounds
917
+ axcel2 = Axis.new(true).set_cell_guess_bounds(xc)
918
+ p "axcel",axcel, "axcel2",axcel2
919
+ print "########\n"
920
+ p axpt.pos.val
921
+ p axcel_c.pos.val
922
+ p axcel_b.pos.val
923
+ z = VArray.new( NArray.float(xc.length, 2).random! )
924
+ w = VArray.new( NArray.float(xc.length).indgen! )
925
+ w2 = VArray.new( NArray.float(xb.length).indgen!-0.5 )
926
+ p z.val
927
+ p axpt.average(z,0), axcel_c.average(z,0)
928
+ p z.sum(0)/10
929
+ print "### avg/integ ###\n"
930
+ p axpt.average(w,0), axcel_c.average(w,0),
931
+ axpt.integrate(w,0), axcel_c.integrate(w,0),
932
+ axcel_b.integrate(w2,0)
933
+ axpt.integ_weight = NArray.sfloat(axpt.length).fill!(0.5)
934
+ p 'with artificial integ_weight:', axpt.integrate(w,0)
935
+ # axcel.set_default_algorithms # this is to fail
936
+ print "////////\n"
937
+ p axpt[1..3].pos.val
938
+ p axcel_c[1..3].cell_center.val, axcel_c[1..3].cell_bounds.val
939
+ p axcel_b[1..3].cell_center.val, axcel_b[1..3].cell_bounds.val
940
+ p axpt[1]
941
+ p axcel_b[5]
942
+ p axcel_b.cut(4.3)
943
+ axcut, slicer = axcel_c.cut(3.0..7.0)
944
+ p axcut.copy, slicer
945
+ p axcel_b.cut([3.2, 2.5, 6.9])
946
+ p axpt
947
+ axcel_c.set_aux('aux1',xc*4)
948
+ p axcel_c.flatten
949
+ p axcel_c.copy.flatten
950
+ print "##\n"
951
+ p axcel_c.each_varray{|va| p va}
952
+ axcl = axcel_c.collect{|va| va*2}
953
+ print "###\n"
954
+ p axcl.class, axcl.each_varray{|va| p va}
955
+
956
+ axpt.pos.set_att("units","days since 2001-01-01")
957
+ p axpt.cut(DateTime.new(2001,1,4,12,0))
958
+ end