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,178 @@
1
+ require 'numru/ggraph'
2
+ require 'numru/gphys/ep_flux'
3
+
4
+ ############################################################
5
+
6
+ =begin
7
+ =module NumRu::GGraph in vector_on_merdional_section.rb
8
+
9
+ This file defines additional method of NumRu::GGraph. This method is for
10
+ drawing vector on merdional sections.
11
+
12
+ ==Index
13
+ * ((<module NumRu::GGraph>))
14
+ * ((<vector_on_merdional_section>))
15
+ Draw vector by selecting the first 2 dimensions
16
+ (with GPhys#first2D) if (({gphys})) is more than 3D.
17
+
18
+ ==Module Functions
19
+
20
+ ---vector_on_merdional_section(fx, fy, newframe=true, options=nil)
21
+ Draw vector by selecting the first 2 dimensions
22
+ (with GPhys#first2D) if (({gphys})) is more than 3D.
23
+
24
+ ARGUMENTS
25
+ * fx (GPhys) : a GPhys whose data is plotted x-componet.
26
+ * fy (GPhys) : a GPhys whose data is plotted y-componet.
27
+ * newframe (true/false) : if true, calls ((<fig>)), ((<axes>)),
28
+ ((<title>)), and ((<annotate>)) internally; if false, only
29
+ the poly-line is drawn (overlaid to the exiting figure).
30
+ * options (Hash) : options to change the default behavior if specified.
31
+ It is a Hash with option names (String) as keys and their values.
32
+ Options are interpreted by a NumRu::Misc::KeywordOptAutoHelp,
33
+ so you can shorten the keys (by omitting tails) as long as it is
34
+ unambiguous.
35
+ option name default value # description:
36
+ "title" nil # Title of the figure(if nil, internally
37
+ # determined)
38
+ "annotate" true # if false, do not put texts on the right
39
+ # margin even when newframe==true
40
+ "transpose" false # if true, exchange x and y axes
41
+ "flow_vect" true # If true, use DCLExt::flow_vect to draw
42
+ # vectors; otherwise, DCL::ugvect is used
43
+ "xintv" 1 # (Effective only if flow_vect) interval
44
+ # sampling in x of data
45
+ "yintv" 1 # (Effective only if flow_vect) interval
46
+ # of data sampling in y
47
+ "factor" 1.0 # (Effective only if flow_vect) scaling
48
+ # factor to strech/reduce the arrow
49
+ # lengths.
50
+ "use_before_scale" #
51
+ false #(Effective only unless flow_vect) If true,
52
+ # use scale factor before vector.
53
+ "unit_vect" false # Show the unit vector
54
+ "max_unit_vect" false # (Effective only if flow_vect &&
55
+ # unit_vect) If true, use the maximum
56
+ # arrows to scale the unit vector;
57
+ # otherwise, normalize in V coordinate.
58
+
59
+ RETURN VALUE
60
+ * nil
61
+
62
+ =end
63
+
64
+ ############################################################
65
+
66
+ module NumRu
67
+
68
+ module GGraph
69
+
70
+ module_function
71
+
72
+ def vector_on_merdional_section(fx, fy, newframe=true, options=nil)
73
+ if ! defined?(@@vector_on_merdional_section_options)
74
+ @@vector_on_merdional_section_options = Misc::KeywordOptAutoHelp.new(
75
+ ['newfig', true, 'if false, do not cleared before figure setting.'],
76
+ ['title', nil, 'Title of the figure(if nil, internally determined)'],
77
+ ['annotate', true, 'if false, do not put texts on the right margin even when newframe==true'],
78
+ ['transpose', false, 'if true, exchange x and y axes'],
79
+ ['flow_vect', true, 'If true, use DCLExt::flow_vect to draw vectors; otherwise, DCL::ugvect is used.'],
80
+ ['xintv', 1, '(Effective only if flow_vect) interval of data sampling in x'],
81
+ ['yintv', 1, '(Effective only if flow_vect) interval of data sampling in y'],
82
+ ['factor', 1.0, '(Effective only if flow_vect) scaling factor to strech/reduce the arrow lengths'],
83
+ ['unit_vect', false, 'Show the unit vector'],
84
+ ['use_before_scale', false, '(Effective only unless flow_vect) If true, use scale factor before vector.'],
85
+ ['max_unit_vect', false, '(Effective only if flow_vect && unit_vect)
86
+ If true, use the maximum arrows to scale the unit vector; otherwise, normalize in V coordinate.']
87
+ )
88
+ end
89
+ opts = @@vector_on_merdional_section_options.interpret(options)
90
+ fx = fx.first2D.copy
91
+ fy = fy.first2D.copy
92
+ sh = fx.shape
93
+ if sh != fy.shape
94
+ raise ArgumentError, "shapes of fx and fy do not agree with each other"
95
+ end
96
+ fx = fx.transpose(1,0) if opts['transpose']
97
+ fy = fy.transpose(1,0) if opts['transpose']
98
+ if ((xi=opts['xintv']) >= 2)
99
+ idx = NArray.int(sh[0]/xi).indgen!*xi # [0,xi,2*xi,..]
100
+ fx = fx[idx, true]
101
+ fy = fy[idx, true]
102
+ end
103
+ if ((yi=opts['xintv']) >= 2)
104
+ idx = NArray.int(sh[1]/yi).indgen!*yi # [0,yi,2*yi,..]
105
+ fx = fx[true, idx]
106
+ fy = fy[true, idx]
107
+ end
108
+ xax = fx.coord(0)
109
+ yax = fy.coord(1)
110
+ aphi_ax, z_ax, was_proportional_to_p = \
111
+ GPhys::EP_Flux::preparate_for_vector_on_merdional_section(xax, yax)
112
+ if was_proportional_to_p
113
+ itr = 2
114
+ else
115
+ itr = 1
116
+ end
117
+ if newframe
118
+ nextfig = @@next_fig.dup if ( @@next_fig != nil ) # backup next_fig
119
+ fig(xax, yax, {'itr'=>itr})
120
+ axes(xax, yax)
121
+ if opts['title']
122
+ ttl = opts['title']
123
+ else
124
+ fxnm = fx.data.get_att('long_name') || fx.name
125
+ fynm = fy.data.get_att('long_name') || fy.name
126
+ ttl = '('+fxnm+','+fynm+')'
127
+ end
128
+ title( ttl )
129
+ annotate(fx.lost_axes) if opts['annotate']
130
+ @@next_fig = nextfig if ( @@next_fig != nil )
131
+ end
132
+ fig(aphi_ax, z_ax, {'new_frame'=>false, 'itr'=>1, 'yreverse'=>false}) \
133
+ if (opts['newfig'])
134
+ DCL.uwsgxa(aphi_ax.val)
135
+ DCL.uwsgya(z_ax.val)
136
+ if opts['flow_vect']
137
+ if opts['use_before_scale']
138
+ vxfxratio = @@uninfo[0]; vxfyratio = @@uninfo[1]
139
+ before=DCLExt.ug_set_params( {'LNRMAL'=>false, 'LMSG'=>false,
140
+ 'XFACT1'=>1.0, 'YFACT1'=>1.0} )
141
+ DCL.ugvect(vxfxratio*fx.val, vxfyratio*fy.val)
142
+ DCLExt.ug_set_params(before)
143
+ if opts['unit_vect']
144
+ if opts['max_unit_vect']
145
+ DCLExt.unit_vect(*@@uninfo)
146
+ else
147
+ DCLExt.unit_vect(*@@uninfo[0..1])
148
+ end
149
+ end
150
+ else
151
+ @@uninfo = DCLExt.flow_vect(fx.val, fy.val, opts['factor'] )
152
+ if opts['unit_vect']
153
+ if opts['max_unit_vect']
154
+ DCLExt.unit_vect(*@@uninfo)
155
+ else
156
+ DCLExt.unit_vect(*@@uninfo[0..1])
157
+ end
158
+ end
159
+ end
160
+ else
161
+ if opts['use_before_scale']
162
+ vxfxratio = @@uninfo[0]; vxfyratio = @@uninfo[1]
163
+ before1=DCLExt.ug_set_params({'lunit'=>true}) if opts['unit_vect']
164
+ before2=DCLExt.ug_set_params( {'LNRMAL'=>false, 'LMSG'=>false,
165
+ 'XFACT1'=>1.0, 'YFACT1'=>1.0} )
166
+ DCL.ugvect(vxfxratio*fx.val, vxfyratio*fy.val)
167
+ DCLExt.ug_set_params(before1) if opts['unit_vect']
168
+ DCLExt.ug_set_params(before2)
169
+ else
170
+ before=DCLExt.ug_set_params({'lunit'=>true}) if opts['unit_vect']
171
+ DCL.ugvect(fx.val, fy.val)
172
+ DCLExt.ug_set_params(before) if opts['unit_vect']
173
+ end
174
+ nil
175
+ end
176
+ end
177
+ end
178
+ end
@@ -0,0 +1,359 @@
1
+ require "narray"
2
+ #require "numru/gphys_ext"
3
+
4
+ module NumRu
5
+
6
+ # = Associated coordinates
7
+ #
8
+ # To use in a Grid in order to support non-rectangular coordnate systems
9
+ #
10
+ class AssocCoords
11
+
12
+ # * assoc_crds : Array of GPhys
13
+ # * axnames : Array of axis names of the original Grid
14
+ #
15
+ def initialize(assoc_crds, axnames)
16
+
17
+ # < argument check >
18
+ if assoc_crds.uniq.length != assoc_crds.length
19
+ raise ArgumentError, "Names are not uniq: #{assoc_crds.inspect}."
20
+ end
21
+ assoc_crds.each do |gp|
22
+ raise(ArgumentError,"Non-GPhys included") if !gp.is_a?(GPhys)
23
+ if axnames.include?(gp.name)
24
+ raise ArgumentError,
25
+ "'#{gp.name}' overwraps an axis name #{axnames.inspect}."
26
+ end
27
+ end
28
+
29
+ # < some internal variables >
30
+
31
+ @assoc_crds = Hash.new
32
+ assoc_crds.each{|gp| @assoc_crds[gp.name] = gp}
33
+ @axnames = axnames.dup
34
+ @lost_assoc_crds = nil
35
+
36
+ # < lengths of original axes >
37
+
38
+ @axlens = Hash.new
39
+ @axnames.each do |nm|
40
+ len = nil
41
+ lens = nil
42
+ assoc_crds.each do |gp|
43
+ if gp.axnames.include?(nm)
44
+ len = gp.axis(nm).length
45
+ if lens && len!=lens
46
+ raise("Inconsistency in assoc coord length for ax #{nm}: #{len} (#{gp.name}) vs #{lens}")
47
+ end
48
+ lens = len
49
+ end
50
+ end
51
+ @axlens[nm] = len # can be nil
52
+ end
53
+
54
+ # < grouping in terms of original-dimension sharing >
55
+ @groups = Hash.new # axnames => assoc coord names
56
+ assoc_crds.each do |gp|
57
+ pushed = false
58
+ @groups.each do | axnames, acnames |
59
+ a = gp.axnames
60
+ if (axnames - a).length < axnames.length # included?
61
+ axnames.concat(a).uniq!
62
+ acnames.push(gp.name)
63
+ pushed = true
64
+ break
65
+ end
66
+ end
67
+ @groups[ gp.axnames ] = [gp.name] if !pushed # new group
68
+ end
69
+
70
+ end
71
+
72
+ attr_reader :assoc_crds, :axnames, :axlens
73
+ protected :assoc_crds, :axnames
74
+
75
+ def merge(other)
76
+ if other.nil?
77
+ self
78
+ else
79
+ ac = self.assoc_crds.merge(other.assoc_crds)
80
+ an = (self.axnames + other.axnames).uniq
81
+ self.class.new(ac,an)
82
+ end
83
+ end
84
+
85
+ def inspect
86
+ "<AssocCoords #{@assoc_crds.collect{|nm,gp| gp.data.inspect}.join("\n\t")}\n\t#{@groups.inspect}>"
87
+ end
88
+
89
+ def copy
90
+ self.class.new( @assoc_crds.values.collect{|gp| gp.copy}, @axnames )
91
+ end
92
+
93
+ def coord(name)
94
+ @assoc_crds[name].data # return a VArray
95
+ end
96
+
97
+ def coord_gphys(name)
98
+ @assoc_crds[name] # return a GPhys
99
+ end
100
+
101
+ def has_coord?(name)
102
+ @assoc_crds.has_key?(name)
103
+ end
104
+
105
+ def coordnames
106
+ @assoc_crds.keys
107
+ end
108
+
109
+ # assoc_crds �Ɋւ�����W�l�x�[�X�̐؂�o�� : ������ Hash �̂�
110
+ def cut(hash)
111
+ cutaxnms = hash.keys
112
+ newcrds = Array.new
113
+ slicer_hash = Hash.new
114
+ @groups.each do |orgaxnms, group|
115
+ ca2 = cutaxnms - group
116
+ if ca2.length < cutaxnms.length
117
+ # Some of cutaxnms are included in group
118
+ # --> Do cutting regarding this group
119
+ crds = Array.new
120
+ crdnms = Array.new
121
+ crdaxexist = Array.new
122
+ masks = Array.new # for NArrayMiss
123
+ cuts = Array.new
124
+ group.each do |nm|
125
+ cutter = hash[nm]
126
+ if !cutter.nil? && cutter!=true && cutter!=(0..-1)
127
+ crdnms.push( nm )
128
+ cuts.push( hash[nm] )
129
+ anms = @assoc_crds[nm].axnames
130
+ crdaxexist.push( NArray.to_na(
131
+ orgaxnms.collect{|a| anms.include?(a) ? 1 : 0} ) )
132
+ v = @assoc_crds[nm].val # ���W�l (NArray or NArrayMiss)
133
+ if v.is_a?(NArrayMiss)
134
+ crds.push(v.to_na)
135
+ masks.push(v.get_mask)
136
+ else
137
+ crds.push(v)
138
+ masks.push(nil)
139
+ end
140
+ end
141
+ end
142
+ cuttype = cuts.collect{|x| x.class}.uniq
143
+ if cuttype.length == 1
144
+ orgaxlens = @axlens.values_at(*orgaxnms)
145
+ if cuttype[0] == Range
146
+ vmins = Array.new
147
+ vmaxs = Array.new
148
+ cuts.each do |range|
149
+ a = range.first
150
+ b = range.last
151
+ if (b<a)
152
+ vmins.push(b)
153
+ vmaxs.push(a)
154
+ else
155
+ vmins.push(a)
156
+ vmaxs.push(b)
157
+ end
158
+ end
159
+ idxs = cut_range(vmins,vmaxs,crds,masks,crdaxexist,orgaxlens)
160
+ elsif cuttype[0] == Numeric
161
+ raise "SORRY! cut_nearest is yet to be implemented."
162
+ idxs = cut_nearest() # YET TO BE IMPLEMENT
163
+ else
164
+ raise ArgumentError, "Not allowed cutting type (#{cuttype[0]})"
165
+ end
166
+ ncrds = group.collect{ |nm|
167
+ gp = @assoc_crds[nm]
168
+ sl = gp.axnames.collect{|anm| idxs[orgaxnms.index(anm)]}
169
+ gp[ *sl ]
170
+ }
171
+ newcrds.concat( ncrds )
172
+ orgaxnms.each_with_index{|nm,i| slicer_hash[nm] = idxs[i]}
173
+ else
174
+ raise "Cutting specification for a group of assoc coords (here, #{group.inspect}) must be uniformly set to either by range or by point -- Cannot mix."
175
+ end
176
+ else
177
+ # None of cutaxnms are included in group --> just copy
178
+ ncrds = group.collect{ |nm| @assoc_crds[nm] }
179
+ newcrds.concat( ncrds )
180
+ end
181
+ cutaxnms = ca2
182
+ break if cutaxnms.length == 0 # cutting finished
183
+ end
184
+ new_assocoords = self.class.new( newcrds, @axnames )
185
+ [ new_assocoords, slicer_hash ]
186
+ end
187
+
188
+ # slicing in terms of the original axes
189
+ #
190
+ def [](*args)
191
+ return self.dup if args.length == 0
192
+
193
+ args = __rubber_expansion( args )
194
+ slicer = Hash.new
195
+ @axnames.each_with_index{|nm,i| slicer[nm] = args[i]}
196
+
197
+ new_assoc_crds = Array.new
198
+ lost_assoc_crds = Array.new
199
+ @assoc_crds.each do |dummy, gp|
200
+ sub = gp[ *( gp.axnames.collect{|nm| slicer[nm] || true} ) ]
201
+ if sub.rank > 0
202
+ new_assoc_crds.push( sub )
203
+ else
204
+ lost_assoc_crds.push( "#{sub.name}=#{sub.val}" )
205
+ end
206
+ end
207
+
208
+ ret = self.class.new( new_assoc_crds, @axnames )
209
+ ret.set_lost_coords( lost_assoc_crds ) if !lost_assoc_crds.empty?
210
+ ret
211
+ end
212
+
213
+ # make a subset with assoc coords related only to axnames
214
+ def subset_having_axnames( axnames )
215
+ acnms = Array.new
216
+ @groups.each do |ks,vs|
217
+ acnms.concat(vs) if ( (ks-axnames).length == 0 ) # all of ks present
218
+ end
219
+ assoc_crds = acnms.collect{|nm| @assoc_crds[nm]}
220
+ self.class.new(assoc_crds, axnames)
221
+ end
222
+
223
+ def set_lost_coords( lost_assoc_crds )
224
+ @lost_assoc_crds = lost_assoc_crds # Array of String
225
+ self
226
+ end
227
+
228
+ def lost_coords
229
+ @lost_assoc_crds.dup
230
+ end
231
+
232
+ def __rubber_expansion( args )
233
+ if (id = args.index(false)) # substitution into id
234
+ # false is incuded
235
+ rank = @axnames.length
236
+ alen = args.length
237
+ if args.rindex(false) != id
238
+ raise ArguemntError,"only one rubber dimension is permitted"
239
+ elsif alen > rank+1
240
+ raise ArgumentError, "too many args"
241
+ end
242
+ ar = ( id!=0 ? args[0..id-1] : [] )
243
+ args = ar + [true]*(rank-alen+1) + args[id+1..-1]
244
+ end
245
+ args
246
+ end
247
+ private :__rubber_expansion
248
+
249
+ end
250
+
251
+ end
252
+
253
+
254
+
255
+ #######################################
256
+ ## < test >
257
+ if $0 == __FILE__
258
+ require "numru/gphys"
259
+ include NumRu
260
+ include NMath
261
+ nx = 10
262
+ ny = 7
263
+ nz = 2
264
+ x = (NArray.sfloat(nx).indgen! + 0.5) * (2*PI/nx)
265
+ y = NArray.sfloat(ny).indgen! * (2*PI/(ny-1))
266
+ z = NArray.sfloat(nz).indgen!
267
+ vx = VArray.new( x ).rename("x")
268
+ vy = VArray.new( y ).rename("y")
269
+ vz = VArray.new( z ).rename("z")
270
+ xax = Axis.new().set_pos(vx)
271
+ yax = Axis.new().set_pos(vy)
272
+ zax = Axis.new().set_pos(vz)
273
+ xygrid = Grid.new(xax, yax)
274
+ xyzgrid = Grid.new(xax, yax, zax)
275
+ p xygrid, xyzgrid
276
+
277
+ sqrt2 = sqrt(2.0)
278
+
279
+ p = NArray.sfloat(nx,ny)
280
+ q = NArray.sfloat(nx,ny)
281
+ for j in 0...ny
282
+ p[true,j] = NArray.sfloat(nx).indgen!(2*j,1)*sqrt2
283
+ q[true,j] = NArray.sfloat(nx).indgen!(2*j,-1)*sqrt2
284
+ end
285
+ vp = VArray.new( p ).rename("p")
286
+ vq = VArray.new( q ).rename("q")
287
+ gp = GPhys.new(xygrid, vp)
288
+ gq = GPhys.new(xygrid, vq)
289
+
290
+ r = NArray.sfloat(nz).indgen! * 2
291
+ vr = VArray.new( r ).rename("r")
292
+ gr = GPhys.new( Grid.new(zax), vr )
293
+
294
+ assoc = AssocCoords.new([gp,gq], xyzgrid.axnames)
295
+ assoc2 = AssocCoords.new([gp,gq,gr], xyzgrid.axnames)
296
+
297
+ print "--- AssocCoord objects ---\n"
298
+ p assoc, assoc2
299
+ p assoc.coordnames
300
+ p assoc.axlens
301
+
302
+ print "\n----- Subsetting by [] -----\n"
303
+
304
+ sa = assoc[0..3,{0..4=>2}]
305
+ p sa.coord('p').val, sa.coord('q').val
306
+ p sa.copy
307
+
308
+ p assoc[1,2].lost_coords
309
+
310
+ print "\n----- Subsetting by cut -----\n"
311
+
312
+ ac,sl = assoc.cut('p'=>4.0..10.0)
313
+ p ac.copy,sl
314
+ ac2,sl = assoc2.cut('p'=>4.0..10.0)
315
+ p ac2.copy,sl
316
+
317
+ print "\n----- GPhys making -----\n"
318
+
319
+ d = sin(x.newdim(1,1)) * cos(y.newdim(0,1)) + z.newdim(0,0)
320
+ vd = VArray.new( d ).rename("d")
321
+ gd = GPhys.new(xyzgrid, vd)
322
+ gd.set_assoc_coords([gp,gq,gr])
323
+ print "GPhys with associated coordinates:\n"
324
+ p gd
325
+
326
+ print "Coordiantes:\n"
327
+ p gd.axnames
328
+ p gd.coordnames
329
+ p gd.coord("p")
330
+
331
+ print "\n--- GPhys Subsetting ---\n"
332
+ p gd[1..2,0,0].copy
333
+ p gd[0,false].first2D
334
+
335
+ p gd.cut('p'=>4.0..10.0, 'z'=>0).copy
336
+
337
+ =begin
338
+ print "\n--- writing in a NetCDF file ---\n"
339
+ file = NetCDF.create("tmp.nc")
340
+ GPhys::IO.write(file,gd)
341
+ file.close
342
+ =end
343
+
344
+ print "\n--- GPhys methods that need proper AssocCoord handling ---\n"
345
+ print "* mean(2)\n"
346
+ p gd.mean(2)
347
+ print "* stddev(0)\n"
348
+ p gd.stddev(0)
349
+ print "* integrate(0)\n"
350
+ p gd.integrate(1)
351
+
352
+ print "\n--- coord_dim ---\n"
353
+ grid = gd.grid_copy
354
+ grid.coordnames.each do |nm|
355
+ print nm, " ", grid.coord_dim_indices(nm).inspect, "\n"
356
+ end
357
+
358
+ end
359
+
@@ -0,0 +1,129 @@
1
+ require "narray"
2
+
3
+ module NumRu
4
+ =begin
5
+ =class Attribute < Hash
6
+ A Hash class compatible with NetCDF attributes.
7
+ * Values are restricted to NetCDFAttr values
8
+ * Keys must be String or Symbol (Symbol is converted into String such that
9
+ they are used interchangeably. E.g., attr[:units] == attr["units"] )
10
+ =end
11
+ class Attribute < Hash
12
+ # privatalize all so that public methods must be set explicitly
13
+ private( *((Hash.instance_methods(false) - Object.new.methods).
14
+ collect{|i| i.intern} - [:[], :default]))
15
+ #":[]" and ":default" should not be private on ruby 1.9.
16
+ #Once they become private, super does not work well.
17
+
18
+ #protected :[], :[]= # to be aliased
19
+ #-> Alias does not work well in this case on ruby 1.9 !!!
20
+ public :each, :each_key, :length, :keys, :delete, :delete_if
21
+ public :has_key?, :include?, :key?, :merge, :update
22
+
23
+ def initialize
24
+ super
25
+ end
26
+
27
+ class << self
28
+ ## < class methods > ##
29
+
30
+ def [](*keyval)
31
+ attr = new
32
+ 0.step(keyval.length-1,2){ |i|
33
+ key,val = keyval[i],keyval[i+1]
34
+ if key.is_a?(Symbol)
35
+ key=key.to_s
36
+ elsif ! key.is_a?(String)
37
+ raise ArgumentError,"Attribute key must be String or Symbol: #{key} -- #{key.class}."
38
+ end
39
+ attr[key]=val
40
+ }
41
+ attr
42
+ end
43
+ end
44
+
45
+ ## < methods > ##
46
+
47
+ def copy(to=nil)
48
+ # deep copy (clone), or addition to "to" if given.
49
+ if to == nil
50
+ to = NumRu::Attribute.new
51
+ end
52
+ self.each{|key, val|
53
+ if(val)
54
+ to[key] = val.clone
55
+ else
56
+ to[key] = val
57
+ end
58
+ }
59
+ to
60
+ end
61
+
62
+ def [](key)
63
+ if key.is_a?(Symbol)
64
+ key = key.to_s
65
+ elsif ! key.is_a?(String)
66
+ raise ArgumentError, "Attribute key must be Symbol or String: #{key} -- #{key.class}."
67
+ end
68
+ if /^[A-Za-z_]\w*$/ !~ key
69
+ raise ArgumentError, "Attribute key must match /^[A-Za-z_]\w*$/"
70
+ end
71
+ super(key)
72
+ end
73
+
74
+ def []=(key, val)
75
+ if _val_allowed?(val)
76
+ if key.is_a?(Symbol)
77
+ key = key.to_s
78
+ elsif ! key.is_a?(String)
79
+ raise ArgumentError, "Attribute key must be Symbol or String: #{key} -- #{key.class}."
80
+ end
81
+ super(key, val)
82
+ else
83
+ raise ArgumentError, "Not allowed as an attribute value: #{val} (String or NArray/Array of numerics are required`)"
84
+ end
85
+ val
86
+ end
87
+
88
+ def rename(key_from, key_to)
89
+ v = self[key_from]
90
+ if v==nil; raise "attribute #{key_from} does not exist"; end
91
+ self[key_to]=v
92
+ self.delete(key_from)
93
+ end
94
+
95
+ ## < private methods > ##
96
+ private
97
+ def _val_allowed?(val)
98
+ # to ensure the compatibility with NetCDFAttr
99
+ begin
100
+ val.is_a?(String) ||
101
+ ## val.is_a?(Numeric) || # disabled 2005/03/25 by horinout
102
+ val.is_a?(NilClass) ||
103
+ ( ( (val.is_a?(NArray) && val.rank==1) ||
104
+ (val.is_a?(Array) && val=NArray.to_na(val)) ) &&
105
+ val.typecode <= NArray::DFLOAT )
106
+ rescue
107
+ # for possible error in val=NArray.to_na(val)) above
108
+ false
109
+ end
110
+ end
111
+ end
112
+ end
113
+
114
+ if __FILE__ == $0
115
+ a = NumRu::Attribute.new
116
+ p a
117
+ a["name"]="takeshi"
118
+ p a
119
+ b = @attr = NumRu::Attribute[:name2,"var", :units,"m/s", :valid_range,nil]
120
+ p b[:units]
121
+ p b["units"]
122
+ p b
123
+ p b["allowd"] = [1,10]
124
+ begin
125
+ b["not_allowd"] = [1,10,'no, no']
126
+ rescue
127
+ print "(OK): exception raised as expected\n"
128
+ end
129
+ end