gphys 1.1.1 → 1.2.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (369) hide show
  1. data/.gitignore +17 -0
  2. data/ChangeLog +221 -0
  3. data/Gemfile +4 -0
  4. data/LICENSE.txt +18 -30
  5. data/README +23 -26
  6. data/README.md +29 -0
  7. data/Rakefile +1 -56
  8. data/bin/gpaop +2 -1
  9. data/bin/gpcut +3 -2
  10. data/bin/gpedit +6 -2
  11. data/bin/gpmath +3 -2
  12. data/bin/gpmaxmin +3 -2
  13. data/bin/gpprint +2 -1
  14. data/bin/gpvect +28 -5
  15. data/bin/gpview +43 -5
  16. data/extconf.rb +5 -6
  17. data/gphys.gemspec +34 -0
  18. data/interpo.c +63 -24
  19. data/lib/gphys.rb +2 -0
  20. data/lib/numru/dclext.rb +2636 -0
  21. data/lib/numru/derivative.rb +53 -12
  22. data/lib/numru/ganalysis/eof.rb +4 -0
  23. data/lib/numru/ganalysis/histogram.rb +73 -5
  24. data/lib/numru/ganalysis/met.rb +163 -2
  25. data/lib/numru/ganalysis/planet.rb +230 -20
  26. data/lib/numru/ggraph.rb +147 -2247
  27. data/lib/numru/gphys/assoccoords.rb +19 -3
  28. data/lib/numru/gphys/axis.rb +1 -1
  29. data/lib/numru/gphys/coordmapping.rb +2 -2
  30. data/lib/numru/gphys/derivative.rb +56 -13
  31. data/lib/numru/gphys/gphys.rb +17 -1
  32. data/lib/numru/gphys/gphys_grads_io.rb +6 -5
  33. data/lib/numru/gphys/gphys_grib_io.rb +6 -6
  34. data/lib/numru/gphys/gphys_io.rb +25 -6
  35. data/lib/numru/gphys/grads_gridded.rb +31 -29
  36. data/lib/numru/gphys/grib.rb +13 -9
  37. data/lib/numru/gphys/interpolate.rb +153 -29
  38. data/lib/numru/gphys/unumeric.rb +29 -6
  39. data/lib/numru/gphys/varray.rb +9 -0
  40. data/lib/numru/gphys/varraygrib.rb +70 -8
  41. data/lib/version.rb +3 -0
  42. metadata +247 -531
  43. data/doc/attribute.html +0 -19
  44. data/doc/attributenetcdf.html +0 -15
  45. data/doc/axis.html +0 -376
  46. data/doc/coordmapping.html +0 -111
  47. data/doc/coordtransform.html +0 -36
  48. data/doc/derivative/gphys-derivative.html +0 -80
  49. data/doc/derivative/index.html +0 -21
  50. data/doc/derivative/index.rd +0 -14
  51. data/doc/derivative/math-doc/document/document.css +0 -30
  52. data/doc/derivative/math-doc/document/document.html +0 -57
  53. data/doc/derivative/math-doc/document/images.aux +0 -1
  54. data/doc/derivative/math-doc/document/images.log +0 -385
  55. data/doc/derivative/math-doc/document/images.pl +0 -186
  56. data/doc/derivative/math-doc/document/images.tex +0 -364
  57. data/doc/derivative/math-doc/document/img1.png +0 -0
  58. data/doc/derivative/math-doc/document/img10.png +0 -0
  59. data/doc/derivative/math-doc/document/img11.png +0 -0
  60. data/doc/derivative/math-doc/document/img12.png +0 -0
  61. data/doc/derivative/math-doc/document/img13.png +0 -0
  62. data/doc/derivative/math-doc/document/img14.png +0 -0
  63. data/doc/derivative/math-doc/document/img15.png +0 -0
  64. data/doc/derivative/math-doc/document/img16.png +0 -0
  65. data/doc/derivative/math-doc/document/img17.png +0 -0
  66. data/doc/derivative/math-doc/document/img18.png +0 -0
  67. data/doc/derivative/math-doc/document/img19.png +0 -0
  68. data/doc/derivative/math-doc/document/img2.png +0 -0
  69. data/doc/derivative/math-doc/document/img20.png +0 -0
  70. data/doc/derivative/math-doc/document/img21.png +0 -0
  71. data/doc/derivative/math-doc/document/img22.png +0 -0
  72. data/doc/derivative/math-doc/document/img23.png +0 -0
  73. data/doc/derivative/math-doc/document/img24.png +0 -0
  74. data/doc/derivative/math-doc/document/img25.png +0 -0
  75. data/doc/derivative/math-doc/document/img26.png +0 -0
  76. data/doc/derivative/math-doc/document/img27.png +0 -0
  77. data/doc/derivative/math-doc/document/img28.png +0 -0
  78. data/doc/derivative/math-doc/document/img29.png +0 -0
  79. data/doc/derivative/math-doc/document/img3.png +0 -0
  80. data/doc/derivative/math-doc/document/img30.png +0 -0
  81. data/doc/derivative/math-doc/document/img4.png +0 -0
  82. data/doc/derivative/math-doc/document/img5.png +0 -0
  83. data/doc/derivative/math-doc/document/img6.png +0 -0
  84. data/doc/derivative/math-doc/document/img7.png +0 -0
  85. data/doc/derivative/math-doc/document/img8.png +0 -0
  86. data/doc/derivative/math-doc/document/img9.png +0 -0
  87. data/doc/derivative/math-doc/document/index.html +0 -57
  88. data/doc/derivative/math-doc/document/labels.pl +0 -13
  89. data/doc/derivative/math-doc/document/next.png +0 -0
  90. data/doc/derivative/math-doc/document/next_g.png +0 -0
  91. data/doc/derivative/math-doc/document/node1.html +0 -238
  92. data/doc/derivative/math-doc/document/node2.html +0 -75
  93. data/doc/derivative/math-doc/document/prev.png +0 -0
  94. data/doc/derivative/math-doc/document/prev_g.png +0 -0
  95. data/doc/derivative/math-doc/document/up.png +0 -0
  96. data/doc/derivative/math-doc/document/up_g.png +0 -0
  97. data/doc/derivative/math-doc/document.pdf +0 -0
  98. data/doc/derivative/math-doc/document.tex +0 -158
  99. data/doc/derivative/numru-derivative.html +0 -129
  100. data/doc/ep_flux/ep_flux.html +0 -469
  101. data/doc/ep_flux/ggraph_on_merdional_section.html +0 -71
  102. data/doc/ep_flux/index.html +0 -31
  103. data/doc/ep_flux/index.rd +0 -24
  104. data/doc/ep_flux/math-doc/document/WARNINGS +0 -1
  105. data/doc/ep_flux/math-doc/document/contents.png +0 -0
  106. data/doc/ep_flux/math-doc/document/crossref.png +0 -0
  107. data/doc/ep_flux/math-doc/document/document.css +0 -30
  108. data/doc/ep_flux/math-doc/document/document.html +0 -101
  109. data/doc/ep_flux/math-doc/document/images.aux +0 -1
  110. data/doc/ep_flux/math-doc/document/images.log +0 -1375
  111. data/doc/ep_flux/math-doc/document/images.pl +0 -1328
  112. data/doc/ep_flux/math-doc/document/images.tex +0 -1471
  113. data/doc/ep_flux/math-doc/document/img1.png +0 -0
  114. data/doc/ep_flux/math-doc/document/img10.png +0 -0
  115. data/doc/ep_flux/math-doc/document/img100.png +0 -0
  116. data/doc/ep_flux/math-doc/document/img101.png +0 -0
  117. data/doc/ep_flux/math-doc/document/img102.png +0 -0
  118. data/doc/ep_flux/math-doc/document/img103.png +0 -0
  119. data/doc/ep_flux/math-doc/document/img104.png +0 -0
  120. data/doc/ep_flux/math-doc/document/img105.png +0 -0
  121. data/doc/ep_flux/math-doc/document/img106.png +0 -0
  122. data/doc/ep_flux/math-doc/document/img107.png +0 -0
  123. data/doc/ep_flux/math-doc/document/img108.png +0 -0
  124. data/doc/ep_flux/math-doc/document/img109.png +0 -0
  125. data/doc/ep_flux/math-doc/document/img11.png +0 -0
  126. data/doc/ep_flux/math-doc/document/img110.png +0 -0
  127. data/doc/ep_flux/math-doc/document/img111.png +0 -0
  128. data/doc/ep_flux/math-doc/document/img112.png +0 -0
  129. data/doc/ep_flux/math-doc/document/img113.png +0 -0
  130. data/doc/ep_flux/math-doc/document/img114.png +0 -0
  131. data/doc/ep_flux/math-doc/document/img115.png +0 -0
  132. data/doc/ep_flux/math-doc/document/img116.png +0 -0
  133. data/doc/ep_flux/math-doc/document/img117.png +0 -0
  134. data/doc/ep_flux/math-doc/document/img118.png +0 -0
  135. data/doc/ep_flux/math-doc/document/img119.png +0 -0
  136. data/doc/ep_flux/math-doc/document/img12.png +0 -0
  137. data/doc/ep_flux/math-doc/document/img120.png +0 -0
  138. data/doc/ep_flux/math-doc/document/img121.png +0 -0
  139. data/doc/ep_flux/math-doc/document/img122.png +0 -0
  140. data/doc/ep_flux/math-doc/document/img123.png +0 -0
  141. data/doc/ep_flux/math-doc/document/img124.png +0 -0
  142. data/doc/ep_flux/math-doc/document/img125.png +0 -0
  143. data/doc/ep_flux/math-doc/document/img126.png +0 -0
  144. data/doc/ep_flux/math-doc/document/img127.png +0 -0
  145. data/doc/ep_flux/math-doc/document/img128.png +0 -0
  146. data/doc/ep_flux/math-doc/document/img129.png +0 -0
  147. data/doc/ep_flux/math-doc/document/img13.png +0 -0
  148. data/doc/ep_flux/math-doc/document/img130.png +0 -0
  149. data/doc/ep_flux/math-doc/document/img131.png +0 -0
  150. data/doc/ep_flux/math-doc/document/img132.png +0 -0
  151. data/doc/ep_flux/math-doc/document/img133.png +0 -0
  152. data/doc/ep_flux/math-doc/document/img134.png +0 -0
  153. data/doc/ep_flux/math-doc/document/img135.png +0 -0
  154. data/doc/ep_flux/math-doc/document/img136.png +0 -0
  155. data/doc/ep_flux/math-doc/document/img137.png +0 -0
  156. data/doc/ep_flux/math-doc/document/img138.png +0 -0
  157. data/doc/ep_flux/math-doc/document/img139.png +0 -0
  158. data/doc/ep_flux/math-doc/document/img14.png +0 -0
  159. data/doc/ep_flux/math-doc/document/img140.png +0 -0
  160. data/doc/ep_flux/math-doc/document/img141.png +0 -0
  161. data/doc/ep_flux/math-doc/document/img142.png +0 -0
  162. data/doc/ep_flux/math-doc/document/img143.png +0 -0
  163. data/doc/ep_flux/math-doc/document/img144.png +0 -0
  164. data/doc/ep_flux/math-doc/document/img145.png +0 -0
  165. data/doc/ep_flux/math-doc/document/img146.png +0 -0
  166. data/doc/ep_flux/math-doc/document/img147.png +0 -0
  167. data/doc/ep_flux/math-doc/document/img148.png +0 -0
  168. data/doc/ep_flux/math-doc/document/img149.png +0 -0
  169. data/doc/ep_flux/math-doc/document/img15.png +0 -0
  170. data/doc/ep_flux/math-doc/document/img150.png +0 -0
  171. data/doc/ep_flux/math-doc/document/img151.png +0 -0
  172. data/doc/ep_flux/math-doc/document/img152.png +0 -0
  173. data/doc/ep_flux/math-doc/document/img153.png +0 -0
  174. data/doc/ep_flux/math-doc/document/img154.png +0 -0
  175. data/doc/ep_flux/math-doc/document/img155.png +0 -0
  176. data/doc/ep_flux/math-doc/document/img156.png +0 -0
  177. data/doc/ep_flux/math-doc/document/img157.png +0 -0
  178. data/doc/ep_flux/math-doc/document/img158.png +0 -0
  179. data/doc/ep_flux/math-doc/document/img159.png +0 -0
  180. data/doc/ep_flux/math-doc/document/img16.png +0 -0
  181. data/doc/ep_flux/math-doc/document/img160.png +0 -0
  182. data/doc/ep_flux/math-doc/document/img161.png +0 -0
  183. data/doc/ep_flux/math-doc/document/img162.png +0 -0
  184. data/doc/ep_flux/math-doc/document/img163.png +0 -0
  185. data/doc/ep_flux/math-doc/document/img164.png +0 -0
  186. data/doc/ep_flux/math-doc/document/img165.png +0 -0
  187. data/doc/ep_flux/math-doc/document/img166.png +0 -0
  188. data/doc/ep_flux/math-doc/document/img167.png +0 -0
  189. data/doc/ep_flux/math-doc/document/img168.png +0 -0
  190. data/doc/ep_flux/math-doc/document/img169.png +0 -0
  191. data/doc/ep_flux/math-doc/document/img17.png +0 -0
  192. data/doc/ep_flux/math-doc/document/img170.png +0 -0
  193. data/doc/ep_flux/math-doc/document/img171.png +0 -0
  194. data/doc/ep_flux/math-doc/document/img172.png +0 -0
  195. data/doc/ep_flux/math-doc/document/img173.png +0 -0
  196. data/doc/ep_flux/math-doc/document/img174.png +0 -0
  197. data/doc/ep_flux/math-doc/document/img175.png +0 -0
  198. data/doc/ep_flux/math-doc/document/img176.png +0 -0
  199. data/doc/ep_flux/math-doc/document/img177.png +0 -0
  200. data/doc/ep_flux/math-doc/document/img178.png +0 -0
  201. data/doc/ep_flux/math-doc/document/img179.png +0 -0
  202. data/doc/ep_flux/math-doc/document/img18.png +0 -0
  203. data/doc/ep_flux/math-doc/document/img180.png +0 -0
  204. data/doc/ep_flux/math-doc/document/img181.png +0 -0
  205. data/doc/ep_flux/math-doc/document/img182.png +0 -0
  206. data/doc/ep_flux/math-doc/document/img183.png +0 -0
  207. data/doc/ep_flux/math-doc/document/img184.png +0 -0
  208. data/doc/ep_flux/math-doc/document/img185.png +0 -0
  209. data/doc/ep_flux/math-doc/document/img186.png +0 -0
  210. data/doc/ep_flux/math-doc/document/img187.png +0 -0
  211. data/doc/ep_flux/math-doc/document/img188.png +0 -0
  212. data/doc/ep_flux/math-doc/document/img189.png +0 -0
  213. data/doc/ep_flux/math-doc/document/img19.png +0 -0
  214. data/doc/ep_flux/math-doc/document/img190.png +0 -0
  215. data/doc/ep_flux/math-doc/document/img191.png +0 -0
  216. data/doc/ep_flux/math-doc/document/img192.png +0 -0
  217. data/doc/ep_flux/math-doc/document/img193.png +0 -0
  218. data/doc/ep_flux/math-doc/document/img194.png +0 -0
  219. data/doc/ep_flux/math-doc/document/img195.png +0 -0
  220. data/doc/ep_flux/math-doc/document/img196.png +0 -0
  221. data/doc/ep_flux/math-doc/document/img197.png +0 -0
  222. data/doc/ep_flux/math-doc/document/img198.png +0 -0
  223. data/doc/ep_flux/math-doc/document/img199.png +0 -0
  224. data/doc/ep_flux/math-doc/document/img2.png +0 -0
  225. data/doc/ep_flux/math-doc/document/img20.png +0 -0
  226. data/doc/ep_flux/math-doc/document/img200.png +0 -0
  227. data/doc/ep_flux/math-doc/document/img21.png +0 -0
  228. data/doc/ep_flux/math-doc/document/img22.png +0 -0
  229. data/doc/ep_flux/math-doc/document/img23.png +0 -0
  230. data/doc/ep_flux/math-doc/document/img24.png +0 -0
  231. data/doc/ep_flux/math-doc/document/img25.png +0 -0
  232. data/doc/ep_flux/math-doc/document/img26.png +0 -0
  233. data/doc/ep_flux/math-doc/document/img27.png +0 -0
  234. data/doc/ep_flux/math-doc/document/img28.png +0 -0
  235. data/doc/ep_flux/math-doc/document/img29.png +0 -0
  236. data/doc/ep_flux/math-doc/document/img3.png +0 -0
  237. data/doc/ep_flux/math-doc/document/img30.png +0 -0
  238. data/doc/ep_flux/math-doc/document/img31.png +0 -0
  239. data/doc/ep_flux/math-doc/document/img32.png +0 -0
  240. data/doc/ep_flux/math-doc/document/img33.png +0 -0
  241. data/doc/ep_flux/math-doc/document/img34.png +0 -0
  242. data/doc/ep_flux/math-doc/document/img35.png +0 -0
  243. data/doc/ep_flux/math-doc/document/img36.png +0 -0
  244. data/doc/ep_flux/math-doc/document/img37.png +0 -0
  245. data/doc/ep_flux/math-doc/document/img38.png +0 -0
  246. data/doc/ep_flux/math-doc/document/img39.png +0 -0
  247. data/doc/ep_flux/math-doc/document/img4.png +0 -0
  248. data/doc/ep_flux/math-doc/document/img40.png +0 -0
  249. data/doc/ep_flux/math-doc/document/img41.png +0 -0
  250. data/doc/ep_flux/math-doc/document/img42.png +0 -0
  251. data/doc/ep_flux/math-doc/document/img43.png +0 -0
  252. data/doc/ep_flux/math-doc/document/img44.png +0 -0
  253. data/doc/ep_flux/math-doc/document/img45.png +0 -0
  254. data/doc/ep_flux/math-doc/document/img46.png +0 -0
  255. data/doc/ep_flux/math-doc/document/img47.png +0 -0
  256. data/doc/ep_flux/math-doc/document/img48.png +0 -0
  257. data/doc/ep_flux/math-doc/document/img49.png +0 -0
  258. data/doc/ep_flux/math-doc/document/img5.png +0 -0
  259. data/doc/ep_flux/math-doc/document/img50.png +0 -0
  260. data/doc/ep_flux/math-doc/document/img51.png +0 -0
  261. data/doc/ep_flux/math-doc/document/img52.png +0 -0
  262. data/doc/ep_flux/math-doc/document/img53.png +0 -0
  263. data/doc/ep_flux/math-doc/document/img54.png +0 -0
  264. data/doc/ep_flux/math-doc/document/img55.png +0 -0
  265. data/doc/ep_flux/math-doc/document/img56.png +0 -0
  266. data/doc/ep_flux/math-doc/document/img57.png +0 -0
  267. data/doc/ep_flux/math-doc/document/img58.png +0 -0
  268. data/doc/ep_flux/math-doc/document/img59.png +0 -0
  269. data/doc/ep_flux/math-doc/document/img6.png +0 -0
  270. data/doc/ep_flux/math-doc/document/img60.png +0 -0
  271. data/doc/ep_flux/math-doc/document/img61.png +0 -0
  272. data/doc/ep_flux/math-doc/document/img62.png +0 -0
  273. data/doc/ep_flux/math-doc/document/img63.png +0 -0
  274. data/doc/ep_flux/math-doc/document/img64.png +0 -0
  275. data/doc/ep_flux/math-doc/document/img65.png +0 -0
  276. data/doc/ep_flux/math-doc/document/img66.png +0 -0
  277. data/doc/ep_flux/math-doc/document/img67.png +0 -0
  278. data/doc/ep_flux/math-doc/document/img68.png +0 -0
  279. data/doc/ep_flux/math-doc/document/img69.png +0 -0
  280. data/doc/ep_flux/math-doc/document/img7.png +0 -0
  281. data/doc/ep_flux/math-doc/document/img70.png +0 -0
  282. data/doc/ep_flux/math-doc/document/img71.png +0 -0
  283. data/doc/ep_flux/math-doc/document/img72.png +0 -0
  284. data/doc/ep_flux/math-doc/document/img73.png +0 -0
  285. data/doc/ep_flux/math-doc/document/img74.png +0 -0
  286. data/doc/ep_flux/math-doc/document/img75.png +0 -0
  287. data/doc/ep_flux/math-doc/document/img76.png +0 -0
  288. data/doc/ep_flux/math-doc/document/img77.png +0 -0
  289. data/doc/ep_flux/math-doc/document/img78.png +0 -0
  290. data/doc/ep_flux/math-doc/document/img79.png +0 -0
  291. data/doc/ep_flux/math-doc/document/img8.png +0 -0
  292. data/doc/ep_flux/math-doc/document/img80.png +0 -0
  293. data/doc/ep_flux/math-doc/document/img81.png +0 -0
  294. data/doc/ep_flux/math-doc/document/img82.png +0 -0
  295. data/doc/ep_flux/math-doc/document/img83.png +0 -0
  296. data/doc/ep_flux/math-doc/document/img84.png +0 -0
  297. data/doc/ep_flux/math-doc/document/img85.png +0 -0
  298. data/doc/ep_flux/math-doc/document/img86.png +0 -0
  299. data/doc/ep_flux/math-doc/document/img87.png +0 -0
  300. data/doc/ep_flux/math-doc/document/img88.png +0 -0
  301. data/doc/ep_flux/math-doc/document/img89.png +0 -0
  302. data/doc/ep_flux/math-doc/document/img9.png +0 -0
  303. data/doc/ep_flux/math-doc/document/img90.png +0 -0
  304. data/doc/ep_flux/math-doc/document/img91.png +0 -0
  305. data/doc/ep_flux/math-doc/document/img92.png +0 -0
  306. data/doc/ep_flux/math-doc/document/img93.png +0 -0
  307. data/doc/ep_flux/math-doc/document/img94.png +0 -0
  308. data/doc/ep_flux/math-doc/document/img95.png +0 -0
  309. data/doc/ep_flux/math-doc/document/img96.png +0 -0
  310. data/doc/ep_flux/math-doc/document/img97.png +0 -0
  311. data/doc/ep_flux/math-doc/document/img98.png +0 -0
  312. data/doc/ep_flux/math-doc/document/img99.png +0 -0
  313. data/doc/ep_flux/math-doc/document/index.html +0 -101
  314. data/doc/ep_flux/math-doc/document/internals.pl +0 -258
  315. data/doc/ep_flux/math-doc/document/labels.pl +0 -265
  316. data/doc/ep_flux/math-doc/document/next.png +0 -0
  317. data/doc/ep_flux/math-doc/document/next_g.png +0 -0
  318. data/doc/ep_flux/math-doc/document/node1.html +0 -104
  319. data/doc/ep_flux/math-doc/document/node10.html +0 -164
  320. data/doc/ep_flux/math-doc/document/node11.html +0 -86
  321. data/doc/ep_flux/math-doc/document/node12.html +0 -166
  322. data/doc/ep_flux/math-doc/document/node13.html +0 -897
  323. data/doc/ep_flux/math-doc/document/node14.html +0 -1065
  324. data/doc/ep_flux/math-doc/document/node15.html +0 -72
  325. data/doc/ep_flux/math-doc/document/node16.html +0 -81
  326. data/doc/ep_flux/math-doc/document/node2.html +0 -82
  327. data/doc/ep_flux/math-doc/document/node3.html +0 -91
  328. data/doc/ep_flux/math-doc/document/node4.html +0 -149
  329. data/doc/ep_flux/math-doc/document/node5.html +0 -330
  330. data/doc/ep_flux/math-doc/document/node6.html +0 -99
  331. data/doc/ep_flux/math-doc/document/node7.html +0 -98
  332. data/doc/ep_flux/math-doc/document/node8.html +0 -83
  333. data/doc/ep_flux/math-doc/document/node9.html +0 -140
  334. data/doc/ep_flux/math-doc/document/prev.png +0 -0
  335. data/doc/ep_flux/math-doc/document/prev_g.png +0 -0
  336. data/doc/ep_flux/math-doc/document/up.png +0 -0
  337. data/doc/ep_flux/math-doc/document/up_g.png +0 -0
  338. data/doc/ep_flux/math-doc/document.pdf +0 -0
  339. data/doc/ep_flux/math-doc/document.tex +0 -2018
  340. data/doc/gdir.html +0 -412
  341. data/doc/gdir_client.html +0 -16
  342. data/doc/gdir_connect_ftp-like.html +0 -61
  343. data/doc/gdir_server.html +0 -45
  344. data/doc/ggraph.html +0 -1615
  345. data/doc/gpcat.html +0 -44
  346. data/doc/gpcut.html +0 -41
  347. data/doc/gphys.html +0 -532
  348. data/doc/gphys_fft.html +0 -324
  349. data/doc/gphys_grads_io.html +0 -69
  350. data/doc/gphys_grib_io.html +0 -82
  351. data/doc/gphys_io.html +0 -120
  352. data/doc/gphys_io_common.html +0 -18
  353. data/doc/gphys_netcdf_io.html +0 -283
  354. data/doc/gplist.html +0 -24
  355. data/doc/gpmath.html +0 -51
  356. data/doc/gpmaxmin.html +0 -31
  357. data/doc/gpprint.html +0 -34
  358. data/doc/gpview.html +0 -270
  359. data/doc/grads2nc_with_gphys.html +0 -21
  360. data/doc/grads_gridded.html +0 -307
  361. data/doc/grib.html +0 -144
  362. data/doc/grid.html +0 -212
  363. data/doc/index.html +0 -133
  364. data/doc/index.rd +0 -127
  365. data/doc/netcdf_convention.html +0 -136
  366. data/doc/unumeric.html +0 -176
  367. data/doc/update +0 -64
  368. data/doc/varray.html +0 -299
  369. data/doc/varraycomposite.html +0 -67
data/lib/numru/ggraph.rb CHANGED
@@ -1,8 +1,8 @@
1
+ # -*- coding: cp932 -*-
1
2
  require "numru/gphys"
2
- require "numru/dcl"
3
3
  require "numru/misc"
4
4
  require "date"
5
- require "numru/dclext_datetime_ax"
5
+ require "numru/dclext"
6
6
 
7
7
  ############################################################
8
8
 
@@ -94,66 +94,6 @@ require "numru/dclext_datetime_ax"
94
94
  is effective only for the next call of ((<tone>)).
95
95
  * ((<vector>)) 2-D vector plot using DCL_Ext::((<flow_vect>))
96
96
 
97
- * ((<module NumRu::DCLExt>))
98
- * ((<gl_set_params>))
99
- Calls (({DCL.glpset})) multiple times (for each key and val of (({hash}))).
100
- * ((<sg_set_params>))
101
- Calls (({DCL.sgpset})) multiple times (for each key and val of (({hash}))).
102
- * ((<sl_set_params>))
103
- Calls (({DCL.slpset})) multiple times (for each key and val of (({hash}))).
104
- * ((<sw_set_params>))
105
- Calls (({DCL.swpset})) multiple times (for each key and val of (({hash}))).
106
- * ((<uz_set_params>))
107
- Calls (({DCL.uzpset})) multiple times (for each key and val of (({hash}))).
108
- * ((<ul_set_params>))
109
- Calls (({DCL.ulpset})) multiple times (for each key and val of (({hash}))).
110
- * ((<uc_set_params>))
111
- Calls (({DCL.ucpset})) multiple times (for each key and val of (({hash}))).
112
- * ((<uu_set_params>))
113
- Calls (({DCL.uupset})) multiple times (for each key and val of (({hash}))).
114
- * ((<us_set_params>))
115
- Calls (({DCL.uspset})) multiple times (for each key and val of (({hash}))).
116
- * ((<ud_set_params>))
117
- Calls (({DCL.udpset})) multiple times (for each key and val of (({hash}))).
118
- * ((<ud_set_linear_levs>))
119
- Set contour levels with a constant interval
120
- * ((<ud_set_contour>))
121
- Set contours of at specified levels.
122
- * ((<ud_add_contour>))
123
- Same as ((<ud_set_contour>)), but does not clear the contour levels that have
124
- been set.
125
- * ((<ue_set_params>))
126
- Calls (({DCL.uepset})) multiple times (for each key and val of (({hash}))).
127
- * ((<ue_set_linear_levs>))
128
- Set tone levels with a constant interval
129
- * ((<ue_set_tone>))
130
- Set tone levels and patterns.
131
- * ((<ue_add_tone>))
132
- Same as ((<ue_set_tone>)), but does not clear the tone levels that have
133
- been set.
134
- * ((<ug_set_params>))
135
- Calls (({DCL.ugpset})) multiple times (for each key and val of (({hash}))).
136
- See ((<gl_set_params>)) for usage.
137
- * ((<um_set_params>))
138
- Calls (({DCL.umpset})) multiple times (for each key and val of (({hash}))).
139
- * ((<lon_ax>))
140
- Draw longitude axis. (label format: degrees + 'E' or 'W')
141
- * ((<lat_ax>))
142
- Draw latitude axis. (label format: degrees + 'N' or 'S')
143
- * ((<unit_vect>)) Show the "unit vector", which indicate the vector scaling.
144
- * ((<set_unit_vect_options>))
145
- Change the default option values for ((<unit_vect>)).
146
- * ((<next_unit_vect_options>))
147
- Set the option values effective only in the next call of ((<unit_vect>))
148
- * ((<flow_vect>)) 2D Vector plot. Unlike (({DCL::ugvect})), scaling are made in term of the physical (or "U") coordinate.
149
- * ((<flow_itr5>)) 2D Vector plot on the 2-dim polar coodinate.
150
- * ((<color_bar>)) Color Bar
151
- * ((<legend>))
152
- Annotates line/mark type and index (and size if mark).
153
- * ((<quasi_log_levels_z>))
154
- Driver of quasi_log_levels with data values
155
- * ((<quasi_log_levels>))
156
- Returns approximately log-scaled contour/tone levels.
157
97
  =module NumRu::GGraph
158
98
 
159
99
  A graphic library for GPhys using RubyDCL.
@@ -365,6 +305,12 @@ library if you like.
365
305
  # (if nil, internally determined)
366
306
  "ylabelint" nil # Interval of y axis label
367
307
  # (if nil, internally determined)
308
+ "xloglabelall" false # Show lavels for all log-level tick marks
309
+ # (x-axes) (e.g.,1000,900,800,... inseatd of
310
+ # 1000,500,200,...)
311
+ "yloglabelall" false # Show lavels for all log-level tick marks
312
+ # (y-axes) (e.g.,1000,900,800,... inseatd of
313
+ # 1000,500,200,...)
368
314
  "xmaplabel" nil # If "lon"("lat"), use
369
315
  # DCLExt::lon_ax(DCLExt::lat_ax) to draw xaxes;
370
316
  # otherwise, DCL::usxaxs is used.
@@ -1118,2175 +1064,11 @@ library if you like.
1118
1064
  "type" 1 # line type
1119
1065
  "help" false # show help message if true
1120
1066
 
1121
- =module NumRu::DCLExt
1122
1067
 
1123
- Collection of various compound DCL functions for convenience.
1124
- This module is to be separated but temporarily included in ggraph.rb
1125
- while it is premature.
1126
-
1127
- ==Index
1128
- MATH1
1129
- * ((<glpack>))
1130
- GRPH1
1131
- * ((<sgpack>))
1132
- * ((<slpack>))
1133
- * ((<swpack>))
1134
- GRPH2
1135
- * ((<uzpack>))
1136
- * ((<ulpack>))
1137
- * ((<ucpack>))
1138
- * ((<uupack>))
1139
- * ((<uspack>))
1140
- * ((<udpack>))
1141
- * ((<uepack>))
1142
- * ((<ugpack>))
1143
- * ((<umpack>))
1144
-
1145
- ==Module Functions
1146
-
1147
- ===glpack
1148
- ---gl_set_params(hash)
1149
- Calls (({DCL.glpset})) multiple times (for each key and val of (({hash}))).
1150
-
1151
- ARGUMENTS
1152
- * hash (Hash) : combinations of parameter names and values for udpset
1153
-
1154
- RETURN VALUE
1155
- * a Hash containing the parameter names and their old values that were
1156
- replaced.
1157
-
1158
- EXAMPLES
1159
- * You can modify parameters temporarily as follows.
1160
-
1161
- before = DCLExt.gl_set_params({'lmiss'=>true,'rmiss'=>9999.0})
1162
- ....
1163
- DCLExt.gl_set_params(before) # reset the change
1164
-
1165
- ===sgpack
1166
- ---sg_set_params(hash)
1167
- Calls (({DCL.sgpset})) multiple times (for each key and val of (({hash}))).
1168
-
1169
- See ((<gl_set_params>)) for usage.
1170
-
1171
- ===slpack
1172
- ---sl_set_params(hash)
1173
- Calls (({DCL.slpset})) multiple times (for each key and val of (({hash}))).
1174
-
1175
- See ((<gl_set_params>)) for usage.
1176
-
1177
- ===swpack
1178
- ---sw_set_params(hash)
1179
- Calls (({DCL.swpset})) multiple times (for each key and val of (({hash}))).
1180
-
1181
- See ((<gl_set_params>)) for usage.
1182
-
1183
- ===uzpack
1184
- ---uz_set_params(hash)
1185
- Calls (({DCL.uzpset})) multiple times (for each key and val of (({hash}))).
1186
-
1187
- See ((<gl_set_params>)) for usage.
1188
-
1189
- ===ulpack
1190
- ---ul_set_params(hash)
1191
- Calls (({DCL.ulpset})) multiple times (for each key and val of (({hash}))).
1192
-
1193
- See ((<gl_set_params>)) for usage.
1194
-
1195
- ===ucpack
1196
- ---uc_set_params(hash)
1197
- Calls (({DCL.ucpset})) multiple times (for each key and val of (({hash}))).
1198
-
1199
- See ((<gl_set_params>)) for usage.
1200
-
1201
- ===uupack
1202
- ---uu_set_params(hash)
1203
- Calls (({DCL.uupset})) multiple times (for each key and val of (({hash}))).
1204
-
1205
- See ((<gl_set_params>)) for usage.
1206
-
1207
- ===uspack
1208
- ---us_set_params(hash)
1209
- Calls (({DCL.uspset})) multiple times (for each key and val of (({hash}))).
1210
-
1211
- See ((<gl_set_params>)) for usage.
1212
-
1213
- ===udpack
1214
- ---ud_set_params(hash)
1215
- Calls (({DCL.udpset})) multiple times (for each key and val of (({hash}))).
1216
-
1217
- ARGUMENTS
1218
- * hash (Hash) : combinations of parameter names and values for udpset
1219
-
1220
- RETURN VALUE
1221
- * a Hash containing the parameter names and their old values that were
1222
- replaced.
1223
-
1224
- EXAMPLES
1225
- * You can modify parameters temporarily as follows.
1226
-
1227
- before = DCLExt.ud_set_params('indxmj'=>4,'lmsg'=>false)
1228
- DCL.udcntz(data)
1229
- DCLExt.ud_set_params(before) # reset the change
1230
-
1231
- ---ud_set_linear_levs(v, options)
1232
- Set contour levels with a constant interval
1233
-
1234
- ARGUMENTS
1235
- * v : Data values to be fed to udcnt[rz]
1236
- * options (Hash) : option specification by keys and values. Available
1237
- options are
1238
- name default value description
1239
- 'min' nil minimum contour value (Numeric)
1240
- 'max' nil maximum contour value (Numeric)
1241
- 'nlev' nil number of levels (Integer)
1242
- 'interval' nil contour interval (Numeric)
1243
- 'nozero' nil delete zero contour (true/false)
1244
- 'coloring' false set color contours with ud_coloring (true/false)
1245
- 'clr_min' 13 (if coloring) minimum color id (Integer)
1246
- 'clr_max' 99 (if coloring) maximum color id (Integer)
1247
- Here, (({interval})) has a higher precedence over (({nlev})).
1248
- Since all the default values are nil, only those explicitly specified
1249
- are interpreted. If no option is provided, the levels generated will
1250
- be the default ones set by udcnt[rz] without any level specification.
1251
-
1252
- ---ud_set_contour(levels,index=nil,line_type=nil,label=nil,label_height=nil)
1253
- Set contours of at specified levels.
1254
-
1255
- Normally you do not have to specify (({label})) and (({label_height})).
1256
-
1257
- It calls DCL.udsclv for each level. So the arguments are basically
1258
- the same as DCL.udsclv, but only levels are mandatory here.
1259
-
1260
- ARGUMENTS
1261
- * levels (Array, NArray, or Numeric) : contour levels to be set.
1262
- If Numeric, a single level is set.
1263
- * index (Array of integers, Integer, or nil) :
1264
- index(es) of the contours. If it is an Array and its length is
1265
- shorter than that of (({levels})), the same Array is repeated (so
1266
- for instance [1,1,3] is interpreted as [1,1,3,1,1,3,1,1,3,...]).
1267
- If it is a single Integer, all the contour will have the same index.
1268
- If nil, the value of 'indxmn' is used.
1269
- * line_type (Array of integers, Integer, or nil) :
1270
- line type(s) of the contours. If it is an Array and its length is
1271
- shorter than that of (({levels})), the same Array is repeated.
1272
- the length must agree with that of (({levels})).
1273
- If it is a single Integer, all the contour will have the same type.
1274
- If nil, set to be 1.
1275
- * label (Array of String, String, true, false, nil) :
1276
- Label(s) of the contours. If it is an Array and its length is
1277
- shorter than that of (({levels})), the same Array is repeated.
1278
- the length must agree with that of (({levels})).
1279
- If it is a single String, all the contour will have the same label.
1280
- If true, all the contours will have the labels representing the levels.
1281
- If false, no label will be drawn (set to "").
1282
- If nil, same as true for the contours whose index is equal to "INDXMJ",
1283
- and same as false otherwise.
1284
- * label_height (Array of Numeric, Numeric, or nil) :
1285
- Heigh of Labels. Normally you do not have to use this.
1286
- If it is an Array and its length is
1287
- shorter than that of (({levels})), the same Array is repeated.
1288
- If nil, the default value ("RSIZEL") is used for non-empty labels.
1289
- If a single Numeric, the same value is used for all the contours.
1290
- Note that it is recommended to not to use this parameter but
1291
- use DCL.udpset('RZISEL'. label_height), since a positive value
1292
- here always means to draw labels even when the label is empty.
1293
-
1294
- RETURN VALUE
1295
- * nil
1296
-
1297
- ---ud_add_contour(levels,index=nil,line_type=nil,label=nil,label_height=nil)
1298
- Same as ((<ud_set_contour>)), but does not clear the contour levels that have
1299
- been set.
1300
-
1301
- ===uepack
1302
- ---ue_set_params(hash)
1303
- Calls (({DCL.uepset})) multiple times (for each key and val of (({hash}))).
1304
-
1305
- See ((<gl_set_params>)) for usage.
1306
-
1307
- ---ue_set_linear_levs(v, options)
1308
- Set tone levels with a constant interval
1309
-
1310
- ARGUMENTS
1311
- * v : Data values to be fed to udcnt[rz]
1312
- * options (Hash) : option specification by keys and values. Available
1313
- options are
1314
- name default value description
1315
- 'min' nil minimum tone level (Numeric)
1316
- 'max' nil maximum tone level (Numeric)
1317
- 'nlev' nil number of levels (Integer)
1318
- 'interval' nil tone-level interval (Numeric)
1319
- Here, (({interval})) has a higher precedence over (({nlev})).
1320
- Since all the default values are nil, only those explicitly specified
1321
- are interpreted. If no option is provided, the levels generated will
1322
- be the default ones set by udcnt[rz] without any level specification.
1323
-
1324
- ---ue_set_tone(levels, patterns)
1325
- Set tone levels and patterns.
1326
-
1327
- patterns are set between levels as follows:
1328
-
1329
- when (levels.length == patterns.length+1)
1330
-
1331
- levels[0] | levels[1] | levels[2] ... | levels[-2] | levels[-1]
1332
- patterns[0] patterns[1] ... patterns[-2] patterns[-1]
1333
-
1334
- when (levels.length == patterns.length)
1335
-
1336
- levels[0] | levels[1] | levels[2] ... | levels[-1] | +infty
1337
- patterns[0] patterns[1] ... patterns[-2] patterns[-1]
1338
-
1339
- when (levels.length == patterns.length-1)
1340
-
1341
- -infty | levels[0] | levels[1] ... | levels[-1] | +infty
1342
- patterns[0] patterns[1] ... patterns[-2] patterns[-1]
1343
-
1344
- else
1345
- error (exception raised)
1346
-
1347
- ARGUMENTS
1348
- * levels (Array or NArray of Numeric) : tone levels. Its length must be
1349
- either 1 larger than, equal to, or 1 smaller than the length of patterns
1350
- * patterns (Array or NArray of Numeric) : tone patterns
1351
-
1352
- RETURN VALUE
1353
- * nil
1354
-
1355
- ---ue_add_tone(levels, patterns)
1356
- Same as ((<ue_set_tone>)), but does not clear the tone levels that have
1357
- been set.
1358
-
1359
- ===ugpack
1360
- ---ug_set_params(hash)
1361
- Calls (({DCL.ugpset})) multiple times (for each key and val of (({hash}))).
1362
- See ((<gl_set_params>)) for usage.
1363
-
1364
- ===umpack
1365
- ---um_set_params(hash)
1366
- Calls (({DCL.umpset})) multiple times (for each key and val of (({hash}))).
1367
-
1368
- See ((<gl_set_params>)) for usage.
1369
-
1370
- ==Original methods:
1371
-
1372
- ===Longitude/Latitude Axes
1373
- ---lon_ax( options=nil )
1374
-
1375
- Draw longitude axis. (label format: degrees + 'E' or 'W')
1376
-
1377
- ARGUMENTS
1378
- * options (Hash) : options to change the default behavior if specified.
1379
- It is a Hash with option names (String) as keys and their values.
1380
- Options are interpreted by a NumRu::Misc::KeywordOptAutoHelp,
1381
- so you can shorten the keys (by omitting tails) as long as it is
1382
- unambiguous.
1383
- option name default value # description:
1384
- "yax" false # true => draw y-axis, false => draw x-axis
1385
- "cside" nil # "b", "t", "l", "r",
1386
- # nil (=>left/bottom), or false (=>right/top)
1387
- "dtick1" nil # Interval of small tickmark
1388
- # (if nil, internally determined)
1389
- "dtick2" nil # Interval of large tickmark with labels
1390
- # (if nil, internally determined)
1391
-
1392
- ---lat_ax( options=nil )
1393
-
1394
- Draw latitude axis. (label format: degrees + 'N' or 'S')
1395
-
1396
- ARGUMENTS
1397
- * options (Hash) : options to change the default behavior if specified.
1398
- It is a Hash with option names (String) as keys and their values.
1399
- Options are interpreted by a NumRu::Misc::KeywordOptAutoHelp,
1400
- so you can shorten the keys (by omitting tails) as long as it is
1401
- unambiguous.
1402
- option name default value # description:
1403
- "xax" false # true => draw x-axis, false => draw y-axis
1404
- "cside" nil # "b", "t", "l", "r",
1405
- # nil (=>left/bottom), or false (=>right/top)
1406
- "dtick1" nil # Interval of small tickmark
1407
- # (if nil, internally determined)
1408
- "dtick2" nil # Interval of large tickmark with labels
1409
- # (if nil, internally determined)
1410
-
1411
- ===Vectors
1412
- ---unit_vect( vxfxratio, vyfyratio, fxunit=nil, fyunit=nil, options=nil )
1413
-
1414
- Show the "unit vector", which indicate the vector scaling.
1415
-
1416
- ARGUMENTS
1417
- * vxfxratio (Float) : (V cood length)/(actual length) in x
1418
- * vyfyratio (Float) : (V cood length)/(actual length) in y
1419
- * fxunit (Float) : If specified, x unit vect len
1420
- * fyunit (Float) : If specified, y unit vect len
1421
- * options (Hash) : options to change the default behavior if specified.
1422
- It is a Hash with option names (String) as keys and their values.
1423
- Options are interpreted by a NumRu::Misc::KeywordOptAutoHelp,
1424
- so you can shorten the keys (by omitting tails) as long as it is
1425
- unambiguous.
1426
- option name default value # description:
1427
- "vxunit" 0.05 # x unit vect len in V coord. Used only when
1428
- # fxunit is omitted (default)
1429
- "vyunit" 0.05 # y unit vect len in V coord. Used only when
1430
- # fyunit is omitted (default)
1431
- "vxuloc" nil # Starting x position of unit vect
1432
- "vyuloc" nil # Starting y position of unit vect
1433
- "vxuoff" 0.05 # Specify vxuloc by offset from right-bottom
1434
- # corner
1435
- "vyuoff" 0.0 # Specify vyuloc by offset from right-bottom
1436
- # corner
1437
- "inplace" true # Whether to print labels right by the unit
1438
- # vector (true) or below the x axis (false)
1439
- "rsizet" nil # Label size(default taken from uz-parameter
1440
- # 'rsizel1')
1441
- "index" 3 # Line index of the unit vector
1442
- "help" false # show help message if true
1443
-
1444
- ---set_unit_vect_options(options)
1445
- Change the default option values for ((<unit_vect>)).
1446
-
1447
- ---next_unit_vect_options(options)
1448
- Set the option values effective only in the next call of ((<unit_vect>))
1449
-
1450
- ---flow_vect( fx, fy, factor=1.0, xintv=1, yintv=1)
1451
-
1452
- 2D Vector plot. Unlike (({DCL::ugvect})), scaling are made in term of the physical (or "U") coordinate.
1453
-
1454
- This method is meant to substitute (({DCL::ugvect})). The scaling
1455
- is made in terms of the U coordinate. This method is suitable to
1456
- show vectors such as velocity, since the arrow direction represets
1457
- the direction in the U coordinate. Also, one can re-scale the
1458
- vector length easily by using the argument (({factor})).
1459
-
1460
- Currently, this method is not compatible with map projection,
1461
- since it calls (({DCL::ugvect})) internally.
1462
-
1463
- ARGUMENTS
1464
- * fx, fy (2D NArray or Array) : the vector field.
1465
- * factor (Integer) : factor to change the arrow length.
1466
- By default, arrows are scaled so that the longest one
1467
- match the grid interval.
1468
- * xintv, yintv (Interger) : interval to thin out (({fx})) and (({fy})),
1469
- respectively. Useful if the grid points are too many.
1470
-
1471
- ---flow_itr5( fx, fy, factor=1.0, unit_vect=false )
1472
-
1473
- 2D Vector plot on the polar coodinate.
1474
-
1475
- This method just perform rotatation of the vector in U-coordinate
1476
- to N-coordinate and passed to DCL.ugvect.
1477
-
1478
- ARGUMENTS
1479
- * fx, fy (2D GPhys) : the vector field.
1480
- * factor (Integer) : factor for scaling in ugvect. When it equals 1,
1481
- vector field will be scaled in DCL.ugvect automatically.
1482
- * unit_vect() : Show the unit vector
1483
-
1484
- ===Color bars
1485
- ---set_color_bar_options(options)
1486
- To set options of ((<color_bar>)) effective in the rest.
1487
-
1488
- ---color_bar(options=nil)
1489
- * Descroption:
1490
- Draws color bars
1491
-
1492
- * Example
1493
- Here is the simplest case, where no argument is given to color_bar.
1494
-
1495
- DCL.uetone(hoge)
1496
- DCL.usdaxs
1497
- ...
1498
- DCL.color_bar
1499
-
1500
- This draws a color bar by using the levels and tone patterns(colors)
1501
- set previously. There are many parameters you can set manually,
1502
- as introduced below:
1503
-
1504
- * Description of options
1505
- option name default value # description:
1506
- "levels" nil # tone levels (if omitted, latest ones are used)
1507
- "patterns" nil # tone patterns (~colors) (if omitted, latest
1508
- # ones are used)
1509
- "voff" nil # how far is the bar from the viewport in the V
1510
- # coordinate
1511
- "vcent" nil # center position of the bar in the V coordinate
1512
- # (VX or VY)
1513
- "vlength" 0.3 # bar length in the V coordinate
1514
- "vwidth" 0.02 # bar width in the V coordinate
1515
- "inffact" 2.25 # factor to change the length of triangle on the
1516
- # side for infinity (relative to 'vwidth')
1517
- "landscape" false # if true, horizonlly long (along x axes)
1518
- "portrait" true # if true, vertically long (along y axes)
1519
- "top" false # place the bar at the top (effective if
1520
- # landscape)
1521
- "left" false # place the bar in the left (effective if
1522
- # portrait)
1523
- "units" nil # units of the axis of the color bar
1524
- "units_voff" 0.0 # offset value for units from the default position
1525
- # in the V coordinate (only for 'units' != nil)
1526
- "title" nil # title of the color bar
1527
- "title_voff" 0.0 # offset value for title from the default position
1528
- # in the V coordinate (only for 'title' != nil)
1529
- "tickintv" 1 # 0,1,2,3,.. to specify how frequently the
1530
- # dividing tick lines are drawn (0: no tick lines,
1531
- # 1: every time, 2: ever other:,...)
1532
- "labelintv" nil # 0,1,2,3,.. to specify how frequently labels are
1533
- # drawn (0: no labels, 1: every time, 2: ever
1534
- # other:,... default: internally determined)
1535
- "labels_ud" nil # user-defined labels for replacing the default
1536
- # labels (Array of String)
1537
- "charfact" 0.9 # factor to change the label/units/title character
1538
- # size (relative to 'rsizel1')
1539
- "log" false # set the color bar scale to logarithmic
1540
- "constwidth" false # if true, each color is drawn with the same width
1541
- "index" nil # line index of tick lines and bar frame
1542
- "charindex" nil # line index of labels, units, and title
1543
- "chval_fmt" nil # string to specify the DCL.chval format for
1544
- # labeling
1545
- "help" false # show help message if true
1546
-
1547
- ===Others
1548
- ---legend(str, type, index, line=false, size=nil, vx=nil, dx=nil, vy=nil, first=true, mark_size=nil)
1549
-
1550
- Annotates line/mark type and index (and size if mark).
1551
- By default it is shown in the right margin of the viewport.
1552
-
1553
- * str is a String to show
1554
- * line: true->line ; false->mark
1555
- * vx: vx of the left-hand point of legend line (or mark position).
1556
- * nil : internally determined
1557
- * Float && > 0 : set explicitly
1558
- * Float && < 0 : move it relatively to the left from the default
1559
- * dx: length of the legend line (not used if mark).
1560
- * nil : internally determined
1561
- * Float && > 0 : set explicitly
1562
- * vy: vy of the legend (not used if !first -- see below).
1563
- * nil : internally determined
1564
- * Float && > 0 : set explicitly
1565
- * Float && < 0 : move it relatively lower from the default
1566
- * first : if false, vy is moved lower relatively from the previous vy.
1567
- * mark_size : size of the mark. if nil, size is used.
1568
-
1569
- ---quasi_log_levels_z(vals, nlev=nil, max=nil, min=nil, cycle=1)
1570
-
1571
- Driver of quasi_log_levels with data values
1572
-
1573
- ---quasi_log_levels(lev0, lev1, cycle=1)
1574
-
1575
- Returns approximately log-scaled contour/tone levels as well as
1576
- major/minor flags for contours. No DCL call is made in here.
1577
-
1578
- * cycle (Integer; 1, or 2 or 3) : number of level in one-order.
1579
- e.g. 1,10,100,.. for cycle==1; 1,3,10,30,.. for cycle==2;
1580
- 1,2,5,10,20,50,.. for cycle==3
1581
- * lev0, lev1 (Float) : levels are set between this two params
1582
- * if lev0 & lev1 > 0 : positive only
1583
- * if lev0 & lev1 < 0 : negative only
1584
- * if lev0 * lev1 < 0 : both positive and negative
1585
- (usig +-[lev0.abs,lev1.abs])
1586
- RETURN VALUE:
1587
- * [ levels, mjmn ]
1588
-
1589
- =end
1590
- ############################################################
1591
-
1592
- module NumRu
1593
-
1594
- module DCLExt
1595
- # to be included in the RubyDCL distribution
1596
-
1597
- module_function
1598
-
1599
- #<<< for many packages >>>
1600
-
1601
- %w!gl sg sl sw uz ul uc uu us ud ue ug um!.each do |pkg|
1602
- eval <<-EOS, nil, __FILE__, __LINE__+1
1603
- def #{pkg}_set_params(hash)
1604
- before = Hash.new
1605
- hash.each{|k,v|
1606
- before[k]=DCL.#{pkg}pget(k)
1607
- if(v.is_a? String) then
1608
- DCL.#{pkg}cset(k,v)
1609
- else
1610
- DCL.#{pkg}pset(k,v)
1611
- end
1612
- }
1613
- before
1614
- end
1615
- EOS
1616
- end
1617
-
1618
- #<<< module data >>>
1619
-
1620
- @@empty_hash = Hash.new
1621
-
1622
- #<<< udpack >>>
1623
-
1624
- def ud_coloring(clr_min=13, clr_max=99)
1625
- # change the colors of existing contours to make a gradation
1626
- # (rainbow colors with the default color map).
1627
- nlev = DCL.udqcln
1628
- cont_params = Array.new
1629
- for i in 1..nlev
1630
- cont_params.push( DCL.udqclv(i) ) # => [zlev,indx,ityp,clv,hl]
1631
- end
1632
- DCL.udiclv # clear the contours
1633
-
1634
- colors = clr_min +
1635
- NArray.int(nlev).indgen! * (clr_max-clr_min) / nlev
1636
-
1637
- cont_params.sort!
1638
- for i in 0...nlev
1639
- cont_params[i][1] += colors[i]*10 # indx += colors[i]*10
1640
- DCL.udsclv(*cont_params[i])
1641
- end
1642
- end
1643
-
1644
- def ud_set_linear_levs(v, options=nil)
1645
- #Accepted options
1646
- # name default description
1647
- # 'min' nil minimum contour value (Numeric)
1648
- # 'max' nil maximum contour value (Numeric)
1649
- # 'nlev' nil number of levels (Integer)
1650
- # 'interval' nil contour interval (Numeric)
1651
- # 'nozero' false delete zero contour (true/false)
1652
- # 'coloring' false set color contours with ud_coloring (true/false)
1653
- # 'clr_min' 13 (if coloring) minimum color number for the
1654
- # maximum data values (Integer)
1655
- # 'clr_max' 99 (if coloring) maximum color number for the
1656
- # maximum data values (Integer)
1657
- options = @@empty_hash if !options
1658
- raise TypeError, "options must be a Hash" if !options.is_a?(Hash)
1659
- min = options['min']
1660
- max = options['max']
1661
- nlev = options['nlev']
1662
- interval = options['interval']
1663
- nozero = options['nozero']
1664
- if interval
1665
- dx = interval
1666
- elsif nlev
1667
- dx = -nlev
1668
- else
1669
- dx = 0
1670
- end
1671
- if min || max
1672
- min = v.min if !min
1673
- max = v.max if !max
1674
- DCL.udgcla(min, max, dx)
1675
- else
1676
- DCL.udgclb(v, dx)
1677
- end
1678
- if nozero
1679
- DCL.uddclv(0.0)
1680
- end
1681
- if options['coloring']
1682
- clr_min = ( options['clr_min'] || 13 )
1683
- clr_max = ( options['clr_max'] || 99 )
1684
- ud_coloring( clr_min, clr_max )
1685
- end
1686
- end
1687
-
1688
- def ud_set_contour(*args)
1689
- DCL.udiclv
1690
- ud_add_contour(*args)
1691
- end
1692
-
1693
- def ud_add_contour(levels,index=nil,line_type=nil,label=nil,label_height=nil)
1694
-
1695
- # < check levels >
1696
- case levels
1697
- when Array, NArray
1698
- # This is expected. Nothing to do.
1699
- when Numric
1700
- levels = [levels]
1701
- else
1702
- raise ArgumentError, "invalid level specification (#{levels})"
1703
- end
1704
-
1705
- nlev = levels.length
1706
-
1707
- # < index >
1708
- index = index.to_a if index.is_a?(NArray)
1709
- case index
1710
- when Array
1711
- raise ArgumentError, "index is an empty array" if index.length == 0
1712
- while (index.length < nlev )
1713
- index += index
1714
- end
1715
- when Numeric
1716
- index = [index]*nlev
1717
- when nil
1718
- index = [DCL.udpget('indxmn')]*nlev
1719
- else
1720
- raise ArgumentError, "unsupported index type (#{index.class})"
1721
- end
1722
-
1723
- # < line_type >
1724
- line_type = line_type.to_a if line_type.is_a?(NArray)
1725
- case line_type
1726
- when Array
1727
- raise ArgumentError, "line_type is an empty array" if line_type.length == 0
1728
- while (line_type.length < nlev )
1729
- line_type += line_type
1730
- end
1731
- when Numeric
1732
- line_type = [line_type]*nlev
1733
- when nil
1734
- line_type = [1]*nlev
1735
- else
1736
- raise ArgumentError, "unsupported index type (#{index.class})"
1737
- end
1738
-
1739
- # < label >
1740
- label = label.to_a if label.is_a?(NArray)
1741
- case label
1742
- when Array
1743
- raise ArgumentError, "label is an empty array" if label.length == 0
1744
- while (label.length < nlev )
1745
- label += label
1746
- end
1747
- when String
1748
- label = [label]*nlev
1749
- when false
1750
- label = [""]*nlev
1751
- when true
1752
- label = (0...nlev).collect{|i|
1753
- DCL.udlabl(levels[i])
1754
- }
1755
- when nil
1756
- indxmj = DCL.udpget('indxmj')
1757
- label = (0...nlev).collect{|i|
1758
- if index[i]==indxmj
1759
- DCL.udlabl(levels[i])
1760
- else
1761
- ""
1762
- end
1763
- }
1764
- else
1765
- raise ArgumentError, "unsupported index type (#{index.class})"
1766
- end
1767
-
1768
- # < label_height >
1769
- label_height = label_height.to_a if label_height.is_a?(NArray)
1770
- case label_height
1771
- when Array
1772
- raise ArgumentError, "label_height is an empty array" if label_height.length == 0
1773
- while (label_height.length < nlev )
1774
- label_height += label_height
1775
- end
1776
- when Numeric
1777
- label_height = [label_height]*nlev
1778
- when nil
1779
- label_height = label.collect{|lv| lv=="" ? 0.0 : DCL.udpget('rsizel')}
1780
- else
1781
- raise ArgumentError, "unsupported index type (#{index.class})"
1782
- end
1783
-
1784
- # < set levels >
1785
-
1786
- for i in 0...nlev
1787
- DCL.udsclv(levels[i],index[i],line_type[i],label[i],label_height[i])
1788
- end
1789
- nil
1790
- end
1791
-
1792
- #<<< uepack >>>
1793
-
1794
- def ue_set_linear_levs(v, options=nil)
1795
- # 'min' nil minimum tone level (Numeric)
1796
- # 'max' nil maximum tone level (Numeric)
1797
- # 'nlev' nil number of levels (Integer)
1798
- # 'interval' nil tone-level interval (Numeric)
1799
- options = @@empty_hash if !options
1800
- raise TypeError, "options must be a Hash" if !options.is_a?(Hash)
1801
- min = options['min']
1802
- max = options['max']
1803
- nlev = options['nlev']
1804
- interval = options['interval']
1805
- if interval
1806
- dx = interval
1807
- elsif nlev
1808
- dx = -nlev
1809
- else
1810
- dx = 0
1811
- end
1812
- if min || max
1813
- min = v.min if !min
1814
- max = v.max if !max
1815
- DCL.uegtla(min, max, dx)
1816
- else
1817
- v = v.reshape(v.length,1) if v.rank==1
1818
- DCL.uegtlb(v, dx)
1819
- end
1820
- end
1821
-
1822
- def ue_set_tone(levels, patterns)
1823
- DCL.ueitlv
1824
- ue_add_tone(levels, patterns)
1825
- end
1826
-
1827
- def ue_add_tone(levels, patterns)
1828
-
1829
- # < check types >
1830
-
1831
- if !levels.is_a?(Array) && !levels.is_a?(NArray)
1832
- raise TypeError, "levels: Array or NArray expected (#{levels.inspect})"
1833
- end
1834
- if !patterns.is_a?(Array) && !patterns.is_a?(NArray)
1835
- raise TypeError, "patterns: Array or NArray expected (#{patterns.inspect})"
1836
- end
1837
-
1838
- # < set levels >
1839
-
1840
- nlev = levels.length
1841
- npat = patterns.length
1842
-
1843
- case (nlev - npat)
1844
- when 1
1845
- for i in 0...nlev-1
1846
- DCL.uestlv(levels[i],levels[i+1],patterns[i])
1847
- end
1848
- when 0
1849
- for i in 0...nlev-1
1850
- DCL.uestlv(levels[i],levels[i+1],patterns[i])
1851
- end
1852
- DCL.uestlv(levels[-1],DCL.glpget('rmiss'),patterns[-1])
1853
- when -1
1854
- DCL.uestlv(DCL.glpget('rmiss'),levels[0],patterns[0])
1855
- for i in 1...nlev
1856
- DCL.uestlv(levels[i-1],levels[i],patterns[i])
1857
- end
1858
- DCL.uestlv(levels[-1],DCL.glpget('rmiss'),patterns[-1])
1859
- else
1860
- raise ArgumentError,
1861
- "lengths of levels(#{nlev}) and patterns(#{npat}) are inconsistent"
1862
- end
1863
- nil
1864
- end
1865
-
1866
- ############################################################
1867
- # RELATIVELY INDEPENDENT OF DCL SUBLIBRARIES
1868
- ############################################################
1869
-
1870
- # <<< longitude/latitude axes package >>>
1871
-
1872
- @@lon_ax_options = Misc::KeywordOptAutoHelp.new(
1873
- ['yax', false, 'true => y-axis, false => x-axis'],
1874
- ['cside', nil, '"b", "t", "l", "r", nil (=>left/bottom), or false (=>right/top)'],
1875
- ['dtick1', nil, 'Interval of small tickmark (if nil, internally determined)'],
1876
- ['dtick2', nil, 'Interval of large tickmark with labels (if nil, internally determined)']
1877
- )
1878
-
1879
- def lon_ax(options=nil)
1880
- opt = @@lon_ax_options.interpret(options)
1881
-
1882
- yax = opt['yax']
1883
- xax = !yax
1884
- if xax
1885
- xy='x'
1886
- else
1887
- xy='y'
1888
- end
1889
-
1890
- if opt['cside']
1891
- cside = opt['cside']
1892
- elsif opt['cside'].nil?
1893
- if xax
1894
- cside='b'
1895
- else
1896
- cside='l'
1897
- end
1898
- else
1899
- if xax
1900
- cside='t'
1901
- else
1902
- cside='r'
1903
- end
1904
- end
1905
-
1906
- vxmin, vxmax, vymin, vymax = DCL.sgqvpt
1907
- uxmin, uxmax, uymin, uymax = DCL.sgqwnd
1908
- if xax
1909
- vmin, vmax = [vxmin,vxmax].min, [vxmin,vxmax].max
1910
- umin, umax = [uxmin,uxmax].min, [uxmin,uxmax].max
1911
- else
1912
- vmin, vmax = [vymin,vymax].min, [vymin,vymax].max
1913
- umin, umax = [uymin,uymax].min, [uymin,uymax].max
1914
- end
1915
-
1916
- # get dtick1 & dtick2
1917
- dtick1 = opt['dtick1']
1918
- dtick2 = opt['dtick2']
1919
- unless dtick1 && dtick2
1920
- irota = DCL.uzpget("irotl#{xy}#{cside}")
1921
- irota += 1 if yax
1922
- mode = irota.modulo(2)
1923
- DCL.ususcu(xy.capitalize,umin,umax,vmin,vmax,mode)
1924
- dtick1 = DCL.uspget("d#{xy}t") unless dtick1
1925
- dtick2 = DCL.uspget("d#{xy}l") unless dtick2
1926
- end
1927
-
1928
- lepsl = DCL.glpget('lepsl')
1929
- repsl = DCL.glpget('repsl')
1930
- DCL.glpset('lepsl',true)
1931
-
1932
- # generate numbers for small tickmarks
1933
- nn = 0
1934
- rx = DCL.irle(umin/dtick1)*dtick1
1935
- if DCL.lreq(umin,rx)
1936
- x = rx
1937
- else
1938
- x = rx + dtick1
1939
- end
1940
- u1 = []
1941
- while DCL.lrle(x,umax)
1942
- if x.abs < dtick1*repsl*nn
1943
- x = 0.0
1944
- end
1945
- u1[nn] = x
1946
- nn = nn + 1
1947
- x = x + dtick1
1948
- end
1949
-
1950
- # generate numbers for large tickmarks and labels
1951
- nn = 0
1952
- rx = DCL.irle(umin/dtick2)*dtick2
1953
- if DCL.lreq(umin,rx)
1954
- x = rx
1955
- else
1956
- x = rx + dtick2
1957
- end
1958
- u2 = []
1959
- while DCL.lrle(x,umax)
1960
- if x.abs < dtick2*repsl*nn
1961
- x = 0
1962
- end
1963
- u2[nn] = x
1964
- nn = nn + 1
1965
- x = x + dtick2
1966
- end
1967
-
1968
- # generate labels
1969
- c2 = NArray.to_na(u2)
1970
- c2[c2.gt(180)] -= 360.0
1971
- c2[c2.lt(-180)] += 360.0
1972
- c2[c2.eq(-180)] = 180.0
1973
- c2 = c2.to_a.collect do |c|
1974
- if c == 0 || c == 180
1975
- c.to_i.to_s
1976
- elsif c > 0
1977
- c.to_i.to_s + 'E'
1978
- else
1979
- c.abs.to_i.to_s + 'W'
1980
- end
1981
- end
1982
- nc = c2.collect{|c| c.size}.max
1983
-
1984
- # call DCL.u[xy]axlb
1985
- if xax
1986
- DCL.uxaxlb(cside,u1,u2,c2,nc)
1987
- else
1988
- DCL.uyaxlb(cside,u1,u2,c2,nc)
1989
- end
1990
- end
1991
-
1992
- @@lat_ax_options = Misc::KeywordOptAutoHelp.new(
1993
- ['xax', false, 'true => x-axis, false => y-axis'],
1994
- ['cside', nil, '"b", "t", "l", "r", nil (=>left/bottom), or false (=>right/top)'],
1995
- ['dtick1', nil, 'Interval of small tickmark (if nil, internally determined)'],
1996
- ['dtick2', nil, 'Interval of large tickmark with labels (if nil, internally determined)']
1997
- )
1998
-
1999
- def lat_ax(options=nil)
2000
- opt = @@lat_ax_options.interpret(options)
2001
-
2002
- xax = opt['xax']
2003
- yax = !xax
2004
- if xax
2005
- xy='x'
2006
- else
2007
- xy='y'
2008
- end
2009
-
2010
- if opt['cside']
2011
- cside = opt['cside']
2012
- elsif opt['cside'].nil?
2013
- if xax
2014
- cside='b'
2015
- else
2016
- cside='l'
2017
- end
2018
- else
2019
- if xax
2020
- cside='t'
2021
- else
2022
- cside='r'
2023
- end
2024
- end
2025
-
2026
- vxmin, vxmax, vymin, vymax = DCL.sgqvpt
2027
- uxmin, uxmax, uymin, uymax = DCL.sgqwnd
2028
- if xax
2029
- vmin, vmax = [vxmin,vxmax].min, [vxmin,vxmax].max
2030
- umin, umax = [uxmin,uxmax].min, [uxmin,uxmax].max
2031
- else
2032
- vmin, vmax = [vymin,vymax].min, [vymin,vymax].max
2033
- umin, umax = [uymin,uymax].min, [uymin,uymax].max
2034
- end
2035
-
2036
- # get dtick1 & dtick2
2037
- dtick1 = opt['dtick1']
2038
- dtick2 = opt['dtick2']
2039
- unless dtick1 && dtick2
2040
- irota = DCL.uzpget("irotl#{xy}#{cside}")
2041
- irota += 1 if yax
2042
- mode = irota.modulo(2)
2043
- DCL.ususcu(xy.capitalize,umin,umax,vmin,vmax,mode)
2044
- dtick1 = DCL.uspget("d#{xy}t") unless dtick1
2045
- dtick2 = DCL.uspget("d#{xy}l") unless dtick2
2046
- end
2047
-
2048
- lepsl = DCL.glpget('lepsl')
2049
- repsl = DCL.glpget('repsl')
2050
- DCL.glpset('lepsl',true)
2051
-
2052
- # generate numbers for small tickmarks
2053
- nn = 0
2054
- rx = DCL.irle(umin/dtick1)*dtick1
2055
- if DCL.lreq(umin,rx)
2056
- x = rx
2057
- else
2058
- x = rx + dtick1
2059
- end
2060
- u1 = []
2061
- while DCL.lrle(x,umax)
2062
- if x.abs < dtick1*repsl*nn
2063
- x = 0.0
2064
- end
2065
- u1[nn] = x
2066
- nn = nn + 1
2067
- x = x + dtick1
2068
- end
2069
-
2070
- # generate numbers for large tickmarks and labels
2071
- nn = 0
2072
- rx = DCL.irle(umin/dtick2)*dtick2
2073
- if DCL.lreq(umin,rx)
2074
- x = rx
2075
- else
2076
- x = rx + dtick2
2077
- end
2078
- u2 = []
2079
- while DCL.lrle(x,umax)
2080
- if x.abs < dtick2*repsl*nn
2081
- x = 0
2082
- end
2083
- u2[nn] = x
2084
- nn = nn + 1
2085
- x = x + dtick2
2086
- end
2087
-
2088
- # generate labels
2089
- c2 = NArray.to_na(u2)
2090
- c2 = c2.to_a.collect do |c|
2091
- if c == 0
2092
- 'EQ'
2093
- elsif c > 0
2094
- c.to_i.to_s + 'N'
2095
- else
2096
- c.abs.to_i.to_s + 'S'
2097
- end
2098
- end
2099
- nc = c2.collect{|c| c.size}.max
2100
-
2101
- # call DCL.u[xy]axlb
2102
- if xax
2103
- DCL.uxaxlb(cside,u1,u2,c2,nc)
2104
- else
2105
- DCL.uyaxlb(cside,u1,u2,c2,nc)
2106
- end
2107
- end
2108
-
2109
- # <<< flow vector package >>>
2110
-
2111
- def __truncate(float, order=2)
2112
- # truncate (round) a floating number with the number digits
2113
- # specified by "order".
2114
- # e.g., if order=3, -0.012345 => -0.0123; 6.6666 => 6.67
2115
- exponent = 10**(-Math::log10(float.abs).floor+order-1)
2116
- (float * exponent).round.to_f/exponent
2117
- end
2118
-
2119
- @@unit_vect_options = Misc::KeywordOptAutoHelp.new(
2120
- ['vxunit', 0.05, "x unit vect len in V coord. Used only when fxunit is omitted (default)"],
2121
- ['vyunit', 0.05, "y unit vect len in V coord. Used only when fyunit is omitted (default)"],
2122
- ['vxuloc', nil, "Starting x position of unit vect"],
2123
- ['vyuloc', nil, "Starting y position of unit vect"],
2124
- ['vxuoff', 0.05, "Specify vxuloc by offset from right-bottom corner"],
2125
- ['vyuoff', 0.0, "Specify vyuloc by offset from right-bottom corner"],
2126
- ['inplace',true, "Whether to print labels right by the unit vector (true) or below the x axis (false)"],
2127
- ['rsizet', nil, "Label size(default taken from uz-parameter 'rsizel1')"],
2128
- ['index', 3," Line index of the unit vector"]
2129
- )
2130
-
2131
- def set_unit_vect_options(options)
2132
- @@unit_vect_options.set(options)
2133
- end
2134
-
2135
- @@next_unit_vect_options = nil
2136
- def next_unit_vect_options(options)
2137
- if options.is_a?(Hash)
2138
- @@next_unit_vect_options = options
2139
- else
2140
- raise TypeError,"Hash expected"
2141
- end
2142
- nil
2143
- end
2144
-
2145
- def unit_vect( vxfxratio, # (V cood length)/(actual length) in x
2146
- vyfyratio, # (V cood length)/(actual length) in y
2147
- fxunit=nil, # If specified, x unit vect len
2148
- fyunit=nil, # If specified, y unit vect len
2149
- options=nil )
2150
- #< options >
2151
- if @@next_unit_vect_options
2152
- options = ( options ? @@next_unit_vect_options.update(options) :
2153
- @@next_unit_vect_options )
2154
- @@next_unit_vect_options = nil
2155
- end
2156
- opt = @@unit_vect_options.interpret(options)
2157
- vxunit = opt['vxunit']
2158
- vyunit = opt['vyunit']
2159
- vxuloc = opt['vxuloc']
2160
- vyuloc = opt['vyuloc']
2161
- rsizet = opt['rsizet']
2162
- index = opt['index']
2163
-
2164
- #< unit vector >
2165
- if fxunit
2166
- vxunit = vxfxratio * fxunit
2167
- else
2168
- fxunit = vxunit / vxfxratio
2169
- end
2170
- if fyunit
2171
- vyunit = vyfyratio * fyunit
2172
- else
2173
- fyunit = vyunit / vyfyratio
2174
- end
2175
- fxunit = __truncate( (uxusv=fxunit) )
2176
- fyunit = __truncate( (uyusv=fyunit) )
2177
- vxunit = vxunit * (fxunit/uxusv)
2178
- vyunit = vyunit * (fyunit/uyusv)
2179
- if !(vxuloc && vyuloc)
2180
- vx0,vx1,vy0,vy1 = DCL.sgqvpt
2181
- vxuloc = vx1 + opt['vxuoff'] if !vxuloc
2182
- vyuloc = vy0 + opt['vyuoff'] if !vyuloc
2183
- end
2184
- DCL.sglazv( vxuloc, vyuloc, vxuloc+vxunit, vyuloc, 1, index )
2185
- DCL.sglazv( vxuloc, vyuloc, vxuloc, vyuloc+vyunit, 1, index )
2186
-
2187
- #< labelling >
2188
- sfxunit = sprintf("%.2g",fxunit)
2189
- sfyunit = sprintf("%.2g",fyunit)
2190
- rsizet = DCL.uzpget('rsizel1') if !rsizet
2191
- if opt['inplace']
2192
- DCL.sgtxzv(vxuloc, vyuloc-1.2*rsizet,
2193
- sfxunit, rsizet, 0, -1, index)
2194
- DCL.sgtxzv(vxuloc+1.2*rsizet, vyuloc+0.5*rsizet,
2195
- sfyunit, rsizet, 90, -1, index)
2196
- else
2197
- msg= "UNIT VECTOR X:#{sfxunit} Y:#{sfyunit}"
2198
- before = uz_set_params({'rsizec1'=>rsizet})
2199
- DCL.uxsttl('b',' ',0.0)
2200
- DCL.uxsttl('b',msg,0.0)
2201
- uz_set_params(before)
2202
- end
2203
- end
2204
-
2205
- def flow_vect( fx, fy, factor=1.0, xintv=1, yintv=1,
2206
- vxfxratio=nil, vyfyratio=nil)
2207
- raise ArgumentError,"Expect 2D arrays" if fx.rank != 2 || fy.rank != 2
2208
- raise ArgumentError,"fx.shape != fy.shape" if fx.shape != fy.shape
2209
- raise ArgumentError,"xintv must be a positive integer" if xintv < 0
2210
- raise ArgumentError,"yintv must be a positive integer" if yintv < 0
2211
- nx, ny = fx.shape
2212
- if xintv >= 2
2213
- idx = NArray.int(nx/xintv).indgen!*xintv # [0,xintv,2*xintv,..]
2214
- fx = fx[idx, true]
2215
- fy = fy[idx, true]
2216
- end
2217
- if yintv >= 2
2218
- idx = NArray.int(ny/yintv).indgen!*yintv # [0,yintv,2*yintv,..]
2219
- fx = fx[true, idx]
2220
- fy = fy[true, idx]
2221
- end
2222
- nx, ny = fx.shape # again, because of xintv & yintv
2223
- vx0,vx1,vy0,vy1 = DCL.sgqvpt
2224
- wnd = DCL.sgqwnd
2225
- if wnd.include?(DCL.glrget('rundef'))
2226
- ux0,ux1,uy0,uy1 = DCL.sgqtxy
2227
- else
2228
- ux0,ux1,uy0,uy1 = wnd
2229
- end
2230
- dvx = (vx1-vx0)/nx
2231
- dvy = (vy1-vy0)/ny
2232
- ax = (vx1-vx0)/(ux1-ux0) # factor to convert from U to V coordinate
2233
- ay = (vy1-vy0)/(uy1-uy0) # factor to convert from U to V coordinate
2234
- fxmx = fx.abs.max
2235
- fymx = fy.abs.max
2236
- raise "fx has no data or all zero" if fxmx == 0
2237
- raise "fy has no data or all zero" if fymx == 0
2238
- cn = [ dvx/(ax*fxmx), dvy/(ay*fymx) ].min # normarization constant
2239
- vxfxratio = factor*cn*ax if !vxfxratio
2240
- vyfyratio = factor*cn*ay if !vyfyratio
2241
- before = ug_set_params( {'LNRMAL'=>false, 'LMSG'=>false,
2242
- 'XFACT1'=>1.0, 'YFACT1'=>1.0} )
2243
- DCL.ugvect( vxfxratio*fx, vyfyratio*fy )
2244
- ug_set_params( before )
2245
- unit_vect_info = [ vxfxratio, vyfyratio, fxmx, fymx ]
2246
- return unit_vect_info
2247
- end
2248
-
2249
- def flow_itr5( gpx, gpy, factor=1.0, unit_vect=false )
2250
- raise ArgumentError,"Expect 2D arrays" if gpx.rank != 2 || gpy.rank != 2
2251
- raise ArgumentError,"gpx.shape != gpy.shape" if gpx.shape != gpy.shape
2252
-
2253
- raise "Transform. No. should be 5" if DCL.sgpget('itr') != 5
2254
-
2255
- theta = gpx.coord(1) / 180 * Math::PI
2256
- theta = theta.reshape(1,theta.shape[0])
2257
-
2258
- vx = gpx * theta.cos - gpy * theta.sin # UC component -> VC
2259
- vy = gpx * theta.sin + gpy * theta.cos # UC component -> VC
2260
-
2261
- DCL.sglset('LCLIP',false)
2262
- before1 = DCLExt.ug_set_params(
2263
- {'LUNIT'=>true, 'LUMSG'=>true} ) if unit_vect
2264
- before2 = DCLExt.ug_set_params(
2265
- {'LNRMAL'=>false,
2266
- 'XFACT1'=>factor, 'YFACT1'=>factor} ) if factor != 1.0
2267
- DCL.ugvect( vx.val, vy.val )
2268
-
2269
- if unit_vect
2270
- uxunit = sprintf("%.2g",DCL.ugrget('UXUNIT'))
2271
- uyunit = sprintf("%.2g",DCL.ugrget('UXUNIT'))
2272
- vxuloc = DCL.ugrget('VXULOC')
2273
- vyuloc = DCL.ugrget('VYULOC')
2274
- rsize = DCL.ugrget('RSIZET')
2275
- dv = rsize
2276
- DCL.sgtxzv(vxuloc, vyuloc-dv, uxunit, rsize, 0, -1, 3 )
2277
- DCL.sgtxzv(vxuloc-dv, vyuloc, uyunit, rsize, 90, -1, 3 )
2278
- end
2279
-
2280
- ug_set_params( before2 ) if factor != 1.0
2281
- ug_set_params( before1 ) if unit_vect
2282
- end
2283
-
2284
- ######################################
2285
-
2286
- # <<< color bar >>>
2287
-
2288
- @@color_bar_options = Misc::KeywordOptAutoHelp.new(
2289
- ["levels", nil, "tone levels (if omitted, latest ones are used)"],
2290
- ["patterns", nil, "tone patterns (~colors) (if omitted, latest ones are used)"],
2291
- ["voff", nil, "how far is the bar from the viewport in the V coordinate"],
2292
- ["vcent",nil, "center position of the bar in the V coordinate (VX or VY)"],
2293
- ["vlength", 0.3, "bar length in the V coordinate"],
2294
- ["vwidth", 0.02, "bar width in the V coordinate"],
2295
- ["inffact", 2.25, "factor to change the length of triangle on the side for infinity (relative to 'vwidth')"],
2296
- ["landscape", false, "if true, horizonlly long (along x axes)"],
2297
- ["portrait", true, "if true, vertically long (along y axes)"],
2298
- ["top", false, "place the bar at the top (effective if landscape)"],
2299
- ["left", false, "place the bar in the left (effective if portrait)"],
2300
- ["units", nil, "units of the axis of the color bar"],
2301
- ["units_voff", 0.0, "offset value for units from the default position in the V coordinate (only for 'units' != nil)"],
2302
- ["title", nil, "title of the color bar"],
2303
- ["title_voff", 0.0, "offset value for title from the default position in the V coordinate (only for 'title' != nil)"],
2304
- ["tickintv", 1, "0,1,2,3,.. to specify how frequently the dividing tick lines are drawn (0: no tick lines, 1: every time, 2: ever other:,...)"],
2305
- ["labelintv", nil, "0,1,2,3,.. to specify how frequently labels are drawn (0: no labels, 1: every time, 2: ever other:,... default: internally determined)"],
2306
- ["labels_ud", nil, "user-defined labels for replacing the default labels (Array of String)"],
2307
- ["charfact", 0.9, "factor to change the label/units/title character size (relative to 'rsizel1')"],
2308
- ["log", false, "set the color bar scale to logarithmic"],
2309
- ["constwidth", false, "if true, each color is drawn with the same width"],
2310
- ["index", nil, "index of tick lines and bar frame"],
2311
- ["charindex", nil, "index of labels, units, and title"],
2312
- ["chval_fmt", nil, "string to specify the DCL.chval format for labeling"]
2313
- )
2314
-
2315
- def set_color_bar_options(options)
2316
- @@color_bar_options.set(options)
2317
- end
2318
-
2319
- def level_chval_fmt(max,min,dx)
2320
- # returns a format for DCL.chval suitable for color-ba labels
2321
- dxabs = dx.abs
2322
- eps = 1e-4 * dxabs
2323
- order = Math::log10(dxabs).floor
2324
- if ( (dxabs+eps*0.1) % 10**order < eps )
2325
- # 1 keta
2326
- least_order = order
2327
- else
2328
- # >=2 keta --> limit to 2 keta
2329
- least_order = order - 1
2330
- end
2331
- ng = Math::log10([max.abs,min.abs,eps].max).floor - least_order + 1
2332
- if ng <= 3
2333
- fmt = 'b'
2334
- else
2335
- n = Math::log10([max.abs,min.abs].max).floor
2336
- nn = Math::log10([max.abs,min.abs].min).floor
2337
- if least_order >= 0 and nn >= 0
2338
- ifg = 'i'
2339
- elsif 0 <= n and n <= 4
2340
- ifg = 'f'
2341
- else
2342
- ifg = 'g'
2343
- end
2344
- case(ifg)
2345
- when 'i'
2346
- fmt = '(i15)'
2347
- when 'g'
2348
- ng = Math::log10([max.abs,min.abs,eps].max).floor - least_order + 1
2349
- ng = [ ng, 2 ].max
2350
- fmt = "(g15.#{ng})"
2351
- when 'f'
2352
- nf = [ -least_order, 0].max
2353
- fmt = "(f15.#{nf})"
2354
- end
2355
- end
2356
- fmt
2357
- end
2358
-
2359
- def sprintf_level(x,max,min,dx)
2360
- # format a float for color-bar labels.
2361
- # like DCL.hval('b',x) but changes according to dx
2362
- if x==0
2363
- fg = 'f'
2364
- else
2365
- n = Math::log10(x.abs).floor
2366
- if 0 <= n and n <= 4
2367
- fg = 'f'
2368
- else
2369
- fg = 'g'
2370
- end
2371
- end
2372
- eps = 1e-6
2373
- if ( dx.abs % 10**Math::log10(dx.abs) < eps )
2374
- # 1 keta
2375
- least_order = Math::log10(dx.abs).floor
2376
- else
2377
- # >=2 keta --> limit to 2 keta
2378
- least_order = Math::log10(dx.abs).floor - 1
2379
- end
2380
- if fg == 'g'
2381
- ng = Math::log10([max.abs,min.abs,eps].max).floor - least_order + 1
2382
- ng = [ ng, 2 ].max
2383
- fmt = "%.#{ng}g"
2384
- else
2385
- nf = [ -least_order, 0].max
2386
- fmt = "%.#{nf}f"
2387
- end
2388
- sprintf(fmt,x).sub(/\.0*$/,'')
2389
- end
2390
-
2391
- def color_bar(options=nil)
2392
-
2393
- # < set parameters >
2394
- opt = @@color_bar_options.interpret(options)
2395
- lsetx = DCL.uwqgxz
2396
- lsety = DCL.uwqgyz
2397
-
2398
- rmiss = DCL.glrget('rmiss')
2399
-
2400
- levels = opt['levels']
2401
- patterns = opt['patterns']
2402
-
2403
- if (levels.nil? && !patterns.nil?) || (!levels.nil? && patterns.nil?)
2404
- raise "levels and patterns must be set at same time\n"
2405
- end
2406
-
2407
- landscape = opt["landscape"] || !opt["portrait"]
2408
- portrait = ! landscape
2409
-
2410
- if !levels.nil?
2411
- ue_set_tone(levels,patterns)
2412
- end
2413
-
2414
- labels_ud = opt["labels_ud"]
2415
- if !labels_ud.nil?
2416
- if labels_ud.class != Array
2417
- raise ArgumentError,"'labels_ud' must be an Array of String"
2418
- elsif labels_ud.size == 0
2419
- raise ArgumentError,"'labels_ud' must be an Array of String"
2420
- else
2421
- labels_ud.each do |lbl_ud|
2422
- if lbl_ud.class != String
2423
- raise ArgumentError,"'labels_ud' must be an Array of String"
2424
- end
2425
- end
2426
- end
2427
- end
2428
-
2429
- if opt["index"]
2430
- index = opt["index"]
2431
- index = 1 if index <= 0
2432
- else
2433
- index = DCL::uziget("indext2")
2434
- end
2435
- indext1_bk = DCL::uziget("indext1")
2436
- indext2_bk = DCL::uziget("indext2")
2437
- DCL::uziset("indext1",index)
2438
- DCL::uziset("indext2",index)
2439
-
2440
- if opt["charindex"]
2441
- charindex = opt["charindex"]
2442
- charindex = 1 if charindex <= 0
2443
- else
2444
- charindex = DCL::uziget("indexl1")
2445
- end
2446
- indexl1_bk = DCL::uziget("indexl1")
2447
- DCL::uziset("indexl1",charindex)
2448
-
2449
- charfact = opt["charfact"]
2450
- rsizel1_bk = DCL::uzrget("rsizel1")
2451
- DCL::uzrset("rsizel1",charfact*rsizel1_bk)
2452
-
2453
- nton = DCL::ueqntl
2454
- if nton==0
2455
- raise "no tone patern was set\n"
2456
- end
2457
- lev1 = Array.new
2458
- lev2 = Array.new
2459
- patterns = Array.new if !opt['patterns']
2460
- for n in 0..nton-1
2461
- tlev1,tlev2,ipat = DCL::ueqtlv(n+1)
2462
- lev1.push(tlev1)
2463
- lev2.push(tlev2)
2464
- patterns.push(ipat) if !opt['patterns']
2465
- end
2466
-
2467
- #levels = lev1+lev2
2468
- #levels = levels.uniq.sort
2469
- #levels.delete(rmiss)
2470
- #if levels.ne(levels.sort).any?
2471
- # raise "levels is not in order\n"
2472
- #end
2473
-
2474
- levels = lev1.push(lev2[-1]) if !levels
2475
- levels = NArray.to_na(levels) if levels.is_a?(Array)
2476
- patterns = NArray.to_na(patterns) if patterns.is_a?(Array)
2477
-
2478
- vx1, vx2, vy1, vy2 = DCL.sgqvpt
2479
-
2480
- if opt['log']
2481
- lv = levels[levels.ne(rmiss).where]
2482
- if lv.length >= 4 && lv[0]*lv[-1]<0
2483
- iturn = 0
2484
- for i in 0...levels.length
2485
- if levels[i] != rmiss
2486
- if levels[i]*lv[0] < 0
2487
- iturn = i
2488
- break
2489
- end
2490
- end
2491
- end
2492
- opt['vlength'] /= 2
2493
- vc0 = opt['vcent'] || ( portrait && (vy1+vy2)/2) || (vx1+vx2)/2
2494
-
2495
- opt["voff"] ||=
2496
- DCL.uzrget('pad1')*DCL::uzrget("rsizec2") +
2497
- ( portrait ? DCL.uzrget('roffyr') : - DCL.uzrget('roffxb') )
2498
-
2499
- vsep2 = 0.02
2500
-
2501
- opt['levels'] = levels[0..iturn-1]
2502
- opt['patterns'] = patterns[0..iturn-2]
2503
- opt['vcent'] = vc0 - opt['vlength']/2 - vsep2
2504
- units = opt['units']
2505
- opt['units'] = nil
2506
- color_bar(opt)
2507
-
2508
- opt['levels'] = levels[iturn..-1]
2509
- opt['patterns'] = patterns[iturn..-1]
2510
- opt['vcent'] = vc0 + opt['vlength']/2 + vsep2
2511
- opt['units'] = units
2512
- color_bar(opt)
2513
-
2514
- # fill between the two bars
2515
- if portrait
2516
- x1 = vx2 + opt["voff"]
2517
- x2 = x1 + opt['vwidth']
2518
- y1 = vc0 - vsep2
2519
- y2 = vc0 + vsep2
2520
- else
2521
- x1 = vc0 - vsep2
2522
- x2 = vc0 + vsep2
2523
- y1 = vy1 - opt["voff"]
2524
- y2 = y1 - opt['vwidth']
2525
- end
2526
- bk = DCLExt.sg_set_params({'lclip'=>false})
2527
- DCL.sgtnzv([x1,x2,x2,x1],[y1,y1,y2,y2],patterns[iturn-1])
2528
- DCL.sgplzv([x1,x2,x2,x1,x1],[y1,y1,y2,y2,y1],1,3)
2529
- DCLExt.sg_set_params(bk)
2530
- return
2531
- end
2532
- end
2533
-
2534
- if levels.length <= 1
2535
- $stderr.print( "WARNING #{__FILE__}:#{__LINE__}: # of levels <= 1. No color bar is drawn." )
2536
- return
2537
- end
2538
-
2539
- itrsv = DCL::sgqtrn
2540
- if itrsv <= 4
2541
- ux1sv, ux2sv, uy1sv, uy2sv = DCL.sgqwnd
2542
- else
2543
- simfacsv, vxoffsv, vyoffsv = DCL.sgqsim
2544
- plxsv, plysv, plrotsv = DCL.sgqmpl()
2545
- end
2546
-
2547
- vwidth = opt["vwidth"]
2548
- vlength = opt["vlength"]
2549
-
2550
- if portrait
2551
- if !opt["left"]
2552
- # left
2553
- voff = opt["voff"] ||
2554
- DCL.uzrget('roffyr') + DCL.uzrget('pad1')*DCL::uzrget("rsizec2")
2555
- vxmin = vx2 + voff
2556
- vxmax = vx2 + voff + vwidth
2557
- else
2558
- # right
2559
- voff = opt["voff"] ? -opt["voff"] : \
2560
- DCL.uzrget('roffyl') - DCL.uzrget('pad1')*DCL::uzrget("rsizec2")
2561
- vxmax = vx1 + voff
2562
- vxmin = vx1 + voff - vwidth
2563
- end
2564
- vymin =( opt["vcent"] ? opt["vcent"]-vlength/2 : vy1 )
2565
- vymax =( opt["vcent"] ? opt["vcent"]+vlength/2 : vy1+vlength )
2566
- else ## landscape ##
2567
- vxmin =( opt["vcent"] ? opt["vcent"]-vlength/2 : (vx1+vx2)/2-vlength/2 )
2568
- vxmax =( opt["vcent"] ? opt["vcent"]+vlength/2 : (vx1+vx2)/2+vlength/2 )
2569
- if opt["top"]
2570
- # top
2571
- voff = opt["voff"] ||
2572
- DCL.uzrget('roffxt') + DCL.uzrget('pad1')*DCL::uzrget("rsizec2")
2573
- vymin = vy2 + voff
2574
- vymax = vy2 + voff + vwidth
2575
- else
2576
- # bottom
2577
- voff = opt["voff"] ? -opt["voff"] : \
2578
- DCL.uzrget('roffxb') - DCL.uzrget('pad1')*DCL::uzrget("rsizec2")
2579
- vymax = vy1 + voff
2580
- vymin = vy1 + voff - vwidth
2581
- end
2582
- end
2583
-
2584
- min = levels[levels.ne(rmiss).where].min
2585
- max = levels[levels.ne(rmiss).where].max
2586
- if levels[0] == rmiss
2587
- inf0 = true
2588
- dummy1,dummy2,ipat0 = DCL::ueqtlv(1)
2589
- return if levels.length==2
2590
- else
2591
- inf0 = false
2592
- end
2593
- if levels[-1] == rmiss
2594
- inf1 = true
2595
- dummy1,dummy2,ipat1 = DCL::ueqtlv(nton)
2596
- return if levels.length==2
2597
- else
2598
- inf1 = false
2599
- end
2600
-
2601
- # < paint color tones >
2602
-
2603
- lclip_bk = DCL::sglget("lclip")
2604
- DCL::sglset("lclip", false)
2605
-
2606
- inffact = opt["inffact"]
2607
- if opt["constwidth"]
2608
-
2609
- if inf0
2610
- levels = levels[1..-1]
2611
- patterns = patterns[1..-1]
2612
- end
2613
- if inf1
2614
- levels = levels[0..-2]
2615
- patterns = patterns[0..-2]
2616
- end
2617
- nlev = levels.length
2618
- npat = patterns.length
2619
-
2620
- if portrait
2621
- vy = (NArray.sfloat(npat+1).indgen!)*(vymax-vymin)/npat + vymin
2622
-
2623
- # paint color tones for infinity (with drawing frame)
2624
- if inf0
2625
- vy3 = [vymin, vymin-vwidth*inffact, vymin]
2626
- vx3 = [vxmax, (vxmax+vxmin)/2, vxmin]
2627
- DCL.sgtnzv(vx3,vy3,ipat0)
2628
- DCL.sgplzv(vx3,vy3,1,index)
2629
- end
2630
- if inf1
2631
- vy3 = [vymax, vymax+vwidth*inffact, vymax]
2632
- vx3 = [vxmax, (vxmax+vxmin)/2, vxmin]
2633
- DCL.sgtnzv(vx3,vy3,ipat1)
2634
- DCL.sgplzv(vx3,vy3,1,index)
2635
- end
2636
-
2637
- # paint color tones for each range (with drawing long-side frame)
2638
- for i in 0..npat-1
2639
- DCL::sgtnzv([vxmin,vxmax,vxmax,vxmin],[vy[i],vy[i],vy[i+1],vy[i+1]],patterns[i])
2640
- DCL::sgplzv([vxmin,vxmin],[vy[i],vy[i+1]],1,index)
2641
- DCL::sgplzv([vxmax,vxmax],[vy[i],vy[i+1]],1,index)
2642
- end
2643
-
2644
- else ## landscape ##
2645
- vx = (NArray.sfloat(npat+1).indgen!)*(vxmax-vxmin)/npat + vxmin
2646
-
2647
- # paint color tones for infinity (with drawing frame)
2648
- if inf0
2649
- vx3 = [vxmin, vxmin-vwidth*inffact, vxmin]
2650
- vy3 = [vymax, (vymax+vymin)/2, vymin]
2651
- DCL.sgtnzv(vx3,vy3,ipat0)
2652
- DCL.sgplzv(vx3,vy3,1,index)
2653
- end
2654
- if inf1
2655
- vx3 = [vxmax, vxmax+vwidth*inffact, vxmax]
2656
- vy3 = [vymax, (vymax+vymin)/2, vymin]
2657
- DCL.sgtnzv(vx3,vy3,ipat1)
2658
- DCL.sgplzv(vx3,vy3,1,index)
2659
- end
2660
-
2661
- # paint color tones for each range (with drawing long-side frame)
2662
- for i in 0..npat-1
2663
- DCL::sgtnzv([vx[i],vx[i],vx[i+1],vx[i+1]],[vymin,vymax,vymax,vymin],patterns[i])
2664
- DCL::sgplzv([vx[i],vx[i+1]],[vymin,vymin],1,index)
2665
- DCL::sgplzv([vx[i],vx[i+1]],[vymax,vymax],1,index)
2666
- end
2667
- end
2668
-
2669
- else ### opt["constwidth"] == false ###
2670
-
2671
- # paint color tones for infinity (with drawing frame)
2672
- if portrait
2673
- if inf0
2674
- vy3 = [vymin, vymin-vwidth*inffact, vymin]
2675
- vx3 = [vxmax, (vxmax+vxmin)/2, vxmin]
2676
- DCL.sgtnzv(vx3,vy3,ipat0)
2677
- DCL.sgplzv(vx3,vy3,1,index)
2678
- end
2679
- if inf1
2680
- vy3 = [vymax, vymax+vwidth*inffact, vymax]
2681
- vx3 = [vxmax, (vxmax+vxmin)/2, vxmin]
2682
- DCL.sgtnzv(vx3,vy3,ipat1)
2683
- DCL.sgplzv(vx3,vy3,1,index)
2684
- end
2685
- else ## landscape ##
2686
- if inf0
2687
- vx3 = [vxmin, vxmin-vwidth*inffact, vxmin]
2688
- vy3 = [vymax, (vymax+vymin)/2, vymin]
2689
- DCL.sgtnzv(vx3,vy3,ipat0)
2690
- DCL.sgplzv(vx3,vy3,1,index)
2691
- end
2692
- if inf1
2693
- vx3 = [vxmax, vxmax+vwidth*inffact, vxmax]
2694
- vy3 = [vymax, (vymax+vymin)/2, vymin]
2695
- DCL.sgtnzv(vx3,vy3,ipat1)
2696
- DCL.sgplzv(vx3,vy3,1,index)
2697
- end
2698
- end
2699
-
2700
- # paint color tones for each range
2701
- nbar = 100
2702
- bar = NArray.float(nbar,2)
2703
- for i in 0..nbar-1
2704
- bar[i,true] = min + (max-min).to_f/(nbar-1)*i
2705
- end
2706
-
2707
- xb = DCL::uzlget("labelxb")
2708
- yl = DCL::uzlget("labelyl")
2709
- if portrait
2710
- xmin = 0.0
2711
- xmax = 1.0
2712
- ymin = min
2713
- ymax = max
2714
- DCL::uzlset("labelxb",false)
2715
- DCL::uzlset("labelyl",true)
2716
- bar = bar.transpose(-1,0)
2717
- DCL::uwsgxa([0,1])
2718
- DCL::uwsgya(bar[0,true])
2719
- else
2720
- xmin = min
2721
- xmax = max
2722
- ymin = 0.0
2723
- ymax = 1.0
2724
- DCL::uzlset("labelxb",true)
2725
- DCL::uzlset("labelyl",false)
2726
- DCL::uwsgxa(bar[true,0])
2727
- DCL::uwsgya([0,1])
2728
- end
2729
-
2730
- type = 1
2731
- if opt["log"]
2732
- type +=1
2733
- type +=1 if !portrait
2734
- end
2735
-
2736
- DCL::grfig
2737
- DCL::grsvpt(vxmin,vxmax,vymin,vymax)
2738
- DCL::grswnd(xmin,xmax,ymin,ymax)
2739
- DCL::grstrn(type)
2740
- DCL::grstrf
2741
-
2742
- DCL::uetone(bar)
2743
- DCL.uwsgxz(false)
2744
- DCL.uwsgyz(false)
2745
-
2746
- end
2747
-
2748
- # < set ticking and labeling levels >
2749
-
2750
- if opt["labelintv"]
2751
- labelintv = opt["labelintv"]
2752
- else
2753
- ntn = nton
2754
- ntn -= 1 if inf0
2755
- ntn -= 1 if inf1
2756
- if portrait
2757
- labelintv = (ntn-1) / 9 + 1
2758
- else
2759
- labelintv = (ntn-1) / 5 + 1
2760
- end
2761
- end
2762
- if labelintv <= 0
2763
- no_label = true
2764
- labelintv = 1
2765
- else
2766
- no_label = false
2767
- end
2768
-
2769
- tickintv = opt["tickintv"]
2770
- if tickintv <= 0
2771
- no_tick = true
2772
- tickintv = labelintv
2773
- else
2774
- no_tick = false
2775
- end
2776
-
2777
- eps = 1e-5
2778
- dummy = -9.9e-38
2779
- dz = dzp = dzc = dummy
2780
- idu = Array.new
2781
- (1...levels.length).each do |i|
2782
- dzc = (levels[i] - levels[i-1]).abs
2783
- if (dzc-dzp).abs <= eps * [dzc.abs,dzp.abs].max
2784
- dz = dzc # set dz if two consecutive inrements are the same
2785
- idu.push( i-1 )
2786
- end
2787
- dzp = (levels[i] - levels[i-1]).abs
2788
- end
2789
- if idu.length > 0
2790
- idumin = idu.min - 1
2791
- idumax = idu.max + 1
2792
- else
2793
- idumin = 0
2794
- idumax = levels.length-1
2795
- end
2796
- if dz != dummy
2797
- # if idumin == 1 and levels[0] != rmiss
2798
- # # to correct non-uniform intv at the beginning
2799
- # levels[0] = levels[1] - dz
2800
- # idumin = 0
2801
- # min = levels[0]
2802
- # end
2803
- # if idumax == levels.length-2 and levels[-1] != rmiss
2804
- # # to correct non-uniform intv at the end
2805
- # levels[-1] = levels[-2] + dz
2806
- # idumax = levels.length-1
2807
- # max = levels[-1]
2808
- # end
2809
- # use the algorithm used in DCL.udgcla
2810
- offs_tick = ( (-levels[idumin]/dz).round % tickintv + idumin ) % tickintv
2811
- offs_label = ( (-levels[idumin]/dz).round % labelintv + idumin ) % labelintv
2812
- else
2813
- md = 0
2814
- if ( (idx=levels.eq(0.0).where).length > 0 )
2815
- md = idx[0] % labelintv
2816
- else
2817
- a = levels[0...([labelintv,levels.length].min)]
2818
- b = a * 10**( -NMath.log10(a.abs).floor.min )
2819
- (0...b.length).each{|i| md=i if (b[i].round-b[i]).abs < 1e-5 }
2820
- end
2821
- offs_tick = (md % tickintv)
2822
- offs_label = md
2823
- end
2824
-
2825
- if levels.length >= 4
2826
- lvmx = levels[1..-2].max
2827
- lvmn = levels[1..-2].min
2828
- dlv = (lvmx-lvmn) / (levels.length-3)
2829
- elsif levels.length == 3 or levels.length == 2
2830
- lvmn = lvmx = dlv = levels[1]
2831
- else
2832
- lvmn = lvmx = dlv = levels[0]
2833
- end
2834
-
2835
- # < draw units, title, labels, and tick lines>
2836
-
2837
- if opt["constwidth"]
2838
-
2839
- if !no_label && labels_ud
2840
- ilbl = 0
2841
- for i in 0..nlev-1
2842
- if (i % labelintv) == offs_label
2843
- ilbl += 1
2844
- end
2845
- end
2846
- if labels_ud.size != ilbl
2847
- raise ArgumentError, "'labels_ud' must be an Array of length==#{ilbl} in this case"
2848
- end
2849
- end
2850
-
2851
- if portrait
2852
-
2853
- if voff > 0
2854
- cent = -1
2855
- vxlabel = vxmax+DCL::uzrget('pad1')*DCL::uzrget('rsizel1')
2856
- # title
2857
- DCL::sgtxzr(vxmin-(0.5+DCL::uzrget('pad1'))*DCL::uzrget('rsizel1'), (vymin+vymax)/2.0+opt['title_voff'], opt['title'], DCL::uzrget('rsizel1'), 90, 0, charindex) if opt['title']
2858
- # units
2859
- DCL::sgtxzr(vxmax+DCL::uzrget('pad1')*DCL::uzrget('rsizel1'), vymax+2.6*DCL::uzrget('rsizel1')+opt['units_voff'], opt['units'], DCL::uzrget('rsizel1'), 0, -1, charindex) if opt['units']
2860
- else
2861
- cent = 1
2862
- vxlabel = vxmin-DCL::uzrget('pad1')*DCL::uzrget('rsizel1')
2863
- # title
2864
- DCL::sgtxzr(vxmax+(0.5+DCL::uzrget('pad1'))*DCL::uzrget('rsizel1'), (vymin+vymax)/2.0-opt['title_voff'], opt['title'], DCL::uzrget('rsizel1'), -90, 0, charindex) if opt['title']
2865
- # units
2866
- DCL::sgtxzr(vxmin-DCL::uzrget('pad1')*DCL::uzrget('rsizel1'), vymax+2.6*DCL::uzrget('rsizel1')+opt['units_voff'], opt['units'], DCL::uzrget('rsizel1'), 0, 1, charindex) if opt['units']
2867
- end
2868
-
2869
- ilbl_ud = 0
2870
- for i in 0..nlev-1
2871
- # labels
2872
- if !no_label && (i % labelintv) == offs_label
2873
- if labels_ud
2874
- char = labels_ud[ilbl_ud]
2875
- DCL::sgtxzr(vxlabel,vy[i],char,DCL::uzrget('rsizel1'),0,cent,charindex)
2876
- ilbl_ud += 1
2877
- else
2878
- begin
2879
- if(opt['chval_fmt'])
2880
- char = DCL::chval(opt['chval_fmt'],levels[i])
2881
- else
2882
- char = sprintf_level(levels[i],lvmx,lvmn,dlv)
2883
- end
2884
- DCL::sgtxzr(vxlabel,vy[i],char,DCL::uzrget('rsizel1'),0,cent,charindex)
2885
- rescue
2886
- DCL::sgtxzr(vxlabel,vy[i],levels[i].to_s,DCL::uzrget('rsizel1'),0,cent,charindex)
2887
- end
2888
- end
2889
- end
2890
- # tick lines and short-side frame
2891
- if (!no_tick && (i % tickintv) == offs_tick) || (!inf0 && i == 0) || (!inf1 && i == nlev-1)
2892
- DCL::sgplzv([vxmin,vxmax],[vy[i],vy[i]],1,index)
2893
- end
2894
- end
2895
-
2896
- else ## landscape ##
2897
- if voff > 0
2898
- vylabel = vymax+(0.5+DCL::uzrget('pad1'))*DCL::uzrget('rsizel1')
2899
- # title
2900
- DCL::sgtxzr((vxmin+vxmax)/2.0+opt['title_voff'], vymin-(0.5+DCL::uzrget('pad1'))*DCL::uzrget('rsizel1'), opt['title'], DCL::uzrget('rsizel1'), 0, 0, charindex) if opt['title']
2901
- # units
2902
- DCL::sgtxzr(vxmax+2.6*DCL::uzrget('rsizel1')+opt['units_voff'], vymax+(0.5+DCL::uzrget('pad1'))*DCL::uzrget('rsizel1'), opt['units'], DCL::uzrget('rsizel1'), 0, -1, charindex) if opt['units']
2903
- else
2904
- vylabel = vymin-(0.5+DCL::uzrget('pad1'))*DCL::uzrget('rsizel1')
2905
- # title
2906
- DCL::sgtxzr((vxmin+vxmax)/2.0+opt['title_voff'], vymax+(0.5+DCL::uzrget('pad1'))*DCL::uzrget('rsizel1'), opt['title'], DCL::uzrget('rsizel1'), 0, 0, charindex) if opt['title']
2907
- # units
2908
- DCL::sgtxzr(vxmax+2.6*DCL::uzrget('rsizel1')+opt['units_voff'], vymin-(0.5+DCL::uzrget('pad1'))*DCL::uzrget('rsizel1'), opt['units'], DCL::uzrget('rsizel1'), 0, -1, charindex) if opt['units']
2909
- end
2910
-
2911
- ilbl_ud = 0
2912
- for i in 0..nlev-1
2913
- # labels
2914
- if !no_label && (i % labelintv) == offs_label
2915
- if labels_ud
2916
- char = labels_ud[ilbl_ud]
2917
- DCL::sgtxzr(vx[i],vylabel,char,DCL::uzrget('rsizel1'),0,0,charindex)
2918
- ilbl_ud += 1
2919
- else
2920
- begin
2921
- if(opt['chval_fmt'])
2922
- char = DCL::chval(opt['chval_fmt'],levels[i])
2923
- else
2924
- char = sprintf_level(levels[i],lvmx,lvmn,dlv)
2925
- end
2926
- DCL::sgtxzr(vx[i],vylabel,char,DCL::uzrget('rsizel1'),0,0,charindex)
2927
- rescue
2928
- DCL::sgtxzr(vx[i],vylabel,levels[i].to_s,DCL::uzrget('rsizel1'),0,0,charindex)
2929
- end
2930
- end
2931
- end
2932
- # tick lines and short-side frame
2933
- if (!no_tick && (i % tickintv) == offs_tick) || (!inf0 && i == 0) || (!inf1 && i == nlev-1)
2934
- DCL::sgplzv([vx[i],vx[i]],[vymin,vymax],1,index)
2935
- end
2936
- end
2937
- end
2938
-
2939
- else ### opt["constwidth"] == false ###
2940
-
2941
- inner_bk = DCL::uziget('inner')
2942
- uz_set_params('inner'=>1)
2943
-
2944
- tick1 = Array.new
2945
- tick2 = Array.new
2946
- for i in 0..levels.length-1
2947
- # if i>=idumin && i<=idumax && levels[i]!=rmiss
2948
- if levels[i]!=rmiss
2949
- tick1.push(levels[i]) if (i % tickintv) == offs_tick
2950
- tick2.push(levels[i]) if (i % labelintv) == offs_label
2951
- end
2952
- end
2953
-
2954
- if portrait
2955
-
2956
- if voff > 0
2957
- before = uz_set_params('labelyl'=>false,'labelyr'=>true,'icentyr'=>-1.0)
2958
- else
2959
- before = uz_set_params('labelyl'=>true,'labelyr'=>false,'icentyl'=>1.0)
2960
- end
2961
-
2962
- # draw frame, tick lines, and labels
2963
- cfmt_bk = DCL::uyqfmt
2964
- if opt["log"]
2965
- fmt = opt['chval_fmt'] || "b"
2966
- else
2967
- fmt = opt['chval_fmt'] || level_chval_fmt(lvmx,lvmn,dlv)
2968
- end
2969
- DCL::uysfmt(fmt)
2970
-
2971
- rsizet1_bk = DCL::uzrget("rsizet1")
2972
- rsizet2_bk = DCL::uzrget("rsizet2")
2973
- uz_set_params('rsizet1'=>vwidth,'rsizet2'=>0.0)
2974
- if no_label
2975
- nl_labelxt = DCL::uzlget('labelxt')
2976
- nl_labelxb = DCL::uzlget('labelxb')
2977
- nl_labelyl = DCL::uzlget('labelyl')
2978
- nl_labelyr = DCL::uzlget('labelyr')
2979
- uz_set_params('labelxt'=>false,'labelxb'=>false,'labelyl'=>false,'labelyr'=>false)
2980
- end
2981
- if no_tick
2982
- nt_rsizet1 = DCL::uzrget('rsizet1')
2983
- DCL::uzrset("rsizet1",0.0)
2984
- end
2985
-
2986
- if labels_ud
2987
- if labels_ud.size != tick2.size
2988
- raise ArgumentError, "'labels_ud' must be an Array of length==#{tick2.size} in this case"
2989
- end
2990
- nc = labels_ud.collect{|c| c.size}.max
2991
- DCL::uyaxlb("l",tick1,tick2,labels_ud,nc)
2992
- DCL::uyaxlb("r",tick1,tick2,labels_ud,nc)
2993
- else
2994
- DCL::uyaxnm("l",tick1,tick2)
2995
- DCL::uyaxnm("r",tick1,tick2)
2996
- end
2997
- DCL::uxaxdv("b",1,index) if !inf0
2998
- DCL::uxaxdv("t",1,index) if !inf1
2999
-
3000
- if no_tick
3001
- DCL::uzrset("rsizet1",nt_rsizet1)
3002
- end
3003
- if no_label
3004
- uz_set_params('labelxt'=>nl_labelxt,'labelxb'=>nl_labelxb,'labelyl'=>nl_labelyl,'labelyr'=>nl_labelyr)
3005
- end
3006
- DCL::uzrset("rsizet1",rsizet1_bk)
3007
- DCL::uzrset("rsizet2",rsizet2_bk)
3008
-
3009
- DCL::uysfmt(cfmt_bk)
3010
-
3011
- if voff > 0
3012
- # title
3013
- DCL::sgtxzr(vxmin-(0.5+DCL::uzrget('pad1'))*DCL::uzrget('rsizel1'), (vymin+vymax)/2.0+opt['title_voff'], opt['title'], DCL::uzrget('rsizel1'), 90, 0, charindex) if opt["title"]
3014
- # units
3015
- DCL::sgtxzr(vxmax+DCL::uzrget('pad1')*DCL::uzrget('rsizel1'), vymax+2.6*DCL::uzrget('rsizel1')+opt['units_voff'], opt['units'], DCL::uzrget('rsizel1'), 0, -1, charindex) if opt['units']
3016
- else
3017
- # title
3018
- DCL::sgtxzr(vxmax+(0.5+DCL::uzrget('pad1'))*DCL::uzrget('rsizel1'), (vymin+vymax)/2.0-opt['title_voff'], opt['title'], DCL::uzrget('rsizel1'), -90, 0, charindex) if opt["title"]
3019
- # units
3020
- DCL::sgtxzr(vxmin-DCL::uzrget('pad1')*DCL::uzrget('rsizel1'), vymax+2.6*DCL::uzrget('rsizel1')+opt['units_voff'], opt['units'], DCL::uzrget('rsizel1'), 0, 1, charindex) if opt['units']
3021
- end
3022
-
3023
- uz_set_params(before)
3024
-
3025
- else ## landscape ##
3026
-
3027
- if voff > 0
3028
- before = uz_set_params('labelxt'=>true,'labelxb'=>false)
3029
- else
3030
- before = uz_set_params('labelxt'=>false,'labelxb'=>true)
3031
- end
3032
-
3033
- # draw frame, tick lines, and labels
3034
- cfmt_bk = DCL::uxqfmt
3035
- if opt["log"]
3036
- fmt = opt['chval_fmt'] || "b"
3037
- else
3038
- fmt = opt['chval_fmt'] || level_chval_fmt(lvmx,lvmn,dlv)
3039
- end
3040
- DCL::uxsfmt(fmt)
3041
-
3042
- rsizet1_bk = DCL::uzrget("rsizet1")
3043
- rsizet2_bk = DCL::uzrget("rsizet2")
3044
- uz_set_params('rsizet1'=>vwidth,'rsizet2'=>0.0)
3045
- if no_label
3046
- nl_labelxt = DCL::uzlget('labelxt')
3047
- nl_labelxb = DCL::uzlget('labelxb')
3048
- nl_labelyl = DCL::uzlget('labelyl')
3049
- nl_labelyr = DCL::uzlget('labelyr')
3050
- uz_set_params('labelxt'=>false,'labelxb'=>false,'labelyl'=>false,'labelyr'=>false)
3051
- end
3052
- if no_tick
3053
- nt_rsizet1 = DCL::uzrget('rsizet1')
3054
- DCL::uzrset("rsizet1",0.0)
3055
- end
3056
-
3057
- if labels_ud
3058
- if labels_ud.size != tick2.size
3059
- raise ArgumentError, "'labels_ud' must be an Array of length==#{tick2.size} in this case"
3060
- end
3061
- nc = labels_ud.collect{|c| c.size}.max
3062
- DCL::uxaxlb("t",tick1,tick2,labels_ud,nc)
3063
- DCL::uxaxlb("b",tick1,tick2,labels_ud,nc)
3064
- else
3065
- DCL::uxaxnm("t",tick1,tick2)
3066
- DCL::uxaxnm("b",tick1,tick2)
3067
- end
3068
- DCL::uyaxdv("l",1,index) if !inf0
3069
- DCL::uyaxdv("r",1,index) if !inf1
3070
-
3071
- if no_tick
3072
- DCL::uzrset("rsizet1",nt_rsizet1)
3073
- end
3074
- if no_label
3075
- uz_set_params('labelxt'=>nl_labelxt,'labelxb'=>nl_labelxb,'labelyl'=>nl_labelyl,'labelyr'=>nl_labelyr)
3076
- end
3077
- DCL::uzrset("rsizet1",rsizet1_bk)
3078
- DCL::uzrset("rsizet2",rsizet2_bk)
3079
-
3080
- DCL::uxsfmt(cfmt_bk)
3081
-
3082
- if voff > 0
3083
- # title
3084
- DCL::sgtxzr((vxmin+vxmax)/2.0+opt['title_voff'], vymin-(0.5+DCL::uzrget('pad1'))*DCL::uzrget('rsizel1'), opt['title'], DCL::uzrget('rsizel1'), 0, 0, charindex) if opt["title"]
3085
- # units
3086
- DCL::sgtxzr(vxmax+2.6*DCL::uzrget('rsizel1')+opt['units_voff'], vymax+(0.5+DCL::uzrget('pad1'))*DCL::uzrget('rsizel1'), opt['units'], DCL::uzrget('rsizel1'), 0, -1, charindex) if opt['units']
3087
- else
3088
- # title
3089
- DCL::sgtxzr((vxmin+vxmax)/2.0+opt['title_voff'], vymax+(0.5+DCL::uzrget('pad1'))*DCL::uzrget('rsizel1'), opt['title'], DCL::uzrget('rsizel1'), 0, 0, charindex) if opt["title"]
3090
- # units
3091
- DCL::sgtxzr(vxmax+2.6*DCL::uzrget('rsizel1')+opt['units_voff'], vymin-(0.5+DCL::uzrget('pad1'))*DCL::uzrget('rsizel1'), opt['units'], DCL::uzrget('rsizel1'), 0, -1, charindex) if opt['units']
3092
- end
3093
-
3094
- uz_set_params(before)
3095
-
3096
- end
3097
-
3098
- DCL::uzlset("labelxb",xb)
3099
- DCL::uzlset("labelyl",yl)
3100
-
3101
- DCL::grsvpt(vx1,vx2,vy1,vy2)
3102
- if itrsv <= 4
3103
- DCL::grswnd(ux1sv, ux2sv, uy1sv, uy2sv)
3104
- DCL::grstrn(itrsv)
3105
- else
3106
- DCL.sgssim(simfacsv,vxoffsv,vyoffsv)
3107
- DCL.sgsmpl(plxsv,plysv,plrotsv)
3108
- end
3109
- DCL::grstrf
3110
-
3111
- uz_set_params('inner'=>inner_bk)
3112
- end
3113
-
3114
- DCL::uziset("indext1",indext1_bk)
3115
- DCL::uziset("indext2",indext2_bk)
3116
- DCL::uziset("indexl1",indexl1_bk)
3117
- DCL::uzrset("rsizel1",rsizel1_bk)
3118
-
3119
- DCL::sglset("lclip", lclip_bk)
3120
- nil
3121
- end
3122
-
3123
- # Annotates line/mark type and index (and size if mark).
3124
- # By default it is shown in the right margin of the viewport.
3125
- #
3126
- # * str is a String to show
3127
- # * line: true->line ; false->mark
3128
- # * vx: vx of the left-hand point of legend line (or mark position).
3129
- # * nil : internally determined
3130
- # * Float && > 0 : set explicitly
3131
- # * Float && < 0 : move it relatively to the left from the default
3132
- # * dx: length of the legend line (not used if mark).
3133
- # * nil : internally determined
3134
- # * Float && > 0 : set explicitly
3135
- # * vy: vy of the legend (not used if !first -- see below).
3136
- # * nil : internally determined
3137
- # * Float && > 0 : set explicitly
3138
- # * Float && < 0 : move it relatively lower from the default
3139
- # * first : if false, vy is moved lower relatively from the previous vy.
3140
- # * mark_size : size of the mark. if nil, size is used.
3141
- def legend(str, type, index, line=false, size=nil,
3142
- vx=nil, dx=nil, vy=nil, first=true, mark_size=nil)
3143
-
3144
- size = DCL::uzrget("rsizel1")*0.95 if !size
3145
- mark_size = size if !mark_size
3146
-
3147
- vpx1,vpx2,vpy1,vpy2 = DCL.sgqvpt
3148
- if first
3149
- if !vy
3150
- vy = vpy2 - 0.04
3151
- elsif vy < 0
3152
- vy = ( vpy2 - 0.04 ) + vy
3153
- end
3154
- @vy = vy
3155
- else
3156
- vy = @vy - 1.5*size
3157
- end
3158
-
3159
- if !vx
3160
- vx = vpx2 + 0.015
3161
- elsif vx < 0
3162
- vx = (vpx2 + 0.015) + vx
3163
- end
3164
-
3165
- if line
3166
- dx=0.06 if !dx
3167
- vx2 = vx + dx
3168
- DCL::sgplzv([vx,vx2],[vy,vy],type,index)
3169
- DCL.sgtxzv(vx2+0.01,vy,str,size,0,-1,3)
3170
- else # --> mark
3171
- DCL::sgpmzv([vx],[vy],type,index,mark_size)
3172
- DCL.sgtxzv(vx+0.015+mark_size*0.5,vy,str,size,0,-1,3)
3173
- end
3174
- nil
3175
- end
3176
-
3177
- # Driver of quasi_log_levels with data values
3178
- def quasi_log_levels_z(vals, nlev=nil, max=nil, min=nil, cycle=1)
3179
- if max && min
3180
- quasi_log_levels(max.to_f, min.to_f, cycle)
3181
- else
3182
- if nlev
3183
- eps = 0.1
3184
- norder = (nlev-1.0+eps)/cycle
3185
- else
3186
- norder = 3
3187
- end
3188
- mx1 = vals.max
3189
- mx2 = vals.min
3190
- if min && min < 0
3191
- max = min
3192
- min = nil
3193
- elsif max && max < 0
3194
- min = max
3195
- max = nil
3196
- end
3197
- maxsv = max
3198
- minsv = min
3199
- if !max
3200
- max = [ mx1.abs, mx2.abs ].max.to_f
3201
- max = -max if mx1<0
3202
- end
3203
- if !min
3204
- min = max/10**norder
3205
- else
3206
- max = min*10**norder if nlev
3207
- end
3208
- if !(minsv && minsv>0) && !(maxsv && maxsv <0) && ( mx2<0 && mx1>0 )
3209
- min = -min
3210
- end
3211
- quasi_log_levels(max, min, cycle)
3212
- end
3213
- end
3214
-
3215
- # Returns approximately log-scaled contour/tone levels as well as
3216
- # major/minor flags for contours. No DCL call is made in here.
3217
- #
3218
- # * cycle (Integer; 1, or 2 or 3) : number of level in one-order.
3219
- # e.g. 1,10,100,.. for cycle==1; 1,3,10,30,.. for cycle==2;
3220
- # 1,2,5,10,20,50,.. for cycle==3
3221
- # * lev0, lev1 (Float) : levels are set between this two params
3222
- # * if lev0 & lev1 > 0 : positive only
3223
- # * if lev0 & lev1 < 0 : negative only
3224
- # * if lev0 * lev1 < 0 : both positive and negative
3225
- # (usig +-[lev0.abs,lev1.abs])
3226
- # RETURN VALUE:
3227
- # * [ levels, mjmn ]
3228
- def quasi_log_levels(lev0, lev1, cycle=1)
3229
- raise(ArgumentError, "lev0 is zero (non-zero required)") if lev0 == 0.0
3230
- raise(ArgumentError, "lev1 is zero (non-zero required)") if lev1 == 0.0
3231
- case cycle
3232
- when 1
3233
- cycl_levs = [1.0]
3234
- when 2
3235
- cycl_levs = [1.0, 3.0]
3236
- when 3
3237
- cycl_levs = [1.0, 2.0, 5.0]
3238
- else
3239
- raise(ArgumentError, "cycle must be 1,2,or 3, which is now #{cycle}")
3240
- end
3241
-
3242
- if lev0 > 0 and lev1 > 0
3243
- positive = true
3244
- negative = false
3245
- elsif lev0 < 0 and lev1 < 0
3246
- positive = false
3247
- negative = true
3248
- else
3249
- positive = true
3250
- negative = true
3251
- end
3252
- sml, big = [lev0.abs,lev1.abs].sort
3253
-
3254
- expsml = Math::log10(sml).floor
3255
- expbig = Math::log10(big).ceil
3256
-
3257
- levels = Array.new
3258
- mjmn = Array.new
3259
-
3260
- for i in expsml..expbig-1
3261
- for k in 0..cycle-1
3262
- lev = cycl_levs[k] * 10**i
3263
- if lev >= sml && lev <= big
3264
- levels.push( lev )
3265
- mjmn.push( k==0 ? 1 : 0 )
3266
- end
3267
- end
3268
- end
3269
- lev = 10**expbig
3270
- if lev == big
3271
- levels.push( lev )
3272
- mjmn.push( 1 )
3273
- end
3274
-
3275
- if negative && !positive
3276
- levels = levels.reverse.collect{|x| -x}
3277
- mjmn = mjmn.reverse
3278
- elsif negative && positive
3279
- levels.dup.each{|x| levels.unshift(-x)}
3280
- mjmn.dup.each{|x| mjmn.unshift(x)}
3281
- end
3282
-
3283
- [ levels, mjmn ]
3284
- end
3285
- end
1068
+ =end
1069
+ ############################################################
3286
1070
 
3287
- ####################################################################
3288
- ####################################################################
3289
- ####################################################################
1071
+ module NumRu
3290
1072
 
3291
1073
  module GGraph
3292
1074
 
@@ -3505,7 +1287,7 @@ module NumRu
3505
1287
  atts = opts['xreverse'].split(',').collect{|v| v.split(':')}
3506
1288
  xreverse = false
3507
1289
  atts.each{|key,val|
3508
- xreverse = ( xax.get_att(key) == val )
1290
+ xreverse = ( key.downcase=="units" ? (Units.new(xax.get_att(key)) =~ Units.new(val)) : (xax.get_att(key) == val) )
3509
1291
  break if xreverse
3510
1292
  }
3511
1293
  end
@@ -3513,7 +1295,7 @@ module NumRu
3513
1295
  atts = opts['yreverse'].split(',').collect{|v| v.split(':')}
3514
1296
  yreverse = false
3515
1297
  atts.each{|key,val|
3516
- yreverse = ( yax.get_att(key) == val )
1298
+ yreverse = ( key.downcase=="units" ? (Units.new(yax.get_att(key)) =~ Units.new(val)) : (yax.get_att(key) == val) )
3517
1299
  break if yreverse
3518
1300
  }
3519
1301
  end
@@ -3537,6 +1319,10 @@ module NumRu
3537
1319
  # if the max and min of the range is the same, shift them a bit
3538
1320
  range[0] = DCL.rgnlt(r0)
3539
1321
  range[1] = DCL.rgngt(r0)
1322
+ if range[0] == range[1] # if min and max are still the same
1323
+ range[0] -= 1
1324
+ range[1] += 1
1325
+ end
3540
1326
  end
3541
1327
  end
3542
1328
  default_window=[xrange[0], xrange[1], yrange[0], yrange[1]]
@@ -3638,7 +1424,8 @@ module NumRu
3638
1424
  end
3639
1425
  end
3640
1426
 
3641
- when 10..15
1427
+ when 10..19
1428
+ sv = DCL.umpget('lglobe')
3642
1429
  if !map_fit
3643
1430
  map_axis = opts['map_axis'] || [180.0, 0.0, 0.0]
3644
1431
  DCL::umscnt( *map_axis )
@@ -3657,6 +1444,8 @@ module NumRu
3657
1444
  tyrange = [ -75, 75 ] # latange is ignored
3658
1445
  end
3659
1446
  DCL::grstxy(map_window[0], map_window[1], tyrange[0], tyrange[1])
1447
+ # 'lglobe' becomes true when itr >= 12 or data coverage is almost global for Mercator
1448
+ DCL.umpset('lglobe', (itr >= 12) || ((itr == 11) && (tyrange[0].abs >= 75) && (tyrange[1].abs >= 75) && (tyrange[0] * tyrange[1] < 0)))
3660
1449
  else
3661
1450
  lon_cent =( window[0] + window[1] ) / 2.0
3662
1451
  dlon2 = ( window[1] - window[0] ) / 2.0
@@ -3664,11 +1453,11 @@ module NumRu
3664
1453
  DCL::sgswnd(*window)
3665
1454
  DCL::umscnt( *map_axis )
3666
1455
  DCL::grstxy( -dlon2, dlon2, window[2], window[3] )
1456
+ # 'lglobe' becomes true when data coverage is almost global for Mercator
1457
+ DCL.umpset('lglobe', (itr == 11) && (window[2].abs >= 75) && (window[3].abs >= 75) && (window[2] * window[3] < 0))
3667
1458
  end
3668
- sv = DCL.umpget('lglobe')
3669
- DCL.umpset('lglobe', true)
3670
1459
  DCL::umpfit
3671
- when 20..33
1460
+ when 20..34
3672
1461
  map_axis = opts['map_axis'] || [180.0, 90.0, 0.0]
3673
1462
  map_radius = opts['map_radius'] || 70.0
3674
1463
  DCL::umscnt( *map_axis )
@@ -3730,6 +1519,10 @@ module NumRu
3730
1519
  'Interval of x axis label (if nil, internally determined)'],
3731
1520
  ['ylabelint', nil,
3732
1521
  'Interval of y axis label (if nil, internally determined)'],
1522
+ ['xloglabelall', false,
1523
+ 'Show lavels for all log-level tick marks (x-axes) (e.g.,1000,900,800,... inseatd of 1000,500,200,...)'],
1524
+ ['yloglabelall', false,
1525
+ 'Show lavels for all log-level tick marks (y-axes) (e.g.,1000,900,800,... inseatd of 1000,500,200,...)'],
3733
1526
  ['xmaplabel', nil,
3734
1527
  'If "lon"("lat"), use DCLExt::lon_ax(DCLExt::lat_ax) to draw xaxes; otherwise, DCL::usxaxs is used.'],
3735
1528
  ['ymaplabel', nil,
@@ -3851,6 +1644,10 @@ module NumRu
3851
1644
  DCL.uscset('cxunit', sunits)
3852
1645
  DCL.uspset('dxt', opts['xtickint']) if(opts['xtickint'])
3853
1646
  DCL.uspset('dxl', opts['xlabelint']) if(opts['xlabelint'])
1647
+ if(opts['xloglabelall'])
1648
+ DCL.uspset('nlblx', 4)
1649
+ DCL.ulsxbl([1,2,3,4,5,6,7,8,9])
1650
+ end
3854
1651
  opts['xside'].split('').each{|s| # scan('.') also works
3855
1652
  DCL.usxaxs(s)
3856
1653
  }
@@ -3886,6 +1683,10 @@ module NumRu
3886
1683
  DCL.uscset('cyunit', sunits )
3887
1684
  DCL.uspset('dyt', opts['ytickint']) if(opts['ytickint'])
3888
1685
  DCL.uspset('dyl', opts['ylabelint']) if(opts['ylabelint'])
1686
+ if(opts['yloglabelall'])
1687
+ DCL.uspset('nlbly', 4)
1688
+ DCL.ulsybl([1,2,3,4,5,6,7,8,9])
1689
+ end
3889
1690
  opts['yside'].split('').each{|s| # scan('.') also works
3890
1691
  DCL.usyaxs(s)
3891
1692
  if s=='l' && sunits && sunits != ''
@@ -4594,12 +2395,24 @@ module NumRu
4594
2395
  @@data_prep_options
4595
2396
  )
4596
2397
 
2398
+ def name_selector(gp, limit)
2399
+ if gp.long_name && gp.name
2400
+ if gp.long_name.length > limit && gp.long_name.length > gp.name.length && !gp.name.empty?
2401
+ gp.name
2402
+ else
2403
+ gp.long_name
2404
+ end
2405
+ else
2406
+ gp.long_name || gp.name
2407
+ end
2408
+ end
2409
+ private :name_selector
2410
+
4597
2411
  def axes_or_map_and_ttl(gp, opts, xax, yax, gp2=nil)
4598
2412
  if !gp2
4599
- ttl = (opts['title'] || gp.long_name || gp.name)
2413
+ ttl = opts['title'] || name_selector(gp, 30)
4600
2414
  else
4601
- ttl = ( opts['title'] ||
4602
- '('+(gp.long_name || gp.name)+','+(gp2.long_name || gp2.name)+')' )
2415
+ ttl = opts['title'] || '(' << name_selector(gp, 15) << ',' << name_selector(gp2, 15) << ')'
4603
2416
  end
4604
2417
  if map_trn?
4605
2418
  map
@@ -4630,7 +2443,7 @@ module NumRu
4630
2443
  if map_fit
4631
2444
  fig(xax,yax, {'itr'=>1, 'new_frame'=>false, 'viewport'=>vpt})
4632
2445
  axes(xax, yax, 'title'=>ttl)
4633
- DCL.sgstrn(trn)
2446
+ fig(xax,yax,{'itr'=>trn, 'new_frame'=>false, 'viewport'=>vpt, 'map_fit'=>true})
4634
2447
  else
4635
2448
  xax_map = xax[0..1].copy
4636
2449
  xax_map[0] = cnt[0] + wnd[0]
@@ -5132,21 +2945,26 @@ module NumRu
5132
2945
  DCLExt.next_unit_vect_options(options)
5133
2946
  end
5134
2947
 
5135
- @@vxfxratio=nil
5136
- @@vyfyratio=nil
2948
+ @@vxfxratio=nil # for flow_vect
2949
+ @@vyfyratio=nil # for flow_vect
2950
+ @@vfratio=nil # for flow_vect_anyproj
5137
2951
 
5138
2952
  @@vector_options = Misc::KeywordOptAutoHelp.new(
5139
2953
  ['title', nil, 'Title of the figure(if nil, internally determined)'],
5140
2954
  ['annotate', true, 'if false, do not put texts on the right margin even when newframe==true'],
5141
2955
  ['map_axes', false, '[USE IT ONLY WHEN itr=10 (cylindrical)] If true, draws axes by temprarilly switching to itr=1 and calling GGraph::axes.'],
5142
2956
  ['flow_vect', true, 'If true, use DCLExt::flow_vect to draw vectors; otherwise, DCL::ugvect is used.'],
2957
+ ['flow_vect_anyproj', nil, 'Whether to use flow_vect_anyproj. If nil, up to the current projection number (when >=2); if true, always; if false, never. (precedence if higher than the flow_vect parameter)'],
5143
2958
  ['keep', false, 'Use the same vector scaling as in the previous call. -- Currently, works only when "flow_vect" is true'],
5144
2959
  ['factor', 1.0, '(Effective only if flow_vect) scaling factor to strech/reduce the arrow lengths'],
5145
2960
  ['unit_vect', false, 'Show the unit vector'],
5146
2961
  ['max_unit_vect', false, '(Effective only if flow_vect && unit_vect) If true, use the maximum arrows to scale the unit vector; otherwise, normalize in V coordinate.'],
5147
2962
  ['ux_unit', nil, '(If Numeric) length of the x direction unit vector (precedence of this option is lower than max_unit_vect)'],
5148
2963
  ['uy_unit', nil, '(If Numeric) length of the y direction unit vector (precedence of this option is lower than max_unit_vect)'],
5149
- ['flow_itr5', false, 'If true, use DclExt::flow_itr5 to draw vectors on 2-dim polar coordinate. Should be set DCL.sgstrn(5)'],
2964
+ ['len_unit', nil, '(Effective only when flow_vect_anyproj is used) If Numeric, length of the the unit vector in terms of (fx,fy); if nil (defualt), the unitvecto length is set to be the maximum one'],
2965
+ ['flow_itr5', false, 'If true, use DclExt::flow_itr5 to draw vectors on 2-dim polar coordinate. Should be set DCL.sgstrn(5)'],
2966
+ ['polar_thinning', nil, '(Effective only when flow_vect_anyproj is used) If Numeric, specifies the maximum grid isotrpy, with which thinning is made near the poles (recommended value: 0.3 ~ 1)'],
2967
+ ['distvect_map', true, '(effective only for flow_vect_anyproj when map projection) by default (true) it is assumed that the vector (fx,fy) is based on lengths (such as wind velocities in m/s and fluxes in which wind velocities are incorporated [q*u, q*v]); set it to false if the vector is based on angles (such as the time derivatives of longitude and latitude).'],
5150
2968
  @@data_prep_options
5151
2969
  )
5152
2970
 
@@ -5163,14 +2981,28 @@ module NumRu
5163
2981
  if newframe
5164
2982
  axes_or_map_and_ttl(fx, opts, xax, yax, fy)
5165
2983
  end
5166
- DCL.uwsgxa(xax.val)
5167
- DCL.uwsgya(yax.val)
2984
+ itr = current_itr
2985
+ xaxv = xax.val
2986
+ yaxv = yax.val
2987
+ DCL.uwsgxa(xaxv)
2988
+ DCL.uwsgya(yaxv)
5168
2989
  if opts['flow_itr5']
5169
2990
  if itr_is?(5)
5170
2991
  DCLExt.flow_itr5( fx, fy, opts['factor'], opts['unit_vect'] )
5171
2992
  else
5172
2993
  raise "flow_itr5 option should use with itr=5."
5173
2994
  end
2995
+ elsif opts['flow_vect_anyproj'] ||
2996
+ ( opts['flow_vect_anyproj'].nil? && opts['flow_vect'] && itr >=2 )
2997
+ @@vfratio, flenmax =
2998
+ DCLExt.flow_vect_anyproj(fx.val, fy.val, xaxv, yaxv,
2999
+ opts['factor'], 1, 1, opts['distvect_map'],
3000
+ (opts['keep'] && @@vfratio),
3001
+ opts['polar_thinning'] )
3002
+ if opts['unit_vect']
3003
+ len_unit = opts['len_unit'] || flenmax
3004
+ DCLExt.unit_vect_single(@@vfratio, len_unit)
3005
+ end
5174
3006
  elsif opts['flow_vect']
5175
3007
  uninfo = DCLExt.flow_vect(fx.val, fy.val, opts['factor'], 1, 1,
5176
3008
  (opts['keep']&& @@vxfxratio), (opts['keep'] && @@vyfyratio) )
@@ -5334,6 +3166,7 @@ end
5334
3166
  if $0 == __FILE__
5335
3167
  include NumRu
5336
3168
 
3169
+
5337
3170
  # < read command line option if any >
5338
3171
 
5339
3172
  if ARGV.length == 1
@@ -5348,7 +3181,8 @@ if $0 == __FILE__
5348
3181
  DCL.slmgn(0.0, 0.0, 0.011, 0.0)
5349
3182
  DCL.slsttl("#PAGE","b",1.0,1.0,0.01,1)
5350
3183
  DCL.sldiv('y',2,2)
5351
- DCL.sgpset('lcntl', false)
3184
+ #DCL.sgpset('lcntl', false)
3185
+ DCL.sgpset('isub', 96) # control character of subscription: '_' --> '`'
5352
3186
  DCL.sgpset('lfull',true)
5353
3187
  DCL.sgpset('lfprop',true)
5354
3188
  DCL.uzfact(0.9)
@@ -5620,13 +3454,14 @@ if $0 == __FILE__
5620
3454
  GGraph.vector(gp_velrad, gp_vellat, true,
5621
3455
  'flow_itr5'=>true,'factor'=>1e-1)
5622
3456
 
3457
+ #/ graph 34/
5623
3458
  GGraph.next_fig('itr'=>5)
5624
3459
  GGraph.tone(gp_velrad,true)
5625
3460
  GGraph.vector(gp_velrad, gp_vellat, false,
5626
3461
  'flow_itr5'=>true,'factor'=>1e-1)
3462
+ GGraph.color_bar
5627
3463
 
5628
-
5629
- #/ graph 34/
3464
+ #/ graph 35/
5630
3465
  # vector field on the polar coordinate (2)
5631
3466
  # -- demo for flow_itr5 option of GGraph.vector
5632
3467
 
@@ -5650,6 +3485,7 @@ if $0 == __FILE__
5650
3485
 
5651
3486
  #### draw vector field in the equatorial plane #####
5652
3487
 
3488
+ #/ graph 36/
5653
3489
  GGraph.next_fig('itr'=>5)
5654
3490
  GGraph.vector(gp_velrad, gp_vellon, true,
5655
3491
  'flow_itr5'=>true,'factor'=>1e-1)
@@ -5658,6 +3494,8 @@ if $0 == __FILE__
5658
3494
  GGraph.tone(gp_velrad,true)
5659
3495
  GGraph.vector(gp_velrad, gp_vellon, false,
5660
3496
  'flow_itr5'=>true,'factor'=>1e-1)
3497
+ GGraph.color_bar
3498
+
5661
3499
 
5662
3500
  #=end
5663
3501
 
@@ -5750,6 +3588,7 @@ if $0 == __FILE__
5750
3588
  file = '../../testdata/UV.jan.nc'
5751
3589
  u = GPhys::NetCDF_IO.open(file, 'U')
5752
3590
  v = GPhys::NetCDF_IO.open(file, 'V')
3591
+
5753
3592
  GGraph.scatter(u.cut("level"=>200),v.cut("level"=>200),true,
5754
3593
  "title"=>"sample scatter plot of multi-D data")
5755
3594
 
@@ -5832,6 +3671,67 @@ if $0 == __FILE__
5832
3671
  GGraph.vector(gphys+10,gphys-10,true,
5833
3672
  {'unit_vect'=>true, 'ux_unit'=>70, 'xintv'=>2, 'yintv'=>2})
5834
3673
 
3674
+ #/ graph 56 /
3675
+
3676
+ DCL.sgpset('lfull',true)
3677
+ GGraph.set_fig('itr'=>1,'viewport'=>[0.08,0.82,0.23,0.57])
3678
+ GGraph.vector(u.cut("level"=>200),v.cut("level"=>200),true,
3679
+ 'unit_vect'=>true)
3680
+
3681
+ #/ graph 57 /
3682
+
3683
+ DCL.sgpset('lfull',true)
3684
+ GGraph.set_fig('itr'=>2,'viewport'=>[0.2,0.8,0.2,0.6])
3685
+ GGraph.vector(u[0,false],v[0,false]*10,true,
3686
+ 'unit_vect'=>true)
3687
+
3688
+ #/ graph 58 /
3689
+
3690
+ GGraph.set_fig('itr'=>10)
3691
+ GGraph.set_map('coast_world'=>true)
3692
+ GGraph.vector(u.cut("level"=>200),v.cut("level"=>200),true,
3693
+ 'unit_vect'=>true,'flow_vect_anyproj'=>true,"factor"=>1.5)
3694
+
3695
+ #/ graph 59 /
3696
+ GGraph.set_fig('itr'=>30,'viewport'=>[0.2,0.7,0.1,0.6])
3697
+ GGraph.vector(u.cut("lat"=>20..90,"level"=>200),
3698
+ v.cut("lat"=>20..90,"level"=>200),true,
3699
+ 'unit_vect'=>true)
3700
+
3701
+ #/ graph 60 /
3702
+ GGraph.set_fig('itr'=>12,'viewport'=>[0.1,0.8,0.15,0.55])
3703
+ DCLExt.next_unit_vect_options('rsizet'=>0.03,'vertical'=>false,"vxuloc"=>0.45)
3704
+ GGraph.vector(u.cut("level"=>200),
3705
+ v.cut("level"=>200),true,
3706
+ 'unit_vect'=>true,"len_unit"=>70)
3707
+
3708
+ #/ graph 61/
3709
+ GGraph.next_fig('itr'=>14)
3710
+ GGraph.next_map('fill'=>true)
3711
+ GGraph.tone(gphys, true)
3712
+ GGraph.color_bar
3713
+ GGraph.contour(gphys, false) # contour after color_bar
3714
+
3715
+ #/ graph 67/
3716
+ GGraph.next_fig('itr'=>23)
3717
+ GGraph.next_map('fill'=>true)
3718
+ GGraph.tone_and_contour(gphys, true, 'color_bar'=>true)
3719
+
3720
+ #/ graph 69/
3721
+ GGraph.next_fig('itr'=>31,'viewport'=>[0.22,0.78,0.06,0.6])
3722
+ GGraph.next_map('fill'=>true)
3723
+ DCL.sgpset('lclip',true)
3724
+ GGraph.tone(gphys, true)
3725
+ GGraph.color_bar
3726
+ GGraph.contour(gphys, false) # contour after color_bar
3727
+ DCL.sgpset('lclip',false)
3728
+
3729
+ #/ graph 71/
3730
+ GGraph.next_fig('itr'=>10)
3731
+ GGraph.next_map('fill'=>true)
3732
+ GGraph.next_axes('xtitle'=>'')
3733
+ GGraph.tone_and_contour(gphys, true, 'map_axes'=>true, 'color_bar'=>true)
3734
+
5835
3735
  ############
5836
3736
  DCL.grcls
5837
3737