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
data/lib/numru/gdir.rb
ADDED
@@ -0,0 +1,1038 @@
|
|
1
|
+
=begin
|
2
|
+
=class NumRu::GDir
|
3
|
+
|
4
|
+
A class to represent diretories and data files for GPhys.
|
5
|
+
|
6
|
+
==Overview
|
7
|
+
|
8
|
+
A GDir object represents a directory, or a file (such as a NetCDF
|
9
|
+
file or GrADS control file), for which
|
10
|
+
GPhys objects can be defined for the variables in it.
|
11
|
+
This means that a NetCDF file, for example, is treated a
|
12
|
+
directory, rather than a plain file.
|
13
|
+
|
14
|
+
GDir serves a directory tree under a root (top) directory, which can
|
15
|
+
be set as a class variable with ((<GDir.top=>)). All the absolute path
|
16
|
+
of GDir is actually relative to the root directory, and to access
|
17
|
+
outside the root directory is prohibited. Furthermore, it has a
|
18
|
+
working directory as a class variable, whose initial value is the top
|
19
|
+
directory and can be changed by ((<GDir.cd>)).
|
20
|
+
|
21
|
+
NEW(2005/06): Now GDir can accept DODS URL as a path. Also,
|
22
|
+
the top directory can be set to a DODS URL.
|
23
|
+
|
24
|
+
==Class Methods
|
25
|
+
|
26
|
+
---GDir.top=(top)
|
27
|
+
Sets the root directory. This should be done before making
|
28
|
+
any GDir objects by ((<GDir.new>)). The default root directory
|
29
|
+
is the root directory of the local file system ('/').
|
30
|
+
|
31
|
+
ARGUMENTS
|
32
|
+
* ((|top|)) (String): path of the top directory
|
33
|
+
|
34
|
+
RETURN VALUE
|
35
|
+
* absolute path of the top directory (String) (followed by a '/')
|
36
|
+
|
37
|
+
---GDir.top
|
38
|
+
|
39
|
+
RETURN VALUE
|
40
|
+
* absolute path of the top directory (String) (followed by a '/')
|
41
|
+
|
42
|
+
---GDir.new(path)
|
43
|
+
Constructor.
|
44
|
+
|
45
|
+
ARGUMENTS
|
46
|
+
* ((|path|)) (String): path of the directory to open as a GDir.
|
47
|
+
The path is expressed in terms of the top directory.
|
48
|
+
|
49
|
+
RETURN VALUE
|
50
|
+
* a GDir
|
51
|
+
|
52
|
+
ERRORS
|
53
|
+
* ArgumentError if ((|path|)) is out of the directory
|
54
|
+
tree (originated at the top directory).
|
55
|
+
|
56
|
+
EXAMPLES
|
57
|
+
* If the top directory is "/hoge", you can open
|
58
|
+
"/hoge/ho" directory by any of the following.
|
59
|
+
|
60
|
+
gdir = GDir.new("/ho")
|
61
|
+
gdir = GDir.new("./ho")
|
62
|
+
|
63
|
+
If you want to open "/hoge" (the top directly), then
|
64
|
+
|
65
|
+
gdir = GDir.new("/")
|
66
|
+
gdir = GDir.new(".")
|
67
|
+
|
68
|
+
To open a NetCDF file or GrADS control file,
|
69
|
+
|
70
|
+
gdir = GDir.new("/ho/data.nc")
|
71
|
+
gdir = GDir.new("/ho/data.ctl")
|
72
|
+
|
73
|
+
---GDir.set_text_pattern(*regexps)
|
74
|
+
|
75
|
+
Sets regular expressions to match the file name of text files.
|
76
|
+
The default is /\.txt$/ and /^\w*$/.
|
77
|
+
|
78
|
+
ARGUMENTS
|
79
|
+
* zero or more Regular expressions (zero means no file will be treated
|
80
|
+
as a NetCDF file).
|
81
|
+
|
82
|
+
RETURN VALUE
|
83
|
+
* nil
|
84
|
+
|
85
|
+
ERRORS
|
86
|
+
* TypeError if any of the arguments is not a Regexp
|
87
|
+
|
88
|
+
---GDir.add_text_pattern(regexp [, regexp [, ...]])
|
89
|
+
Similar to ((<GDir.set_text_pattern>)), but adds regular expressions
|
90
|
+
instead of replacing existing ones.
|
91
|
+
|
92
|
+
RETURN VALUE
|
93
|
+
* nil
|
94
|
+
|
95
|
+
ERRORS
|
96
|
+
* TypeError if any of the arguments is not a Regexp
|
97
|
+
|
98
|
+
---GDir.cd(path)
|
99
|
+
|
100
|
+
Changes the working directory of the class.
|
101
|
+
|
102
|
+
RETURN VALUE
|
103
|
+
* a GDir
|
104
|
+
|
105
|
+
---GDir.cwd=(path)
|
106
|
+
Aliased to ((<GDir.cd>)).
|
107
|
+
|
108
|
+
---GDir.cwd
|
109
|
+
Returns the current working directory as a GDir. The initial value of
|
110
|
+
the working directory is the top directory.
|
111
|
+
|
112
|
+
RETURN VALUE
|
113
|
+
* a GDir
|
114
|
+
|
115
|
+
---GDir.cd(path)
|
116
|
+
Changes the working directory to path
|
117
|
+
|
118
|
+
RETURN VALUE
|
119
|
+
* a GDir (current working directory changed by path)
|
120
|
+
|
121
|
+
---GDir[]
|
122
|
+
---GDir.data
|
123
|
+
---GDir.text
|
124
|
+
---GDir.list_dirs
|
125
|
+
---GDir.list_dirs_v
|
126
|
+
---GDir.list_data
|
127
|
+
---GDir.list_data_v
|
128
|
+
---GDir.list_texts
|
129
|
+
---GDir.list_texts_v
|
130
|
+
---GDir.ls
|
131
|
+
---GDir.ls_v
|
132
|
+
|
133
|
+
All of these are dispatched to the current working directory.
|
134
|
+
Thus, (('GDir.show')) is equivalent to (('GDir.cwd.show')), for example.
|
135
|
+
|
136
|
+
==Instance Methods
|
137
|
+
|
138
|
+
---close
|
139
|
+
Closes the file/directory objects in the GDir.
|
140
|
+
|
141
|
+
---path
|
142
|
+
Returns the path (relative to the top directory)
|
143
|
+
|
144
|
+
RETURN VALUE
|
145
|
+
* a String
|
146
|
+
|
147
|
+
---name
|
148
|
+
Name of the GDir
|
149
|
+
|
150
|
+
RETURN VALUE
|
151
|
+
* a String
|
152
|
+
|
153
|
+
---inspect
|
154
|
+
Returns the path
|
155
|
+
|
156
|
+
RETURN VALUE
|
157
|
+
* a String
|
158
|
+
|
159
|
+
---[](path)
|
160
|
+
Returns a GDir, GPhys, or File (text), by calling
|
161
|
+
((<dir>)), ((<data>)), or ((<text>)) depending on (('path')).
|
162
|
+
|
163
|
+
ARGUMENTS
|
164
|
+
* ((|path|)) (String): Either relative or absolute.
|
165
|
+
|
166
|
+
RETURN VALUE
|
167
|
+
* a GDir, GPhys, or File (text assumed)
|
168
|
+
|
169
|
+
ERROR
|
170
|
+
* an exception is raised if ((|path|)) is not appropriate.
|
171
|
+
|
172
|
+
|
173
|
+
---dir(path)
|
174
|
+
Returns a GDir specified the ((|path|)).
|
175
|
+
|
176
|
+
ARGUMENTS
|
177
|
+
* ((|path|)) (String): Either relative or absolute.
|
178
|
+
|
179
|
+
RETURN VALUE
|
180
|
+
* a GDir
|
181
|
+
|
182
|
+
ERROR
|
183
|
+
* an exception is raised if ((|path|)) is invalid as a GDir.
|
184
|
+
|
185
|
+
---data(path)
|
186
|
+
Returns a GPhys specified the ((|path|)).
|
187
|
+
|
188
|
+
ARGUMENTS
|
189
|
+
* ((|path|)) (String): Either relative or absolute.
|
190
|
+
|
191
|
+
RETURN VALUE
|
192
|
+
* a GPhys
|
193
|
+
|
194
|
+
ERROR
|
195
|
+
* an exception is raised if ((|path|)) is invalid as a GPhys.
|
196
|
+
|
197
|
+
---text(path)
|
198
|
+
Returns a text file object specified the ((|path|)).
|
199
|
+
|
200
|
+
ARGUMENTS
|
201
|
+
* ((|path|)) (String): Either relative or absolute.
|
202
|
+
|
203
|
+
RETURN VALUE
|
204
|
+
* a File
|
205
|
+
|
206
|
+
ERROR
|
207
|
+
* an exception is raised if ((|path|)) is invalid as a text file
|
208
|
+
(based on the pattern: see above).
|
209
|
+
|
210
|
+
---find_dir( filt )
|
211
|
+
Recursively search a GDir whose name match ((|filt|))..
|
212
|
+
|
213
|
+
ARGUMENTS
|
214
|
+
* ((|filt|)) (Regexp or String) If String, converted to Regexp
|
215
|
+
with (('Regexp.new(filt)')).
|
216
|
+
|
217
|
+
RETURN VALUE
|
218
|
+
* an Array holding pathes (String) that matched.
|
219
|
+
|
220
|
+
---find_data( name=nil,long_name=nil,units=nil )
|
221
|
+
Recursively search data variables under the directory.
|
222
|
+
Mathces are by taking "AND" for non-nil arguments.
|
223
|
+
(At least one of the three arguments must be non-nil.)
|
224
|
+
|
225
|
+
ARGUMENTS
|
226
|
+
* ((|name|)) (Regexp or String or nil) Variable name. If String,
|
227
|
+
converted to Regexp with (('Regexp.new(name)')).
|
228
|
+
* ((|long_name|)) (Regexp or String or nil) long_name. If String,
|
229
|
+
converted to Regexp with (('Regexp.new(long_name)')).
|
230
|
+
* ((|long_name|)) (Units or String or nil) long_name. If String,
|
231
|
+
converted to Units with (('Units.new(units)')).
|
232
|
+
|
233
|
+
RETURN VALUE
|
234
|
+
* an Array holding the path and variable name that matched
|
235
|
+
(two-element Array of String; [path, variable_name] ).
|
236
|
+
|
237
|
+
---list_dirs(path=nil)
|
238
|
+
Returns the names of the directories.
|
239
|
+
|
240
|
+
See also ((<ls>)).
|
241
|
+
|
242
|
+
ARGUMENTS
|
243
|
+
* ((|path|)) (nil or String): if nil, the method is applied to the
|
244
|
+
current directory. If specified, listing is made for the directory
|
245
|
+
designated by it. Either relative or absolute.
|
246
|
+
|
247
|
+
RETURN VALUE
|
248
|
+
* an Array of String
|
249
|
+
|
250
|
+
---list_dirs_v(path=nil)
|
251
|
+
Verbose version of ((<list_dirs>)), showing size and mtime like 'ls -l'.
|
252
|
+
|
253
|
+
See also ((<ls_l>)).
|
254
|
+
|
255
|
+
ARGUMENTS
|
256
|
+
* See ((<list_dirs>)).
|
257
|
+
|
258
|
+
RETURN VALUE
|
259
|
+
* an Array of String
|
260
|
+
|
261
|
+
Example of a string:
|
262
|
+
275492 Apr 12 19:15 hogehoge_data.nc/
|
263
|
+
|
264
|
+
---list_data(path=nil)
|
265
|
+
Returns the names of the data (variables on which GPhys objects
|
266
|
+
can be defined.) Returns a non-empty array if the GDir (current
|
267
|
+
or at the path) is actually a file recognized by GPhys (i.e.,
|
268
|
+
NetCDF or GrADS control file).
|
269
|
+
|
270
|
+
ARGUMENTS
|
271
|
+
* ((|path|)) (nil or String): if nil, the method is applied to the
|
272
|
+
current directory. If specified, listing is made for the directory
|
273
|
+
designated by it. Either relative or absolute.
|
274
|
+
|
275
|
+
RETURN VALUE
|
276
|
+
* an Array of String
|
277
|
+
|
278
|
+
---list_data_v(path=nil)
|
279
|
+
Verbose version of ((<list_data>)), showing shape, long_name,
|
280
|
+
and units.
|
281
|
+
|
282
|
+
See also ((<ls_l>)).
|
283
|
+
|
284
|
+
ARGUMENTS
|
285
|
+
* See ((<list_data>)).
|
286
|
+
|
287
|
+
RETURN VALUE
|
288
|
+
* an Array of String
|
289
|
+
|
290
|
+
Example of a string:
|
291
|
+
u [lon=120,lat=120,z=40,t=73] 'x components of velocity' (m/s)
|
292
|
+
|
293
|
+
---list_texts(path=nil)
|
294
|
+
Returns the names of the text files.
|
295
|
+
Whether a file is a text file or not is judged based on the
|
296
|
+
name of the file: That matched the predefined patters is
|
297
|
+
judged as a text file regardless whether it is really so.
|
298
|
+
The default pattern is /\.txt$/ and /^\w*$/. The patterns
|
299
|
+
can be customized by ((<set_text_patterns>)) or
|
300
|
+
((<add_text_patterns>)).
|
301
|
+
|
302
|
+
ARGUMENTS
|
303
|
+
* ((|path|)) (nil or String): if nil, the method is applied to the
|
304
|
+
current directory. If specified, listing is made for the directory
|
305
|
+
designated by it. Either relative or absolute.
|
306
|
+
|
307
|
+
RETURN VALUE
|
308
|
+
* an Array of String
|
309
|
+
|
310
|
+
---list_texts_v(path=nil)
|
311
|
+
Verbose version of ((<list_texts>)), showing size and mtime like 'ls -l'.
|
312
|
+
|
313
|
+
See also ((<ls_l>)).
|
314
|
+
|
315
|
+
ARGUMENTS
|
316
|
+
* See ((<list_texts>)).
|
317
|
+
|
318
|
+
RETURN VALUE
|
319
|
+
* an Array of String
|
320
|
+
|
321
|
+
---ls(path=nil)
|
322
|
+
Prints the results of ((<list_dirs>)), ((<list_data>)), and
|
323
|
+
((<list_texts>)) on the standard output.
|
324
|
+
|
325
|
+
RETURN VALUE
|
326
|
+
* nil
|
327
|
+
|
328
|
+
---each_dir
|
329
|
+
Iterator for each directory (GDir) under self.
|
330
|
+
|
331
|
+
---each_data
|
332
|
+
Iterator for each GPhys under self.
|
333
|
+
|
334
|
+
---ls_l(path=nil)
|
335
|
+
Verbose version of ((<ls>)).
|
336
|
+
Prints the results of ((<list_dirs_v>)), ((<list_data_v>)), and
|
337
|
+
((<list_texts_v>)) on the standard output.
|
338
|
+
|
339
|
+
RETURN VALUE
|
340
|
+
* nil
|
341
|
+
|
342
|
+
---mtime
|
343
|
+
Returns the last modified time.
|
344
|
+
|
345
|
+
RETURN VALUE
|
346
|
+
* a Time
|
347
|
+
|
348
|
+
---atime
|
349
|
+
Returns the last accessed time.
|
350
|
+
|
351
|
+
RETURN VALUE
|
352
|
+
* a Time
|
353
|
+
|
354
|
+
---ctime
|
355
|
+
Returns ctime.
|
356
|
+
|
357
|
+
RETURN VALUE
|
358
|
+
* a Time
|
359
|
+
|
360
|
+
---mtime_like_ls_l
|
361
|
+
|
362
|
+
Returns the last modified time formated as in ls -l.
|
363
|
+
That is, if the time of last modification is greater than
|
364
|
+
six months ago, it is shown in the format 'month date year';
|
365
|
+
otherwise, 'month date time'.
|
366
|
+
|
367
|
+
RETURN VALUE
|
368
|
+
* a String.
|
369
|
+
|
370
|
+
=end
|
371
|
+
|
372
|
+
require "numru/gphys"
|
373
|
+
require "numru/htdir"
|
374
|
+
|
375
|
+
module NumRu
|
376
|
+
|
377
|
+
class GDir
|
378
|
+
|
379
|
+
@@top = '/' # default
|
380
|
+
@@top_pat = Regexp.new('^'+@@top)
|
381
|
+
|
382
|
+
@@text_pattern = [/\.txt$/,/^\w*$/]
|
383
|
+
|
384
|
+
@@cwd = nil # current working directory
|
385
|
+
|
386
|
+
HtDir.dods_interpret = true
|
387
|
+
|
388
|
+
def initialize(path)
|
389
|
+
http = false
|
390
|
+
if /^http/ =~ path
|
391
|
+
http = true
|
392
|
+
abspath = path.sub(/\/+$/,'')
|
393
|
+
@path = @abspath = ( abspath + '/' )
|
394
|
+
elsif /^http/ =~ @@top
|
395
|
+
http = true
|
396
|
+
abspath = @@top + path.sub(/\/+$/,'')
|
397
|
+
abspath = File.expand_path( '/'+abspath ).sub(/^\//,'').sub(/^http:\//,'http://') # to clean up the path
|
398
|
+
@path = @abspath = ( abspath + '/' )
|
399
|
+
else
|
400
|
+
path = '/' + path if /^\// !~ path # to always start with '/'
|
401
|
+
path = File.expand_path( path ) # to clean up the path
|
402
|
+
abspath = @@top.sub(/^(\/.*)\/$/,'\1')+path.sub(/\/+$/,'')
|
403
|
+
@path = abspath.sub(@@top_pat,'') + '/'
|
404
|
+
@abspath = abspath + '/'
|
405
|
+
end
|
406
|
+
ftype = __ftype(abspath)
|
407
|
+
case ftype
|
408
|
+
when "directory"
|
409
|
+
if http
|
410
|
+
@dir = HtDir.new(abspath)
|
411
|
+
else
|
412
|
+
@dir = Dir.new(abspath)
|
413
|
+
end
|
414
|
+
@file = nil
|
415
|
+
when "file"
|
416
|
+
if (file_class = GPhys::IO::file2file_class( abspath ))
|
417
|
+
# non-nil means GPhys knows it.
|
418
|
+
@dir = nil
|
419
|
+
@file = file_class.open( abspath )
|
420
|
+
else
|
421
|
+
raise path+" are not dealt with GPhys. " +
|
422
|
+
"Use GPhys::IO::add_(nc|gr)_pattern if it should be."
|
423
|
+
end
|
424
|
+
else
|
425
|
+
raise ArgumentError, abspath+": Unsupported file type "+ftype
|
426
|
+
end
|
427
|
+
end
|
428
|
+
|
429
|
+
####### CLASS METHODS ######
|
430
|
+
|
431
|
+
class << self
|
432
|
+
alias open new
|
433
|
+
|
434
|
+
def top=(top)
|
435
|
+
if /^http:\/\// =~ top
|
436
|
+
top = top.sub(/\/+$/,'')
|
437
|
+
else
|
438
|
+
top = File.expand_path( top ) # to absolute path
|
439
|
+
end
|
440
|
+
### top.untaint
|
441
|
+
@@top_pat = Regexp.new('^'+top)
|
442
|
+
@@top = top + '/'
|
443
|
+
@@cwd = GDir.new('/') if @@cwd # reset to the top if set
|
444
|
+
@@top
|
445
|
+
end
|
446
|
+
|
447
|
+
alias set_top top=
|
448
|
+
|
449
|
+
def top
|
450
|
+
@@top
|
451
|
+
end
|
452
|
+
|
453
|
+
## // private >>
|
454
|
+
def set_cwd
|
455
|
+
@@cwd = GDir.new('/') if !@@cwd
|
456
|
+
end
|
457
|
+
private :set_cwd
|
458
|
+
## << private //
|
459
|
+
|
460
|
+
def cwd
|
461
|
+
set_cwd
|
462
|
+
@@cwd
|
463
|
+
end
|
464
|
+
|
465
|
+
def pwd
|
466
|
+
cwd.path
|
467
|
+
end
|
468
|
+
|
469
|
+
def cd(path)
|
470
|
+
if /^\// =~ path
|
471
|
+
# absolute path
|
472
|
+
@@cwd = GDir.new( path )
|
473
|
+
else
|
474
|
+
# relative path
|
475
|
+
set_cwd
|
476
|
+
@@cwd = GDir.new( @@cwd.path + path )
|
477
|
+
end
|
478
|
+
end
|
479
|
+
|
480
|
+
alias chdir cd
|
481
|
+
alias cwd= cd
|
482
|
+
|
483
|
+
[ ## 'mtime','ctime','atime',
|
484
|
+
## 'size','mtime_like_ls_l',
|
485
|
+
'[]','data','text',
|
486
|
+
'list_dirs','list_dirs_v','list_data','list_data_v',
|
487
|
+
'list_texts','list_texts_v','ls','ls_l'
|
488
|
+
].each do |method|
|
489
|
+
eval <<-EOS
|
490
|
+
def #{method}(*args)
|
491
|
+
set_cwd
|
492
|
+
@@cwd.#{method}(*args)
|
493
|
+
end
|
494
|
+
EOS
|
495
|
+
end
|
496
|
+
|
497
|
+
def add_text_pattern(*regexps)
|
498
|
+
regexps.each{ |regexp|
|
499
|
+
raise TypeError,"Regexp expected" unless Regexp===regexp
|
500
|
+
@@text_pattern.push(regexp)
|
501
|
+
}
|
502
|
+
nil
|
503
|
+
end
|
504
|
+
|
505
|
+
def GDir.set_text_pattern(*regexps)
|
506
|
+
regexps.each{ |regexp|
|
507
|
+
raise TypeError,"Regexp expected" unless Regexp===regexp
|
508
|
+
}
|
509
|
+
@@text_pattern = regexps
|
510
|
+
nil
|
511
|
+
end
|
512
|
+
|
513
|
+
end
|
514
|
+
|
515
|
+
####### INSTANCE METHODS ######
|
516
|
+
|
517
|
+
def close
|
518
|
+
@dir.close if @dir
|
519
|
+
@file.close if @file
|
520
|
+
end
|
521
|
+
|
522
|
+
def path
|
523
|
+
@path
|
524
|
+
end
|
525
|
+
def name
|
526
|
+
@path=='/' ? @path : File.basename( @path.sub(/\/$/,'') )
|
527
|
+
end
|
528
|
+
|
529
|
+
def inspect
|
530
|
+
path
|
531
|
+
end
|
532
|
+
|
533
|
+
def [](path)
|
534
|
+
begin
|
535
|
+
begin
|
536
|
+
dir(path)
|
537
|
+
rescue
|
538
|
+
begin
|
539
|
+
data(path)
|
540
|
+
rescue
|
541
|
+
text(path)
|
542
|
+
end
|
543
|
+
end
|
544
|
+
rescue
|
545
|
+
pt = path || ''
|
546
|
+
raise @path+pt+': no such data, directory or text (or is outside the tree)'
|
547
|
+
end
|
548
|
+
end
|
549
|
+
|
550
|
+
def dir(path)
|
551
|
+
case path
|
552
|
+
when /^\//
|
553
|
+
# absolute path
|
554
|
+
GDir.new(path)
|
555
|
+
else
|
556
|
+
# relative path
|
557
|
+
GDir.new(@path+path)
|
558
|
+
end
|
559
|
+
end
|
560
|
+
|
561
|
+
alias cd dir
|
562
|
+
|
563
|
+
def data(path)
|
564
|
+
dirname = File.dirname(path)
|
565
|
+
if dirname != '.'
|
566
|
+
self.dir(dirname).data( File.basename(path) )
|
567
|
+
else
|
568
|
+
# path is for the current directory.
|
569
|
+
if @dir
|
570
|
+
raise "data #{path} is not found" # cannot be directly under a Dir
|
571
|
+
else
|
572
|
+
GPhys::IO::open(@file,path)
|
573
|
+
end
|
574
|
+
end
|
575
|
+
end
|
576
|
+
|
577
|
+
def text(path)
|
578
|
+
dirname = File.dirname(path)
|
579
|
+
if dirname != '.'
|
580
|
+
self.dir(dirname).text( File.basename(path) )
|
581
|
+
else
|
582
|
+
# path is for the current directory.
|
583
|
+
if @dir
|
584
|
+
if __ftype(@abspath+path) == "file"
|
585
|
+
case path
|
586
|
+
when *@@text_pattern
|
587
|
+
File.open(@abspath+path)
|
588
|
+
else
|
589
|
+
raise "#{path} does not match patterns to find text files"
|
590
|
+
end
|
591
|
+
else
|
592
|
+
raise "text #{path} is not a plain file"
|
593
|
+
end
|
594
|
+
else
|
595
|
+
raise "text #{path} is not found"
|
596
|
+
end
|
597
|
+
end
|
598
|
+
end
|
599
|
+
|
600
|
+
def open_all_data
|
601
|
+
hash = Hash.new
|
602
|
+
if @file
|
603
|
+
GPhys::IO::var_names(@file).each do |nm|
|
604
|
+
hash[nm.to_sym] = data(nm)
|
605
|
+
end
|
606
|
+
end
|
607
|
+
hash
|
608
|
+
end
|
609
|
+
|
610
|
+
def find_dir( filt )
|
611
|
+
# filt is a Regexp or String
|
612
|
+
filt = Regexp.new( filt ) if filt.is_a?(String)
|
613
|
+
if ( filt =~ name )
|
614
|
+
result = [ path ]
|
615
|
+
else
|
616
|
+
result = []
|
617
|
+
end
|
618
|
+
|
619
|
+
if @dir
|
620
|
+
dnames = []
|
621
|
+
@dir.rewind
|
622
|
+
@dir.each{|fnm|
|
623
|
+
if fnm != '.' && fnm != '..' && __can_be_a_gdir(@abspath+fnm)
|
624
|
+
dnames.push( @path+fnm )
|
625
|
+
end
|
626
|
+
}
|
627
|
+
dnames.each do |nm|
|
628
|
+
dir = GDir.new(nm)
|
629
|
+
result.push(*dir.find_dir(filt))
|
630
|
+
dir.close
|
631
|
+
end
|
632
|
+
end
|
633
|
+
|
634
|
+
result
|
635
|
+
end
|
636
|
+
|
637
|
+
def find_data(name=nil,long_name=nil,units=nil)
|
638
|
+
# GC.start
|
639
|
+
# name (Regexp (or String; partial match))
|
640
|
+
# long_name (Regexp (or String; partial match))
|
641
|
+
# units (Units or String)
|
642
|
+
|
643
|
+
if !(name || long_name || units)
|
644
|
+
raise ArgumentError,
|
645
|
+
"You must specify at least one of name, long_name, and units"
|
646
|
+
end
|
647
|
+
|
648
|
+
name = Regexp.new( name ) if name.is_a?(String)
|
649
|
+
long_name = Regexp.new( long_name ) if long_name.is_a?(String)
|
650
|
+
units = Units.new( units ) if units.is_a?(String)
|
651
|
+
|
652
|
+
result = []
|
653
|
+
|
654
|
+
if @file
|
655
|
+
#p @file.path
|
656
|
+
GPhys::IO::var_names(@file).each do |nm|
|
657
|
+
if !name || name =~ nm
|
658
|
+
# name inspection passed
|
659
|
+
gph = GPhys::IO::open(@file,nm) if long_name || units
|
660
|
+
if !long_name || long_name =~ gph.long_name
|
661
|
+
# long_name inspection passed
|
662
|
+
if !units || units == gph.units
|
663
|
+
# units inspection passed
|
664
|
+
result.push( [path, nm] )
|
665
|
+
end
|
666
|
+
end
|
667
|
+
end
|
668
|
+
|
669
|
+
end
|
670
|
+
end
|
671
|
+
|
672
|
+
if @dir
|
673
|
+
dnames = []
|
674
|
+
@dir.rewind
|
675
|
+
@dir.each{|fnm|
|
676
|
+
if fnm != '.' && fnm != '..' && __can_be_a_gdir(@abspath+fnm)
|
677
|
+
dnames.push( @path+fnm )
|
678
|
+
end
|
679
|
+
}
|
680
|
+
dnames.each do |nm|
|
681
|
+
dir = GDir.new(nm)
|
682
|
+
result.push(*dir.find_data(name,long_name,units))
|
683
|
+
dir.close
|
684
|
+
end
|
685
|
+
end
|
686
|
+
|
687
|
+
result
|
688
|
+
end
|
689
|
+
|
690
|
+
def list_dirs(path = nil)
|
691
|
+
if path
|
692
|
+
self.dir(path).list_dirs
|
693
|
+
else
|
694
|
+
if @dir
|
695
|
+
gdir_names = []
|
696
|
+
@dir.rewind
|
697
|
+
@dir.each{|fnm|
|
698
|
+
if fnm != '.' && fnm != '..' && __can_be_a_gdir(@abspath+fnm)
|
699
|
+
gdir_names.push( fnm )
|
700
|
+
end
|
701
|
+
}
|
702
|
+
gdir_names.sort
|
703
|
+
else
|
704
|
+
[]
|
705
|
+
end
|
706
|
+
end
|
707
|
+
end
|
708
|
+
|
709
|
+
def list_dirs_v(path = nil)
|
710
|
+
# verbose version
|
711
|
+
if path
|
712
|
+
self.dir(path).list_dirs_v
|
713
|
+
else
|
714
|
+
if @dir
|
715
|
+
if /^http:\/\// =~ @abspath
|
716
|
+
return self.list_dirs
|
717
|
+
end
|
718
|
+
list = []
|
719
|
+
@dir.rewind
|
720
|
+
@dir.collect{|x| x}.sort.each{|fnm|
|
721
|
+
if fnm != '.' && fnm != '..' && __can_be_a_gdir(@abspath+fnm)
|
722
|
+
gdir = GDir.new(@path+fnm)
|
723
|
+
list.push( sprintf("%10d %s %s/",gdir.size.to_s,
|
724
|
+
gdir.mtime_like_ls_l, fnm) )
|
725
|
+
gdir.close
|
726
|
+
end
|
727
|
+
}
|
728
|
+
list
|
729
|
+
else
|
730
|
+
[]
|
731
|
+
end
|
732
|
+
end
|
733
|
+
end
|
734
|
+
|
735
|
+
def list_data(path = nil)
|
736
|
+
if path
|
737
|
+
self.dir(path).list_data
|
738
|
+
else
|
739
|
+
if @file
|
740
|
+
GPhys::IO::var_names(@file)
|
741
|
+
else
|
742
|
+
[]
|
743
|
+
end
|
744
|
+
end
|
745
|
+
end
|
746
|
+
|
747
|
+
def list_data_v(path = nil)
|
748
|
+
# verbose version
|
749
|
+
if path
|
750
|
+
self.dir(path).list_data_v
|
751
|
+
else
|
752
|
+
if @file
|
753
|
+
GPhys::IO::var_names(@file).collect do |nm|
|
754
|
+
gph = GPhys::IO::open(@file,nm)
|
755
|
+
axinfo = '['
|
756
|
+
(0...gph.rank).collect do |i|
|
757
|
+
axinfo += gph.axis(i).name + '=' + gph.shape[i].to_s + ','
|
758
|
+
end
|
759
|
+
axinfo.sub!(/,$/,']')
|
760
|
+
"#{nm}\t#{axinfo}\t'#{gph.long_name}'\t(#{gph.units.to_s})"
|
761
|
+
end
|
762
|
+
else
|
763
|
+
[]
|
764
|
+
end
|
765
|
+
end
|
766
|
+
end
|
767
|
+
|
768
|
+
def list_texts(path = nil)
|
769
|
+
if path
|
770
|
+
self.dir(path).list_texts
|
771
|
+
else
|
772
|
+
if @dir
|
773
|
+
text_files = []
|
774
|
+
@dir.rewind
|
775
|
+
@dir.each{|fnm|
|
776
|
+
if __ftype(@abspath+fnm) == "file"
|
777
|
+
case fnm
|
778
|
+
when *@@text_pattern
|
779
|
+
text_files.push( fnm )
|
780
|
+
end
|
781
|
+
end
|
782
|
+
}
|
783
|
+
text_files.sort
|
784
|
+
else
|
785
|
+
[]
|
786
|
+
end
|
787
|
+
end
|
788
|
+
end
|
789
|
+
|
790
|
+
def list_texts_v(path = nil)
|
791
|
+
# verbose version
|
792
|
+
if path
|
793
|
+
self.dir(path).list_texts_v
|
794
|
+
else
|
795
|
+
if @dir
|
796
|
+
if /^http:\/\// =~ @abspath
|
797
|
+
return self.list_texts
|
798
|
+
end
|
799
|
+
list = []
|
800
|
+
@dir.rewind
|
801
|
+
@dir.collect{|x| x}.sort.each{|fnm|
|
802
|
+
if __ftype(@abspath+fnm) == "file"
|
803
|
+
case fnm
|
804
|
+
when *@@text_pattern
|
805
|
+
path = @abspath + fnm
|
806
|
+
list.push( sprintf("%10d %s %s",File.size(path),
|
807
|
+
__fmt_like_ls_l(File.mtime(path)), fnm) )
|
808
|
+
end
|
809
|
+
end
|
810
|
+
}
|
811
|
+
list
|
812
|
+
else
|
813
|
+
[]
|
814
|
+
end
|
815
|
+
end
|
816
|
+
end
|
817
|
+
|
818
|
+
def each_dir
|
819
|
+
if @dir
|
820
|
+
@dir.rewind
|
821
|
+
@dir.each do |fnm|
|
822
|
+
if fnm != '.' && fnm != '..' && __can_be_a_gdir(@abspath+fnm)
|
823
|
+
yield( self.dir(fnm) )
|
824
|
+
end
|
825
|
+
end
|
826
|
+
self
|
827
|
+
end
|
828
|
+
end
|
829
|
+
|
830
|
+
def each_data
|
831
|
+
if @file
|
832
|
+
GPhys::IO::var_names(@file).each do |vnm|
|
833
|
+
gphys = GPhys::IO::open(@file,vnm)
|
834
|
+
yield(gphys)
|
835
|
+
end
|
836
|
+
end
|
837
|
+
end
|
838
|
+
|
839
|
+
def list_all(path = nil)
|
840
|
+
result = ''
|
841
|
+
dirs = list_dirs(path)
|
842
|
+
if dirs.length > 0
|
843
|
+
result << "Directories:\n"
|
844
|
+
dirs.each{|s| result << " '#{s}/'\n"}
|
845
|
+
end
|
846
|
+
texts = list_texts(path)
|
847
|
+
if texts.length > 0
|
848
|
+
result << "Text files?:\n"
|
849
|
+
texts.each{|s| result << " '#{s}'\n"}
|
850
|
+
end
|
851
|
+
data = list_data(path)
|
852
|
+
if data.length > 0
|
853
|
+
result << "Data:\n"
|
854
|
+
data.each{|s| result << " '#{s}'\n"}
|
855
|
+
end
|
856
|
+
result
|
857
|
+
end
|
858
|
+
|
859
|
+
def ls(path = nil)
|
860
|
+
print list_all(path)
|
861
|
+
end
|
862
|
+
|
863
|
+
def list_all_v(path = nil)
|
864
|
+
result = ''
|
865
|
+
dirs = list_dirs_v(path)
|
866
|
+
if dirs.length > 0
|
867
|
+
result << "Directories:\n"
|
868
|
+
dirs.each{|s| result << " #{s}\n"}
|
869
|
+
end
|
870
|
+
texts = list_texts_v(path)
|
871
|
+
if texts.length > 0
|
872
|
+
result << "Text files?:\n"
|
873
|
+
texts.each{|s| result << " #{s}\n"}
|
874
|
+
end
|
875
|
+
data = list_data_v(path)
|
876
|
+
if data.length > 0
|
877
|
+
result << "Data:\n"
|
878
|
+
data.each{|s| result << " #{s}\n"}
|
879
|
+
end
|
880
|
+
result
|
881
|
+
end
|
882
|
+
|
883
|
+
def ls_l(path = nil)
|
884
|
+
print list_all_v(path)
|
885
|
+
end
|
886
|
+
|
887
|
+
def mtime
|
888
|
+
File.mtime(@abspath.sub(/\/$/,''))
|
889
|
+
end
|
890
|
+
def ctime
|
891
|
+
File.ctime(@abspath.sub(/\/$/,''))
|
892
|
+
end
|
893
|
+
def atime
|
894
|
+
File.ctime(@abspath.sub(/\/$/,''))
|
895
|
+
end
|
896
|
+
def size
|
897
|
+
File.size(@abspath.sub(/\/$/,''))
|
898
|
+
end
|
899
|
+
|
900
|
+
def mtime_like_ls_l
|
901
|
+
# format mtime like ls -l
|
902
|
+
__fmt_like_ls_l( self.mtime )
|
903
|
+
end
|
904
|
+
|
905
|
+
def __fmt_like_ls_l(time)
|
906
|
+
if ( (Time.now - time) < 15811200 ) # == 86400*183: a half year
|
907
|
+
time.strftime('%b %d %H:%M')
|
908
|
+
else
|
909
|
+
time.strftime('%b %d %Y')
|
910
|
+
end
|
911
|
+
end
|
912
|
+
private :__fmt_like_ls_l
|
913
|
+
|
914
|
+
#################################
|
915
|
+
private
|
916
|
+
|
917
|
+
def __ftype(path, _depth=0)
|
918
|
+
# Same as File.ftype, but traces symbolic links
|
919
|
+
|
920
|
+
if /^http/ =~ path
|
921
|
+
if /\.(nc|ctl|ctrl|grib|cdf|hdf|dat|bin|gz|jg)$/i =~ path
|
922
|
+
ftype = 'file'
|
923
|
+
else
|
924
|
+
ftype = 'directory'
|
925
|
+
end
|
926
|
+
else
|
927
|
+
ftype = File.ftype(path)
|
928
|
+
if ftype == "link"
|
929
|
+
if _depth < 10 # == max_depth
|
930
|
+
begin
|
931
|
+
lkpath = File.readlink(path)
|
932
|
+
unless /^\// === lkpath
|
933
|
+
lkpath = File.dirname(path)+'/'+lkpath
|
934
|
+
end
|
935
|
+
ftype = __ftype( lkpath, _depth+1 )
|
936
|
+
rescue
|
937
|
+
nil # possibly a link to non-existent file
|
938
|
+
end
|
939
|
+
else
|
940
|
+
nil # Max depth exeeded: Link too long (possibly circular)
|
941
|
+
end
|
942
|
+
end
|
943
|
+
end
|
944
|
+
ftype
|
945
|
+
end
|
946
|
+
|
947
|
+
def __can_be_a_gdir(path)
|
948
|
+
ftype = __ftype(path)
|
949
|
+
if ftype=="directory" || ftype=="file" && GPhys::IO::file2type(path)
|
950
|
+
true
|
951
|
+
else
|
952
|
+
false
|
953
|
+
end
|
954
|
+
end
|
955
|
+
|
956
|
+
end # class GDir
|
957
|
+
end # module NumRu
|
958
|
+
|
959
|
+
|
960
|
+
###############################################
|
961
|
+
# test program usage
|
962
|
+
# % ruby gdir.rb [topdir]
|
963
|
+
# EXAMPLE
|
964
|
+
# % ruby gdir.rb
|
965
|
+
# % ruby gdir.rb ..
|
966
|
+
|
967
|
+
if __FILE__ == $0
|
968
|
+
|
969
|
+
include NumRu
|
970
|
+
|
971
|
+
def find_gphys(gdir)
|
972
|
+
gphyses = []
|
973
|
+
subdirs = gdir.list_dirs.collect{ |dnm| gdir[dnm] }
|
974
|
+
subdirs.each{ |subdir|
|
975
|
+
ary = find_gphys(subdir)
|
976
|
+
gphyses += ary if ary.length != 0
|
977
|
+
}
|
978
|
+
gdir.list_data.each{|var|
|
979
|
+
gp = gdir.data(var)
|
980
|
+
gphyses.push( gp )
|
981
|
+
}
|
982
|
+
gphyses
|
983
|
+
end
|
984
|
+
|
985
|
+
def find_txt(gdir)
|
986
|
+
texts = []
|
987
|
+
subdirs = gdir.list_dirs.collect{ |dnm| gdir[dnm] }
|
988
|
+
subdirs.each{ |subdir|
|
989
|
+
ary = find_txt(subdir)
|
990
|
+
texts += ary if ary.length != 0
|
991
|
+
}
|
992
|
+
gdir.list_texts.each{|var|
|
993
|
+
gp = gdir.text(var)
|
994
|
+
texts.push( gp )
|
995
|
+
}
|
996
|
+
texts
|
997
|
+
end
|
998
|
+
|
999
|
+
top = ARGV.shift || '.'
|
1000
|
+
GDir.top = top
|
1001
|
+
|
1002
|
+
gdir = GDir.new('/')
|
1003
|
+
#gdir = GDir.new('.') # same as above
|
1004
|
+
|
1005
|
+
print "*(test)* Set the top directory to #{top}\n"
|
1006
|
+
|
1007
|
+
p gdir.mtime
|
1008
|
+
p gdir.list_dirs
|
1009
|
+
gdir.list_dirs_v.each{|s| print s+"\n"}
|
1010
|
+
p gdir.list_texts
|
1011
|
+
gdir.list_texts_v.each{|s| print s+"\n"}
|
1012
|
+
p gdir.list_data
|
1013
|
+
gdir.list_data_v.each{|s| print s+"\n"}
|
1014
|
+
print gdir.path, ' ', gdir.name, "\n"
|
1015
|
+
# print gdir[gdir.list_dirs[0]].path, ' ', gdir[gdir.list_dirs[0]].name, "\n"
|
1016
|
+
# p gdir[gdir.list_dirs[0]]['.']['..']['..']
|
1017
|
+
|
1018
|
+
print "*(test)* Searching all NetCDF&GrADS files under the top dir...\n"
|
1019
|
+
gphyses = find_gphys(gdir)
|
1020
|
+
gphyses.each{ |gp|
|
1021
|
+
print gp.name, gp.shape_current.inspect, ' ', gp.data.file.path,"\n"
|
1022
|
+
}
|
1023
|
+
|
1024
|
+
print "*(test)* Searching all text files under the top dir...\n"
|
1025
|
+
find_txt(gdir).each{|txt| print txt.path,"\n"}
|
1026
|
+
|
1027
|
+
print "\n***(test)*** DODS access \n"
|
1028
|
+
gdir = GDir.new('http://davis-dods.rish.kyoto-u.ac.jp/cgi-bin/nph-dods/jmadata/gpv/latest/gpv')
|
1029
|
+
p gdir.ls
|
1030
|
+
gd2 = gdir.dir('latest/')
|
1031
|
+
p gd2.ls_l
|
1032
|
+
gd3 = gd2.dir('MSM00S.nc/')
|
1033
|
+
p gd3.ls_l
|
1034
|
+
GDir.top = 'http://davis-dods.rish.kyoto-u.ac.jp/cgi-bin/nph-dods/jmadata/gpv/latest/gpv'
|
1035
|
+
gdir = GDir.new('.')
|
1036
|
+
g2 = GDir.new('latest')
|
1037
|
+
p gdir.ls,g2.ls
|
1038
|
+
end
|