gphys 1.1.1 → 1.2.2
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +17 -0
- data/ChangeLog +221 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +18 -30
- data/README +23 -26
- data/README.md +29 -0
- data/Rakefile +1 -56
- data/bin/gpaop +2 -1
- data/bin/gpcut +3 -2
- data/bin/gpedit +6 -2
- data/bin/gpmath +3 -2
- data/bin/gpmaxmin +3 -2
- data/bin/gpprint +2 -1
- data/bin/gpvect +28 -5
- data/bin/gpview +43 -5
- data/extconf.rb +5 -6
- data/gphys.gemspec +34 -0
- data/interpo.c +63 -24
- data/lib/gphys.rb +2 -0
- data/lib/numru/dclext.rb +2636 -0
- data/lib/numru/derivative.rb +53 -12
- data/lib/numru/ganalysis/eof.rb +4 -0
- data/lib/numru/ganalysis/histogram.rb +73 -5
- data/lib/numru/ganalysis/met.rb +163 -2
- data/lib/numru/ganalysis/planet.rb +230 -20
- data/lib/numru/ggraph.rb +147 -2247
- data/lib/numru/gphys/assoccoords.rb +19 -3
- data/lib/numru/gphys/axis.rb +1 -1
- data/lib/numru/gphys/coordmapping.rb +2 -2
- data/lib/numru/gphys/derivative.rb +56 -13
- data/lib/numru/gphys/gphys.rb +17 -1
- data/lib/numru/gphys/gphys_grads_io.rb +6 -5
- data/lib/numru/gphys/gphys_grib_io.rb +6 -6
- data/lib/numru/gphys/gphys_io.rb +25 -6
- data/lib/numru/gphys/grads_gridded.rb +31 -29
- data/lib/numru/gphys/grib.rb +13 -9
- data/lib/numru/gphys/interpolate.rb +153 -29
- data/lib/numru/gphys/unumeric.rb +29 -6
- data/lib/numru/gphys/varray.rb +9 -0
- data/lib/numru/gphys/varraygrib.rb +70 -8
- data/lib/version.rb +3 -0
- metadata +247 -531
- data/doc/attribute.html +0 -19
- data/doc/attributenetcdf.html +0 -15
- data/doc/axis.html +0 -376
- data/doc/coordmapping.html +0 -111
- data/doc/coordtransform.html +0 -36
- data/doc/derivative/gphys-derivative.html +0 -80
- data/doc/derivative/index.html +0 -21
- data/doc/derivative/index.rd +0 -14
- data/doc/derivative/math-doc/document/document.css +0 -30
- data/doc/derivative/math-doc/document/document.html +0 -57
- data/doc/derivative/math-doc/document/images.aux +0 -1
- data/doc/derivative/math-doc/document/images.log +0 -385
- data/doc/derivative/math-doc/document/images.pl +0 -186
- data/doc/derivative/math-doc/document/images.tex +0 -364
- data/doc/derivative/math-doc/document/img1.png +0 -0
- data/doc/derivative/math-doc/document/img10.png +0 -0
- data/doc/derivative/math-doc/document/img11.png +0 -0
- data/doc/derivative/math-doc/document/img12.png +0 -0
- data/doc/derivative/math-doc/document/img13.png +0 -0
- data/doc/derivative/math-doc/document/img14.png +0 -0
- data/doc/derivative/math-doc/document/img15.png +0 -0
- data/doc/derivative/math-doc/document/img16.png +0 -0
- data/doc/derivative/math-doc/document/img17.png +0 -0
- data/doc/derivative/math-doc/document/img18.png +0 -0
- data/doc/derivative/math-doc/document/img19.png +0 -0
- data/doc/derivative/math-doc/document/img2.png +0 -0
- data/doc/derivative/math-doc/document/img20.png +0 -0
- data/doc/derivative/math-doc/document/img21.png +0 -0
- data/doc/derivative/math-doc/document/img22.png +0 -0
- data/doc/derivative/math-doc/document/img23.png +0 -0
- data/doc/derivative/math-doc/document/img24.png +0 -0
- data/doc/derivative/math-doc/document/img25.png +0 -0
- data/doc/derivative/math-doc/document/img26.png +0 -0
- data/doc/derivative/math-doc/document/img27.png +0 -0
- data/doc/derivative/math-doc/document/img28.png +0 -0
- data/doc/derivative/math-doc/document/img29.png +0 -0
- data/doc/derivative/math-doc/document/img3.png +0 -0
- data/doc/derivative/math-doc/document/img30.png +0 -0
- data/doc/derivative/math-doc/document/img4.png +0 -0
- data/doc/derivative/math-doc/document/img5.png +0 -0
- data/doc/derivative/math-doc/document/img6.png +0 -0
- data/doc/derivative/math-doc/document/img7.png +0 -0
- data/doc/derivative/math-doc/document/img8.png +0 -0
- data/doc/derivative/math-doc/document/img9.png +0 -0
- data/doc/derivative/math-doc/document/index.html +0 -57
- data/doc/derivative/math-doc/document/labels.pl +0 -13
- data/doc/derivative/math-doc/document/next.png +0 -0
- data/doc/derivative/math-doc/document/next_g.png +0 -0
- data/doc/derivative/math-doc/document/node1.html +0 -238
- data/doc/derivative/math-doc/document/node2.html +0 -75
- data/doc/derivative/math-doc/document/prev.png +0 -0
- data/doc/derivative/math-doc/document/prev_g.png +0 -0
- data/doc/derivative/math-doc/document/up.png +0 -0
- data/doc/derivative/math-doc/document/up_g.png +0 -0
- data/doc/derivative/math-doc/document.pdf +0 -0
- data/doc/derivative/math-doc/document.tex +0 -158
- data/doc/derivative/numru-derivative.html +0 -129
- data/doc/ep_flux/ep_flux.html +0 -469
- data/doc/ep_flux/ggraph_on_merdional_section.html +0 -71
- data/doc/ep_flux/index.html +0 -31
- data/doc/ep_flux/index.rd +0 -24
- data/doc/ep_flux/math-doc/document/WARNINGS +0 -1
- data/doc/ep_flux/math-doc/document/contents.png +0 -0
- data/doc/ep_flux/math-doc/document/crossref.png +0 -0
- data/doc/ep_flux/math-doc/document/document.css +0 -30
- data/doc/ep_flux/math-doc/document/document.html +0 -101
- data/doc/ep_flux/math-doc/document/images.aux +0 -1
- data/doc/ep_flux/math-doc/document/images.log +0 -1375
- data/doc/ep_flux/math-doc/document/images.pl +0 -1328
- data/doc/ep_flux/math-doc/document/images.tex +0 -1471
- data/doc/ep_flux/math-doc/document/img1.png +0 -0
- data/doc/ep_flux/math-doc/document/img10.png +0 -0
- data/doc/ep_flux/math-doc/document/img100.png +0 -0
- data/doc/ep_flux/math-doc/document/img101.png +0 -0
- data/doc/ep_flux/math-doc/document/img102.png +0 -0
- data/doc/ep_flux/math-doc/document/img103.png +0 -0
- data/doc/ep_flux/math-doc/document/img104.png +0 -0
- data/doc/ep_flux/math-doc/document/img105.png +0 -0
- data/doc/ep_flux/math-doc/document/img106.png +0 -0
- data/doc/ep_flux/math-doc/document/img107.png +0 -0
- data/doc/ep_flux/math-doc/document/img108.png +0 -0
- data/doc/ep_flux/math-doc/document/img109.png +0 -0
- data/doc/ep_flux/math-doc/document/img11.png +0 -0
- data/doc/ep_flux/math-doc/document/img110.png +0 -0
- data/doc/ep_flux/math-doc/document/img111.png +0 -0
- data/doc/ep_flux/math-doc/document/img112.png +0 -0
- data/doc/ep_flux/math-doc/document/img113.png +0 -0
- data/doc/ep_flux/math-doc/document/img114.png +0 -0
- data/doc/ep_flux/math-doc/document/img115.png +0 -0
- data/doc/ep_flux/math-doc/document/img116.png +0 -0
- data/doc/ep_flux/math-doc/document/img117.png +0 -0
- data/doc/ep_flux/math-doc/document/img118.png +0 -0
- data/doc/ep_flux/math-doc/document/img119.png +0 -0
- data/doc/ep_flux/math-doc/document/img12.png +0 -0
- data/doc/ep_flux/math-doc/document/img120.png +0 -0
- data/doc/ep_flux/math-doc/document/img121.png +0 -0
- data/doc/ep_flux/math-doc/document/img122.png +0 -0
- data/doc/ep_flux/math-doc/document/img123.png +0 -0
- data/doc/ep_flux/math-doc/document/img124.png +0 -0
- data/doc/ep_flux/math-doc/document/img125.png +0 -0
- data/doc/ep_flux/math-doc/document/img126.png +0 -0
- data/doc/ep_flux/math-doc/document/img127.png +0 -0
- data/doc/ep_flux/math-doc/document/img128.png +0 -0
- data/doc/ep_flux/math-doc/document/img129.png +0 -0
- data/doc/ep_flux/math-doc/document/img13.png +0 -0
- data/doc/ep_flux/math-doc/document/img130.png +0 -0
- data/doc/ep_flux/math-doc/document/img131.png +0 -0
- data/doc/ep_flux/math-doc/document/img132.png +0 -0
- data/doc/ep_flux/math-doc/document/img133.png +0 -0
- data/doc/ep_flux/math-doc/document/img134.png +0 -0
- data/doc/ep_flux/math-doc/document/img135.png +0 -0
- data/doc/ep_flux/math-doc/document/img136.png +0 -0
- data/doc/ep_flux/math-doc/document/img137.png +0 -0
- data/doc/ep_flux/math-doc/document/img138.png +0 -0
- data/doc/ep_flux/math-doc/document/img139.png +0 -0
- data/doc/ep_flux/math-doc/document/img14.png +0 -0
- data/doc/ep_flux/math-doc/document/img140.png +0 -0
- data/doc/ep_flux/math-doc/document/img141.png +0 -0
- data/doc/ep_flux/math-doc/document/img142.png +0 -0
- data/doc/ep_flux/math-doc/document/img143.png +0 -0
- data/doc/ep_flux/math-doc/document/img144.png +0 -0
- data/doc/ep_flux/math-doc/document/img145.png +0 -0
- data/doc/ep_flux/math-doc/document/img146.png +0 -0
- data/doc/ep_flux/math-doc/document/img147.png +0 -0
- data/doc/ep_flux/math-doc/document/img148.png +0 -0
- data/doc/ep_flux/math-doc/document/img149.png +0 -0
- data/doc/ep_flux/math-doc/document/img15.png +0 -0
- data/doc/ep_flux/math-doc/document/img150.png +0 -0
- data/doc/ep_flux/math-doc/document/img151.png +0 -0
- data/doc/ep_flux/math-doc/document/img152.png +0 -0
- data/doc/ep_flux/math-doc/document/img153.png +0 -0
- data/doc/ep_flux/math-doc/document/img154.png +0 -0
- data/doc/ep_flux/math-doc/document/img155.png +0 -0
- data/doc/ep_flux/math-doc/document/img156.png +0 -0
- data/doc/ep_flux/math-doc/document/img157.png +0 -0
- data/doc/ep_flux/math-doc/document/img158.png +0 -0
- data/doc/ep_flux/math-doc/document/img159.png +0 -0
- data/doc/ep_flux/math-doc/document/img16.png +0 -0
- data/doc/ep_flux/math-doc/document/img160.png +0 -0
- data/doc/ep_flux/math-doc/document/img161.png +0 -0
- data/doc/ep_flux/math-doc/document/img162.png +0 -0
- data/doc/ep_flux/math-doc/document/img163.png +0 -0
- data/doc/ep_flux/math-doc/document/img164.png +0 -0
- data/doc/ep_flux/math-doc/document/img165.png +0 -0
- data/doc/ep_flux/math-doc/document/img166.png +0 -0
- data/doc/ep_flux/math-doc/document/img167.png +0 -0
- data/doc/ep_flux/math-doc/document/img168.png +0 -0
- data/doc/ep_flux/math-doc/document/img169.png +0 -0
- data/doc/ep_flux/math-doc/document/img17.png +0 -0
- data/doc/ep_flux/math-doc/document/img170.png +0 -0
- data/doc/ep_flux/math-doc/document/img171.png +0 -0
- data/doc/ep_flux/math-doc/document/img172.png +0 -0
- data/doc/ep_flux/math-doc/document/img173.png +0 -0
- data/doc/ep_flux/math-doc/document/img174.png +0 -0
- data/doc/ep_flux/math-doc/document/img175.png +0 -0
- data/doc/ep_flux/math-doc/document/img176.png +0 -0
- data/doc/ep_flux/math-doc/document/img177.png +0 -0
- data/doc/ep_flux/math-doc/document/img178.png +0 -0
- data/doc/ep_flux/math-doc/document/img179.png +0 -0
- data/doc/ep_flux/math-doc/document/img18.png +0 -0
- data/doc/ep_flux/math-doc/document/img180.png +0 -0
- data/doc/ep_flux/math-doc/document/img181.png +0 -0
- data/doc/ep_flux/math-doc/document/img182.png +0 -0
- data/doc/ep_flux/math-doc/document/img183.png +0 -0
- data/doc/ep_flux/math-doc/document/img184.png +0 -0
- data/doc/ep_flux/math-doc/document/img185.png +0 -0
- data/doc/ep_flux/math-doc/document/img186.png +0 -0
- data/doc/ep_flux/math-doc/document/img187.png +0 -0
- data/doc/ep_flux/math-doc/document/img188.png +0 -0
- data/doc/ep_flux/math-doc/document/img189.png +0 -0
- data/doc/ep_flux/math-doc/document/img19.png +0 -0
- data/doc/ep_flux/math-doc/document/img190.png +0 -0
- data/doc/ep_flux/math-doc/document/img191.png +0 -0
- data/doc/ep_flux/math-doc/document/img192.png +0 -0
- data/doc/ep_flux/math-doc/document/img193.png +0 -0
- data/doc/ep_flux/math-doc/document/img194.png +0 -0
- data/doc/ep_flux/math-doc/document/img195.png +0 -0
- data/doc/ep_flux/math-doc/document/img196.png +0 -0
- data/doc/ep_flux/math-doc/document/img197.png +0 -0
- data/doc/ep_flux/math-doc/document/img198.png +0 -0
- data/doc/ep_flux/math-doc/document/img199.png +0 -0
- data/doc/ep_flux/math-doc/document/img2.png +0 -0
- data/doc/ep_flux/math-doc/document/img20.png +0 -0
- data/doc/ep_flux/math-doc/document/img200.png +0 -0
- data/doc/ep_flux/math-doc/document/img21.png +0 -0
- data/doc/ep_flux/math-doc/document/img22.png +0 -0
- data/doc/ep_flux/math-doc/document/img23.png +0 -0
- data/doc/ep_flux/math-doc/document/img24.png +0 -0
- data/doc/ep_flux/math-doc/document/img25.png +0 -0
- data/doc/ep_flux/math-doc/document/img26.png +0 -0
- data/doc/ep_flux/math-doc/document/img27.png +0 -0
- data/doc/ep_flux/math-doc/document/img28.png +0 -0
- data/doc/ep_flux/math-doc/document/img29.png +0 -0
- data/doc/ep_flux/math-doc/document/img3.png +0 -0
- data/doc/ep_flux/math-doc/document/img30.png +0 -0
- data/doc/ep_flux/math-doc/document/img31.png +0 -0
- data/doc/ep_flux/math-doc/document/img32.png +0 -0
- data/doc/ep_flux/math-doc/document/img33.png +0 -0
- data/doc/ep_flux/math-doc/document/img34.png +0 -0
- data/doc/ep_flux/math-doc/document/img35.png +0 -0
- data/doc/ep_flux/math-doc/document/img36.png +0 -0
- data/doc/ep_flux/math-doc/document/img37.png +0 -0
- data/doc/ep_flux/math-doc/document/img38.png +0 -0
- data/doc/ep_flux/math-doc/document/img39.png +0 -0
- data/doc/ep_flux/math-doc/document/img4.png +0 -0
- data/doc/ep_flux/math-doc/document/img40.png +0 -0
- data/doc/ep_flux/math-doc/document/img41.png +0 -0
- data/doc/ep_flux/math-doc/document/img42.png +0 -0
- data/doc/ep_flux/math-doc/document/img43.png +0 -0
- data/doc/ep_flux/math-doc/document/img44.png +0 -0
- data/doc/ep_flux/math-doc/document/img45.png +0 -0
- data/doc/ep_flux/math-doc/document/img46.png +0 -0
- data/doc/ep_flux/math-doc/document/img47.png +0 -0
- data/doc/ep_flux/math-doc/document/img48.png +0 -0
- data/doc/ep_flux/math-doc/document/img49.png +0 -0
- data/doc/ep_flux/math-doc/document/img5.png +0 -0
- data/doc/ep_flux/math-doc/document/img50.png +0 -0
- data/doc/ep_flux/math-doc/document/img51.png +0 -0
- data/doc/ep_flux/math-doc/document/img52.png +0 -0
- data/doc/ep_flux/math-doc/document/img53.png +0 -0
- data/doc/ep_flux/math-doc/document/img54.png +0 -0
- data/doc/ep_flux/math-doc/document/img55.png +0 -0
- data/doc/ep_flux/math-doc/document/img56.png +0 -0
- data/doc/ep_flux/math-doc/document/img57.png +0 -0
- data/doc/ep_flux/math-doc/document/img58.png +0 -0
- data/doc/ep_flux/math-doc/document/img59.png +0 -0
- data/doc/ep_flux/math-doc/document/img6.png +0 -0
- data/doc/ep_flux/math-doc/document/img60.png +0 -0
- data/doc/ep_flux/math-doc/document/img61.png +0 -0
- data/doc/ep_flux/math-doc/document/img62.png +0 -0
- data/doc/ep_flux/math-doc/document/img63.png +0 -0
- data/doc/ep_flux/math-doc/document/img64.png +0 -0
- data/doc/ep_flux/math-doc/document/img65.png +0 -0
- data/doc/ep_flux/math-doc/document/img66.png +0 -0
- data/doc/ep_flux/math-doc/document/img67.png +0 -0
- data/doc/ep_flux/math-doc/document/img68.png +0 -0
- data/doc/ep_flux/math-doc/document/img69.png +0 -0
- data/doc/ep_flux/math-doc/document/img7.png +0 -0
- data/doc/ep_flux/math-doc/document/img70.png +0 -0
- data/doc/ep_flux/math-doc/document/img71.png +0 -0
- data/doc/ep_flux/math-doc/document/img72.png +0 -0
- data/doc/ep_flux/math-doc/document/img73.png +0 -0
- data/doc/ep_flux/math-doc/document/img74.png +0 -0
- data/doc/ep_flux/math-doc/document/img75.png +0 -0
- data/doc/ep_flux/math-doc/document/img76.png +0 -0
- data/doc/ep_flux/math-doc/document/img77.png +0 -0
- data/doc/ep_flux/math-doc/document/img78.png +0 -0
- data/doc/ep_flux/math-doc/document/img79.png +0 -0
- data/doc/ep_flux/math-doc/document/img8.png +0 -0
- data/doc/ep_flux/math-doc/document/img80.png +0 -0
- data/doc/ep_flux/math-doc/document/img81.png +0 -0
- data/doc/ep_flux/math-doc/document/img82.png +0 -0
- data/doc/ep_flux/math-doc/document/img83.png +0 -0
- data/doc/ep_flux/math-doc/document/img84.png +0 -0
- data/doc/ep_flux/math-doc/document/img85.png +0 -0
- data/doc/ep_flux/math-doc/document/img86.png +0 -0
- data/doc/ep_flux/math-doc/document/img87.png +0 -0
- data/doc/ep_flux/math-doc/document/img88.png +0 -0
- data/doc/ep_flux/math-doc/document/img89.png +0 -0
- data/doc/ep_flux/math-doc/document/img9.png +0 -0
- data/doc/ep_flux/math-doc/document/img90.png +0 -0
- data/doc/ep_flux/math-doc/document/img91.png +0 -0
- data/doc/ep_flux/math-doc/document/img92.png +0 -0
- data/doc/ep_flux/math-doc/document/img93.png +0 -0
- data/doc/ep_flux/math-doc/document/img94.png +0 -0
- data/doc/ep_flux/math-doc/document/img95.png +0 -0
- data/doc/ep_flux/math-doc/document/img96.png +0 -0
- data/doc/ep_flux/math-doc/document/img97.png +0 -0
- data/doc/ep_flux/math-doc/document/img98.png +0 -0
- data/doc/ep_flux/math-doc/document/img99.png +0 -0
- data/doc/ep_flux/math-doc/document/index.html +0 -101
- data/doc/ep_flux/math-doc/document/internals.pl +0 -258
- data/doc/ep_flux/math-doc/document/labels.pl +0 -265
- data/doc/ep_flux/math-doc/document/next.png +0 -0
- data/doc/ep_flux/math-doc/document/next_g.png +0 -0
- data/doc/ep_flux/math-doc/document/node1.html +0 -104
- data/doc/ep_flux/math-doc/document/node10.html +0 -164
- data/doc/ep_flux/math-doc/document/node11.html +0 -86
- data/doc/ep_flux/math-doc/document/node12.html +0 -166
- data/doc/ep_flux/math-doc/document/node13.html +0 -897
- data/doc/ep_flux/math-doc/document/node14.html +0 -1065
- data/doc/ep_flux/math-doc/document/node15.html +0 -72
- data/doc/ep_flux/math-doc/document/node16.html +0 -81
- data/doc/ep_flux/math-doc/document/node2.html +0 -82
- data/doc/ep_flux/math-doc/document/node3.html +0 -91
- data/doc/ep_flux/math-doc/document/node4.html +0 -149
- data/doc/ep_flux/math-doc/document/node5.html +0 -330
- data/doc/ep_flux/math-doc/document/node6.html +0 -99
- data/doc/ep_flux/math-doc/document/node7.html +0 -98
- data/doc/ep_flux/math-doc/document/node8.html +0 -83
- data/doc/ep_flux/math-doc/document/node9.html +0 -140
- data/doc/ep_flux/math-doc/document/prev.png +0 -0
- data/doc/ep_flux/math-doc/document/prev_g.png +0 -0
- data/doc/ep_flux/math-doc/document/up.png +0 -0
- data/doc/ep_flux/math-doc/document/up_g.png +0 -0
- data/doc/ep_flux/math-doc/document.pdf +0 -0
- data/doc/ep_flux/math-doc/document.tex +0 -2018
- data/doc/gdir.html +0 -412
- data/doc/gdir_client.html +0 -16
- data/doc/gdir_connect_ftp-like.html +0 -61
- data/doc/gdir_server.html +0 -45
- data/doc/ggraph.html +0 -1615
- data/doc/gpcat.html +0 -44
- data/doc/gpcut.html +0 -41
- data/doc/gphys.html +0 -532
- data/doc/gphys_fft.html +0 -324
- data/doc/gphys_grads_io.html +0 -69
- data/doc/gphys_grib_io.html +0 -82
- data/doc/gphys_io.html +0 -120
- data/doc/gphys_io_common.html +0 -18
- data/doc/gphys_netcdf_io.html +0 -283
- data/doc/gplist.html +0 -24
- data/doc/gpmath.html +0 -51
- data/doc/gpmaxmin.html +0 -31
- data/doc/gpprint.html +0 -34
- data/doc/gpview.html +0 -270
- data/doc/grads2nc_with_gphys.html +0 -21
- data/doc/grads_gridded.html +0 -307
- data/doc/grib.html +0 -144
- data/doc/grid.html +0 -212
- data/doc/index.html +0 -133
- data/doc/index.rd +0 -127
- data/doc/netcdf_convention.html +0 -136
- data/doc/unumeric.html +0 -176
- data/doc/update +0 -64
- data/doc/varray.html +0 -299
- data/doc/varraycomposite.html +0 -67
@@ -1,5 +1,6 @@
|
|
1
1
|
require "numru/gphys/gphys"
|
2
|
-
require "numru/dcl" # math1/gt2dlib is used for pure-2D interpolation
|
2
|
+
require "numru/dcl" # math1/gt2dlib is used for pure-2D interpolation.
|
3
|
+
# Also for dcl_fig_cut
|
3
4
|
require "numru/dcl_mouse" # for mouse_cut, mouse_cut_repeat
|
4
5
|
require "narray_miss"
|
5
6
|
|
@@ -13,9 +14,21 @@ module NumRu
|
|
13
14
|
|
14
15
|
@@interpo_previous_cutter = nil
|
15
16
|
@@interpo_previous_modifier = nil
|
16
|
-
@@interpo_missval =
|
17
|
+
@@interpo_missval = 9.9692099683868690e+36 # NC_FILL_DOUBLE/FLOAT ~15*2^119
|
18
|
+
@@interpo_extrapolation = false
|
17
19
|
|
18
|
-
#
|
20
|
+
# Change the behavior of the interpolation methods to extrapolate
|
21
|
+
# outside the grid coverage.
|
22
|
+
#
|
23
|
+
# ARGUMENTS
|
24
|
+
# * extrapo : true or false --- the default behaviour is false
|
25
|
+
# (not to extrapolate), so use this method if you
|
26
|
+
# want to set it to true.
|
27
|
+
def self.extrapolation=(extrapo)
|
28
|
+
@@interpo_extrapolation = extrapo
|
29
|
+
end
|
30
|
+
|
31
|
+
# Makes a subset interactively by specifying a (poly-)line on the DCL viewport
|
19
32
|
#
|
20
33
|
# ARGUMENTS
|
21
34
|
# * dimx {String] : name of number (0,1,..) of the dimension
|
@@ -28,7 +41,7 @@ module NumRu
|
|
28
41
|
#
|
29
42
|
# RETURN VALUE
|
30
43
|
# * a GPhys
|
31
|
-
def mouse_cut(dimx, dimy, num=2)
|
44
|
+
def mouse_cut(dimx, dimy, num=2, line_type=1, line_index=1)
|
32
45
|
|
33
46
|
# < preparation >
|
34
47
|
|
@@ -46,12 +59,40 @@ module NumRu
|
|
46
59
|
break
|
47
60
|
end
|
48
61
|
end
|
49
|
-
line.draw
|
62
|
+
line.draw(line_type, line_index)
|
50
63
|
vx = line.vx
|
51
64
|
vy = line.vy
|
52
65
|
ux = line.ux
|
53
66
|
uy = line.uy
|
67
|
+
gpnew = dcl_fig_cut(dimx,dimy,ux,uy)
|
68
|
+
[gpnew, line]
|
69
|
+
end
|
70
|
+
|
71
|
+
# Interpolation on the DCL window (automatic iso-interval interpolation
|
72
|
+
# along a poly line that can be drawn in the current viewport of the
|
73
|
+
# DCL window). Used in mouse_cut.
|
74
|
+
#
|
75
|
+
# ARGUMENTS
|
76
|
+
# * dimx [Integer or String] : specifies the dimension corresponding
|
77
|
+
# to the UX coordinate.
|
78
|
+
# (Here, the UX coordinate is the X coordinate of the DCL's USER
|
79
|
+
# coordinate. For exapmle, longitude if map projection.)
|
80
|
+
# * dimy [Integer or String] : specifies the dimension corresponding
|
81
|
+
# to the UY coordinate.
|
82
|
+
# (Here, the UY coordinate is the Y coordinate of the DCL's USER
|
83
|
+
# coordinate. For exapmle, latitude if map projection.)
|
84
|
+
# * ux [Array] : x values in terms of the UX coordinate
|
85
|
+
# * uy [Array] : y values in terms of the UY coordinate
|
86
|
+
# Lengths of ux and uy must be the same and greter or equal to 2.
|
87
|
+
#
|
88
|
+
def dcl_fig_cut(dimx,dimy,ux,uy)
|
54
89
|
len = ux.length
|
90
|
+
raise("ux and uy must be arrays with the (same) length >= 2") if len<=1
|
91
|
+
raise("ux's len (#{len}) != uy's len (#{uy.length})") if uy.length != len
|
92
|
+
vx=Array.new; vy=Array.new
|
93
|
+
for i in 0...len
|
94
|
+
vx[i],vy[i] = NumRu::DCL.stftrf(ux[i],uy[i])
|
95
|
+
end
|
55
96
|
kx = Array.new
|
56
97
|
ky = Array.new
|
57
98
|
cut = [true]*rank
|
@@ -66,13 +107,18 @@ module NumRu
|
|
66
107
|
ndsum = [0]
|
67
108
|
for i in 0...len-1
|
68
109
|
ndiv[i] = Math.sqrt( (kx[i+1]-kx[i])**2 + (ky[i+1]-ky[i])**2).to_i
|
110
|
+
ndiv[i] += 1 if i==len-2
|
69
111
|
ndsum.push ndsum[-1] + ndiv[i] # 0, ndiv[0], ndiv[0]+ndiv[1], ...
|
70
112
|
end
|
71
113
|
ndtot = ndsum[-1]
|
72
114
|
vxdiv = NArray.float(ndtot)
|
73
115
|
vydiv = NArray.float(ndtot)
|
74
116
|
for i in 0...len-1
|
75
|
-
|
117
|
+
if i!=len-2
|
118
|
+
a = NArray.float(ndiv[i]).indgen / ndiv[i]
|
119
|
+
else
|
120
|
+
a = NArray.float(ndiv[i]).indgen / (ndiv[i]-1)
|
121
|
+
end
|
76
122
|
vxdiv[ndsum[i]...ndsum[i+1]] = (1.0-a)*vx[i] + a*vx[i+1]
|
77
123
|
vydiv[ndsum[i]...ndsum[i+1]] = (1.0-a)*vy[i] + a*vy[i+1]
|
78
124
|
end
|
@@ -115,10 +161,10 @@ module NumRu
|
|
115
161
|
|
116
162
|
gpnew = interpolate(cutter)
|
117
163
|
gpnew = modifier[gpnew] if modifier
|
118
|
-
|
164
|
+
gpnew
|
119
165
|
end
|
120
166
|
|
121
|
-
#
|
167
|
+
# Interpolation onto grid points specified by the previous call of GPhys#mouse_cut
|
122
168
|
def mouse_cut_repeat
|
123
169
|
if @@interpo_previous_cutter.nil?
|
124
170
|
raise("You must first use GPhys#mouse_cut. This method repeats it")
|
@@ -150,7 +196,7 @@ module NumRu
|
|
150
196
|
end
|
151
197
|
private :__sp_dist
|
152
198
|
|
153
|
-
#
|
199
|
+
# Interpolate to conform the grid to a target GPhys object
|
154
200
|
#
|
155
201
|
# ARGUMENTS
|
156
202
|
# * to [GPhys] : the target gphys
|
@@ -163,7 +209,36 @@ module NumRu
|
|
163
209
|
interpolate(*coords)
|
164
210
|
end
|
165
211
|
|
166
|
-
#
|
212
|
+
# Reverse the main data (i.e., the dependent variable) and one of the
|
213
|
+
# coordinates (an independent variable) through interpolation.
|
214
|
+
#
|
215
|
+
# Returns a GPhys in which the main data is the specfied coordinate
|
216
|
+
# (argument: axname) sampled at specified locations (argument: pos)
|
217
|
+
# in terms of the main data of self. The main data of self is expected
|
218
|
+
# to be quai-monotonic with respect to the specfied coordinate.
|
219
|
+
#
|
220
|
+
# ARGUMENTS
|
221
|
+
# * axname [String] : one of the names of the axes (i.e. main
|
222
|
+
# coordinates. Auxiliary coordinates are not supported as the target.)
|
223
|
+
# * pos [NArray] : grid locations. For example, if the current data is
|
224
|
+
# potential temperature theta, pos consists of the theta levels to
|
225
|
+
# make sampling.
|
226
|
+
#
|
227
|
+
# RETURN VALUE
|
228
|
+
# * a GPhys
|
229
|
+
#
|
230
|
+
def coord_data_reverse(axname,pos)
|
231
|
+
gp = self.axis(axname).to_gphys
|
232
|
+
gp = self.shape_coerce_full(gp)[0] # conform the shape to that of self
|
233
|
+
gp = GPhys.new( gp.grid.copy, gp.data ) # copy grid to avoid side effect
|
234
|
+
# on the grid of self
|
235
|
+
gp.set_assoc_coords([self])
|
236
|
+
pos = NArray[*pos].to_type(NArray::FLOAT) if pos.is_a?(Array)
|
237
|
+
newcrd = VArray.new(pos,self.data,self.name) # succeeds the attributes
|
238
|
+
gp.interpolate(axname=>newcrd)
|
239
|
+
end
|
240
|
+
|
241
|
+
# Wide-purpose multi-dimensional linear interpolation
|
167
242
|
#
|
168
243
|
# This method supports interpolation regarding combinations of
|
169
244
|
# 1D and 2D coordinate variables. For instance, suppose self is
|
@@ -320,16 +395,25 @@ module NumRu
|
|
320
395
|
missval = ( (a=get_att('_FillValue')) ? a[0] : nil ) ||
|
321
396
|
( (a=get_att('missing_value')) ? a[0] : nil ) ||
|
322
397
|
@@interpo_missval
|
323
|
-
z = z.to_na(missval)
|
398
|
+
z = z.to_na(missval)
|
399
|
+
input_nomiss = false
|
324
400
|
else
|
325
|
-
|
401
|
+
input_nomiss = true
|
402
|
+
if @@interpo_extrapolation
|
403
|
+
missval = nil
|
404
|
+
else
|
405
|
+
missval = @@interpo_missval
|
406
|
+
end
|
326
407
|
end
|
327
408
|
|
328
|
-
na = c_interpo_do(newgrid.shape, idxmap, z, missval
|
409
|
+
na = c_interpo_do(newgrid.shape, idxmap, z, missval,
|
410
|
+
@@interpo_extrapolation) # [C-extension]
|
329
411
|
|
330
|
-
if
|
412
|
+
if !input_nomiss || !@@interpo_extrapolation
|
331
413
|
mask = na.ne(missval)
|
332
|
-
|
414
|
+
if !input_nomiss || mask.min == 0
|
415
|
+
na = NArrayMiss.to_nam_no_dup(na,mask)
|
416
|
+
end
|
333
417
|
end
|
334
418
|
|
335
419
|
va = VArray.new(na, data, name)
|
@@ -353,7 +437,8 @@ module NumRu
|
|
353
437
|
elsif cd.is_a?(Numeric) && mp[1].is_a?(NArray)
|
354
438
|
xto = mp[1] # 1-D new coordinate var
|
355
439
|
xfrom = mp[2] # 1-D original coordinate var
|
356
|
-
ids, f = c_interpo_find_loc_1D(xto,xfrom
|
440
|
+
ids, f = c_interpo_find_loc_1D(xto,xfrom,@@interpo_missval,
|
441
|
+
@@interpo_extrapolation) # [C-extension]
|
357
442
|
idxmap.push( [ m[0], cd, nil, ids, f ] ) # mapping from 1D
|
358
443
|
else
|
359
444
|
# partially 2D case
|
@@ -367,7 +452,8 @@ module NumRu
|
|
367
452
|
break
|
368
453
|
end
|
369
454
|
end
|
370
|
-
ids, f = c_interpo_find_loc_1D_MD(xto,xfrom,dimc
|
455
|
+
ids, f = c_interpo_find_loc_1D_MD(xto,xfrom,dimc,@@interpo_missval,
|
456
|
+
@@interpo_extrapolation) # [C-extension]
|
371
457
|
|
372
458
|
dims_covd = mp[1] #dimensions covered by the coordinate variable(orig)
|
373
459
|
idxmap.push( [ od, cd, dims_covd, ids, f ] ) # mapping from 2D
|
@@ -462,10 +548,14 @@ module NumRu
|
|
462
548
|
for j in 0...coords[ic].length
|
463
549
|
xto = coords[ic][j].val
|
464
550
|
xfrom = org_coords[ic][j].val
|
465
|
-
xto = xto.to_na if !xto.is_a?(NArray)
|
466
|
-
# missing in the coordinate, if any, is ignored
|
467
|
-
xfrom = xfrom.to_na if !xfrom.is_a?(NArray)
|
551
|
+
xto = xto.to_na if !xto.is_a?(NArray)
|
468
552
|
# missing in the coordinate, if any, is ignored
|
553
|
+
if xfrom.is_a?(NArrayMiss)
|
554
|
+
xfrom = xfrom.to_type(NArray::FLOAT).to_na(@@interpo_missval)
|
555
|
+
# if xfrom is NArrayMiss, this fixed missing value is set.
|
556
|
+
# The conversion into double is just in case (not needed for
|
557
|
+
# the default @@interpo_missval).
|
558
|
+
end
|
469
559
|
if org_dims[ic][j].length == 1
|
470
560
|
crdmap1D.push( [ org_dims[ic][j][0], ic, xto,
|
471
561
|
xfrom] )
|
@@ -731,14 +821,15 @@ if $0 == __FILE__
|
|
731
821
|
|
732
822
|
gd.set_assoc_coords([gp,gq,gr,ga])
|
733
823
|
|
734
|
-
print "GPhys with associated coordinates:\n"
|
735
|
-
p gd
|
824
|
+
#print "GPhys with associated coordinates:\n"
|
825
|
+
#p gd
|
736
826
|
|
737
827
|
|
738
828
|
DCL.swpset('iwidth',700)
|
739
829
|
DCL.swpset('iheight',700)
|
740
830
|
#DCL.sgscmn(4) # set colomap
|
741
831
|
DCL.gropn(1)
|
832
|
+
DCL.sgpset('isub', 96) # control character of subscription: '_' --> '`'
|
742
833
|
DCL.glpset("lmiss",true)
|
743
834
|
DCL.sldiv("y",2,2)
|
744
835
|
GGraph::set_fig "viewport"=>[0.15,0.85,0.15,0.85]
|
@@ -746,12 +837,13 @@ if $0 == __FILE__
|
|
746
837
|
GGraph::color_bar
|
747
838
|
GGraph::tone gd[true,ny/2,true]
|
748
839
|
GGraph::color_bar
|
840
|
+
gdd = gd.copy
|
749
841
|
|
750
842
|
#< prepare coordinates to interpolate >
|
751
843
|
|
752
844
|
xi = NArray[1.0, 2.0, 3.0, 4.0, 5.0]
|
753
845
|
# yi = NArray[1.0, 4.0, 5.0]
|
754
|
-
yi = NArray[-0.1,
|
846
|
+
yi = NArray[-0.1,2.5, 4.0, 5.5, 6.8] # test of extrapolation
|
755
847
|
vxi = VArray.new( xi, {"units"=>"m"}, "x") # "0.5m" to test unit conversion
|
756
848
|
vyi = VArray.new( yi, {"units"=>"m"}, "y") # "0.5m" to test unit conversion
|
757
849
|
|
@@ -764,7 +856,7 @@ if $0 == __FILE__
|
|
764
856
|
vpi = VArray.new( pi, {"units"=>"mm"}, "p")
|
765
857
|
vqi = VArray.new( qi, {"units"=>"mm"}, "q")
|
766
858
|
|
767
|
-
ai = NArray[2.0,
|
859
|
+
ai = NArray[2.0, 2.5]
|
768
860
|
vai = VArray.new( ai ).rename("a")
|
769
861
|
|
770
862
|
#< test of interpolate >
|
@@ -774,6 +866,7 @@ if $0 == __FILE__
|
|
774
866
|
gp = GPhys.new(xygrid,vp)
|
775
867
|
gq = GPhys.new(xygrid,vq)
|
776
868
|
|
869
|
+
#GPhys::extrapolation = true
|
777
870
|
gi = gd.interpolate(vxi,vyi,{"z"=>0.5})
|
778
871
|
GGraph::tone gi,true,"color_bar"=>true
|
779
872
|
|
@@ -781,9 +874,9 @@ if $0 == __FILE__
|
|
781
874
|
|
782
875
|
gi = gd.interpolate([vxi,vyi])
|
783
876
|
#p gi.max, gi.min
|
784
|
-
GGraph::tone gd,true,"min"=>-1.2,"max"=>1.2,"int"=>0.1
|
877
|
+
GGraph::tone gd[false,0],true,"min"=>-1.2,"max"=>1.2,"int"=>0.1
|
785
878
|
GGraph::scatter gxi, gyi, false,"type"=>4,"size"=>0.027,"index"=>3
|
786
|
-
GGraph::color_scatter gxi, gyi, gi, false,"min"=>-1.2,"max"=>1.2,"int"=>0.1,"type"=>10,"size"=>0.029
|
879
|
+
GGraph::color_scatter gxi, gyi, gi[true,0], false,"min"=>-1.2,"max"=>1.2,"int"=>0.1,"type"=>10,"size"=>0.029
|
787
880
|
GGraph::color_bar
|
788
881
|
|
789
882
|
gi = gd.interpolate(vyi,vxi)
|
@@ -833,21 +926,52 @@ if $0 == __FILE__
|
|
833
926
|
GGraph::tone gi,true,"color_bar"=>true
|
834
927
|
|
835
928
|
###gd.interpolate(vpi) # must fail by insufficient specification
|
836
|
-
=begin
|
837
|
-
=end
|
838
929
|
|
839
930
|
|
840
931
|
mask=d.lt(0.7)
|
841
932
|
missv = -999.0
|
842
933
|
d[mask.not] = missv
|
843
|
-
p d[false,0]
|
934
|
+
#p d[false,0]
|
844
935
|
dm = NArrayMiss.to_nam(d, mask )
|
845
936
|
vdm = VArray.new( dm, {"missing_value"=>NArray[missv]}, "d")
|
846
937
|
gdm = GPhys.new(xyzgrid, vdm)
|
847
938
|
gi = gdm.interpolate(vpi,vqi)
|
848
939
|
# gi = gdm.interpolate(vxi,vyi)
|
849
940
|
GGraph::tone gi,true,"color_bar"=>true
|
941
|
+
|
942
|
+
print "start the test of coord_data_reverse\n"
|
943
|
+
GGraph::tone gp
|
944
|
+
GGraph::color_bar
|
945
|
+
xp = gp.coord_data_reverse("x",NArray.sfloat(30).indgen! )
|
946
|
+
GGraph::tone xp,true,"title"=>"#{xp.name} <-coord_data_reverse"
|
947
|
+
GGraph::color_bar
|
948
|
+
|
949
|
+
#< test of mouse_cut / dcl_fig_cut >
|
950
|
+
gdc = gdd[1..-1,1..-1,true]
|
951
|
+
|
952
|
+
=begin
|
953
|
+
GGraph.set_fig "itr"=>4
|
954
|
+
GGraph.tone gdc,true,"int"=>0.15,"min"=>-1.05,"max"=>1.05
|
955
|
+
gpcut, line = gdc.mouse_cut(0,1,3)
|
956
|
+
x = gpcut.coord("x")
|
957
|
+
y = gpcut.coord("y")
|
958
|
+
DCL.sgpmzu(x.val,y.val,2,1,0.015)
|
959
|
+
GGraph.set_fig "itr"=>1
|
960
|
+
GGraph.tone gpcut,true,"int"=>0.15,"min"=>-1.05,"max"=>1.05
|
961
|
+
GGraph.color_bar
|
962
|
+
=end
|
850
963
|
|
964
|
+
GGraph.set_fig "itr"=>4
|
965
|
+
GGraph.tone gdc,true,"int"=>0.15,"min"=>-1.05,"max"=>1.05
|
966
|
+
gpcut = gdc.dcl_fig_cut(0,1,[1.0,3.0,6.0],[1.1,2.2,5.5])
|
967
|
+
x = gpcut.coord("x")
|
968
|
+
y = gpcut.coord("y")
|
969
|
+
DCL.sgplu(x.val,y.val)
|
970
|
+
DCL.sgpmzu(x.val,y.val,2,1,0.015)
|
971
|
+
GGraph.set_fig "itr"=>1
|
972
|
+
GGraph.tone gpcut,true,"int"=>0.15,"min"=>-1.05,"max"=>1.05
|
973
|
+
GGraph.color_bar
|
974
|
+
|
851
975
|
|
852
976
|
#< finish >
|
853
977
|
DCL.grcls
|
data/lib/numru/gphys/unumeric.rb
CHANGED
@@ -187,8 +187,8 @@ module NumRu
|
|
187
187
|
new(val, uni)
|
188
188
|
end
|
189
189
|
|
190
|
-
@@supported_calendars = [nil,"gregorian", "standard","
|
191
|
-
"360_day"]
|
190
|
+
@@supported_calendars = [nil,"gregorian", "standard", "proleptic_gregorian",
|
191
|
+
"noleap", "365_day", "360_day"]
|
192
192
|
|
193
193
|
def self::supported_calendar?(cal)
|
194
194
|
@@supported_calendars.include?(cal)
|
@@ -216,6 +216,9 @@ module NumRu
|
|
216
216
|
case calendar
|
217
217
|
when nil, "gregorian", "standard"
|
218
218
|
time = Units['days'].convert( date-since, tun )
|
219
|
+
when "proleptic_gregorian"
|
220
|
+
since = DateTime.parse(UNumeric::before_date_parse($2),false,Date::GREGORIAN)
|
221
|
+
time = Units['days'].convert( date-since, tun )
|
219
222
|
when "noleap", "365_day"
|
220
223
|
since_yday = since - DateTime.new(since.year,1,1) # day number of year (0..364)
|
221
224
|
since_yday = since_yday - 1 if( since.leap? && since.mon > 2 )
|
@@ -224,14 +227,24 @@ module NumRu
|
|
224
227
|
if date_yday >= 60.0 # after Mar1
|
225
228
|
date_yday = date_yday - 1
|
226
229
|
elsif date_yday >= 59.0 # Feb29
|
227
|
-
raise
|
230
|
+
raise("Feb.29 is specified, but calendar is #{calendar}.")
|
228
231
|
end
|
229
232
|
end
|
230
233
|
days = (date.year - since.year)*365 + (date_yday - since_yday)
|
231
234
|
time = Units['days'].convert( days, tun )
|
232
235
|
when "360_day" # does not work perfectly
|
233
|
-
|
234
|
-
|
236
|
+
if date.day == 31
|
237
|
+
raise("day=31 is specified, but calendar is #{calendar}.")
|
238
|
+
end
|
239
|
+
if date.is_a?(DateTime)
|
240
|
+
date_hour,date_min,date_sec = date.hour,date.min,date.sec
|
241
|
+
else
|
242
|
+
date_hour,date_min,date_sec = 0,0,0
|
243
|
+
end
|
244
|
+
days = (date.year-since.year)*360 + (date.mon-since.mon)*30 +
|
245
|
+
(date.day-since.day) + Rational(date_hour-since.hour,24) +
|
246
|
+
Rational(date_min-since.min,1440) + Rational(date_sec-since.sec,86400)
|
247
|
+
time = Units['days'].convert( days.to_f, tun )
|
235
248
|
else
|
236
249
|
#raise("Unrecognized calendar: #{calendar}")
|
237
250
|
return nil
|
@@ -313,6 +326,11 @@ module NumRu
|
|
313
326
|
elsif( tun =~ Units['days since 0001-01-01'] )
|
314
327
|
case calendar
|
315
328
|
when nil, "gregorian", "standard"
|
329
|
+
# default: Julian calendar before 1582-10-15, Gregorian calendar afterward
|
330
|
+
datetime = since + tun.convert( time, Units['days'] )
|
331
|
+
when "proleptic_gregorian"
|
332
|
+
# Gregorian calendar extended to the past
|
333
|
+
since = DateTime.parse(UNumeric::before_date_parse(sincestr),false,Date::GREGORIAN)
|
316
334
|
datetime = since + tun.convert( time, Units['days'] )
|
317
335
|
when "noleap", "365_day"
|
318
336
|
since_yday = since - DateTime.new(since.year,1,1) # day number of year (0..364)
|
@@ -327,7 +345,12 @@ module NumRu
|
|
327
345
|
days = (since.mon-1)*30 + since_day + tun.convert( time, Units['days'] )
|
328
346
|
year = since.year + (days/360).to_i
|
329
347
|
mon = ((days%360)/30).to_i + 1
|
330
|
-
datetime = DateTime.new(year,mon,1) + days%30
|
348
|
+
datetime = DateTime.new(year,mon,1) + days%30 # Feb29->Mar1,Feb30->Mar2
|
349
|
+
#datetime = DateTime.new(year,mon,days%30 + 1) # stops if Feb29,Feb30
|
350
|
+
if datetime.mon != mon # Feb29,Feb30
|
351
|
+
$stderr.print("cannot convert #{year}-#{mon}-#{(days%30+1).to_i} to DateTime instance\n")
|
352
|
+
return nil
|
353
|
+
end
|
331
354
|
else
|
332
355
|
#raise("Unrecognized calendar: #{calendar}")
|
333
356
|
return nil
|
data/lib/numru/gphys/varray.rb
CHANGED
@@ -987,6 +987,15 @@ These methods returns a NArray (not a VArray).
|
|
987
987
|
|
988
988
|
alias shape_current shape
|
989
989
|
|
990
|
+
## < marshal dump/load >
|
991
|
+
def marshal_dump
|
992
|
+
[@name, @mapping, @varray, @ary, @attr]
|
993
|
+
end
|
994
|
+
|
995
|
+
def marshal_load(ary)
|
996
|
+
@name, @mapping, @varray, @ary, @attr = *ary
|
997
|
+
end
|
998
|
+
|
990
999
|
## < private methods >
|
991
1000
|
private
|
992
1001
|
def __rubber_expansion( args )
|
@@ -4,6 +4,14 @@
|
|
4
4
|
=end
|
5
5
|
|
6
6
|
require "numru/gphys/grib"
|
7
|
+
|
8
|
+
### to be made below in the definition of VArrayGrib in order to record
|
9
|
+
### whetehr its successfull or not
|
10
|
+
#begin
|
11
|
+
# require "numru/grib"
|
12
|
+
#rescue LoadError
|
13
|
+
#end
|
14
|
+
|
7
15
|
require "numru/gphys/varray"
|
8
16
|
|
9
17
|
module NumRu
|
@@ -16,8 +24,50 @@ module NumRu
|
|
16
24
|
=end
|
17
25
|
class VArrayGrib < VArray
|
18
26
|
|
27
|
+
begin
|
28
|
+
require "numru/grib"
|
29
|
+
@@rbgribloaded = true
|
30
|
+
rescue LoadError
|
31
|
+
@@rbgribloaded = false
|
32
|
+
end
|
33
|
+
|
34
|
+
@@GribLib = :gphys_grib
|
35
|
+
|
36
|
+
class << self
|
37
|
+
def use_gphys_grib
|
38
|
+
@@GribLib = :gphys_grib
|
39
|
+
set_grib_lib
|
40
|
+
end
|
41
|
+
def use_rb_grib
|
42
|
+
if !@@rbgribloaded
|
43
|
+
raise LoadError, "Loading rb-GRIB has been failed. You probably need to install it."
|
44
|
+
end
|
45
|
+
@@GribLib = :rb_grib
|
46
|
+
set_grib_lib
|
47
|
+
end
|
48
|
+
def grib_lib
|
49
|
+
@@GribLib.dup
|
50
|
+
end
|
51
|
+
def grib
|
52
|
+
@@Grib
|
53
|
+
end
|
54
|
+
def set_grib_lib
|
55
|
+
case @@GribLib
|
56
|
+
when :gphys_grib
|
57
|
+
@@GribDim = GPhys::GribDim
|
58
|
+
@@GribVar = GPhys::GribVar
|
59
|
+
@@Grib = GPhys::Grib
|
60
|
+
when :rb_grib
|
61
|
+
@@GribDim = GribDim
|
62
|
+
@@GribVar = GribVar
|
63
|
+
@@Grib = Grib
|
64
|
+
end
|
65
|
+
end
|
66
|
+
end
|
67
|
+
set_grib_lib
|
68
|
+
|
19
69
|
def initialize(aGribVar)
|
20
|
-
if
|
70
|
+
if !@@GribVar===aGribVar && !@@GribDim===aGribVar
|
21
71
|
raise ArgumentError,"Not a GribVar or GribDim"
|
22
72
|
end
|
23
73
|
@name = aGribVar.name
|
@@ -26,9 +76,11 @@ module NumRu
|
|
26
76
|
@ary = aGribVar
|
27
77
|
@attr = Attribute.new
|
28
78
|
aGribVar.att_names.each{|name|
|
29
|
-
|
79
|
+
val = aGribVar.att(name)
|
80
|
+
val = [val] if val.is_a?(Numeric)
|
81
|
+
@attr[name] = val
|
30
82
|
}
|
31
|
-
if GribDim===@ary
|
83
|
+
if @@GribDim===@ary
|
32
84
|
class << @ary
|
33
85
|
def rank
|
34
86
|
return 1
|
@@ -41,9 +93,9 @@ module NumRu
|
|
41
93
|
end
|
42
94
|
|
43
95
|
def inspect
|
44
|
-
if GribVar===@ary
|
96
|
+
if @@GribVar===@ary
|
45
97
|
"<'#{@name}' in '#{@ary.file.path}' [#{@ary.shape.join(", ")}]>"
|
46
|
-
elsif GribDim===@ary
|
98
|
+
elsif @@GribDim===@ary
|
47
99
|
"<'#{@name}' in '#{@ary.var.name}' #{@ary.length}>"
|
48
100
|
end
|
49
101
|
end
|
@@ -55,7 +107,7 @@ module NumRu
|
|
55
107
|
v = file.def_var(name)
|
56
108
|
dims.length.times{|n|
|
57
109
|
d = dims[n]
|
58
|
-
if GribDim===d
|
110
|
+
if @@GribDim===d
|
59
111
|
gd = v.def_dim(d.name,n)
|
60
112
|
gd.put(d.get)
|
61
113
|
d.att_names.each{|name| gd.put_att(name,d.att(name)) }
|
@@ -80,7 +132,7 @@ module NumRu
|
|
80
132
|
## < additional class methods > ##
|
81
133
|
|
82
134
|
def write(file,vary,dims=nil)
|
83
|
-
Grib===file || raise(ArgumentError,"1st arg: not a Grib")
|
135
|
+
@@Grib===file || raise(ArgumentError,"1st arg: not a Grib")
|
84
136
|
VArray===vary || raise(ArgumentError,"2st arg: not a VArray")
|
85
137
|
rank = vary.rank
|
86
138
|
if !dims
|
@@ -157,7 +209,7 @@ if $0 == __FILE__
|
|
157
209
|
|
158
210
|
include NumRu
|
159
211
|
|
160
|
-
grib =
|
212
|
+
grib = VArrayGrib.grib.open("../../../testdata/T.jan.grib")
|
161
213
|
gv = grib.var("TMP")
|
162
214
|
|
163
215
|
va = VArrayGrib.new(gv)
|
@@ -174,4 +226,14 @@ if $0 == __FILE__
|
|
174
226
|
p va2.shape
|
175
227
|
p va2.val
|
176
228
|
|
229
|
+
begin
|
230
|
+
VArrayGrib.use_rb_grib
|
231
|
+
grib = VArrayGrib.grib.open("../../../testdata/T.jan.grib")
|
232
|
+
p grib.var_names
|
233
|
+
gv = grib.var("t")
|
234
|
+
p gv.val
|
235
|
+
rescue LoadError
|
236
|
+
print "...error rescued & test skipped\n\n"
|
237
|
+
end
|
238
|
+
|
177
239
|
end
|
data/lib/version.rb
ADDED