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,1109 @@
1
+ require "numru/gphys/subsetmapping"
2
+ require "numru/gphys/attribute"
3
+ require "narray_miss"
4
+ require "numru/units"
5
+ require "numru/gphys/unumeric"
6
+ require "rational" # for VArray#sqrt
7
+ require "numru/misc"
8
+
9
+ module NumRu
10
+
11
+ =begin
12
+ =class NumRu::VArray
13
+
14
+ VArray is a Virtual Array class, in which a multi-dimensional array data is
15
+ stored on memory (NArray, NArrayMiss) or in file (NetCDFVar etc).
16
+ The in-file data handling is left to subclasses such as VArrayNetCDF,
17
+ and this base class handles the following two cases:
18
+
19
+ (1) Data are stored on memory using NArray
20
+ (2) Subset of another VArray (possibly a subclass such as VArrayNetCDF).
21
+
22
+ Perhaps the latter case needs more explanation. Here, a VArray is defined
23
+ as a subset of another VArray, so the current VArray has only the link
24
+ and info on how the subset is mapped to the other VArray.
25
+
26
+ A VArray behaves just like a NArray, i.e., a numeric multi-dimensional
27
+ array. The important difference is that a VArray has a name and can
28
+ have "attributes" like a NetCDF variable. Therefore, VArray can perfectly
29
+ represent a NetCDFVar, which is realized by a sub-class VArrayNetCDF.
30
+
31
+ NOMENCLATURE
32
+
33
+ * value(s): The multi-dimensional numeric array contained in the VArray,
34
+ or its contents
35
+
36
+ * attribute(s): A combination of name and data that describes a VArray.
37
+ Often realized by NumRu::Attribute class (or it is a NetCDFAttr in
38
+ VArrayNetCDF). The name must be a string, and the type of attribute
39
+ values is restricted to a few classes for compatibility with
40
+ NetCDFAttr (See NumRu::Attribute)
41
+
42
+ ==Class Methods
43
+
44
+ ---VArray.new(narray=nil, attr=nil, name=nil)
45
+
46
+ A constructor
47
+
48
+ ARGUMENTS
49
+ * narray (NArray or NArrayMiss; default:nil) The array to be held.
50
+ (nil is used to initialize a mapping to another VArray by a protected
51
+ method).
52
+ * attr (NumRu::Attribute; default:nil) Attributes. If nil, an empty
53
+ attribute object is created and stored.
54
+ * name (String; default nil) Name of the VArray. If nil, it is named "noname".
55
+
56
+ RETURN VALUE
57
+ * a VArray
58
+
59
+ EXAMPLE
60
+
61
+ na = NArray.int(6,3).indgen!
62
+ va1 = VArray.new( na, nil, "test" )
63
+
64
+ ---VArray.new2(ntype, shape, attr=nil, name=nil)
65
+
66
+ Another constructor. Uses parameters to initialize a NArray to hold.
67
+
68
+ ARGUMENTS
69
+ * ntype (String or NArray constants): Numeric type of the NArray to be
70
+ held (e.g., "sfloat", "float", NArray::SFLOAT, NArray::FLOAT)
71
+ * shape (Array of Integers): shape of the NArray
72
+ * attr (Attribute; default:nil) Attributes. If nil, an empty attribute
73
+ object is created and stored.
74
+ * name (String; default nil) Name of the VArray.
75
+
76
+ RETURN VALUE
77
+ * a VArray
78
+
79
+
80
+ ==Instance Methods
81
+
82
+ ---val
83
+ Returns the values as a NArray (or NArrayMiss).
84
+
85
+ This is the case even when the VArray is a mapping to another. Also,
86
+ this method is to be redefined in subclasses to do the same thing.
87
+
88
+ ARGUMENTS -- none
89
+
90
+ RETURN VALUE
91
+ * a NArray (or NArrayMiss)
92
+
93
+ ---val=(narray)
94
+
95
+ Set values.
96
+
97
+ The whole values are set. If you want to set partly, use ((<[]=>)).
98
+ In this method, values are read from narray and set into the internal
99
+ value holder. Thus, for exampled, the numeric type is not changed
100
+ regardress the numeric type of narray. Use ((<replace_val>)) to
101
+ replace entirely with narray.
102
+
103
+ ARGUMENTS
104
+ * narray (NArray or NArrayMiss or Numeric): If Numeric, the whole
105
+ values are set to be equal to it. If NArray (or NArrayMiss), its
106
+ shape must agree with the shape of the VArray.
107
+
108
+ ---replace_val(narray)
109
+
110
+ Replace the internal array data with the object narray.
111
+ Use ((<val=>)) if you want to copy the values of narray.
112
+
113
+ ARGUMENTS
114
+ * narray (NArray or NArrayMiss): as pxlained above.
115
+ Its shape must agree with the shape of the VArray (self).
116
+
117
+ RETURN VALUE
118
+ * if (self.class == VArray), self;
119
+ otherwise (if self.class is a subclass of VArray), a new VArray.
120
+
121
+ ---[]
122
+ Get a subset. Its usage is the same as NArray#[]
123
+
124
+ ---[]=
125
+ Set a subset. Its usage is the same as NArray#[]=
126
+
127
+ ---attr
128
+ To be undefined.
129
+
130
+ ---ntype
131
+
132
+ Returns the numeric type.
133
+
134
+ ARGUMENTS -- none
135
+
136
+ RETURN VALUE
137
+ * a String ("byte", "sint", "int", "sfloat", "float", "scomplex"
138
+ "complex", or "obj"). It can be used in NArray.new to initialize
139
+ another NArray.
140
+
141
+ ---rank
142
+ Returns the rank (number of dimensions)
143
+
144
+ ---shape
145
+ Returns the shape
146
+
147
+ ---shape_current
148
+ aliased to ((<shape>)).
149
+
150
+ ---length
151
+ Returns the length of the VArray
152
+
153
+ ---typecode
154
+ Returns the NArray typecode
155
+
156
+ ---name
157
+ Returns the name
158
+
159
+ RETURN VALUE
160
+ * (String) name of the VArray
161
+
162
+ ---name=(nm)
163
+ Changes the name.
164
+
165
+ ARGUMENTS
166
+ * nm(String): the new name.
167
+
168
+ RETURN VALUE
169
+ * nm
170
+
171
+ ---rename!(nm)
172
+ Changes the name (Same as ((<name=>)), but returns self)
173
+
174
+ ARGUMENTS
175
+ * nm(String): the new name.
176
+
177
+ RETURN VALUE
178
+ * self
179
+
180
+ ---rename(nm)
181
+ Same as rename! but duplicate the VArray object and set its name.
182
+
183
+ This method may not be supported in sub-classes, since it is sometimes
184
+ problematic not to change the original.
185
+
186
+ ---copy(to=nil)
187
+ Copy a VArray. If to is nil, works as the deep cloning (duplication of the entire object).
188
+
189
+ Both the values and the attributes are copied.
190
+
191
+ ARGUMENTS
192
+ * to (VArray (possibly a subclass) or nil): The VArray to which the
193
+ copying is made.
194
+
195
+ ---reshape!( *shape )
196
+ Changes the shape without changing the total size. May not be available in subclasses.
197
+
198
+ ARGUMENTS
199
+ * shape (Array of Integer): new shape
200
+
201
+ RETURN VALUE
202
+ * self
203
+
204
+ EXAMPLE
205
+ vary = VArray.new2( "float", [10,2])
206
+ vary.reshape!(5,4) # changes the vary
207
+ vary.copy.reshape!(2,2,5) # make a deep clone and change it
208
+ # This always works with a VArray subclass, since vary.copy
209
+ # makes a deep clone to VArray with NArray.
210
+
211
+ ---file
212
+ Returns a file object if the data of the VArray is in a file, nil if it is on memory
213
+
214
+ ARGUMENTS
215
+ * none
216
+
217
+ RETURN VALUE
218
+ * an object representing the file in which data are stored. Its class
219
+ depends on the file type. nil is returned if the data is not in a file.
220
+
221
+
222
+ ---transpose(*dims)
223
+ Transpose. Argument specification is as in NArray.
224
+
225
+ ---reshape(*shape)
226
+ Reshape. Argument specification is as in NArray.
227
+
228
+ ---axis_draw_positive
229
+ Returns the direction to plot the axis (meaningful only if self is a
230
+ coordinate variable.)
231
+
232
+ The current implementation is based on NetCDF conventions,
233
+ so REDEFINE IT IN SUBCLASSES if it is not appropriate.
234
+
235
+ RETURN VALUE
236
+ * one of the following:
237
+ * true: axis should be drawn in the increasing order (to right/upward)
238
+ * false: axis should be drawn in the decreasing order
239
+ * nil: not specified
240
+
241
+ ---axis_cyclic?
242
+ Returns whether the axis is cyclic (meaningful only if self is a
243
+ coordinate variable.)
244
+
245
+ The current implementation is based on NetCDF conventions,
246
+ so REDEFINE IT IN SUBCLASSES if it is not appropriate.
247
+
248
+ RETURN VALUE
249
+ * one of the following:
250
+ * true: cyclic
251
+ * false: not cyclic
252
+ * nil: not specified
253
+
254
+ ---axis_modulo
255
+ Returns the modulo of a cyclic axis (meaningful only if self is a
256
+ coordinate variable and it is cyclic.)
257
+
258
+ The current implementation is based on NetCDF conventions,
259
+ so REDEFINE IT IN SUBCLASSES if it is not appropriate.
260
+
261
+ RETURN VALUE
262
+ * one of the following:
263
+ * Float if the modulo is defined
264
+ * nil if modulo is not found
265
+
266
+ ---axis_cyclic_extendible?
267
+ (meaningful only if self is a coordinate variable.)
268
+ Returns true if self is cyclic and it is suitable to exend
269
+ cyclically (having the distance between both ends
270
+ equal to (modulo - dx), where dx is the mean increment).
271
+
272
+ ---coerce(other)
273
+ For Numeric operators. (If you do not know it, see a manual or book of Ruby)
274
+
275
+ ==Methods compatible with NArray
276
+
277
+ VArray is a numeric multi-dimensional array, so it supports most of the
278
+ methods and operators in NArray. Here, the name of those methods are just
279
+ quoted. See the documentation of NArray for their usage.
280
+
281
+ === Math functions
282
+
283
+ ====sqrt, exp, log, log10, log2, sin, cos, tan, sinh, cosh, tanh, asin, acos, atan, asinh, acosh, atanh, csc, sec, cot, csch, sech, coth, acsc, asec, acot, acsch, asech, acoth
284
+
285
+ === Binary operators
286
+
287
+ ====-, +, *, /, %, **, .add!, .sub!, .mul!, .div!, mod!, >, >=, <, <=, &, |, ^, .eq, .ne, .gt, .ge, .lt, .le, .and, .or, .xor, .not
288
+
289
+ === Unary operators
290
+
291
+ ====~ - +
292
+
293
+ === Mean etc
294
+
295
+ ====mean, sum, stddev, min, max, median
296
+
297
+ === Other methods
298
+
299
+ These methods returns a NArray (not a VArray).
300
+
301
+ ====all?, any?, none?, where, where2, floor, ceil, round, to_f, to_i, to_a
302
+
303
+ =end
304
+
305
+ class Units
306
+ # for automatic operator generation in VArray
307
+ def mul!(other); self*other; end
308
+ def div!(other); self/other; end
309
+ end # class Units
310
+
311
+ class VArray
312
+
313
+ ### < basic parts to be redefined in subclasses > ###
314
+
315
+ def initialize(narray=nil, attr=nil, name=nil)
316
+ # initialize with an actual array --- initialization by subset
317
+ # mapping is made with VArray.new.initialize_mapping(...)
318
+ @name = ( name || "noname" )
319
+ @mapping = nil
320
+ @varray = nil
321
+ @ary = __check_ary_class(narray)
322
+ case attr
323
+ when Attribute
324
+ @attr = attr
325
+ when VArray
326
+ vary = attr
327
+ @attr = vary.attr_copy
328
+ when Hash
329
+ @attr = NumRu::Attribute.new
330
+ attr.each{|key,val| @attr[key]=val}
331
+ when nil
332
+ @attr = NumRu::Attribute.new
333
+ else
334
+ raise TypeError, "#{attr.class} is unsupported for the 2nd arg"
335
+ end
336
+ end
337
+
338
+ attr_reader :mapping, :varray, :ary
339
+ protected :mapping, :varray, :ary
340
+
341
+ def inspect
342
+ if !@mapping
343
+ "<'#{name}' #{ntype}#{shape.inspect} val=[#{(0...(4<length ? 4 : length)).collect do |i| @ary[i].to_s+',' end}#{'...' if 4<length}]>"
344
+ else
345
+ "<'#{name}' shape=#{shape.inspect} subset of a #{@varray.class}>"
346
+ end
347
+ end
348
+
349
+ def VArray.new2(ntype, shape, attr=nil, name=nil)
350
+ ary = NArray.new(ntype, *shape)
351
+ VArray.new(ary, attr, name)
352
+ end
353
+
354
+ def val
355
+ if @mapping
356
+ ary = @varray.ary
357
+ slicer = @mapping.slicer
358
+ if ary.is_a?(NArray) || ary.is_a?(NArrayMiss)
359
+ # interpret Hash slicers for NArray/NArrayMiss
360
+ # -- this part would not be needed if NArray supported it.
361
+ new_slicer = Array.new
362
+ for idx in 0...slicer.length
363
+ sl = slicer[idx]
364
+ if sl.is_a?(Hash)
365
+ range, step = sl.to_a[0]
366
+ dim_len = ary.shape[idx]
367
+ first = range.first
368
+ first += dim_len if first<0
369
+ last = range.last
370
+ last += dim_len if last<0
371
+ if first<0 || first>=dim_len || last<0 || last>=dim_len || step==0
372
+ raise "slicer #{slicer.inspect} for dim #{idx} is invalid (dim_len=#{dim_len})"
373
+ end
374
+ step = -step if ( (last-first)*step < 0 )
375
+ length = (last-first) / step + 1
376
+ new_slicer[idx] = first + step * NArray.int(length).indgen!
377
+ else
378
+ new_slicer[idx] = sl
379
+ end
380
+ end
381
+ slicer = new_slicer
382
+ end
383
+ ary[*slicer]
384
+ else
385
+ @ary.dup
386
+ end
387
+ end
388
+
389
+ def val=(narray)
390
+ if @mapping
391
+ @varray.ary[*@mapping.slicer] = __check_ary_class2(narray)
392
+ else
393
+ @ary[] = __check_ary_class2(narray)
394
+ end
395
+ narray
396
+ end
397
+
398
+ def replace_val(narray)
399
+ narray = __check_ary_class(narray)
400
+ if self.class != VArray
401
+ raise "replace_val to #{self.class} is disabled. Use val= instead"
402
+ end
403
+ if narray.shape != shape
404
+ raise "shape of the argument (#{narray.shape.inspect}) !="+
405
+ " self.shape (#{shape.inspect})"
406
+ end
407
+ @ary = narray
408
+ if @mapping
409
+ # to non subset
410
+ @name = @varray.name
411
+ @attr = @varray.attr_copy
412
+ @mapping = @varray = nil
413
+ end
414
+ self
415
+ end
416
+
417
+ def ntype
418
+ __ntype(typecode)
419
+ end
420
+
421
+ def name=(nm)
422
+ raise ArgumentError, "name should be a String" if ! nm.is_a?(String)
423
+ if @mapping
424
+ @varray.name = nm
425
+ else
426
+ @name = nm
427
+ end
428
+ nm
429
+ end
430
+ def rename!(nm)
431
+ self.name=nm
432
+ self
433
+ end
434
+ def rename(nm)
435
+ self.dup.rename!(nm)
436
+ end
437
+
438
+ def reshape!( *shape )
439
+ if @mapping
440
+ raise "Cannot reshape an VArray mapped to another. Use copy first to make it independent"
441
+ else
442
+ @ary.reshape!( *shape )
443
+ end
444
+ self
445
+ end
446
+
447
+ def file
448
+ if @mapping
449
+ @varray.file
450
+ else
451
+ return nil
452
+ end
453
+ end
454
+
455
+ ### < basic parts invariant in subclasses > ###
456
+
457
+ def copy(to=nil)
458
+ attr = self.attr_copy( (to ? to.attr : to) )
459
+ val = self.val
460
+ if self.class==VArray && !self.mapped? && (to==nil || to.class==VArray)
461
+ val = val.dup
462
+ end
463
+ if to
464
+ to.val = val
465
+ to
466
+ else
467
+ VArray.new(val, attr, self.name)
468
+ end
469
+ end
470
+
471
+ #def reshape( *shape )
472
+ # # reshape method that returns a new entire copy (deep one).
473
+ # # ToDo :: prepare another reshape method that does not make the
474
+ # # entire copy (you could use NArray.refer, but be careful not
475
+ # # to make it public, because it's easily misused)
476
+ # newobj = self.copy
477
+ # newobj.ary.reshape!( *shape )
478
+ # newobj
479
+ #end
480
+
481
+ def mapped?
482
+ @mapping ? true : false
483
+ end
484
+
485
+ def initialize_mapping(mapping, varray)
486
+ # protected method
487
+ raise ArgumentError if ! mapping.is_a?(SubsetMapping)
488
+ raise ArgumentError if ! varray.is_a?(VArray)
489
+ if ! varray.mapping
490
+ @mapping = mapping
491
+ @varray = varray
492
+ else
493
+ # To keep the mapping within one step
494
+ @mapping = varray.mapping.composite(mapping)
495
+ @varray = varray.varray
496
+ end
497
+ @attr = NumRu::Attribute.new
498
+ @ary = nil
499
+ self
500
+ end
501
+ protected :initialize_mapping
502
+
503
+ def attr
504
+ if @mapping
505
+ @varray.attr
506
+ else
507
+ @attr
508
+ end
509
+ end
510
+ protected :attr
511
+
512
+ def attr_copy(to=nil)
513
+ attr.copy(to)
514
+ end
515
+
516
+ def att_names
517
+ attr.keys
518
+ end
519
+ def get_att(name)
520
+ attr[name]
521
+ end
522
+ def set_att(name, val)
523
+ attr[name]=val
524
+ self
525
+ end
526
+ def del_att(name)
527
+ attr.delete(name)
528
+ end
529
+ alias put_att set_att
530
+
531
+ def units
532
+ str_units = attr['units']
533
+ if !str_units || str_units==''
534
+ str_units = '1' # represents non-dimension
535
+ end
536
+ Units.new( str_units )
537
+ end
538
+
539
+ def units=(units)
540
+ attr['units'] = units.to_s
541
+ units
542
+ end
543
+
544
+ def convert_units(to)
545
+ if ! to.is_a?(Units)
546
+ to = Units.new(to)
547
+ end
548
+ myunits = self.units
549
+ if myunits != to
550
+ gp = myunits.convert2(self, to)
551
+ gp.units = to
552
+ gp
553
+ else
554
+ self # returns self (no duplication)
555
+ end
556
+ end
557
+
558
+ def long_name
559
+ attr['long_name']
560
+ end
561
+
562
+ def long_name=(nm)
563
+ attr['long_name'] = nm
564
+ end
565
+
566
+ def [](*slicer)
567
+ slicer = __rubber_expansion( slicer )
568
+ mapping = SubsetMapping.new(self.shape_current, slicer)
569
+ VArray.new.initialize_mapping(mapping, self)
570
+ end
571
+
572
+ def []=(*args)
573
+ val = args.pop
574
+ slicer = args
575
+ slicer = __rubber_expansion( slicer )
576
+ if val.is_a?(VArray)
577
+ val = val.val
578
+ else
579
+ val = __check_ary_class2(val)
580
+ end
581
+ if @mapping
582
+ sl= @mapping.composite(SubsetMapping.new(self.shape,slicer)).slicer
583
+ @varray[*sl]=val
584
+ else
585
+ @ary[*slicer]=val
586
+ end
587
+ val
588
+ end
589
+
590
+ def name
591
+ if @mapping
592
+ @varray.name
593
+ else
594
+ @name.dup
595
+ end
596
+ end
597
+
598
+ def transpose(*dims)
599
+ VArray.new( val.transpose(*dims), attr_copy, name )
600
+ end
601
+
602
+ def reshape(*shape)
603
+ VArray.new( val.reshape(*shape), attr_copy, name )
604
+ end
605
+
606
+ def axis_draw_positive
607
+ # Default setting is taken from a widely used netcdf convention.
608
+ # You can override it in a sub-class or using convention specific
609
+ # mixins.
610
+ positive = attr['positive']
611
+ case positive
612
+ when /up/i
613
+ true
614
+ when /down/i
615
+ false
616
+ else
617
+ nil # not defined, or if not 'up' or 'down'
618
+ end
619
+ end
620
+
621
+ def axis_cyclic?
622
+ # Default setting is taken from a widely used netcdf convention.
623
+ # You can override it in a sub-class or using convention specific
624
+ # mixins.
625
+ topology = attr['topology']
626
+ case topology
627
+ when /circular/i
628
+ true
629
+ when nil # 'topology' not defined
630
+ if /degrees?_east/ =~ attr['units']
631
+ true # special treatment a common convention for the earth
632
+ else
633
+ nil # not defined --> nil
634
+ end
635
+ else
636
+ false
637
+ end
638
+ end
639
+
640
+ def axis_modulo
641
+ # Default setting is taken from a widely used netcdf convention.
642
+ # You can override it in a sub-class or using convention specific
643
+ # mixins.
644
+ if attval=attr['modulo']
645
+ if attval.is_a?(String)
646
+ attval.to_f
647
+ else
648
+ attval[0]
649
+ end
650
+ elsif /degrees?_east/ =~ attr['units']
651
+ 360.0 # special treatment: a common convention for the earth
652
+ elsif (tp = attr['topology']) and (/circular/i =~ tp)
653
+ un = Units[attr['units']]
654
+ if un == Units['degrees']
655
+ 360.0
656
+ elsif un == Units['radian']
657
+ 2*Math::PI
658
+ else
659
+ nil # cannot guess --> nil
660
+ end
661
+ else
662
+ nil # not defined --> nil
663
+ end
664
+ end
665
+
666
+ def axis_cyclic_extendible?
667
+ modulo = axis_modulo
668
+ return false if !modulo
669
+ v = val
670
+ width = (v[-1] - v[0]).abs
671
+ dx = width / (length-1)
672
+ eps = 1e-4
673
+ modulo = modulo.abs
674
+ extendible = ( ((width+dx) - modulo).abs < eps*modulo )
675
+ return extendible
676
+ end
677
+
678
+ ### < NArray methods > ###
679
+
680
+ ## ToDo: implement units handling
681
+ ## ToDo: coerce
682
+
683
+ def coerce(other)
684
+ oattr = self.attr_copy
685
+ case other
686
+ when UNumeric
687
+ oattr['units'] = other.units.to_s
688
+ na_other, = NArray.new(self.typecode, 1).coerce(other.val) # scalar
689
+ c_other = VArray.new(na_other, oattr, self.name)
690
+ else
691
+ oattr['units'] = self.get_att('units') # Assume the same units
692
+ case other
693
+ when Numeric
694
+ na_other, = NArray.new(self.typecode, 1).coerce(other) # scalar
695
+ c_other = VArray.new(na_other, oattr, self.name)
696
+ when Array
697
+ na = NArray.to_na(other)
698
+ c_other = VArray.new(na, oattr, self.name)
699
+ when NArray, NArrayMiss
700
+ c_other = VArray.new(other, oattr, self.name)
701
+ else
702
+ raise "Cannot coerse #{other.class}"
703
+ end
704
+ end
705
+ [c_other, self]
706
+ end
707
+
708
+ Math_funcs_nondim = ["exp","log","log10","log2","sin","cos","tan",
709
+ "sinh","cosh","tanh","asinh","acosh",
710
+ "atanh","csc","sec","cot","csch","sech","coth",
711
+ "acsch","asech","acoth"]
712
+ Math_funcs_radian = ["asin","acos","atan","atan2","acsc","asec","acot"]
713
+ Math_funcs = Math_funcs_nondim + Math_funcs_radian + ["sqrt"]
714
+
715
+ Binary_operators_Uop = ["*","/","**", ".mul!",".div!"]
716
+ Binary_operators_Uconv = ["+","-",".add!",".sbt!"]
717
+ Binary_operators_Unone = ["%",".mod!",".imag="]
718
+ Binary_operators = Binary_operators_Uop +
719
+ Binary_operators_Uconv +
720
+ Binary_operators_Unone
721
+
722
+ Binary_operatorsL_comp = [">",">=","<","<=",
723
+ ".eq",".ne",".gt",".ge",".lt",".le"]
724
+ Binary_operatorsL_other = ["&","|","^",".and",".or",".xor",".not"]
725
+ Binary_operatorsL = Binary_operatorsL_comp +
726
+ Binary_operatorsL_other
727
+
728
+ Unary_operators = ["-@","~"]
729
+
730
+ # type1 methods: returns a VArray with the same shape
731
+ # type2 methods: returns the result directly
732
+ NArray_type1_methods = ["sort", "sort_index",
733
+ "floor","ceil","round","to_f","to_i","to_type","abs",
734
+ "real","im","imag","angle","arg","conj","conjugate","cumsum",
735
+ "indgen","random"]
736
+
737
+ NArray_type2_methods1 = ["all?","any?","none?","where","where2",
738
+ "to_a", "to_string"]
739
+ NArray_type2_methods2 = ["rank", "shape", "total","length"]
740
+ NArray_type2_methods3 = ["typecode"]
741
+ NArray_type3_methods = ["mean","sum","stddev","min","max","median"]
742
+ # remaining: "transpose"
743
+
744
+ NArray_type2_methods = Array.new.push(*NArray_type2_methods1).
745
+ push(*NArray_type2_methods2).
746
+ push(*NArray_type2_methods3)
747
+
748
+ for f in Math_funcs_nondim
749
+ eval <<-EOS, nil, __FILE__, __LINE__+1
750
+ def #{f}(*arg)
751
+ newattr = self.attr_copy
752
+ newattr['units'] = '1'
753
+ case arg.length
754
+ when 0
755
+ VArray.new( Misc::EMath.#{f}(self.val), newattr, self.name )
756
+ #when 1 # for atan2
757
+ # ar = arg[0].respond_to?(:val) ? arg[0].val : arg[0]
758
+ # VArray.new( Misc::EMath.#{f}(self.val, ar), newattr, self.name )
759
+ else
760
+ raise ArgumentError, "# of args must be 0 or 1"
761
+ end
762
+ end
763
+ EOS
764
+ end
765
+ for f in Math_funcs_radian
766
+ eval <<-EOS, nil, __FILE__, __LINE__+1
767
+ def #{f}(*arg)
768
+ newattr = self.attr_copy
769
+ newattr['units'] = 'rad'
770
+ case arg.length
771
+ when 0
772
+ VArray.new( Misc::EMath.#{f}(self.val), newattr, self.name )
773
+ when 1 # for atan2
774
+ ar = arg[0].respond_to?(:val) ? arg[0].val : arg[0]
775
+ ## ar = ar.to_f # NMath.atan2 does not work with NArray.int
776
+ VArray.new( Misc::EMath.#{f}(self.val, ar), newattr, self.name )
777
+ else
778
+ raise ArgumentError, "# of args must be 0 or 1"
779
+ end
780
+ end
781
+ EOS
782
+ end
783
+ def sqrt
784
+ va = VArray.new( Misc::EMath.sqrt(self.val), self.attr_copy, self.name )
785
+ va.units = units**Rational(1,2)
786
+ va
787
+ end
788
+
789
+ for f in Binary_operators_Uop
790
+ eval <<-EOS, nil, __FILE__, __LINE__+1
791
+ def #{f.delete(".")}(other)
792
+ case other
793
+ when VArray, UNumeric
794
+ vl = self.val
795
+ vr = other.val
796
+ if !( vl.is_a?(NArray) and vr.is_a?(NArrayMiss) )
797
+ ary = vl#{f}(vr)
798
+ else
799
+ ary = NArrayMiss.to_nam(vl)#{f}(vr)
800
+ end
801
+ va = VArray.new( ary, self.attr_copy, self.name )
802
+ va.units= self.units#{f}(other.units)
803
+ va
804
+ when Numeric, NArray, NArrayMiss, Array
805
+ vl = self.val
806
+ vr = other
807
+ if !( vl.is_a?(NArray) and vr.is_a?(NArrayMiss) )
808
+ ary = vl#{f}(vr)
809
+ else
810
+ ary = NArrayMiss.to_nam(vl)#{f}(vr)
811
+ end
812
+ va = VArray.new( ary, self.attr_copy, self.name )
813
+ if "#{f}" == "**"
814
+ va.units= self.units#{f}(other)
815
+ end
816
+ va
817
+ else
818
+ c_me, c_other = other.coerce(self)
819
+ c_me#{f}(c_other)
820
+ end
821
+ end
822
+ EOS
823
+ end
824
+ for f in Binary_operators_Uconv
825
+ eval <<-EOS, nil, __FILE__, __LINE__+1
826
+ def #{f.delete(".")}(other)
827
+ case other
828
+ when VArray, UNumeric
829
+ if self.get_att('units')
830
+ # self have non nil units
831
+ oval = other.units.convert2(other.val,self.units)
832
+ uni = self.units
833
+ else
834
+ oval = other.val
835
+ uni = other.units
836
+ end
837
+ vl = self.val
838
+ vr = oval
839
+ if !( vl.is_a?(NArray) and vr.is_a?(NArrayMiss) )
840
+ ary = vl#{f}(vr)
841
+ else
842
+ ary = NArrayMiss.to_nam(vl)#{f}(vr)
843
+ end
844
+ va = VArray.new( ary, self.attr_copy, self.name )
845
+ va.units = uni
846
+ va
847
+ when Numeric, NArray, NArrayMiss, Array
848
+ vl = self.val
849
+ vr = other
850
+ if !( vl.is_a?(NArray) and vr.is_a?(NArrayMiss) )
851
+ ary = vl#{f}(vr)
852
+ else
853
+ ary = NArrayMiss.to_nam(vl)#{f}(vr)
854
+ end
855
+ VArray.new( ary, self.attr_copy, self.name )
856
+ else
857
+ c_me, c_other = other.coerce(self)
858
+ c_me#{f}(c_other)
859
+ end
860
+ end
861
+ EOS
862
+ end
863
+ for f in Binary_operators_Unone
864
+ eval <<-EOS, nil, __FILE__, __LINE__+1
865
+ def #{f.delete(".")}(other)
866
+ case other
867
+ when VArray, UNumeric
868
+ vl = self.val
869
+ vr = other.val
870
+ if !( vl.is_a?(NArray) and vr.is_a?(NArrayMiss) )
871
+ ary = vl#{f}(vr)
872
+ else
873
+ ary = NArrayMiss.to_nam(vl)#{f}(vr)
874
+ end
875
+ VArray.new( ary, self.attr_copy, self.name )
876
+ when Numeric, NArray, NArrayMiss, Array
877
+ vl = self.val
878
+ vr = other
879
+ if !( vl.is_a?(NArray) and vr.is_a?(NArrayMiss) )
880
+ ary = vl#{f}(vr)
881
+ else
882
+ ary = NArrayMiss.to_nam(vl)#{f}(vr)
883
+ end
884
+ VArray.new( ary, self.attr_copy, self.name )
885
+ else
886
+ c_me, c_other = other.coerce(self)
887
+ c_me#{f}(c_other)
888
+ end
889
+ end
890
+ EOS
891
+ end
892
+ for f in Binary_operatorsL_comp
893
+ eval <<-EOS, nil, __FILE__, __LINE__+1
894
+ def #{f.delete(".")}(other)
895
+ # returns NArray
896
+ case other
897
+ when VArray, UNumeric
898
+ self.val#{f}( other.units.convert2(other.val,units) )
899
+ when Numeric, NArray, NArrayMiss, Array
900
+ self.val#{f}(other)
901
+ else
902
+ c_me, c_other = other.coerce(self)
903
+ self#{f}(other)
904
+ end
905
+ end
906
+ EOS
907
+ end
908
+ for f in Binary_operatorsL_other
909
+ eval <<-EOS, nil, __FILE__, __LINE__+1
910
+ def #{f.delete(".")}(other)
911
+ # returns NArray
912
+ case other
913
+ when VArray, UNumeric
914
+ self.val#{f}(other.val)
915
+ when Numeric, NArray, NArrayMiss, Array
916
+ self.val#{f}(other)
917
+ else
918
+ c_me, c_other = other.coerce(self)
919
+ self#{f}(other)
920
+ end
921
+ end
922
+ EOS
923
+ end
924
+ for f in Unary_operators
925
+ eval <<-EOS, nil, __FILE__, __LINE__+1
926
+ def #{f}
927
+ ary = #{f.delete("@")} self.val
928
+ VArray.new( ary, self.attr_copy, self.name )
929
+ end
930
+ EOS
931
+ end
932
+ def +@
933
+ self
934
+ end
935
+ for f in NArray_type1_methods
936
+ eval <<-EOS, nil, __FILE__, __LINE__+1
937
+ def #{f}(*args)
938
+ newattr = self.attr_copy
939
+ newattr['units'] = '1' if "#{f}"=="angle" || "#{f}"=="arg"
940
+ VArray.new(self.val.#{f}(*args), newattr, self.name )
941
+ end
942
+ EOS
943
+ end
944
+ for f in NArray_type2_methods1
945
+ eval <<-EOS, nil, __FILE__, __LINE__+1
946
+ def #{f}(*args)
947
+ self.val.#{f}(*args)
948
+ end
949
+ EOS
950
+ end
951
+ for f in NArray_type2_methods2
952
+ eval <<-EOS, nil, __FILE__, __LINE__+1
953
+ def #{f}
954
+ if @mapping
955
+ @mapping.#{f}
956
+ else
957
+ @ary.#{f}
958
+ end
959
+ end
960
+ EOS
961
+ end
962
+ for f in NArray_type2_methods3
963
+ eval <<-EOS, nil, __FILE__, __LINE__+1
964
+ def #{f}
965
+ if @mapping
966
+ @varray.ary.#{f}
967
+ else
968
+ @ary.#{f}
969
+ end
970
+ end
971
+ EOS
972
+ end
973
+ for f in NArray_type3_methods
974
+ eval <<-EOS, nil, __FILE__, __LINE__+1
975
+ def #{f}(*args)
976
+ result = self.val.#{f}(*args)
977
+ if result.is_a?(NArray) || result.is_a?(NArrayMiss)
978
+ VArray.new(result , self.attr_copy, self.name )
979
+ elsif result.nil?
980
+ result
981
+ else
982
+ UNumeric[result, units] # used to be 'result' (not UNumeric)
983
+ end
984
+ end
985
+ EOS
986
+ end
987
+
988
+ alias shape_current shape
989
+
990
+ ## < private methods >
991
+ private
992
+ def __rubber_expansion( args )
993
+ if (id = args.index(false)) # substitution into id
994
+ # false is incuded
995
+ alen = args.length
996
+ if args.rindex(false) != id
997
+ raise ArguemntError,"only one rubber dimension is permitted"
998
+ elsif alen > rank+1
999
+ raise ArgumentError, "too many args"
1000
+ end
1001
+ ar = ( id!=0 ? args[0..id-1] : [] )
1002
+ args = ar + [true]*(rank-alen+1) + args[id+1..-1]
1003
+ end
1004
+ args
1005
+ end
1006
+ def __check_ary_class(narray)
1007
+ case narray
1008
+ when NArray, NArrayMiss, nil
1009
+ else
1010
+ raise ArgumentError, "Invalid array class: #{narray.class}"
1011
+ end
1012
+ narray
1013
+ end
1014
+ def __check_ary_class2(narray)
1015
+ case narray
1016
+ when NArray, NArrayMiss, nil, Numeric
1017
+ else
1018
+ raise ArgumentError, "Invalid array class: #{narray.class}"
1019
+ end
1020
+ narray
1021
+ end
1022
+ def __ntype(typecode)
1023
+ case typecode
1024
+ when NArray::BYTE
1025
+ "byte"
1026
+ when NArray::SINT
1027
+ "sint"
1028
+ when NArray::LINT
1029
+ "int"
1030
+ when NArray::SFLOAT
1031
+ "sfloat"
1032
+ when NArray::DFLOAT
1033
+ "float"
1034
+ when NArray::SCOMPLEX
1035
+ "scomplex"
1036
+ when NArray::DCOMPLEX
1037
+ "complex"
1038
+ when NArray::ROBJ
1039
+ "obj"
1040
+ end
1041
+ end
1042
+
1043
+ end # class VArray
1044
+
1045
+ end
1046
+
1047
+ ##################################
1048
+ ### < test > ###
1049
+
1050
+ if $0 == __FILE__
1051
+ include NumRu
1052
+ p va = VArray.new( NArray.int(6,2,3).indgen!, nil, 'va' )
1053
+ va.units="m"
1054
+ va.long_name="test data"
1055
+ vs = va[2..4,0,0..1]
1056
+ p "@@@",vs.rank,vs.shape,vs.total,vs.val,vs.get_att("name")
1057
+ p '@@@@',vs.long_name,vs.units.to_s
1058
+ vs.val=999
1059
+ p "*1*",va
1060
+ co,=va.coerce(UNumeric.new(1,Units.new("rad")))
1061
+ p '*coerce*',co, co.units
1062
+ p "*2*",vt = vs/9, vs + vt
1063
+ p "*3*",vt.log10
1064
+ p "*4*",(vt < vs)
1065
+ vt.name='vvvttt'
1066
+ p "*5*",(3+vt), vt.sin, vt.cos
1067
+ vc = vt.copy
1068
+ p 'atan2'
1069
+ vv = VArray.new( NArray.sfloat(5).indgen!, nil, 'vv' )
1070
+ p vv.atan2(vv).val
1071
+ p "eq",vc.eq(vt),vc.equal?(vt)
1072
+
1073
+ vd = VArray.new( NArray.int(6).indgen!+10 )
1074
+ p "+++",vd[1],vd[1].rank,vd[1].val
1075
+ p va.val
1076
+ p vs
1077
+ p va.sort.val
1078
+ p vs.to_a, vs.to_string, vs.to_f, vs.to_type(NArray::SINT)
1079
+ p "@@@",va.max, va.max(0), va.max(0,1)
1080
+
1081
+ vkg = VArray.new( NArray.float(4,3).indgen!, nil, 'vkg' )
1082
+ vkg.units = 'kg'
1083
+ vg = vkg.copy
1084
+ vg.units = 'g'
1085
+ vmul = vkg*vg
1086
+ p '##', vkg.val, vmul.get_att('units'), vmul.units
1087
+ p '##', (vkg + vg).val, (vg + vkg).val, vkg > vg
1088
+
1089
+ p '*convert_units*'
1090
+ p vg.units,vg.val
1091
+ vkg = vg.convert_units('kg')
1092
+ p vkg.units,vkg.val
1093
+
1094
+ p '*axis conventions*'
1095
+ p vx = VArray.new( NArray.int(6).indgen!, nil, 'x' )
1096
+
1097
+ vx.put_att("topology","circular")
1098
+ vx.set_att('modulo',[360.0])
1099
+ vx.set_att('positive','down')
1100
+ p vx.axis_draw_positive, vx.axis_cyclic?, vx.axis_modulo
1101
+
1102
+ p ' cyclic extendible:'
1103
+ p vx.axis_cyclic_extendible?
1104
+ vx.set_att('modulo',[6.0])
1105
+ p vx.axis_cyclic_extendible?
1106
+
1107
+ p '*typecode*'
1108
+ p vx.typecode, vx[0..1].typecode
1109
+ end