gphys 1.1.1a

Sign up to get free protection for your applications and to get access to all the features.
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,220 @@
1
+ require "numru/dcl"
2
+ require "numru/misc"
3
+ require "date" # needs ruby >= 1.8 for DateTime class
4
+
5
+
6
+ module NumRu
7
+ module DCLExt
8
+
9
+ module_function
10
+
11
+ @@datetime_ax_options = Misc::KeywordOptAutoHelp.new(
12
+ ['yax', false, 'true => y-axis, false => x-axis'],
13
+ ['cside', nil, '"b", "t", "l", "r", nil (=>left/bottom), or false (=>right/top)'],
14
+ ['dtick1', 1, 'small tick interval in hours'],
15
+ ['dtick2', nil, 'large tick (with hour labels) interval in hours'],
16
+ ['year', false, 'true => add year to date label'],
17
+ ['month', true, 'true => add month to date label']
18
+ )
19
+
20
+ def datetime_ax(date_from, date_to, options=nil)
21
+ # date_from [a DateTime] : start on this date&time
22
+ # date_to [a DateTime] : end on this date&time
23
+
24
+ opt = @@datetime_ax_options.interpret(options)
25
+
26
+ yax = opt['yax']
27
+ xax = !yax
28
+ if xax
29
+ xy='x'
30
+ else
31
+ xy='y'
32
+ end
33
+
34
+ if opt['cside']
35
+ cside = opt['cside']
36
+ elsif opt['cside'].nil?
37
+ if xax
38
+ cside='b'
39
+ else
40
+ cside='l'
41
+ end
42
+ else
43
+ if xax
44
+ cside='t'
45
+ else
46
+ cside='r'
47
+ end
48
+ end
49
+
50
+ if opt['year']
51
+ datefmt = '%Y/%m/%d'
52
+ elsif opt['month']
53
+ datefmt = '%m/%d'
54
+ else
55
+ datefmt = '%d'
56
+ end
57
+
58
+ # < window parameters >
59
+
60
+ ux1,ux2,uy1,uy2 = DCL.sgqwnd
61
+ if xax
62
+ u1, u2 = ux1, ux2
63
+ else
64
+ u1, u2 = uy1, uy2
65
+ end
66
+
67
+ loffset_save = DCL.uzpget('loffset')
68
+ xyfact_save = DCL.uzpget(xy+'fact')
69
+ xyoffset_save = DCL.uzpget(xy+'offset')
70
+
71
+ tu1 = date_from.day_fraction.to_f
72
+ range_day = date_to - date_from # time btwn start and end (in days)
73
+ tu2 = tu1 + range_day
74
+
75
+ # < axis in hours >
76
+
77
+ DCL.uzpset('loffset',true)
78
+
79
+ DCL.uzpset(xy+'fact',24.0)
80
+ DCL.uzpset(xy+'offset',(tu1-u1)*24)
81
+
82
+ dtick1 = opt['dtick1']
83
+ if opt['dtick2']
84
+ dtick2 = opt['dtick2']
85
+ else
86
+ if range_day >= 4
87
+ dtick2 = 24
88
+ elsif range_day >= 2
89
+ dtick2 = 12
90
+ elsif range_day >= 1
91
+ dtick2 = 6
92
+ elsif range_day >= 0.5
93
+ dtick2 = 3
94
+ elsif range_day >= 0.25
95
+ dtick2 = 2
96
+ else
97
+ dtick2 = 1
98
+ end
99
+ end
100
+
101
+ str_hour = (tu1*24).ceil
102
+ end_hour = (tu2*24).floor
103
+ tick1=Array.new
104
+ tick2=Array.new
105
+ labels=Array.new
106
+ h1 = str_hour + (-str_hour % dtick1)
107
+ (h1..end_hour).step(dtick1){|i| tick1.push(i)}
108
+ h2 = str_hour + (-str_hour % dtick2)
109
+ (h2..end_hour).step(dtick2) do |i|
110
+ tick2.push(i)
111
+ labels.push((i%24).to_s)
112
+ end
113
+ if xax
114
+ DCL.uxaxlb(cside, tick1, tick2, labels, 2)
115
+ else
116
+ irotl_save = DCL.uzpget('irotly'+cside)
117
+ icent_save = DCL.uzpget('icenty'+cside)
118
+ DCL.uzpset('irotly'+cside,1)
119
+ DCL.uzpset('icenty'+cside,0)
120
+ DCL.uyaxlb(cside, tick1, tick2, labels, 2)
121
+ end
122
+
123
+ # < labels in days >
124
+
125
+ if DCL.uzpget('label'+xy+cside)
126
+ DCL.uzpset(xy+'fact',1.0)
127
+ DCL.uzpset(xy+'offset',0.0)
128
+
129
+ str_day = tu1.floor
130
+ end_day = tu2.floor
131
+ pos=Array.new
132
+ labels=Array.new
133
+ (str_day..end_day).step(1) do |i|
134
+ u = i.to_f + 0.5 + (u1- tu1)
135
+ u = (u1+u+0.5)/2 if u < u1
136
+ u = (u2+u-0.5)/2 if u > u2
137
+ pos.push(u)
138
+ str = (date_from+i).strftime(datefmt)
139
+ str.sub!(/^0/,'') if !opt['year'] && opt['month']
140
+ labels.push(str)
141
+ end
142
+
143
+ if xax
144
+ DCL.uxsaxz(cside,DCL.uzpget('roffx'+cside))
145
+ DCL.uxplbl(cside,1,pos,labels,10)
146
+ else
147
+ DCL.uysaxz(cside,DCL.uzpget('roffy'+cside))
148
+ DCL.uyplbl(cside,1,pos,labels,10)
149
+ # DCL.uzpset('irotly'+cside,irotl_save)
150
+ # DCL.uzpset('icenty'+cside,icent_save)
151
+ end
152
+
153
+ end
154
+
155
+ if xax
156
+ else
157
+ DCL.uzpset('irotly'+cside,irotl_save)
158
+ DCL.uzpset('icenty'+cside,icent_save)
159
+ end
160
+
161
+ # < to finish >
162
+
163
+ DCL.uzpset('loffset',loffset_save)
164
+ DCL.uzpset(xy+'fact',xyfact_save)
165
+ DCL.uzpset(xy+'offset',xyoffset_save)
166
+
167
+ end
168
+ end
169
+ end
170
+
171
+
172
+ ######## test program ######
173
+
174
+ if $0 == __FILE__
175
+
176
+ include NumRu
177
+
178
+ iws = (ARGV[0] || (puts ' WORKSTATION ID (I) ? ;'; DCL.sgpwsn; gets)).to_i
179
+ DCL.swpset('ldump',true) if iws==4
180
+ DCL.gropn iws
181
+ DCL.sldiv('y',2,1)
182
+
183
+ date_from = DateTime.parse('2005-06-30 17:00')
184
+ date_to = DateTime.parse('2005-07-01 5:00')
185
+ date_from2 = DateTime.parse('2005-06-29 17:00')
186
+ date_to2 = DateTime.parse('2005-07-02 5:00')
187
+
188
+ any_offst = 10
189
+
190
+ DCL.grfrm
191
+ DCL.grswnd(0.0, date_to-date_from, any_offst, date_to2-date_from2+any_offst)
192
+ DCL.grsvpt(0.2, 0.8, 0.2, 0.8)
193
+ DCL.grstrn(1)
194
+ DCL.grstrf
195
+ DCLExt.datetime_ax(date_from, date_to, 'year'=>true)
196
+ DCLExt.datetime_ax(date_from, date_to, 'cside'=>'t', 'year'=>true)
197
+ DCLExt.datetime_ax(date_from2, date_to2, 'yax'=>true)
198
+ DCLExt.datetime_ax(date_from2, date_to2, 'yax'=>true, 'cside'=>'r')
199
+ DCL.uxsttl('b','TIME AND DATE',0.0)
200
+ DCL.uysttl('l','TIME AND DATE',0.0)
201
+
202
+ DCL.grfrm
203
+ DCL.grswnd(0.0, date_to-date_from, 0, date_to2-date_from2)
204
+ DCL.grsvpt(0.2, 0.8, 0.2, 0.8)
205
+ DCL.grstrn(1)
206
+ DCL.grstrf
207
+ DCL.uzpset('inner',-1)
208
+ DCLExt.datetime_ax(date_from, date_to, 'dtick2'=>2)
209
+ DCLExt.datetime_ax(date_from, date_to, 'cside'=>'t', 'dtick2'=>2)
210
+ DCL.uzpset('inner',1)
211
+ DCLExt.datetime_ax(date_from2, date_to2, 'yax'=>true,
212
+ 'dtick1'=>2, 'dtick2'=>24)
213
+ DCLExt.datetime_ax(date_from2, date_to2, 'yax'=>true, 'cside'=>'r',
214
+ 'dtick1'=>2, 'dtick2'=>24)
215
+ DCL.uxsttl('b','TIME AND DATE',0.0)
216
+ DCL.uysttl('l','TIME AND DATE',0.0)
217
+
218
+ DCL.grcls
219
+
220
+ end
@@ -0,0 +1,348 @@
1
+ require "narray"
2
+
3
+ ############################################################
4
+
5
+ =begin
6
+ =module NumRu::Derivative in derivative.rb
7
+
8
+ ==todo
9
+ * decide argument of b_expand_linear_ext is Symbol or Numeric.
10
+ * now is Numeric.
11
+ * it denpends the treatment of dRuby.
12
+ * support other boundary conditions.
13
+
14
+ ==Index
15
+ * ((<module NumRu::Derivative>))
16
+ * ((<threepoint_O2nd_deriv>))
17
+ * First derivative (2nd Order difference use three point.)
18
+ * ((<cderiv>))
19
+ * First derivative (center difference use two point.)
20
+ * ((<b_expand_linear_ext>))
21
+ * return array extended boundaries with linear extention.
22
+ * ((<cdiff>))
23
+ * return difference. (center difference)
24
+
25
+ =module NumRu::Derivative
26
+
27
+ Module functions of Derivative Operater for NArray.
28
+
29
+ ---threepoint_O2nd_deriv(z, x, dim, bc=LINEAR_EXT)
30
+
31
+ Derivate (({z})) respect to (({dim})) th dimension with 2nd Order difference.
32
+ return an NArray which result of the difference ((<z>)) divided difference
33
+ (({x})) (in other wards,
34
+ (s**2*z_{i+1} + (t**2 - s**2)*f_{i} - t**2*f_{i-1}) / (s*t*(s + t)):
35
+ now s represents (x_{i} - x_{i-1}) ,t represents (x_{i+1} - x_{i})
36
+ and _{i} represents the suffix of {i} th element in the ((<dim>)) th
37
+ dimension of array. ).
38
+
39
+ ARGUMENTS
40
+ * z (NArray): a NArray which you want to derivative.
41
+ * x (NArray): a NArray represents the dimension which derivative respect to.
42
+ z.rank must be 1.
43
+ * dim (Numeric): a Numeric represents the dimention which derivative respect to.
44
+ you can give number count backward (((<dim>))<0), but ((<z.rank ��dim>)) must be > 0.
45
+ * bc (Numeric) : a Numeric to represent boundary condition.
46
+ Supported conditions are expressed in terms of boundary extension
47
+ applied before differentiation:
48
+ * LINEAR_EXT(=1): default value. linear extension using two
49
+ grid points at the boundaries.
50
+ * CYCLIC_EXT(=2): cyclic extension as k,0,1,..,k,0 for indices 0,1,..,k
51
+ * MIRROR_A(=3): for indices 0,1,..,k, extends as 0,0,1,..,k,k
52
+ (good for cell interior values with the Neumann condition)
53
+ * MIRROR_B(=4): for indices 0,1,..,k, extends as 1,0,1,..,k,k-1
54
+ (good for cell boundary values with the Neumann condition)
55
+
56
+ RETURN VALUE
57
+ * O2nd_deriv_data (NArray): (s**2*z_{i+1} + (t**2 - s**2)*f_{i} - t**2*f_{i-1}) / (s*t*(s + t))
58
+
59
+
60
+ ---cderiv(z, x, dim, bc=LINEAR_EXT)
61
+
62
+ Derivate (({z})) respect to (({dim})) th dimension with center difference.
63
+ return an NArray which result of the difference ((<z>)) divided difference
64
+ (({x})) ( in other wards, (z_{i+1} - z_{i-1}) / (x_{i+1} - x_{i-1}):
65
+ now _{i} represents the suffix of {i} th element in the ((<dim>)) th
66
+ dimension of array. ).
67
+
68
+ ARGUMENTS
69
+ * z (NArray): a NArray which you want to derivative.
70
+ * x (NArray): a NArray represents the dimension which derivative respect
71
+ to. z.rank must be 1.
72
+ * dim (Numeric): a Numeric represents the dimention which derivative
73
+ respect to. you can give number count backward (((<dim>))<0), but
74
+ ((<z.rank ��dim>)) must be > 0.
75
+ * bc (Numeric) : a Numeric to represent boundary condition.
76
+ See ((<threepoint_O2nd_deriv>)) for supported conditions.
77
+
78
+ RETURN VALUE
79
+ * cderiv_data (NArray): (z_{i+1} - z_{i-1}) / (x_{i+1} - x_{i-1})
80
+
81
+ ---b_expand_linear_ext(z, dim)
82
+
83
+ expand boundary with linear value. extend array with 1 grid at each
84
+ boundary with ((<dim>)) th dimension, and assign th value which diffrential
85
+ value between a grid short of boundary and boundary grid in original array.
86
+ (on other wards, 2*z_{0}-z_{1} or 2*z_{n-1}-z_{n-2}: now _{i} represents the
87
+ suffix of {i} th element in the ((<dim>)) th dimension of array. ).
88
+
89
+
90
+ ARGUMENTS
91
+ * z (NArray): a NArray which you want to expand boundary.
92
+ * dim (Numeric): a Numeric represents the dimention which derivative
93
+ respect to. you can give number count backward (((<dim>))<0), but
94
+ ((<z.rank ��dim>)) must be > 0.
95
+
96
+ RETURN VALUE
97
+ * expand_data (NArray):
98
+
99
+ ---cdiff(x, dim)
100
+
101
+ Diffrence operater. return an NArray which a difference ((<x>))
102
+ ( in other wards, (x_{i+1} - x_{i-1}): now _{i} represents the suffix of
103
+ {i} th element in the ((<dim>)) th dimension of array. ).
104
+
105
+ ARGUMENTS
106
+ * x (NArray): a NArray which you want to get difference.
107
+ * dim (Numeric): a Numeric representing the dimention which derivative
108
+ respect to. you can give number count backward (((<dim>))<0), but
109
+ ((<z.rank ��dim>)) must be > 0.
110
+
111
+ RETURN VALUE
112
+ * cdiff_data (NArray): (x_{i+1} - x_{i-1})
113
+
114
+ =end
115
+ ############################################################
116
+
117
+ module NumRu
118
+
119
+ module Derivative
120
+
121
+ module_function
122
+
123
+ #<<module constant>>
124
+ LINEAR_EXT = 1
125
+ CYCLIC_EXT = 2
126
+ MIRROR_A = 3
127
+ MIRROR_B = 4
128
+
129
+ def threepoint_O2nd_deriv(z, x, dim, bc=LINEAR_EXT)
130
+ dim += z.rank if dim<0
131
+ if dim < 0 || dim >= z.rank
132
+ raise ArgumentError,"dim value(#{dim}) must be between 0 and (#{z.rank-1}"
133
+ end
134
+ raise ArgumentError,"rank of x (#{x.rank}) must be 1" if x.rank != 1
135
+ # <<expand boundaries>>
136
+ ze = b_expand(z,dim,bc)
137
+ xe = b_expand_linear_ext(x,0) # always linear extention
138
+ # <<differenciation>>
139
+ to_rankD = [1]*dim + [true] + [1]*(ze.rank-1-dim) # to exand 1D to rank D
140
+ dx = xe[1..-1] - xe[0..-2] # x_{i} - x_{i-1} (for i=0..n-2)
141
+ dx2 = dx**2
142
+ s = dx[0..-2] # x_{i} - x_{i-1} (for i=0..n-3)
143
+ t = dx[1..-1] # x_{i+1} - x_{i} (for i=0..n-3)
144
+ s2 = dx2[0..-2].reshape(*to_rankD) # s**2
145
+ t2 = dx2[1..-1].reshape(*to_rankD) # t**2
146
+ numerator = ze[ *([true]*dim+[2..-1,false]) ] * s2\
147
+ + ze[ *([true]*dim+[1..-2,false]) ] * (t2-s2) \
148
+ - ze[ *([true]*dim+[0..-3,false]) ] * t2
149
+ denominator = (s*t*(s+t)).reshape(*to_rankD)
150
+ dzdx = numerator / denominator
151
+ return dzdx
152
+ end
153
+
154
+
155
+ def cderiv(z, x, dim, bc=LINEAR_EXT)
156
+ dim += z.rank if dim<0
157
+ raise ArgumentError,"dim value (#{dim}) must be smaller than z.rank and >= 0" if dim >= z.rank || dim<0
158
+ raise ArgumentError,"rank of x (#{x.rank}) must be 1" if x.rank != 1
159
+ # <<expand boundary>>
160
+ ze = b_expand(z,dim,bc)
161
+ xe = b_expand_linear_ext(x,0) # expand boundary of axis.
162
+ # <<difference operation>>
163
+ dz = cdiff(ze,dim)
164
+ dx = cdiff(xe,0)
165
+ if dx.rank != dz.rank # make dx.rank == dz.rank
166
+ dx = dx.reshape(*([1]*dim + [true] + [1]*(dz.rank-1-dim)))
167
+ end
168
+ dzdx = dz/dx
169
+ return dzdx
170
+ end
171
+
172
+ def b_expand(z,dim,bc)
173
+ case bc
174
+ when LINEAR_EXT
175
+ ze = b_expand_linear_ext(z,dim) # linear extention
176
+ when CYCLIC_EXT
177
+ ze = b_expand_cyclic(z,dim)
178
+ when MIRROR_A
179
+ ze = b_expand_mirror_A(z,dim)
180
+ when MIRROR_B
181
+ ze = b_expand_mirror_B(z,dim)
182
+ else
183
+ raise ArgumentError,"unsupported boundary condition: #{bc}."
184
+ end
185
+ ze
186
+ end
187
+
188
+ def b_expand_linear_ext(z,dim)
189
+ raise ArgumentError,"Len of #{dim}th dim (#{z.shape[dim]}) must be >= 2" if z.shape[dim] < 2
190
+
191
+ val0 = z[*([true]*dim + [0] + [false])] # first
192
+ val1 = z[*([true]*dim + [1] + [false])] # second
193
+ valm1 = z[*([true]*dim + [-1] + [false])] # last
194
+ valm2 = z[*([true]*dim + [-2] + [false])] # one before last
195
+
196
+ # expand boundary
197
+ ze = z[*([true]*dim + [[0,0..(z.shape[dim]-1),0]] + [false])]
198
+ ze[*([true]*dim + [0] + [false])] = 2*val0-val1
199
+ ze[*([true]*dim + [-1] + [false])] = 2*valm1-valm2
200
+ return ze
201
+ end
202
+
203
+ def b_expand_cyclic(z,dim)
204
+ k = z.shape[dim]-1
205
+ z[*([true]*dim + [[k,0..k,0]] + [false])]
206
+ end
207
+
208
+ def b_expand_mirror_A(z,dim)
209
+ k = z.shape[dim]-1
210
+ z[*([true]*dim + [[0,0..k,k]] + [false])]
211
+ end
212
+
213
+ def b_expand_mirror_B(z,dim)
214
+ raise ArgumentError,"Len of #{dim}th dim (#{z.shape[dim]}) must be >= 2" if z.shape[dim] < 2
215
+ k = z.shape[dim]-1
216
+ z[*([true]*dim + [[1,0..k,k-1]] + [false])]
217
+ end
218
+
219
+ def cdiff(z,dim)
220
+ z1 = z[*([true]*dim + [2..-1] + [false])]
221
+ z2 = z[*([true]*dim + [0..-3] + [false])]
222
+ cz = z1-z2 # cz[i] = cz[n+1] - cz[n-1]
223
+ return cz
224
+ end
225
+
226
+ end
227
+
228
+ end
229
+
230
+ ######################################################
231
+ ## < test >
232
+ if $0 == __FILE__
233
+
234
+ include NumRu
235
+ include NMath
236
+
237
+ def test1(x1)
238
+ f1 = sin(x1)
239
+ dfdx1 = Derivative::cderiv(f1, x1, 0)
240
+ dfdx2 = cos(x1)
241
+ p(dfdx1) if $VERBOSE
242
+ diff = (dfdx1 - dfdx2)[1..-2].abs
243
+ err = diff.mean
244
+ print "dfdx - kaiseki_kai (except boundary): "
245
+ print err, "\t", diff.max,"\n"
246
+ err
247
+ end
248
+
249
+ def test2(x1)
250
+ f1 = sin(x1)
251
+ dfdx1 = Derivative::threepoint_O2nd_deriv(f1, x1, 0)
252
+ dfdx2 = cos(x1)
253
+ p(dfdx1) if $VERBOSE
254
+ diff = (dfdx1 - dfdx2)[1..-2].abs
255
+ err = diff.mean
256
+ print "dfdx - kaiseki_kai (except boundary): "
257
+ print err, "\t", diff.max,"\n"
258
+ err
259
+ end
260
+
261
+ def test3
262
+ nx = 21
263
+ x = 2*PI*NArray.float(nx).indgen!/nx
264
+ f = sin(2*PI*NArray.float(nx,nx,nx).indgen!/nx)
265
+ dfdx1 = Derivative::cderiv(f, x, 0)
266
+ dfdx2 = Derivative::threepoint_O2nd_deriv(f, x, 0)
267
+ diff = (dfdx1 - dfdx2).abs
268
+ print "cderiv - o2deriv: "
269
+ print diff.mean, "\t", diff.max,"\n"
270
+ dfdx1 = Derivative::cderiv(f, x, 1)
271
+ dfdx2 = Derivative::threepoint_O2nd_deriv(f, x, 1)
272
+ diff = (dfdx1 - dfdx2).abs
273
+ print "cderiv - o2deriv: "
274
+ print diff.mean, "\t", diff.max,"\n"
275
+ dfdx1 = Derivative::cderiv(f, x, 2)
276
+ dfdx2 = Derivative::threepoint_O2nd_deriv(f, x, 2)
277
+ diff = (dfdx1 - dfdx2).abs
278
+ print "cderiv - o2deriv: "
279
+ print diff.mean, "\t", diff.max,"\n"
280
+ end
281
+
282
+ def test4
283
+ x = NArray.to_na([-1.0, 0.0, 2.0, 3.0])
284
+ f = NArray.to_na([1.0, 0.0, 4.0, 4.0])
285
+ dfdx = Derivative::threepoint_O2nd_deriv(f, x, 0)
286
+ dfdx_anal = NArray.to_na([-1.0, 0.0, 2.0/3.0, 0.0])
287
+ print "o2deriv - analytic: "
288
+ diff = (dfdx - dfdx_anal).abs
289
+ print diff.mean, "\t", diff.max,"\n"
290
+ end
291
+
292
+ def test5(x1)
293
+ f1 = sin(x1)
294
+ dfdx1 = Derivative::cderiv(f1, x1, 0, Derivative::CYCLIC_EXT)
295
+ dfdx2 = cos(x1)
296
+ p(dfdx1) if $VERBOSE
297
+ diff = (dfdx1 - dfdx2).abs
298
+ err = diff.mean
299
+ print "dfdx - kaiseki_kai: "
300
+ print err, "\t", diff.max,"\n"
301
+ err
302
+ end
303
+
304
+ def gen_x(nx)
305
+ 2*PI*NArray.float(nx).indgen!/(nx-1)
306
+ end
307
+ def gen_xc(nx)
308
+ 2*PI*NArray.float(nx).indgen!/nx
309
+ end
310
+ def gen_x2(nx)
311
+ 2*PI*exp(-NArray.float(nx).indgen!/(nx-1))
312
+ end
313
+
314
+
315
+ print "**** single-D ****\n"
316
+
317
+ print "**** equally spaced grid ****\n"
318
+ er1 = test1( gen_x(11) )
319
+ er2 = test1( gen_x(21) )
320
+ print "error change from nx=11->21: ", er2/er1,"\n"
321
+
322
+ print "**** equally spaced grid ****\n"
323
+ er1 = test2( gen_x(11) )
324
+ er2 = test2( gen_x(21) )
325
+ print "error change from nx=11->21: ", er2/er1,"\n"
326
+
327
+ print "**** equally spaced grid (cyclic) ****\n"
328
+ er1 = test1( gen_xc(80) )
329
+ er1 = test5( gen_xc(80) )
330
+
331
+ print "**** multi-D ****\n"
332
+ test3
333
+
334
+ print "**** non-uniform grid ****\n"
335
+ p 'x(11):',gen_x2(11),'x(21):',gen_x2(21)
336
+ er1 = test1( gen_x2(11) )
337
+ er2 = test1( gen_x2(21) )
338
+ print "error change from nx=11->21: ", er2/er1,"\n"
339
+
340
+ print "**** non-uniform grid (2nd order) ****\n"
341
+ er1 = test2( gen_x2(11) )
342
+ er2 = test2( gen_x2(21) )
343
+ print "error change from nx=11->21: ", er2/er1,"\n"
344
+
345
+ print "**** non-uniform grid (analytic test) ****\n"
346
+ test4
347
+
348
+ end