gphys 1.1.1a
Sign up to get free protection for your applications and to get access to all the features.
- data/ChangeLog +1777 -0
- data/LICENSE.txt +34 -0
- data/README +33 -0
- data/Rakefile +57 -0
- data/TODO_ep_flux +6 -0
- data/bin/gdir_client +27 -0
- data/bin/gdir_server +129 -0
- data/bin/gpaop +146 -0
- data/bin/gpcat +148 -0
- data/bin/gpcut +102 -0
- data/bin/gpedit +228 -0
- data/bin/gplist +68 -0
- data/bin/gpmath +120 -0
- data/bin/gpmaxmin +128 -0
- data/bin/gpprint +60 -0
- data/bin/gpvect +706 -0
- data/bin/gpview +704 -0
- data/bin/grads2nc_with_gphys +61 -0
- data/doc/attribute.html +19 -0
- data/doc/attributenetcdf.html +15 -0
- data/doc/axis.html +376 -0
- data/doc/coordmapping.html +111 -0
- data/doc/coordtransform.html +36 -0
- data/doc/derivative/gphys-derivative.html +80 -0
- data/doc/derivative/index.html +21 -0
- data/doc/derivative/index.rd +14 -0
- data/doc/derivative/math-doc/document/document.css +30 -0
- data/doc/derivative/math-doc/document/document.html +57 -0
- data/doc/derivative/math-doc/document/images.aux +1 -0
- data/doc/derivative/math-doc/document/images.log +385 -0
- data/doc/derivative/math-doc/document/images.pl +186 -0
- data/doc/derivative/math-doc/document/images.tex +364 -0
- 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 +57 -0
- data/doc/derivative/math-doc/document/labels.pl +13 -0
- 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 +238 -0
- data/doc/derivative/math-doc/document/node2.html +75 -0
- 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 +158 -0
- data/doc/derivative/numru-derivative.html +129 -0
- data/doc/ep_flux/ep_flux.html +469 -0
- data/doc/ep_flux/ggraph_on_merdional_section.html +71 -0
- data/doc/ep_flux/index.html +31 -0
- data/doc/ep_flux/index.rd +24 -0
- data/doc/ep_flux/math-doc/document/WARNINGS +1 -0
- 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 +30 -0
- data/doc/ep_flux/math-doc/document/document.html +101 -0
- data/doc/ep_flux/math-doc/document/images.aux +1 -0
- data/doc/ep_flux/math-doc/document/images.log +1375 -0
- data/doc/ep_flux/math-doc/document/images.pl +1328 -0
- data/doc/ep_flux/math-doc/document/images.tex +1471 -0
- 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 +101 -0
- data/doc/ep_flux/math-doc/document/internals.pl +258 -0
- data/doc/ep_flux/math-doc/document/labels.pl +265 -0
- 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 +104 -0
- data/doc/ep_flux/math-doc/document/node10.html +164 -0
- data/doc/ep_flux/math-doc/document/node11.html +86 -0
- data/doc/ep_flux/math-doc/document/node12.html +166 -0
- data/doc/ep_flux/math-doc/document/node13.html +897 -0
- data/doc/ep_flux/math-doc/document/node14.html +1065 -0
- data/doc/ep_flux/math-doc/document/node15.html +72 -0
- data/doc/ep_flux/math-doc/document/node16.html +81 -0
- data/doc/ep_flux/math-doc/document/node2.html +82 -0
- data/doc/ep_flux/math-doc/document/node3.html +91 -0
- data/doc/ep_flux/math-doc/document/node4.html +149 -0
- data/doc/ep_flux/math-doc/document/node5.html +330 -0
- data/doc/ep_flux/math-doc/document/node6.html +99 -0
- data/doc/ep_flux/math-doc/document/node7.html +98 -0
- data/doc/ep_flux/math-doc/document/node8.html +83 -0
- data/doc/ep_flux/math-doc/document/node9.html +140 -0
- 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 +2018 -0
- data/doc/gdir.html +412 -0
- data/doc/gdir_client.html +16 -0
- data/doc/gdir_connect_ftp-like.html +61 -0
- data/doc/gdir_server.html +45 -0
- data/doc/ggraph.html +1615 -0
- data/doc/gpcat.html +44 -0
- data/doc/gpcut.html +41 -0
- data/doc/gphys.html +532 -0
- data/doc/gphys_fft.html +324 -0
- data/doc/gphys_grads_io.html +69 -0
- data/doc/gphys_grib_io.html +82 -0
- data/doc/gphys_io.html +120 -0
- data/doc/gphys_io_common.html +18 -0
- data/doc/gphys_netcdf_io.html +283 -0
- data/doc/gplist.html +24 -0
- data/doc/gpmath.html +51 -0
- data/doc/gpmaxmin.html +31 -0
- data/doc/gpprint.html +34 -0
- data/doc/gpview.html +270 -0
- data/doc/grads2nc_with_gphys.html +21 -0
- data/doc/grads_gridded.html +307 -0
- data/doc/grib.html +144 -0
- data/doc/grid.html +212 -0
- data/doc/index.html +133 -0
- data/doc/index.rd +127 -0
- data/doc/netcdf_convention.html +136 -0
- data/doc/unumeric.html +176 -0
- data/doc/update +64 -0
- data/doc/varray.html +299 -0
- data/doc/varraycomposite.html +67 -0
- data/ext_coord.c +209 -0
- data/ext_init.c +7 -0
- data/extconf.rb +42 -0
- data/install.rb +130 -0
- data/interpo.c +497 -0
- data/lib/numru/dcl_mouse.rb +71 -0
- data/lib/numru/dclext_datetime_ax.rb +220 -0
- data/lib/numru/derivative.rb +348 -0
- data/lib/numru/ganalysis/covariance.rb +154 -0
- data/lib/numru/ganalysis/eof.rb +298 -0
- data/lib/numru/ganalysis/histogram.rb +252 -0
- data/lib/numru/ganalysis/met.rb +317 -0
- data/lib/numru/ganalysis/planet.rb +182 -0
- data/lib/numru/ganalysis.rb +7 -0
- data/lib/numru/gdir.rb +1038 -0
- data/lib/numru/gdir_connect_ftp-like.rb +149 -0
- data/lib/numru/ggraph.rb +5838 -0
- data/lib/numru/ggraph_on_merdional_section.rb +178 -0
- data/lib/numru/gphys/assoccoords.rb +359 -0
- data/lib/numru/gphys/attribute.rb +129 -0
- data/lib/numru/gphys/attributenetcdf.rb +80 -0
- data/lib/numru/gphys/axis.rb +963 -0
- data/lib/numru/gphys/coordmapping.rb +286 -0
- data/lib/numru/gphys/coordtransform.rb +209 -0
- data/lib/numru/gphys/derivative.rb +314 -0
- data/lib/numru/gphys/ep_flux.rb +868 -0
- data/lib/numru/gphys/gpcommon.rb +52 -0
- data/lib/numru/gphys/gphys.rb +1207 -0
- data/lib/numru/gphys/gphys_fft.rb +886 -0
- data/lib/numru/gphys/gphys_grads_io.rb +212 -0
- data/lib/numru/gphys/gphys_grib_io.rb +214 -0
- data/lib/numru/gphys/gphys_gtool3_io.rb +162 -0
- data/lib/numru/gphys/gphys_hdfeos5_io.rb +672 -0
- data/lib/numru/gphys/gphys_io.rb +452 -0
- data/lib/numru/gphys/gphys_io_common.rb +126 -0
- data/lib/numru/gphys/gphys_netcdf_io.rb +800 -0
- data/lib/numru/gphys/gphys_nusdas_io.rb +132 -0
- data/lib/numru/gphys/grads_gridded.rb +1638 -0
- data/lib/numru/gphys/grib.rb +2049 -0
- data/lib/numru/gphys/grib_params.rb +1465 -0
- data/lib/numru/gphys/grid.rb +723 -0
- data/lib/numru/gphys/gtool3.rb +771 -0
- data/lib/numru/gphys/interpolate.rb +854 -0
- data/lib/numru/gphys/narray_ext.rb +34 -0
- data/lib/numru/gphys/netcdf_convention.rb +406 -0
- data/lib/numru/gphys/subsetmapping.rb +332 -0
- data/lib/numru/gphys/unumeric.rb +522 -0
- data/lib/numru/gphys/varray.rb +1109 -0
- data/lib/numru/gphys/varraycomposite.rb +415 -0
- data/lib/numru/gphys/varraygrads.rb +225 -0
- data/lib/numru/gphys/varraygrib.rb +177 -0
- data/lib/numru/gphys/varraygtool3.rb +226 -0
- data/lib/numru/gphys/varrayhdfeos5.rb +451 -0
- data/lib/numru/gphys/varraynetcdf.rb +350 -0
- data/lib/numru/gphys/varraynusdas.rb +59 -0
- data/lib/numru/gphys.rb +9 -0
- data/lib/numru/htdir.rb +170 -0
- data/multibitIO.c +567 -0
- data/sample/cira86_to_nc.rb +122 -0
- data/sample/druby_cli1.rb +21 -0
- data/sample/druby_cli2.rb +34 -0
- data/sample/druby_serv1.rb +30 -0
- data/sample/druby_serv2.rb +64 -0
- data/sample/ep_flux/demo_NCEP_1.rb +48 -0
- data/sample/ep_flux/demo_NCEP_2.rb +57 -0
- data/sample/ep_flux/demo_NCEP_3.rb +81 -0
- data/sample/ggraph_latlon_labelling_dr002690.rb +159 -0
- data/sample/ggraph_mapfit-axes_dr002687.rb +131 -0
- data/sample/map_projection.rb +121 -0
- data/sample/ncep_theta_coord.rb +79 -0
- data/test/eof_slp.rb +28 -0
- data/test/mltbit.dat +0 -0
- data/test/test_ep_flux.rb +533 -0
- data/test/test_multibitIO.rb +19 -0
- data/testdata/T.jan.ctl +12 -0
- data/testdata/T.jan.dat +0 -0
- data/testdata/T.jan.grib +0 -0
- data/testdata/T.jan.nc +0 -0
- data/testdata/T.jan.packed.withmiss.nc +0 -0
- data/testdata/UV.jan.nc +0 -0
- data/testdata/assoc_crds.nc +0 -0
- data/testdata/cira86.dat +1332 -0
- metadata +621 -0
@@ -0,0 +1,723 @@
|
|
1
|
+
require "numru/gphys/axis"
|
2
|
+
require "numru/gphys/assoccoords"
|
3
|
+
|
4
|
+
=begin
|
5
|
+
=class NumRU::Grid
|
6
|
+
|
7
|
+
A class to handle discretized grids of physical quantities.
|
8
|
+
|
9
|
+
==Class Methods
|
10
|
+
---Grid.new( *axes )
|
11
|
+
Constructor.
|
12
|
+
|
13
|
+
RETURN VALUE
|
14
|
+
* a Grid
|
15
|
+
|
16
|
+
==Instance Methods
|
17
|
+
---axnames
|
18
|
+
Returns the names of the axes
|
19
|
+
|
20
|
+
RETURN VALUE
|
21
|
+
* an Array of String
|
22
|
+
|
23
|
+
---lost_axes
|
24
|
+
Returns info on axes eliminated during operations.
|
25
|
+
|
26
|
+
Useful for annotation in plots, for example (See the code of GGraph
|
27
|
+
for an application).
|
28
|
+
|
29
|
+
RETURN VALUE
|
30
|
+
* an Array of String
|
31
|
+
|
32
|
+
---axis(dim_or_dimname)
|
33
|
+
Returns an Axis
|
34
|
+
|
35
|
+
ARGUMENTS
|
36
|
+
* dim_or_dimname (String or Integer) to specify an axis.
|
37
|
+
|
38
|
+
RETURN VALUE
|
39
|
+
* an Axis
|
40
|
+
|
41
|
+
---dim_index(dimname)
|
42
|
+
Returns the integer id (count from zero) of the dimension
|
43
|
+
|
44
|
+
ARGUMENT
|
45
|
+
* dimname (String or Integer) : this method is trivial if is is an integer
|
46
|
+
|
47
|
+
RETURN VALUE
|
48
|
+
* an Integer
|
49
|
+
|
50
|
+
---coord_dim_indices(coordname)
|
51
|
+
Coordinate name --> dimension indices.
|
52
|
+
|
53
|
+
ARGUMENT
|
54
|
+
* coordname (String) : Name of a coordinate
|
55
|
+
|
56
|
+
RETURN VALUE
|
57
|
+
* Array of Integer or nil --
|
58
|
+
If the coordinate is present it is an Array
|
59
|
+
containing dimension indices (If the coordinate is 1D,
|
60
|
+
the lengthof the array is 1.)
|
61
|
+
|
62
|
+
---set_axis(dim_or_dimname,ax)
|
63
|
+
|
64
|
+
Sets an axis.
|
65
|
+
|
66
|
+
ARGUMENTS
|
67
|
+
* dim_or_dimname (String or Integer) to specify an axis.
|
68
|
+
* ax (Axis) the axis
|
69
|
+
|
70
|
+
RETURN VALUE
|
71
|
+
* self
|
72
|
+
|
73
|
+
---set_lost_axes( lost )
|
74
|
+
|
75
|
+
Sets info on axes eliminated.
|
76
|
+
|
77
|
+
RETURN VALUE
|
78
|
+
* self
|
79
|
+
|
80
|
+
---add_lost_axes( lost )
|
81
|
+
|
82
|
+
Adds info on axes eliminated to existing ones.
|
83
|
+
|
84
|
+
RETURN VALUE
|
85
|
+
* self
|
86
|
+
|
87
|
+
---delete_axes( at, deleted_by=nil )
|
88
|
+
|
89
|
+
Delete an axis.
|
90
|
+
|
91
|
+
ARGUMENTS
|
92
|
+
* at (String or Integer) to specify an axis.
|
93
|
+
* deleted_by (String or nil) if non-nil, it is written in
|
94
|
+
the internal lost-axis info. Best if you put the name of the
|
95
|
+
method, in which this method is called.
|
96
|
+
|
97
|
+
RETURN VALUE
|
98
|
+
* a Grid
|
99
|
+
|
100
|
+
---copy
|
101
|
+
Makes a deep clone onto memory.
|
102
|
+
|
103
|
+
RETURN VALUE
|
104
|
+
* a Grid
|
105
|
+
|
106
|
+
---merge(other)
|
107
|
+
merge two grids by basically using copies of self's axes but
|
108
|
+
using the other's if the length in self is 1 and
|
109
|
+
the length in the other is longer
|
110
|
+
|
111
|
+
ARGUMENTS
|
112
|
+
* other (Grid)
|
113
|
+
|
114
|
+
RETURN VALUE
|
115
|
+
* a Grid
|
116
|
+
|
117
|
+
---shape
|
118
|
+
Returns the shape of self.
|
119
|
+
|
120
|
+
RETURN VALUE
|
121
|
+
* an Array of Integer
|
122
|
+
|
123
|
+
---[] (*slicer)
|
124
|
+
Returns a subset.
|
125
|
+
|
126
|
+
ARGUMENTS
|
127
|
+
* Same as those for NArray#[], NetCDFVar#[], etc.
|
128
|
+
|
129
|
+
RETURN VALUE
|
130
|
+
* a Grid
|
131
|
+
|
132
|
+
---cut(*args)
|
133
|
+
Similar to ((<[]>)), but the subset is specified by physical coordinate.
|
134
|
+
|
135
|
+
ARGUMENTS
|
136
|
+
* pattern 1: similar to those for ((<[]>)), where the first
|
137
|
+
argument specifies a subset for the first dimension.
|
138
|
+
* pattern 2: by a Hash, in which keys are axis names.
|
139
|
+
|
140
|
+
EXAMPLES
|
141
|
+
* Pattern 1
|
142
|
+
gphys.cut(135.5,0..20.5,false)
|
143
|
+
* Pattern 2
|
144
|
+
gphys.cut({'lon'=>135.5,'lat'=>0..20})
|
145
|
+
|
146
|
+
RETURN VALUE
|
147
|
+
* an Array : [a Grid, slicer], where slicer is an array
|
148
|
+
to be used to make a subset of an corresponding varray
|
149
|
+
(to be used in GPhys#cut).
|
150
|
+
|
151
|
+
---cut_rank_conserving(*args)
|
152
|
+
Similar to ((<cut>)), but the rank is conserved by not eliminating
|
153
|
+
any dimension (whose length could be one).
|
154
|
+
|
155
|
+
---cut_assoccoord(hasharg)
|
156
|
+
Cut with respect to the asscoated coordinates. Similar to cut,
|
157
|
+
when the argeuemnt is a Hash, but hash keys are the names of the
|
158
|
+
asscoated coordinates.
|
159
|
+
|
160
|
+
#---exclude(dim_or_dimname)
|
161
|
+
# Returns a Grid in which an axis is eliminated from self.
|
162
|
+
#
|
163
|
+
# ARGUMENTS
|
164
|
+
# * dim_or_dimname (String or Integer) to specify an axis.
|
165
|
+
#
|
166
|
+
# RETURN VALUE
|
167
|
+
# * a Grid
|
168
|
+
#
|
169
|
+
---change_axis(dim, axis)
|
170
|
+
Replaces an axis. (Returns a new object)
|
171
|
+
|
172
|
+
ARGUMENTS
|
173
|
+
* dim_or_dimname (String or Integer) to specify an axis.
|
174
|
+
* axis (Axis)
|
175
|
+
|
176
|
+
RETURN VALUE
|
177
|
+
* a Grid
|
178
|
+
#
|
179
|
+
#---change_axis!(dim_or_dimname, axis)
|
180
|
+
# Replaces an axis. (overwrites self)
|
181
|
+
#
|
182
|
+
# ARGUMENTS
|
183
|
+
# * dim_or_dimname (String or Integer) to specify an axis.
|
184
|
+
# * axis (Axis)
|
185
|
+
#
|
186
|
+
# RETURN VALUE
|
187
|
+
# * self
|
188
|
+
#
|
189
|
+
#---insert_axis(dim_or_dimname, axis)
|
190
|
+
# Inserts an axis. (Returns a new object)
|
191
|
+
#
|
192
|
+
# ARGUMENTS
|
193
|
+
# * dim_or_dimname (String or Integer) to specify an axis.
|
194
|
+
# * axis (Axis)
|
195
|
+
#
|
196
|
+
# RETURN VALUE
|
197
|
+
# * a Grid
|
198
|
+
#
|
199
|
+
#---insert_axis!(dim_or_dimname, axis)
|
200
|
+
# Inserts an axis. (overwrites self)
|
201
|
+
#
|
202
|
+
# ARGUMENTS
|
203
|
+
# * dim_or_dimname (String or Integer) to specify an axis.
|
204
|
+
# * axis (Axis)
|
205
|
+
#
|
206
|
+
# RETURN VALUE
|
207
|
+
# * self
|
208
|
+
|
209
|
+
---transpose( *dims )
|
210
|
+
Transpose.
|
211
|
+
|
212
|
+
ARGUMENTS
|
213
|
+
* dims (integers) : for example, [1,0] to transpose a 2D object.
|
214
|
+
For 3D objects, [1,0,2], [2,1,0], etc.etc.
|
215
|
+
|
216
|
+
RETURN VALUE
|
217
|
+
* a Grid
|
218
|
+
|
219
|
+
=end
|
220
|
+
|
221
|
+
module NumRu
|
222
|
+
|
223
|
+
class Grid
|
224
|
+
|
225
|
+
def initialize( *axes )
|
226
|
+
@axes = Array.new
|
227
|
+
axes.each{|ag|
|
228
|
+
if ag.is_a?(Axis)
|
229
|
+
@axes.push(ag)
|
230
|
+
else
|
231
|
+
raise ArgumentError, "each argument must be an Axis"
|
232
|
+
end
|
233
|
+
}
|
234
|
+
@lost_axes = Array.new # Array of String
|
235
|
+
@rank = @axes.length
|
236
|
+
@axnames = Array.new
|
237
|
+
__check_and_set_axnames
|
238
|
+
@assoc_coords = nil
|
239
|
+
end
|
240
|
+
|
241
|
+
# * assoc_crds : an Array of GPhys
|
242
|
+
#
|
243
|
+
def set_assoc_coords(assoc_crds)
|
244
|
+
@assoc_coords = AssocCoords.new(assoc_crds, @axnames)
|
245
|
+
@assoc_coords.axlens.each do |nm,l|
|
246
|
+
if l && l != (l0 = shape[dim_index(nm)])
|
247
|
+
raise ArgumentError, "Length mismatch in coord #{nm} (#{l0}) and assoc_crds (#{l}). You may need to regrid (use GPhys#regrid method) associated coordinate(s) in advance."
|
248
|
+
end
|
249
|
+
end
|
250
|
+
self
|
251
|
+
end
|
252
|
+
|
253
|
+
# * assoc_coords : an AssocCoords
|
254
|
+
#
|
255
|
+
def assoc_coords=(assoc_coords)
|
256
|
+
@assoc_coords = assoc_coords
|
257
|
+
end
|
258
|
+
|
259
|
+
def assoc_coords
|
260
|
+
@assoc_coords
|
261
|
+
end
|
262
|
+
|
263
|
+
def inspect
|
264
|
+
"<#{rank}D grid #{@axes.collect{|ax| ax.inspect}.join("\n\t")}#{@assoc_coords ? "\n"+@assoc_coords.inspect.gsub(/^/,"\t") : ''}>"
|
265
|
+
end
|
266
|
+
|
267
|
+
def __check_and_set_axnames
|
268
|
+
@axnames.clear
|
269
|
+
@axes.each{|ax|
|
270
|
+
nm=ax.name
|
271
|
+
if @axnames.include?(nm)
|
272
|
+
raise "Two or more axes share a name: #{nm}"
|
273
|
+
end
|
274
|
+
@axnames.push(nm)
|
275
|
+
}
|
276
|
+
end
|
277
|
+
private :__check_and_set_axnames
|
278
|
+
|
279
|
+
attr_reader :rank
|
280
|
+
|
281
|
+
def axnames
|
282
|
+
@axnames.dup
|
283
|
+
end
|
284
|
+
def lost_axes
|
285
|
+
@lost_axes.dup
|
286
|
+
end
|
287
|
+
|
288
|
+
def coordnames
|
289
|
+
ret = axnames
|
290
|
+
ret.concat(@assoc_coords.coordnames) if @assoc_coords
|
291
|
+
ret
|
292
|
+
end
|
293
|
+
|
294
|
+
def has_axis?(name)
|
295
|
+
@axnames.include?(name)
|
296
|
+
end
|
297
|
+
|
298
|
+
def has_assoccoord?(*arg)
|
299
|
+
if arg.length == 0
|
300
|
+
!@assoc_coords.nil? # if a grid has assoc coords
|
301
|
+
else
|
302
|
+
name = arg[0]
|
303
|
+
if @assoc_coords
|
304
|
+
@assoc_coords.has_coord?(name)
|
305
|
+
else
|
306
|
+
false
|
307
|
+
end
|
308
|
+
end
|
309
|
+
end
|
310
|
+
|
311
|
+
def has_coord?(name)
|
312
|
+
has_axis?(name) || has_assoccoord?(name)
|
313
|
+
end
|
314
|
+
|
315
|
+
def assoccoordnames
|
316
|
+
@assoc_coords && @assoc_coords.coordnames
|
317
|
+
end
|
318
|
+
|
319
|
+
# def axis(i)
|
320
|
+
# @axes[i]
|
321
|
+
# end
|
322
|
+
|
323
|
+
def axis(dim_or_dimname)
|
324
|
+
ax_dim(dim_or_dimname)[0]
|
325
|
+
end
|
326
|
+
|
327
|
+
alias get_axis axis
|
328
|
+
|
329
|
+
def coord(i)
|
330
|
+
if @assoc_coords && i.is_a?(String) && @assoc_coords.has_coord?(i)
|
331
|
+
@assoc_coords.coord(i)
|
332
|
+
else
|
333
|
+
axis(i).pos
|
334
|
+
end
|
335
|
+
end
|
336
|
+
|
337
|
+
def assoc_coord_gphys(name)
|
338
|
+
@assoc_coords && @assoc_coords.coord_gphys(name)
|
339
|
+
end
|
340
|
+
|
341
|
+
def dim_index(dimname)
|
342
|
+
ax_dim(dimname)[1]
|
343
|
+
end
|
344
|
+
|
345
|
+
def coord_dim_indices(coordname)
|
346
|
+
dim = @axnames.index(coordname)
|
347
|
+
if dim
|
348
|
+
[dim]
|
349
|
+
elsif @assoc_coords && @assoc_coords.has_coord?(coordname)
|
350
|
+
axnms = @assoc_coords.coord_gphys(coordname).axnames
|
351
|
+
axnms.collect{|nm| @axnames.index(nm)}
|
352
|
+
else
|
353
|
+
nil
|
354
|
+
end
|
355
|
+
end
|
356
|
+
|
357
|
+
def set_axis(dim_or_dimname,ax)
|
358
|
+
@axes[ i = dim_index(dim_or_dimname) ] = ax
|
359
|
+
@axnames[ i ] = ax.name
|
360
|
+
self
|
361
|
+
end
|
362
|
+
|
363
|
+
def set_lost_axes( lost )
|
364
|
+
@lost_axes = lost # Array of String
|
365
|
+
self
|
366
|
+
end
|
367
|
+
def add_lost_axes( lost )
|
368
|
+
@lost_axes = @lost_axes + lost # Array of String
|
369
|
+
self
|
370
|
+
end
|
371
|
+
|
372
|
+
def delete_axes( at, deleted_by=nil )
|
373
|
+
case at
|
374
|
+
when String
|
375
|
+
at = [dim_index(at)]
|
376
|
+
when Numeric
|
377
|
+
at = [at]
|
378
|
+
when Array
|
379
|
+
at = at.collect{|x|
|
380
|
+
case x
|
381
|
+
when String
|
382
|
+
dim_index(x)
|
383
|
+
when Integer
|
384
|
+
x
|
385
|
+
else
|
386
|
+
raise ArgumentError,"'at' must consist of Integer and/or String"
|
387
|
+
end
|
388
|
+
}
|
389
|
+
else
|
390
|
+
raise TypeError, "1st arg not an Array"
|
391
|
+
end
|
392
|
+
|
393
|
+
at.collect!{|pos|
|
394
|
+
if pos < 0
|
395
|
+
pos + a.length
|
396
|
+
else
|
397
|
+
pos
|
398
|
+
end
|
399
|
+
}
|
400
|
+
at.sort!
|
401
|
+
newaxes = @axes.dup
|
402
|
+
at.reverse.each{|pos|
|
403
|
+
del = newaxes.delete_at(pos)
|
404
|
+
if !del
|
405
|
+
raise ArgumentError, "dimension #{pos} does not exist in a #{rank}D Grid"
|
406
|
+
end
|
407
|
+
}
|
408
|
+
|
409
|
+
newgrid = self.class.new( *newaxes )
|
410
|
+
newgrid.set_lost_axes( @lost_axes.dup )
|
411
|
+
if @assoc_coords
|
412
|
+
newgrid.assoc_coords=@assoc_coords.subset_having_axnames(newgrid.axnames)
|
413
|
+
end
|
414
|
+
|
415
|
+
if !deleted_by
|
416
|
+
msg = '(deleted) '
|
417
|
+
else
|
418
|
+
raise TypeError, "2nd arg not a String" if !deleted_by.is_a?(String)
|
419
|
+
msg = '('+deleted_by+') '
|
420
|
+
end
|
421
|
+
lost = at.collect{|pos|
|
422
|
+
mn = sprintf("%g", ( UNumeric===(a=@axes[pos].pos.min) ? a.val : a) )
|
423
|
+
mx = sprintf("%g", ( UNumeric===(a=@axes[pos].pos.max) ? a.val : a) )
|
424
|
+
msg +
|
425
|
+
"#{@axes[pos].name}:#{mn}..#{mx}"
|
426
|
+
}
|
427
|
+
|
428
|
+
newgrid.add_lost_axes( lost )
|
429
|
+
newgrid
|
430
|
+
end
|
431
|
+
|
432
|
+
def copy
|
433
|
+
# deep clone onto memory
|
434
|
+
out = self.class.new( *@axes.collect{|ax| ax.copy} )
|
435
|
+
out.set_lost_axes( @lost_axes.dup )
|
436
|
+
out.assoc_coords = @assoc_coords.copy if @assoc_coords
|
437
|
+
out
|
438
|
+
end
|
439
|
+
|
440
|
+
def merge(other)
|
441
|
+
# merge two grids by basically using copies of self's axes but
|
442
|
+
# using the other's if the length in self is 1 and
|
443
|
+
# the length in the other is longer
|
444
|
+
if self.rank != other.rank
|
445
|
+
raise "ranks do not agree (self:#{self.rank} vs other:#{other.rank})"
|
446
|
+
end
|
447
|
+
axes = Array.new
|
448
|
+
for i in 0...self.rank
|
449
|
+
if @axes[i].length == 1 and other.axis(i).length > 1
|
450
|
+
axes[i] = other.axis(i)
|
451
|
+
else
|
452
|
+
axes[i] = @axes[i]
|
453
|
+
end
|
454
|
+
end
|
455
|
+
out = self.class.new( *axes )
|
456
|
+
out.set_lost_axes( (@lost_axes.dup + other.lost_axes).uniq )
|
457
|
+
if (oac = other.assoc_coords) || (sac = self.assoc_coords)
|
458
|
+
sac ? ac=sac.merge(oac) : ac=oac.merge(sac)
|
459
|
+
out.assoc_coords = ac
|
460
|
+
end
|
461
|
+
out
|
462
|
+
end
|
463
|
+
|
464
|
+
def shape
|
465
|
+
@axes.collect{|ax| ax.length}
|
466
|
+
end
|
467
|
+
alias shape_current shape
|
468
|
+
|
469
|
+
def [] (*slicer)
|
470
|
+
if slicer.length == 0
|
471
|
+
# make a clone
|
472
|
+
axes = Array.new
|
473
|
+
(0...rank).each{ |i| axes.push( @axes[i][0..-1] ) }
|
474
|
+
grid = self.class.new( *axes )
|
475
|
+
else
|
476
|
+
slicer = __rubber_expansion(slicer)
|
477
|
+
if slicer.length != rank
|
478
|
+
raise ArgumentError,"# of the args does not agree with the rank"
|
479
|
+
end
|
480
|
+
axes = Array.new
|
481
|
+
lost = self.lost_axes #Array.new
|
482
|
+
for i in 0...rank
|
483
|
+
ax = @axes[i][slicer[i]]
|
484
|
+
if ax.is_a?(Axis) # else its rank became zero (lost)
|
485
|
+
axes.push( ax )
|
486
|
+
else
|
487
|
+
lost.push( ax )
|
488
|
+
end
|
489
|
+
end
|
490
|
+
grid = self.class.new( *axes )
|
491
|
+
grid.set_lost_axes( lost ) if lost.length != 0
|
492
|
+
grid
|
493
|
+
end
|
494
|
+
if @assoc_coords
|
495
|
+
grid.assoc_coords = @assoc_coords[*slicer]
|
496
|
+
end
|
497
|
+
grid
|
498
|
+
end
|
499
|
+
|
500
|
+
def __rubber_expansion( args )
|
501
|
+
if (id = args.index(false)) # substitution into id
|
502
|
+
# false is incuded
|
503
|
+
alen = args.length
|
504
|
+
if args.rindex(false) != id
|
505
|
+
raise ArguemntError,"only one rubber dimension is permitted"
|
506
|
+
elsif alen > rank+1
|
507
|
+
raise ArgumentError, "too many args"
|
508
|
+
end
|
509
|
+
ar = ( id!=0 ? args[0..id-1] : [] )
|
510
|
+
args = ar + [true]*(rank-alen+1) + args[id+1..-1]
|
511
|
+
end
|
512
|
+
args
|
513
|
+
end
|
514
|
+
private :__rubber_expansion
|
515
|
+
|
516
|
+
def cut_assoccoord(hasharg)
|
517
|
+
ac, acsl = @assoc_coords.cut(hasharg)
|
518
|
+
sl = @axnames.collect{|nm| acsl[nm] || true}
|
519
|
+
[ self[*sl], sl ]
|
520
|
+
end
|
521
|
+
|
522
|
+
def cut(*args)
|
523
|
+
_cut_(false, *args)
|
524
|
+
end
|
525
|
+
def cut_rank_conserving(*args)
|
526
|
+
_cut_(true, *args)
|
527
|
+
end
|
528
|
+
|
529
|
+
# cut along the regular coorinates.
|
530
|
+
# assume that the coordinates are monotonic (without checking).
|
531
|
+
def _cut_(conserve_rank, *args)
|
532
|
+
|
533
|
+
hasharg = ( args.length==1 && args[0].is_a?(Hash) )
|
534
|
+
|
535
|
+
if hasharg
|
536
|
+
# specification by axis names
|
537
|
+
spec = args[0]
|
538
|
+
if (spec.keys - axnames).length > 0
|
539
|
+
raise ArgumentError,"One or more of the hash keys "+
|
540
|
+
"(#{spec.keys.inspect}) are not found in the axis names "+
|
541
|
+
"(#{axnames.inspect})."
|
542
|
+
end
|
543
|
+
args = axnames.collect{|ax| spec[ax] || true}
|
544
|
+
end
|
545
|
+
|
546
|
+
args = __rubber_expansion(args)
|
547
|
+
|
548
|
+
if rank != args.length
|
549
|
+
raise ArgumentError, "# of dims doesn't agree with the rank(#{rank})"
|
550
|
+
end
|
551
|
+
|
552
|
+
slicer = Array.new
|
553
|
+
|
554
|
+
for dim in 0...rank
|
555
|
+
ax = @axes[dim]
|
556
|
+
if conserve_rank
|
557
|
+
dummy, slicer[dim] = ax.cut_rank_conserving(args[dim])
|
558
|
+
else
|
559
|
+
dummy, slicer[dim] = ax.cut(args[dim])
|
560
|
+
end
|
561
|
+
end
|
562
|
+
|
563
|
+
[ self[*slicer], slicer ]
|
564
|
+
end
|
565
|
+
private :_cut_
|
566
|
+
|
567
|
+
# def exclude(dim_or_dimname)
|
568
|
+
# dim = dim_index(dim_or_dimname)
|
569
|
+
# axes = @axes.dup
|
570
|
+
# axes.delete_at(dim)
|
571
|
+
# self.class.new( *axes )
|
572
|
+
# end
|
573
|
+
|
574
|
+
def change_axis(dim, axis)
|
575
|
+
axes = @axes.dup
|
576
|
+
lost = @lost_axes.dup
|
577
|
+
if axis.is_a?(Axis)
|
578
|
+
axes[dim] = axis
|
579
|
+
else
|
580
|
+
lost.push(axis) if axis.is_a?(String)
|
581
|
+
axes.delete_at(dim)
|
582
|
+
end
|
583
|
+
grid = self.class.new( *axes ).add_lost_axes( lost )
|
584
|
+
if @assoc_coords
|
585
|
+
grid.assoc_coords=@assoc_coords.subset_having_axnames(grid.axnames)
|
586
|
+
end
|
587
|
+
grid
|
588
|
+
end
|
589
|
+
|
590
|
+
# def change_axis!(dim_or_dimname, axis)
|
591
|
+
# if axis.is_a?(Axis)
|
592
|
+
# @axes[ dim_index(dim_or_dimname) ] = axis
|
593
|
+
# else
|
594
|
+
# @lost_axes.push(axis) if axis.is_a?(String)
|
595
|
+
# @axes.delete_at( dim_index(dim_or_dimname) )
|
596
|
+
# end
|
597
|
+
# @rank = @axes.length
|
598
|
+
# __check_and_set_axnames
|
599
|
+
# self
|
600
|
+
# end
|
601
|
+
|
602
|
+
# def insert_axis(dim_or_dimname, axis)
|
603
|
+
# dim = dim_index(dim_or_dimname)
|
604
|
+
# axes = @axes.dup
|
605
|
+
# if axis.is_a?(Axis)
|
606
|
+
# axes[dim+1,0] = axis # axes.insert(dim, axis) if ruby 1.7
|
607
|
+
# else
|
608
|
+
# # do nothing
|
609
|
+
# end
|
610
|
+
# self.class.new( *axes )
|
611
|
+
# end
|
612
|
+
|
613
|
+
# def insert_axis!(dim_or_dimname, axis)
|
614
|
+
# dim = dim_index(dim_or_dimname)
|
615
|
+
# if axis == nil
|
616
|
+
# # do nothing
|
617
|
+
# else
|
618
|
+
# @axes[dim+1,0] = axis # @axes.insert(dim, axis) if ruby 1.7
|
619
|
+
# @rank = @axes.length
|
620
|
+
# __check_and_set_axnames
|
621
|
+
# end
|
622
|
+
# self
|
623
|
+
# end
|
624
|
+
|
625
|
+
def transpose( *dims )
|
626
|
+
if dims.sort != NArray.int(rank).indgen!.to_a
|
627
|
+
raise ArgumentError,
|
628
|
+
"Args must a permutation of 0..rank-1 (eg, if 3D 2,1,0; 1,0,2;etc)"
|
629
|
+
end
|
630
|
+
axes = Array.new
|
631
|
+
for i in 0...rank
|
632
|
+
axes[i] = @axes[dims[i]]
|
633
|
+
end
|
634
|
+
grid = self.class.new(*axes)
|
635
|
+
grid.set_lost_axes( lost_axes )
|
636
|
+
grid.assoc_coords = @assoc_coords.dup if @assoc_coords
|
637
|
+
grid
|
638
|
+
end
|
639
|
+
|
640
|
+
# Define operations along each axis --- The following defines
|
641
|
+
# instance methods such as "average" and "integrate":
|
642
|
+
|
643
|
+
Axis.defined_operations.each do |method|
|
644
|
+
eval <<-EOS, nil, __FILE__, __LINE__+1
|
645
|
+
def #{method}(vary, dim_or_dimname, *extra_args)
|
646
|
+
ax, dim = self.ax_dim(dim_or_dimname)
|
647
|
+
va, new_ax = ax.#{method}(vary, dim, *extra_args)
|
648
|
+
if va.is_a?(Numeric) || va.is_a?(UNumeric)
|
649
|
+
va
|
650
|
+
else
|
651
|
+
[va, self.change_axis(dim, new_ax)]
|
652
|
+
end
|
653
|
+
end
|
654
|
+
EOS
|
655
|
+
end
|
656
|
+
|
657
|
+
######### < protected methods > ###########
|
658
|
+
|
659
|
+
protected
|
660
|
+
|
661
|
+
def ax_dim(dim_or_dimname)
|
662
|
+
if dim_or_dimname.is_a?(Integer)
|
663
|
+
dim = dim_or_dimname
|
664
|
+
if dim < -rank || dim >= rank
|
665
|
+
raise ArgumentError,"rank=#{rank}: #{dim}th grid does not exist"
|
666
|
+
end
|
667
|
+
dim += rank if dim < 0
|
668
|
+
else
|
669
|
+
dim = @axnames.index(dim_or_dimname)
|
670
|
+
if !dim
|
671
|
+
raise ArgumentError, "Axis #{dim_or_dimname} is not contained"
|
672
|
+
end
|
673
|
+
end
|
674
|
+
[@axes[dim], dim]
|
675
|
+
end
|
676
|
+
|
677
|
+
|
678
|
+
end
|
679
|
+
|
680
|
+
end
|
681
|
+
|
682
|
+
######################################################
|
683
|
+
## < test >
|
684
|
+
if $0 == __FILE__
|
685
|
+
include NumRu
|
686
|
+
vx = VArray.new( NArray.float(10).indgen! + 0.5 ).rename("x")
|
687
|
+
vy = VArray.new( NArray.float(6).indgen! ).rename("y")
|
688
|
+
xax = Axis.new().set_pos(vx)
|
689
|
+
yax = Axis.new(true).set_cell_guess_bounds(vy).set_pos_to_center
|
690
|
+
grid = Grid.new(xax, yax)
|
691
|
+
|
692
|
+
z = VArray.new( NArray.float(vx.length, vy.length).indgen! )
|
693
|
+
p z.val
|
694
|
+
p "average along x-axis:", grid.average(z,0)[0].val,
|
695
|
+
grid.average(z,"x")[0].val
|
696
|
+
p "average along y-axis:", grid.average(z,1)[0].val,
|
697
|
+
grid.average(z,"y")[0].val
|
698
|
+
p "grid set by an operation:", (g = grid.average(z,1)[1]).rank, g.shape
|
699
|
+
|
700
|
+
p grid.shape, grid.axis(0).pos.val, grid.axis(1).pos.val
|
701
|
+
subgrid = grid[1..3,1..2]
|
702
|
+
p subgrid.shape, subgrid.axis(0).pos.val, subgrid.axis(1).pos.val
|
703
|
+
p grid[3,2].lost_axes
|
704
|
+
|
705
|
+
p grid
|
706
|
+
|
707
|
+
gr,slice = grid.cut(1.0..4.0, 3.2)
|
708
|
+
p "%%",gr.copy,slice,gr.lost_axes
|
709
|
+
gr,slice = grid.cut_rank_conserving(-10,false)
|
710
|
+
p "%%",gr.copy,slice,gr.lost_axes
|
711
|
+
|
712
|
+
p grid[0,0]
|
713
|
+
|
714
|
+
p Grid.new(xax).average(vx,0) # --> scalar
|
715
|
+
|
716
|
+
p "+++++"
|
717
|
+
p grid.delete_axes(0).lost_axes
|
718
|
+
p grid.delete_axes([0,1]).lost_axes
|
719
|
+
p grid.delete_axes([0,1], 'mean').lost_axes
|
720
|
+
|
721
|
+
p grid, grid.transpose(1,0)
|
722
|
+
end
|
723
|
+
|