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,154 @@
1
+ require "numru/gphys"
2
+
3
+ module NumRu
4
+ module GAnalysis
5
+
6
+ module_function
7
+
8
+ def covariance(gphys0, gphys1, *dims)
9
+ unless GPhys===gphys0 && GPhys===gphys1
10
+ raise "gphys0 and gphys1 must be GPhys"
11
+ end
12
+ unless gphys0.shape == gphys1.shape
13
+ raise "gphys0 and gphys1 must have the same shape"
14
+ end
15
+ units = gphys0.units*gphys1.units
16
+ if dims.length == 0
17
+ dims = Array.new
18
+ gphys0.rank.times{|i| dims.push i }
19
+ else
20
+ dims = dims.map{|dim| gphys0.dim_index(dim) }
21
+ end
22
+ val0 = gphys0.val
23
+ val1 = gphys1.val
24
+ if val0.is_a?(NArrayMiss)
25
+ if val1.is_a?(NArrayMiss)
26
+ mask = val0.get_mask * val1.get_mask
27
+ ndiv = mask.to_type(NArray::LINT).accum(*dims)
28
+ val0 = val0.set_mask(mask)
29
+ val1 = val1.set_mask(mask)
30
+ else
31
+ ndiv = val0.get_mask.to_type(NArray::LINT).accum(*dims)
32
+ val1 = NArrayMiss.to_nam(val1,val0.get_mask)
33
+ end
34
+ elsif val1.is_a?(NArrayMiss)
35
+ ndiv = val1.get_mask.to_type(NArray::LINT).accum(*dims)
36
+ val0 = NArrayMiss.to_nam(val0,val1.get_mask)
37
+ else
38
+ ndiv = 1
39
+ gphys0.shape.each_with_index{|s,i|
40
+ ndiv *= s if dims.include?(i)
41
+ }
42
+ end
43
+ val0 -= val0.accum(*dims).div!(ndiv)
44
+ val1 -= val1.accum(*dims).div!(ndiv)
45
+ nary = val0.mul_add(val1,*dims)
46
+ if Float === nary
47
+ ndiv = ndiv[0] if ndiv.is_a?(NArray)
48
+ nary /= (ndiv-1)
49
+ return UNumeric.new(nary, units), ndiv
50
+ else
51
+ nary.div!(ndiv-1)
52
+ vary = VArray.new(nary,
53
+ {"long_name"=>"covariance","units"=>units.to_s},
54
+ "covariance")
55
+ new_grid = gphys0.grid.delete_axes(dims, "covariance").copy
56
+ return GPhys.new(new_grid,vary), ndiv
57
+ end
58
+ end
59
+
60
+ def corelation(gphys0, gphys1, *dims)
61
+ val0 = gphys0.val
62
+ val1 = gphys1.val
63
+ if val0.is_a?(NArrayMiss)
64
+ mask = val0.get_mask
65
+ else
66
+ mask = NArray.byte(*(val0.shape)).fill!(1)
67
+ end
68
+ if val1.is_a?(NArrayMiss)
69
+ mask2 = val1.get_mask
70
+ else
71
+ mask2 = NArray.byte(*(val1.shape)).fill!(1)
72
+ end
73
+ mask.mul!(mask2)
74
+ val0 = NArrayMiss.to_nam(val0) unless val0.is_a?(NArrayMiss)
75
+ val1 = NArrayMiss.to_nam(val1) unless val1.is_a?(NArrayMiss)
76
+ val0 = val0.set_mask(mask)
77
+ val1 = val1.set_mask(mask)
78
+ p val0,val1 if $DEBUG
79
+ gphys0 = gphys0.copy.replace_val(val0)
80
+ gphys1 = gphys1.copy.replace_val(val1)
81
+
82
+ covariance, ndiv = gphys0.covariance(gphys1,*dims)
83
+ return covariance/(gphys0.stddev(*dims)*gphys1.stddev(*dims)), mask.to_type(NArray::LINT).sum(*dims)
84
+ end
85
+ alias correlation corelation
86
+ end
87
+
88
+ class GPhys
89
+ def covariance(other, *dims)
90
+ GAnalysis.covariance(self, other, *dims)
91
+ end
92
+
93
+ def corelation(other, *dims)
94
+ GAnalysis.corelation(self, other, *dims)
95
+ end
96
+ alias correlation corelation
97
+ end
98
+ end
99
+
100
+ if $0 == __FILE__
101
+ require "numru/ggraph"
102
+ include NumRu
103
+
104
+ # TEST DATA WITHOUT MISSING VALUE
105
+ p x = NArray[1.0, 2.0, 4.0, 8.0, 9.0, 10.0]
106
+ p y = NArray[1.0, 2.0, 4.0, 8.0, 9.0, 10.0]
107
+
108
+ vx = VArray.new(x, {}, "x")
109
+ vy = VArray.new(y, {}, "y")
110
+ i = VArray.new(NArray.int(6).indgen!, {}, "i")
111
+ ai = Axis.new.set_pos(i)
112
+ gi = Grid.new(ai)
113
+
114
+ p gx = GPhys.new(gi, vx)
115
+ p gy = GPhys.new(gi, vy)
116
+
117
+ corr_true, n = gx.correlation(gy)
118
+ covar_true, m = gx.covariance(gy)
119
+
120
+ puts "Test of GPhys::correlation"
121
+ puts "gx.correlation(gy) = #{corr_true.val}, num of samples = #{n}"
122
+
123
+ puts "Test of GPhys::covariance"
124
+ puts "gx.covariance(gy) = #{covar_true.val}, num of samples = #{m}"
125
+
126
+ # TEST DATA WITH MISSING VALUE
127
+ x = NArray[1.0, 2.0, 2.9, 4.0, 4.9, -99, -99, 8.0, 9.0, 10.0]
128
+ y = NArray[1.0, 2.0, -99, 4.0, -99, 6.1, -99, 8.0, 9.0, 10.0]
129
+
130
+ p x = NArrayMiss.to_nam_no_dup(x,x.gt(-99))
131
+ p y = NArrayMiss.to_nam_no_dup(y,y.gt(-99))
132
+
133
+ vx = VArray.new(x, {}, "x")
134
+ vy = VArray.new(y, {}, "y")
135
+ i = VArray.new(NArray.int(10).indgen!, {}, "i")
136
+ ai = Axis.new.set_pos(i)
137
+ gi = Grid.new(ai)
138
+
139
+ p gx = GPhys.new(gi, vx)
140
+ p gy = GPhys.new(gi, vy)
141
+
142
+ corr, n2 = gx.correlation(gy)
143
+ covar, m2 = gx.covariance(gy)
144
+
145
+ puts "Test of GPhys::correlation"
146
+ puts "gx.correlation(gy) must be #{corr_true.val}"
147
+ puts "gx.correlation(gy) = #{corr.val}, num of samples = #{n2}"
148
+
149
+ puts "Test of GPhys::covariance"
150
+ puts "gx.covariance(gy) must be #{covar_true.val}"
151
+ puts "gx.covariance(gy) = #{covar.val}, num of smaples = #{m2}"
152
+
153
+ end
154
+
@@ -0,0 +1,298 @@
1
+ require "numru/gphys"
2
+
3
+ module NumRu
4
+ module GAnalysis
5
+
6
+ begin
7
+ require "numru/ssl2"
8
+ @@EOF_engin = "ssl2"
9
+ rescue LoadError
10
+ begin
11
+ require "numru/lapack"
12
+ @@EOF_engin = "lapack"
13
+ rescue LoadError
14
+ begin
15
+ require "gsl"
16
+ @@EOF_engin = "gsl"
17
+ rescue LoadError
18
+ end
19
+ end
20
+ end
21
+
22
+ print "EOF engin is #{@@EOF_engin}\n" if $DEBUG
23
+
24
+ module_function
25
+
26
+ # = Calculate EOF vectors and contribution rate
27
+ # call-seq:
28
+ # NumRu::GAnalysis.eof(gphys, dim0[, dim1, ..., dimN[, opts]]) => [eof, rate]
29
+ #
30
+ # == Arguments
31
+ # +gphys+:: GPhys object to be calculated its EOF
32
+ # +dim0+, ..., +dimN+:: dimension name (String) or number (Ingeter) to calculate variance or covariance, and those dimensions are not contained in the result EOF vectors.
33
+ # +opts+:: a Hash object whose key is String or Symbol. The following options are available:
34
+ # * nmodes: Integer, number of EOF modes to be calculate (default all EOF modes)
35
+ # * weight: GPhys or NArray, weight vector
36
+ # +gphys+ is multiplied by the weight vector before calculation of variance covariance matrix
37
+ # and the result eigen vectors are divided by the vector.
38
+ # If weight vector is not set,
39
+ # it is cosine of latitude when the first two axes of the +gphys+ are "lon" and "lat" and +disable_weight+ option is not +true+,
40
+ # else 1.
41
+ # * disable_weight: See weight option.
42
+ #
43
+ # == Return values
44
+ # +eof+:: GPhys object for array of EOF vectors.
45
+ # +rate+:: GPhys object for array of contribution rate correspoinding to the EOF vectors.
46
+ def eof(gphys, *args)
47
+
48
+ unless defined?(@@EOF_engin)
49
+ raise "SSL2 (Ruby-SSL2) or LAPACK (Ruby-LAPACK) or GSL (Ruby/GSL) must have been installed. (SSL2 or LAPACK is recommended for large computation)"
50
+ end
51
+
52
+ if Hash === args[-1]
53
+ dims = args[0..-2]
54
+ opts = args[-1]
55
+ else
56
+ dims = args
57
+ opts = Hash.new
58
+ end
59
+ dims = dims.map{|dim| gphys.dim_index(dim) }
60
+ n = 1
61
+ n_lost = 1
62
+ dims1 = Array.new
63
+ shape1 = Array.new
64
+ gphys.shape.each_with_index{|s,i|
65
+ if dims.include?(i)
66
+ n_lost *= s
67
+ else
68
+ n *= s
69
+ dims1.push i
70
+ shape1.push s
71
+ end
72
+ }
73
+ new_grid = gphys.instance_variable_get("@grid").delete_axes(dims, "covariance matrix").copy
74
+ new_index = NArray.sint(*new_grid.shape).indgen
75
+ index = NArray.object(gphys.rank)
76
+ index[dims] = true
77
+
78
+ if w = (opts[:weight] || opts["weight"])
79
+ if GPhys === w
80
+ w = w.val
81
+ end
82
+ unless NArray === w
83
+ raise "weight must be NArray of GPhys"
84
+ end
85
+ unless w.shape == new_grid.shape
86
+ raise "shape of weight is invalid"
87
+ end
88
+ w /= w.mean
89
+ w.reshape!(n)
90
+ else
91
+ if !(opts[:disable_weight]||opts["disable_weight"]) && /^lon/ =~ new_grid.coord(0).name && /^lat/ =~ new_grid.coord(1).name
92
+ rad = NumRu::Units.new("radian")
93
+ nlon = new_grid.coord(0).length
94
+ lat = new_grid.coord(1).convert_units(rad).val
95
+ w = NArray.new(lat.typecode,nlon).fill!(1) * NMath::cos(lat).reshape(1,lat.length)
96
+ w /= w.mean
97
+ w.reshape!(n)
98
+ else
99
+ w = nil
100
+ end
101
+ end
102
+
103
+ ary = NArrayMiss.new(gphys.typecode, n_lost, n)
104
+ ind_rank = dims1.length
105
+ ind = Array.new(ind_rank,0)
106
+ n.times{|n1|
107
+ index[dims1] = ind
108
+ val = gphys[*index].val
109
+ val.reshape!(n_lost)
110
+ val -= val.mean
111
+ ary[true,n1] = val
112
+ break if n1==n-1
113
+ ind[0] += 1
114
+ ind_rank.times{|i|
115
+ if ind[i] == shape1[i]
116
+ ind[i] = 0
117
+ ind[i+1] += 1
118
+ else
119
+ break
120
+ end
121
+ }
122
+ }
123
+ ary.mul!(w.reshape(1,n)) if w
124
+
125
+
126
+ nmodes = opts[:nmodes] || opts["nmodes"] || n
127
+ case @@EOF_engin
128
+ when "ssl2"
129
+ print "start calc covariance matrix\n" if $DEBUG
130
+ nary = NArray.new(gphys.typecode,n*(n+1)/2)
131
+ nn = 0
132
+ total_var = 0
133
+ n.times{|n0|
134
+ for n1 in n0...n
135
+ nary[nn] = ary[n0].mul_add(ary[n1],0)/(n_lost-1)
136
+ if n1==n0
137
+ total_var += nary[nn]
138
+ end
139
+ nn += 1
140
+ end
141
+ }
142
+ ary = nil # for GC
143
+ print "start calc eigen vector\n" if $DEBUG
144
+ val, vec = SSL2.seig2(nary,nmodes)
145
+ when "lapack"
146
+ print "start calc covariance matrix\n" if $DEBUG
147
+ nary = NArray.new(gphys.typecode,n,n)
148
+ total_var = 0.0
149
+ n.times{|n0|
150
+ nary[n0...n,n0] = (ary[true,n0...n].mul_add(ary[true,n0],0)/(n_lost-1)).get_array!
151
+ total_var += nary[n0,n0]
152
+ }
153
+ ary = nil # for GC
154
+ print "start calc eigen vector\n" if $DEBUG
155
+ case nary.typecode
156
+ when NArray::DFLOAT
157
+ m, val, vec, isuppz, work, iwork, info, = NumRu::Lapack.dsyevr("V", "I", "L", nary, 0, 0, n-nmodes+1, n, 0.0, -1, -1)
158
+ m, val, vec, = NumRu::Lapack.dsyevr("V", "I", "L", nary, 0, 0, n-nmodes+1, n, 0.0, work[0], iwork[0])
159
+ when NArray::SFLOAT
160
+ m, val, vec, isuppz, work, iwork, info, = NumRu::Lapack.ssyevr("V", "I", "L", nary, 0, 0, n-nmodes+1, n, 0.0, -1, -1)
161
+ m, val, vec, = NumRu::Lapack.ssyevr("V", "I", "L", nary, 0, 0, n-nmodes+1, n, 0.0, work[0], iwork[0])
162
+ end
163
+ val = val[-1..0]
164
+ vec = vec[true,-1..0]
165
+ when "gsl"
166
+ print "start calc covariance matrix\n" if $DEBUG
167
+ nary = NArray.new(gphys.typecode,n,n)
168
+ n.times{|n0|
169
+ nary[n0...n,n0] = (ary[true,n0...n].mul_add(ary[true,n0],0)/(n_lost-1)).get_array!
170
+ nary[n0,n0...n] = nary[n0...n,n0]
171
+ }
172
+ ary = nil # for GC
173
+ print "start calc eigen vector\n" if $DEBUG
174
+ val, vec = GSL::Eigen::symmv(nary.to_gm)
175
+ GSL::Eigen.symmv_sort(val, vec, GSL::Eigen::SORT_VAL_DESC)
176
+ vec = vec.to_na[0...nmodes,true].transpose(1,0)
177
+ val = val.to_na
178
+ total_var = val.sum
179
+ val = val[0...nmodes]
180
+ end
181
+
182
+ axes = new_grid.instance_variable_get('@axes')
183
+ axis_order = Axis.new
184
+ axis_order.pos = VArray.new(NArray.sint(nmodes).indgen(1),
185
+ {}, "mode")
186
+ axes << axis_order
187
+ new_grid = Grid.new(*axes)
188
+ vec /= w if w
189
+ vec.reshape!(*new_grid.shape)
190
+ vec *= NMath::sqrt( val.reshape( *([1]*(axes.length-1)+[nmodes]) ) )
191
+ va_eof = VArray.new(vec,
192
+ {"long_name"=>"EOF vector","units"=>gphys.units.to_s },
193
+ "EOF")
194
+ eof = GPhys.new(new_grid, va_eof)
195
+
196
+ va_rate = VArray.new(val.div!(total_var),
197
+ {"long_name"=>"EOF contribution rate", "units"=>"1" },
198
+ "rate")
199
+ rate = GPhys.new(Grid.new(axis_order), va_rate)
200
+
201
+ return [eof, rate]
202
+ end
203
+
204
+ def eof2(gphys1, gphys2, *args)
205
+ if Hash === args[-1]
206
+ opts = args[-1]
207
+ else
208
+ opts = Hash.new
209
+ end
210
+ raise ArgumentError, "The 1st arg must be a GPhys of rank 1: arg1 = #{gphys1.inspect}" unless gphys1.rank==1
211
+ raise ArgumentError, "The 2nd arg must be a GPhys of rank 1: arg2 = #{gphys2.inspect}" unless gphys2.rank==1
212
+ raise ArgumentError, "The 1st and 2nd args must have the same length: #{gphys1.length}!=#{gphys2.length}" unless gphys2.rank==1
213
+ nam = NArrayMiss.new(gphys1.typecode, 2, gphys1.length)
214
+ nam[0,true] = gphys1.val
215
+ nam[1,true] = gphys2.val
216
+ gphys = GPhys.new(Grid.new(Axis.new.set_pos(VArray.new(NArray[0,1],{},"var")),
217
+ gphys1.axis(0)),
218
+ VArray.new(nam,gphys1.data.attr_copy,gphys1.name))
219
+ eof(gphys, 1, opts)
220
+ end
221
+ end
222
+
223
+ class GPhys
224
+ def eof(*args)
225
+ GAnalysis.eof(self, *args)
226
+ end
227
+ end
228
+
229
+ end
230
+
231
+
232
+ #:enddoc
233
+
234
+ if $0 == __FILE__
235
+ require "numru/ggraph"
236
+ include NumRu
237
+ N = 10000
238
+ x = NArray.float(N).randomn!*2
239
+ y = NArray.float(N).randomn!*1
240
+ ary = NArray.float(2,N)
241
+ theta = Math::PI/6
242
+ ary[0,true] = x*Math::cos(theta)-y*Math::sin(theta)
243
+ ary[1,true] = x*Math::sin(theta)+y*Math::cos(theta)
244
+ vary = VArray.new(ary, { }, "test")
245
+ axis0 = Axis.new
246
+ axis0.pos = VArray.new(NArray[0,1], {}, "dimensions")
247
+ axis1 = Axis.new
248
+ axis1.pos = VArray.new(NArray.sint(N).indgen, {}, "t")
249
+ gphys = GPhys.new(Grid.new(axis0,axis1), vary)
250
+
251
+ eof,rate = gphys.eof("t")
252
+
253
+ max = 5
254
+ DCL::gropn(4)
255
+ DCL::grfrm
256
+ DCL::grsvpt(0.1,0.9,0.1,0.9)
257
+ DCL::grswnd(-max,max,-max,max)
258
+ DCL::grstrn(1)
259
+ DCL::grstrf
260
+
261
+ DCL::sgpmzu(ary[0,true],ary[1,true],1,1,0.01)
262
+
263
+ eof1 = eof[true,0].val
264
+ eof2 = eof[true,1].val
265
+ DCL::sgplzu([eof1[0],-eof1[0]],[eof1[1],-eof1[1]], 1, 23)
266
+ DCL::sgplzu([eof2[0],-eof2[0]],[eof2[1],-eof2[1]], 1, 43)
267
+
268
+ DCL::usdaxs
269
+ DCL::uxsttl("T","test of GAnalysis::eof",0)
270
+
271
+ # TEST OF GAnalysis::eof2
272
+
273
+ vary1 = VArray.new(ary[0,true], { }, "test")
274
+ gphys1 = GPhys.new(Grid.new(axis1), vary1)
275
+ vary2 = VArray.new(ary[1,true], { }, "test")
276
+ gphys2 = GPhys.new(Grid.new(axis1), vary2)
277
+
278
+ eof,rate = GAnalysis.eof2(gphys1,gphys2)
279
+
280
+ max = 5
281
+ DCL::grfrm
282
+ DCL::grsvpt(0.1,0.9,0.1,0.9)
283
+ DCL::grswnd(-max,max,-max,max)
284
+ DCL::grstrn(1)
285
+ DCL::grstrf
286
+
287
+ DCL::sgpmzu(ary[0,true],ary[1,true],1,1,0.01)
288
+
289
+ eof1 = eof[true,0].val
290
+ eof2 = eof[true,1].val
291
+ DCL::sgplzu([eof1[0],-eof1[0]],[eof1[1],-eof1[1]], 1, 23)
292
+ DCL::sgplzu([eof2[0],-eof2[0]],[eof2[1],-eof2[1]], 1, 43)
293
+
294
+ DCL::usdaxs
295
+ DCL::uxsttl("T","test of GAnalysis::eof2",0)
296
+
297
+ DCL::grcls
298
+ end
@@ -0,0 +1,252 @@
1
+ require "numru/gphys"
2
+ require "numru/ggraph"
3
+ module NumRu
4
+ module GAnalysis
5
+
6
+ begin
7
+ require "gsl"
8
+ HistogramGSL = true
9
+ rescue LoadError
10
+ HistogramGSL = false
11
+ end
12
+
13
+ module_function
14
+
15
+ def histogram(gphys0,opts=Hash.new)
16
+ unless HistogramGSL
17
+ raise "gsl is necessary to use this method"
18
+ end
19
+ unless GPhys === gphys0
20
+ raise "gphys0 (1st arg) must be GPhys"
21
+ end
22
+ unless Hash === opts
23
+ raise "opts (2nd arg) must be Hash"
24
+ end
25
+ if opts["bins"]
26
+ bins = opts["bins"]
27
+ unless (bins.is_a?(NArray) || bins.is_a?(Array))
28
+ raise(TypeError, "option 'bins' must be Array or NArray")
29
+ end
30
+ bins = bins.to_gslv if bins.is_a?(NArray)
31
+ hist = GSL::Histogram.alloc(bins)
32
+ else
33
+ nbins = opts["nbins"] || gphys0.total/500
34
+ nbins = 10 if nbins < 10
35
+ min = opts["min"] || gphys0.min.val
36
+ max = opts["max"] || gphys0.max.val
37
+ hist = GSL::Histogram.alloc(nbins,[min,max])
38
+ end
39
+ val = gphys0.val
40
+ val = val.get_array![val.get_mask!] if NArrayMiss === val
41
+ hist.increment(val)
42
+
43
+ bounds = hist.range.to_na
44
+ center = (bounds[0..-2]+bounds[1..-1])/2
45
+ name = gphys0.name
46
+ attr = gphys0.data.attr_copy
47
+ bounds = VArray.new(bounds, attr, name)
48
+ center = VArray.new(center, attr, name)
49
+ axis = Axis.new(true)
50
+ axis.set_cell(center, bounds, name)
51
+ axis.set_pos_to_center
52
+
53
+ bin = hist.bin.to_na
54
+ bin = VArray.new(bin,
55
+ {"long_name"=>"number in bins", "units"=>"1"},
56
+ "bin")
57
+ new_gphys = GPhys.new(Grid.new(axis), bin)
58
+ new_gphys.set_att("mean",[hist.mean])
59
+ new_gphys.set_att("standard_deviation",[hist.sigma])
60
+ return new_gphys
61
+ end
62
+ alias :histogram1D :histogram
63
+
64
+ def histogram2D(gphys0, gphys1, opts=Hash.new)
65
+ unless HistogramGSL
66
+ raise "gsl is necessary to use this method"
67
+ end
68
+ unless GPhys === gphys0
69
+ raise "gphys0 (1st arg) must be GPhys"
70
+ end
71
+ unless GPhys === gphys1
72
+ raise "gphys1 (2nd arg) must be GPhys"
73
+ end
74
+ unless Hash === opts
75
+ raise "opts (3nd arg) must be Hash"
76
+ end
77
+
78
+ nbins0 = opts["nbins0"] || gphys0.total/500
79
+ nbins0 = 10 if nbins0 < 10
80
+ nbins1 = opts["nbins1"] || gphys1.total/500
81
+ nbins1 = 10 if nbins1 < 10
82
+
83
+ min0 = opts["min0"] || gphys0.min.val
84
+ max0 = opts["max0"] || gphys0.max.val
85
+ min1 = opts["min1"] || gphys1.min.val
86
+ max1 = opts["max1"] || gphys1.max.val
87
+
88
+ hist = GSL::Histogram2d.alloc(nbins0,[min0,max0],nbins1,[min1,max1])
89
+ val0 = gphys0.val
90
+ val1 = gphys1.val
91
+ mask = nil
92
+ if NArrayMiss === val0
93
+ mask = val0.get_mask!
94
+ val0 = val0.get_array!
95
+ end
96
+ if NArrayMiss === val1
97
+ if mask
98
+ mask = mask & val1.get_mask!
99
+ else
100
+ mask = val1.get_mask!
101
+ end
102
+ val1 = val1.get_array!
103
+ end
104
+ if mask
105
+ val0 = val0[mask]
106
+ val1 = val1[mask]
107
+ end
108
+ hist.increment(val0.to_gslv, val1.to_gslv)
109
+
110
+ bounds0 = hist.xrange.to_na
111
+ center0 = (bounds0[0..-2]+bounds0[1..-1])/2
112
+ name = gphys0.name
113
+ attr = gphys0.data.attr_copy
114
+ bounds0 = VArray.new(bounds0, attr, name)
115
+ center0 = VArray.new(center0, attr, name)
116
+ axis0 = Axis.new(true)
117
+ axis0.set_cell(center0, bounds0, name)
118
+ axis0.set_pos_to_center
119
+
120
+ bounds1 = hist.yrange.to_na
121
+ center1 = (bounds1[0..-2]+bounds1[1..-1])/2
122
+ name = gphys1.name
123
+ attr = gphys1.data.attr_copy
124
+ bounds1 = VArray.new(bounds1, attr, name)
125
+ center1 = VArray.new(center1, attr, name)
126
+ axis1 = Axis.new(true)
127
+ axis1.set_cell(center1, bounds1, name)
128
+ axis1.set_pos_to_center
129
+
130
+ bin = hist.bin.to_na.reshape!(nbins1,nbins0).transpose(1,0)
131
+ bin = VArray.new(bin,
132
+ {"long_name"=>"number in bins", "units"=>"1"},
133
+ "bin")
134
+ new_gphys = GPhys.new(Grid.new(axis0,axis1), bin)
135
+ new_gphys.set_att("mean0",[hist.xmean])
136
+ new_gphys.set_att("standard_deviation0",[hist.xsigma])
137
+ new_gphys.set_att("mean1",[hist.ymean])
138
+ new_gphys.set_att("standard_deviation1",[hist.ysigma])
139
+ new_gphys.set_att("covariance",[hist.cov])
140
+ return new_gphys
141
+ end
142
+
143
+
144
+ end
145
+
146
+ class GPhys
147
+ def histogram(opts=Hash.new)
148
+ GAnalysis.histogram(self, opts)
149
+ end
150
+ alias :histogram1D :histogram
151
+ end
152
+
153
+ module GGraph
154
+ module_function
155
+
156
+ @@histogram_options = Misc::KeywordOptAutoHelp.new(
157
+ ['window', [nil,nil,0,nil], "window bounds"],
158
+ ['title', "histogram", "window title"],
159
+ ['exchange', false, "exchange x and y"],
160
+ ['fill', false, "fill bars"]
161
+ )
162
+ def histogram(gphys, newframe=true, options=nil)
163
+ gropn_1_if_not_yet
164
+ if newframe!=true && newframe!=false
165
+ raise ArgumentError, "2nd arg (newframe) must be true of false"
166
+ end
167
+ unless gphys.rank == 1
168
+ raise ArgumentError, "rank of gphys must be 1"
169
+ end
170
+ unless gphys.axis(0).cell?
171
+ raise ArgumentError, "axis must be cell type"
172
+ end
173
+ opts = @@histogram_options.interpret(options)
174
+ exchange = opts["exchange"]
175
+ unless exchange
176
+ x = gphys.axis(0).cell_bounds
177
+ y = gphys
178
+ else
179
+ y = gphys.axis(0).cell_bounds
180
+ x = gphys
181
+ end
182
+ if newframe
183
+ fig(x, y, "window"=>opts["window"])
184
+ axes(x, y, "title"=>opts["title"])
185
+ end
186
+ unless exchange
187
+ if opts["fill"]
188
+ DCL::uvbxa(x.val, [0]*y.length, y.val)
189
+ end
190
+ DCL::uvbxf(x.val, [0]*y.length, y.val)
191
+ else
192
+ if opts["fill"]
193
+ DCL::uhbxa([0]*x.length, x.val, y.val)
194
+ end
195
+ DCL::uhbxf([0]*x.length, x.val, y.val)
196
+ end
197
+ return nil
198
+ end
199
+ alias :histogram1D :histogram
200
+
201
+ end
202
+
203
+ end
204
+
205
+
206
+
207
+ if $0 == __FILE__
208
+ include NumRu
209
+
210
+ npoints = 10000
211
+ rng = GSL::Rng.alloc
212
+
213
+ vary = VArray.new(rng.weibull(1,2,npoints).to_na,
214
+ {"long_name"=>"wind speed", "units"=>"m/s"},
215
+ "u")
216
+ axis = Axis.new
217
+ axis.pos = VArray.new(NArray.sint(npoints),
218
+ {"long_name"=>"points"},
219
+ "points")
220
+ gphys1D = GPhys.new(Grid.new(axis), vary)
221
+
222
+ npoints = 100000
223
+ na0 = rng.weibull(1,2,npoints).to_na
224
+ na1 = rng.gaussian(0.5,npoints).to_na
225
+ theta = Math::PI/6
226
+ vary0 = VArray.new(na0*Math.cos(theta)-na1*Math.sin(theta),
227
+ {"long_name"=>"zonal wind speed", "units"=>"m/s"},
228
+ "u")
229
+ vary1 = VArray.new(na0*Math.sin(theta)+na1*Math.cos(theta),
230
+ {"long_name"=>"meridional wind speed", "units"=>"m/s"},
231
+ "v")
232
+ axis = Axis.new
233
+ axis.pos = VArray.new(NArray.sint(npoints),
234
+ {"long_name"=>"points"},
235
+ "points")
236
+ gphys2D_0 = GPhys.new(Grid.new(axis), vary0)
237
+ gphys2D_1 = GPhys.new(Grid.new(axis), vary1)
238
+
239
+ DCL::gropn(4)
240
+
241
+ hist = GAnalysis.histogram(gphys1D)
242
+ GGraph.histogram(hist)
243
+
244
+ hist = gphys1D.histogram("nbins"=>10)
245
+ GGraph.histogram(hist, true, "title"=>"histogram 1D")
246
+
247
+ hist = GAnalysis.histogram2D(gphys2D_0, gphys2D_1, "nbins0"=>50)
248
+ GGraph.tone(hist, true, "tonc"=>true)
249
+
250
+
251
+ DCL::grcls
252
+ end