gphys 1.1.1a

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
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,963 @@
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
+ ---cyclic_extendible?
321
+ Returns whether the axis is cyclic and appropriate to extend.
322
+ (Relies on the VArray#axis_cyclic_extendible? method.)
323
+
324
+ RETURN VALUE
325
+ * true or false
326
+
327
+ =end
328
+
329
+ module NumRu
330
+
331
+ class Axis
332
+
333
+ @@humane_message = true # if true, [] returns a humane message when the
334
+ # axis is lost. if false, it returns a naive one
335
+ def self.humane_message=(t_or_f)
336
+ @@humane_message = t_or_f
337
+ end
338
+
339
+ @@strftime_fmt = nil # nil, or String to explicitly specify the format
340
+ # for strftime used in []
341
+ def self.strftime_fmt=(fmt)
342
+ @@strftime_fmt = fmt
343
+ end
344
+ def self.strftime_fmt
345
+ @@strftime_fmt
346
+ end
347
+
348
+ def initialize(cell=false,bare_index=false,name=nil)
349
+ @init_fin = false # true/false (true if initializatn finished)
350
+ @name = name # String
351
+ @pos = nil # VArray (to set it can be deferred if
352
+ # @cell to support mother axes)
353
+ @cell = cell # true/false
354
+ @cell_center = nil # VArray (defined if @cell)
355
+ @cell_bounds = nil # VArray (defined if @cell)
356
+ @bare_index = bare_index # true/false(if true @cell is meaningless)
357
+ @aux = nil # Hash of VArray (auxiliary quantities)
358
+ end
359
+
360
+ def inspect
361
+ "<axis pos=#{@pos.inspect}>"
362
+ end
363
+
364
+ def name=(nm)
365
+ @name=nm
366
+ end
367
+ def name
368
+ @name || "noname"
369
+ end
370
+
371
+ def cell?
372
+ @cell
373
+ end
374
+ def cell_center?
375
+ @cell && @pos.equal?(@cell_center)
376
+ end
377
+ def cell_bounds?
378
+ @cell && @pos.equal?(@cell_bounds)
379
+ end
380
+ def bare_index?
381
+ @bare_index
382
+ end
383
+
384
+ def flatten
385
+ # return VArrays contained in a flat array
386
+ out = Array.new
387
+ out.push(@pos) if @pos
388
+ out.push(@cell_center) if @cell_center && !cell_center?
389
+ out.push(@cell_bounds) if @cell_bounds && !cell_bounds?
390
+ if @aux
391
+ @aux.each{|k,v|
392
+ out.push(v)
393
+ }
394
+ end
395
+ out
396
+ end
397
+
398
+ def each_varray
399
+ self.flatten.each{|x| yield x}
400
+ end
401
+
402
+ def copy
403
+ # deep clone onto memory
404
+ out = Axis.new(cell?, bare_index?, name)
405
+ if cell?
406
+ out.set_cell( @cell_center.copy, @cell_bounds.copy )
407
+ if cell_center?
408
+ out.set_pos_to_center
409
+ elsif cell_bounds?
410
+ out.set_pos_to_bounds
411
+ end
412
+ else
413
+ out.set_pos( @pos.copy )
414
+ end
415
+ if @aux
416
+ @aux.each{|k,v|
417
+ out.set_aux(k, v.copy)
418
+ }
419
+ end
420
+ out
421
+ end
422
+
423
+ def collect
424
+ # This method is like ((<copy>)), but it is the 'collect'
425
+ # iterator for each VArray in self (block required).
426
+ out = Axis.new(cell?, bare_index?, name)
427
+ if cell?
428
+ out.set_cell( yield(@cell_center), yield(@cell_bounds) )
429
+ if cell_center?
430
+ out.set_pos_to_center
431
+ elsif cell_bounds?
432
+ out.set_pos_to_bounds
433
+ end
434
+ else
435
+ out.set_pos( yield(@pos) )
436
+ end
437
+ if @aux
438
+ @aux.each{|k,v|
439
+ out.set_aux(k, yield(v))
440
+ }
441
+ end
442
+ out
443
+ end
444
+
445
+ def pos=(pos)
446
+ if !@cell
447
+ if ! pos.is_a?(VArray)
448
+ raise ArgumentError,"arg not a VArray: #{pos.class}"
449
+ end
450
+ if pos.rank != 1
451
+ raise ArgumentError,"rank of #{pos.name} (#{pos.rank}) is not 1"
452
+ end
453
+
454
+ @pos=pos
455
+ @init_fin = true
456
+ if ! @name
457
+ @name = pos.name
458
+ end
459
+ else
460
+ raise "This method is not available for a cell axis. "+
461
+ "Use set_pos_to_center or set_pos_to_bounds instead."
462
+ end
463
+ pos
464
+ end
465
+
466
+ def set_pos(pos)
467
+ self.pos= pos
468
+ @name = pos.name
469
+ self
470
+ end
471
+
472
+ def pos
473
+ raise "pos has not been set" if !@pos
474
+ @pos
475
+ end
476
+ def cell_center
477
+ @cell_center
478
+ end
479
+ def cell_bounds
480
+ @cell_bounds
481
+ end
482
+
483
+ def length
484
+ if @pos
485
+ @pos.length
486
+ else
487
+ raise "length is not determined until pos is set"
488
+ end
489
+ end
490
+
491
+ def set_cell(center, bounds, name=nil)
492
+ # it is the user's obligation to ensure that center and bounds
493
+ # have the same units etc.
494
+
495
+ # < error check >
496
+
497
+ if ! @cell; raise "method not available for a non-cell axis"; end
498
+
499
+ if ! center.is_a?(VArray)
500
+ raise ArgumentError,"1st arg not a VArray: #{center.class}"
501
+ end
502
+ if center.rank != 1
503
+ raise ArgumentError,"center: rank of #{center.name} (#{center.rank}) is not 1"
504
+ end
505
+
506
+ if ! bounds.is_a?(VArray)
507
+ raise ArgumentError,"2nd arg not a VArray: #{bounds.class}"
508
+ end
509
+ if bounds.rank != 1
510
+ raise ArgumentError,"bounds: rank of #{bounds.name} (#{bounds.rank}) is not 1"
511
+ end
512
+
513
+ if( center.length != bounds.length-1 )
514
+ raise "center.length != bounds.length-1"
515
+ end
516
+
517
+ # < do the job >
518
+
519
+ @cell_center = center
520
+ @cell_bounds = bounds
521
+ if name
522
+ @name=name
523
+ end
524
+ @init_fin = true # To set @pos is deferred at this moment.
525
+ # use set_pos_to_(bounds|center) to make
526
+ # the object fully available
527
+ self
528
+ end
529
+
530
+ def set_aux(name,vary)
531
+ if !name.is_a?(String)
532
+ raise ArgumentError,"1nd arg: not a String"
533
+ end
534
+
535
+ if ! vary.is_a?(VArray)
536
+ raise ArgumentError,"2nd arg not a VArray: #{vary.class}"
537
+ end
538
+ if vary.rank != 1
539
+ raise ArgumentError,"rank of #{vary.name} (#{vary.rank}) is not 1"
540
+ end
541
+
542
+ if !@aux; @aux = Hash.new; end
543
+
544
+ @aux[name] = vary
545
+ self
546
+ end
547
+ def get_aux(name)
548
+ @aux[name]
549
+ end
550
+ def aux_names
551
+ @aux ? @aux.keys : []
552
+ end
553
+
554
+ def to_gphys(datavary1d=nil)
555
+ # To form a 1-dimensional GPhys
556
+ # (Dependent on GPhys&Grid, unlike other methods Axis,
557
+ # so the test program is in gphys.rb)
558
+ # Arguments
559
+ # * datavary1d (nil or VArray): 1D VArray with the same
560
+ # size as the axis. If omitted, @pos (coordinate variable
561
+ # of the variable) is used.
562
+ if !datavary1d
563
+ datavary1d = @pos.copy
564
+ else
565
+ if datavary1d.rank != 1 || datavary1d.length != length
566
+ raise ArgumentError, "Must be 1D and same size"
567
+ end
568
+ end
569
+ GPhys.new( Grid.new(self), datavary1d )
570
+ end
571
+
572
+ def [] (slicer)
573
+ if ! @pos
574
+ raise "pos has not been set. Forgot set_pos_to_(center|bounds)?"
575
+ end
576
+
577
+ case slicer
578
+ when Fixnum
579
+ pos=@pos[slicer]
580
+ cval = ( pos.val.is_a?(Numeric) ? pos.val : pos.val[0] )
581
+ units = pos.get_att('units')
582
+ info_lost = false
583
+ if @@humane_message
584
+ if units && /(.*) *since *(.*)/ =~ units
585
+ calendar = self.pos.get_att('calendar')
586
+ datetime = UNumeric[cval, units].to_datetime(0.1,calendar)
587
+ if datetime
588
+ if Units[units] =~ Units['days since 1-1-1'] # s,hour,day,..
589
+ info_lost = datetime.strftime(@@strftime_fmt || '%Y-%m-%d %H:%M:%S%z')
590
+ elsif Units[units] =~ Units['months since 1-1-1'] # year,month,pentad,..
591
+ if /mon/ =~ units.to_s || /year/ =~ units.to_s
592
+ info_lost = datetime.strftime(@@strftime_fmt || '%Y-%m')
593
+ else # maybe pentad
594
+ info_lost = datetime.strftime(@@strftime_fmt || '%Y-%m-%d')
595
+ end
596
+ end
597
+ end
598
+ info_lost_set = true
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
+ calendar = self.pos.get_att('calendar')
688
+
689
+ case coord_cutter
690
+ when true
691
+ slicer=true
692
+ when Range
693
+ # find the grid points included in the range
694
+ range = coord_cutter
695
+ range_ary = [range.first, range.last]
696
+ xmin = range_ary.min
697
+ xmax = range_ary.max
698
+ xmin = UNumeric.from_date(xmin,units,calendar).val if xmin.class <= Date
699
+ xmax = UNumeric.from_date(xmax,units,calendar).val if xmax.class <= Date
700
+ wh = ( (ax >= xmin) & (ax <= xmax) ).where
701
+ if wh.length == 0
702
+ raise "Range #{range} does not include any grid point in the axis '#{name}'"
703
+ end
704
+ idmin = wh.min
705
+ idmax = wh.max
706
+ slicer=idmin..idmax
707
+ when Numeric, Date, DateTime
708
+ # find the nearst point
709
+ pt = coord_cutter
710
+ pt = UNumeric.from_date(pt,units,calendar).val if pt.class <= Date
711
+ dx = (ax-pt).abs
712
+ minloc = _minloc_(dx)
713
+ if conserve_rank
714
+ slicer=minloc..minloc
715
+ else
716
+ slicer=minloc
717
+ end
718
+ when Array, NArray
719
+ # find the nearst points
720
+ ary = coord_cutter
721
+ slicer = ary.collect{ |pt|
722
+ pt = UNumeric.from_date(pt,units,calendar).val if pt.class <= Date
723
+ dx = (ax-pt).abs
724
+ minloc = _minloc_(dx)
725
+ }
726
+ else
727
+ raise TypeError, "(#{coord_cutter.inspect}) is not accepted as a coordinate selector"
728
+ end
729
+
730
+ [ self[slicer], slicer ]
731
+ end
732
+ private :_cut_
733
+
734
+ def _minloc_(a) # private to be used in _cut_
735
+ # Developper's MEMO: Such a method should be supported in NArray
736
+ minloc = 0 # initialization
737
+ for i in 0...(a.length-1) # here, do not assume monotonic
738
+ minloc = i+1 if a[i+1]<a[i]
739
+ end
740
+ minloc
741
+ end
742
+ private :_minloc_
743
+
744
+ def set_cell_guess_bounds(center, name=nil)
745
+ # derive bounds with a naive assumption (should be OK for
746
+ # an equally separated axis).
747
+ if ! center.is_a?(VArray) || center.rank != 1
748
+ raise ArgumentError, "1st arg: not a VArray, or its rank != 1"
749
+ end
750
+ vc = center.val
751
+ vb = NArray.float( vc.length + 1 )
752
+ vb[0] = vc[0] - (vc[1]-vc[0])/2 # Assume this!!
753
+ for i in 1...vb.length
754
+ vb[i] = 2*vc[i-1] - vb[i-1] # from vc[i-1] = (vb[i-1]+vb[i])/2
755
+ end
756
+ bounds = VArray.new(vb, center) # borrow attributes from center
757
+ set_cell(center, bounds, name)
758
+ end
759
+
760
+ def set_pos_to_center
761
+ raise "The method is not available for a non-cell axis" if ! @cell
762
+ @pos = @cell_center
763
+ if !@name
764
+ @name = @cell_center.name
765
+ end
766
+ self
767
+ end
768
+
769
+ def set_pos_to_bounds
770
+ raise "The method is not available for a non-cell axis" if ! @cell
771
+ @pos = @cell_bounds
772
+ if !@name
773
+ @name = @cell_bounds.name
774
+ end
775
+ self
776
+ end
777
+
778
+ def Axis.defined_operations
779
+ @@operations
780
+ end
781
+
782
+ @@operations = ["integrate","average"]
783
+
784
+ def integrate(ary,dim)
785
+ if !@integ_weight; _set_default_integ_weight; end
786
+ sh = (0...ary.rank).collect{|i| (i==dim) ? @integ_weight.length : 1 }
787
+ mn = sprintf("%g", ( UNumeric===(a=@pos.min) ? a.val : a) )
788
+ mx = sprintf("%g", ( UNumeric===(a=@pos.max) ? a.val : a) )
789
+ return [ ( ary * @integ_weight.reshape(*sh) ).sum(dim),
790
+ "integrated "+@name+":#{mn}..#{mx}" ]
791
+ end
792
+
793
+ def integ_weight; @integ_weight; end
794
+ def integ_weight=(wgt); @integ_weight=wgt; end
795
+
796
+ def average(ary,dim)
797
+ if !@avg_weight; _set_default_avg_weight; end
798
+ sh = (0...ary.rank).collect{|i| (i==dim) ? @avg_weight.length : 1 }
799
+ mn = sprintf("%g", ( UNumeric===(a=@pos.min) ? a.val : a) )
800
+ mx = sprintf("%g", ( UNumeric===(a=@pos.max) ? a.val : a) )
801
+ return [ ( ary * @avg_weight.reshape(*sh) ).sum(dim),
802
+ "averaged "+@name+":#{mn}..#{mx}" ]
803
+ end
804
+
805
+ def average_weight; @avg_weight; end
806
+ def average_weight=(wgt); @avg_weight=wgt; end
807
+
808
+ def draw_positive
809
+ # Returns the direction to plot the axis
810
+ # * true: axis should be drawn in the increasing order(to right/upward)
811
+ # * false: axis should be drawn in the decreasing order
812
+ # * nil: not specified (VArray's default if not overridden in
813
+ # subclasses)
814
+ @pos.axis_draw_positive
815
+ end
816
+
817
+ def cyclic?
818
+ @pos.axis_cyclic?
819
+ end
820
+
821
+ def modulo
822
+ @pos.axis_modulo
823
+ end
824
+
825
+ def cyclic_extendible?
826
+ @pos.axis_cyclic?
827
+ end
828
+
829
+ ######### private methods ####################################
830
+
831
+ private
832
+
833
+ def _set_default_integ_weight
834
+
835
+ raise "Initialization is not completed" if ! @init_fin
836
+ if ! @pos
837
+ raise "pos has not been set. Call set_pos_to_(center|bounds)."
838
+ end
839
+
840
+ # < define numerical integration / averaging >
841
+
842
+ ## 2005/09/12 DEVLOPMENT MEMO by horinout
843
+ ## cyclic �ł��傤�ǂP�O���b�h�L�΂����� modulo �ɒB����ꍇ
844
+ ## �_�T���v����Z�������^�C�v�ł��T�C�N���b�N�p�d�݂��‚���
845
+ ## �悤�ɂ������D
846
+
847
+ if( @bare_index )
848
+ @integ_weight = NArray.int(@pos.length).fill!(1)
849
+ #dist = weight.length
850
+ elsif ( !@cell || (@cell && @pos.equal?(@cell_bounds)) )
851
+ # --- use trapezoidal formula ---
852
+ posv = @pos.val
853
+ if posv.length == 1
854
+ raise "cannot define the default integration when length==1 and non-cell"
855
+ end
856
+ #dist = (posv[-1]-posv[0]).abs
857
+ @integ_weight = posv.dup
858
+ @integ_weight[0] = (posv[1]-posv[0]).abs/2
859
+ @integ_weight[-1] = (posv[-1]-posv[-2]).abs/2
860
+ @integ_weight[1..-2] = (posv[2..-1] - posv[0..-3]).abs/2
861
+ else
862
+ # --- assume that the center values represents the averages ---
863
+ bd = @cell_bounds.val
864
+ @integ_weight = (bd[1..-1] - bd[0..-2]).abs
865
+ #dist = (bd[-1]-bd[0]).abs
866
+ end
867
+
868
+ end
869
+
870
+ def _set_default_avg_weight
871
+
872
+ raise "Initialization is not completed" if ! @init_fin
873
+ if ! @pos
874
+ raise "pos has not been set. Call set_pos_to_(center|bounds)."
875
+ end
876
+
877
+ # < define numerical integration / averaging >
878
+
879
+ if( @bare_index )
880
+ @avg_weight = NArray.int(@pos.length).fill!(1)
881
+ dist = @avg_weight.length
882
+ @avg_weight /= dist
883
+ elsif ( !@cell || (@cell && @pos.equal?(@cell_bounds)) )
884
+ # --- use trapezoidal formula ---
885
+ posv = @pos.val
886
+ if posv.length == 1
887
+ @avg_weight = NArray[1]
888
+ else
889
+ dist = (posv[-1]-posv[0]).abs
890
+ @avg_weight = posv.dup
891
+ @avg_weight[0] = (posv[1]-posv[0]).abs/2
892
+ @avg_weight[-1] = (posv[-1]-posv[-2]).abs/2
893
+ @avg_weight[1..-2] = (posv[2..-1] - posv[0..-3]).abs/2
894
+ @avg_weight /= dist
895
+ end
896
+ else
897
+ # --- assume that the center values represents the averages ---
898
+ bd = @cell_bounds.val
899
+ @avg_weight = (bd[1..-1] - bd[0..-2]).abs
900
+ dist = (bd[-1]-bd[0]).abs
901
+ @avg_weight /= dist
902
+ end
903
+
904
+ end
905
+
906
+ #######
907
+
908
+ end
909
+ end
910
+
911
+ ###################################################
912
+ ## < test >
913
+
914
+ if $0 == __FILE__
915
+ include NumRu
916
+ xc = VArray.new( NArray.float(10).indgen! + 0.5 ).rename("x")
917
+ xb = VArray.new( NArray.float(11).indgen! ).rename("xb")
918
+ axpt = Axis.new().set_pos(xc)
919
+ axcel = Axis.new(true).set_cell(xc,xb)
920
+ axcel_c = axcel.dup.set_pos_to_center
921
+ axcel_b = axcel.dup.set_pos_to_bounds
922
+ axcel2 = Axis.new(true).set_cell_guess_bounds(xc)
923
+ p "axcel",axcel, "axcel2",axcel2
924
+ print "########\n"
925
+ p axpt.pos.val
926
+ p axcel_c.pos.val
927
+ p axcel_b.pos.val
928
+ z = VArray.new( NArray.float(xc.length, 2).random! )
929
+ w = VArray.new( NArray.float(xc.length).indgen! )
930
+ w2 = VArray.new( NArray.float(xb.length).indgen!-0.5 )
931
+ p z.val
932
+ p axpt.average(z,0), axcel_c.average(z,0)
933
+ p z.sum(0)/10
934
+ print "### avg/integ ###\n"
935
+ p axpt.average(w,0), axcel_c.average(w,0),
936
+ axpt.integrate(w,0), axcel_c.integrate(w,0),
937
+ axcel_b.integrate(w2,0)
938
+ axpt.integ_weight = NArray.sfloat(axpt.length).fill!(0.5)
939
+ p 'with artificial integ_weight:', axpt.integrate(w,0)
940
+ # axcel.set_default_algorithms # this is to fail
941
+ print "////////\n"
942
+ p axpt[1..3].pos.val
943
+ p axcel_c[1..3].cell_center.val, axcel_c[1..3].cell_bounds.val
944
+ p axcel_b[1..3].cell_center.val, axcel_b[1..3].cell_bounds.val
945
+ p axpt[1]
946
+ p axcel_b[5]
947
+ p axcel_b.cut(4.3)
948
+ axcut, slicer = axcel_c.cut(3.0..7.0)
949
+ p axcut.copy, slicer
950
+ p axcel_b.cut([3.2, 2.5, 6.9])
951
+ p axpt
952
+ axcel_c.set_aux('aux1',xc*4)
953
+ p axcel_c.flatten
954
+ p axcel_c.copy.flatten
955
+ print "##\n"
956
+ p axcel_c.each_varray{|va| p va}
957
+ axcl = axcel_c.collect{|va| va*2}
958
+ print "###\n"
959
+ p axcl.class, axcl.each_varray{|va| p va}
960
+
961
+ axpt.pos.set_att("units","days since 2001-01-01")
962
+ p axpt.cut(DateTime.new(2001,1,4,12,0))
963
+ end