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,771 @@
|
|
1
|
+
=begin
|
2
|
+
= Gtool3 �`�� IO ���C�u�����[�i�Ƃ����Ă� O (����) �͂Ȃ��j
|
3
|
+
|
4
|
+
== ���t�@�C���i�i�q���t�@�C���j�ɂ���
|
5
|
+
|
6
|
+
���ϐ� GTAXDIR �ŁC���t�@�C���̂��肩���w�肷�邩,
|
7
|
+
Gtool3.gtaxdir= ���\�b�h���g���Ďw�肷��D
|
8
|
+
|
9
|
+
== Development Memo / �J������
|
10
|
+
|
11
|
+
�����i��ȏ�j�̕ϐ��̑g�̌J��Ԃ������肷��D����āC�w�b�_��ǂ��
|
12
|
+
�����āC�ϐ������CT,U,PS,T,..�ȂǂƓ����̂ɖ߂�����C���̎��_�� T,U,PS
|
13
|
+
��3�ϐ��̌J��Ԃ��ł���Ƃ݂Ȃ��D�������邱�ƂŁCGrADS �Ƃقړ����悤��
|
14
|
+
������悤�ɂȂ�D�Ȃ��C���ۂ� Gtool3 �t�@�C���͂��ׂĂ���ł�����͂��D
|
15
|
+
|
16
|
+
�G���f�B�A���̓u���b�N��肩�玩�����ʂ���D
|
17
|
+
|
18
|
+
|
19
|
+
|
20
|
+
=end
|
21
|
+
|
22
|
+
require "narray_miss"
|
23
|
+
require "date"
|
24
|
+
require "numru/gphys/unumeric"
|
25
|
+
|
26
|
+
module NumRu
|
27
|
+
|
28
|
+
module IndexMixin
|
29
|
+
def gen_idx(fst,lst,stp,len)
|
30
|
+
fst = 0 if fst.nil?
|
31
|
+
lst = len-1 if lst.nil?
|
32
|
+
stp = 1 if stp.nil?
|
33
|
+
lst += len if lst<0
|
34
|
+
idx = Array.new
|
35
|
+
fst.step(lst,stp){|i| idx.push(i)}
|
36
|
+
idx
|
37
|
+
end
|
38
|
+
|
39
|
+
def slicer2idx(sl,len)
|
40
|
+
sl = slicer_negproc(sl,len)
|
41
|
+
case sl
|
42
|
+
when NArray
|
43
|
+
if sl.length == len and sl.typecode == NArray::BYTE
|
44
|
+
sl.where
|
45
|
+
else
|
46
|
+
sl
|
47
|
+
end
|
48
|
+
when Array
|
49
|
+
NArray[*sl]
|
50
|
+
when true
|
51
|
+
NArray.int(len).indgen!
|
52
|
+
when Integer
|
53
|
+
sl
|
54
|
+
when Range
|
55
|
+
NArray[*sl.to_a]
|
56
|
+
when Hash
|
57
|
+
rg = sl.first[0]
|
58
|
+
fst = rg.first
|
59
|
+
lenr = (rg.last - fst + (rg.exclude_end? ? 0 : 1))
|
60
|
+
stp = sl.first[1]
|
61
|
+
len = (lenr-1)/stp+1
|
62
|
+
NArray.int(len).indgen!(fst,stp)
|
63
|
+
else
|
64
|
+
raise ArgumentError, "Unsupported slicer #{sl.inspect}"
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
68
|
+
def slicer_minmax(sl,len)
|
69
|
+
sl = slicer_negproc(sl,len)
|
70
|
+
if sl.is_a?(Array)
|
71
|
+
sl = NArray[*sl]
|
72
|
+
end
|
73
|
+
case sl
|
74
|
+
when NArray
|
75
|
+
if sl.length == len and sl.typecode == NArray::BYTE
|
76
|
+
w = sl.where
|
77
|
+
[ w[0], w[-1] ]
|
78
|
+
else
|
79
|
+
[ sl.min, sl.max ]
|
80
|
+
end
|
81
|
+
when true
|
82
|
+
[ 0, len-1 ]
|
83
|
+
when Integer
|
84
|
+
[sl, sl]
|
85
|
+
when Range
|
86
|
+
[ sl.first, (sl.exclude_end? ? sl.last-1 : sl.last ) ]
|
87
|
+
when Hash
|
88
|
+
sl = slicer2idx(sl,len)
|
89
|
+
[ sl.min, sl.max ]
|
90
|
+
else
|
91
|
+
raise ArgumentError, "Unsupported slicer #{sl.inspect}"
|
92
|
+
end
|
93
|
+
end
|
94
|
+
|
95
|
+
def slicer_len(sl,len)
|
96
|
+
sl = slicer_negproc(sl,len)
|
97
|
+
case sl
|
98
|
+
when NArray
|
99
|
+
if sl.length == len and sl.typecode == NArray::BYTE
|
100
|
+
sl.count_true
|
101
|
+
else
|
102
|
+
sl.length
|
103
|
+
end
|
104
|
+
when Array
|
105
|
+
sl.length
|
106
|
+
when true
|
107
|
+
len
|
108
|
+
when Integer
|
109
|
+
1
|
110
|
+
when Range
|
111
|
+
sl.length
|
112
|
+
when Hash
|
113
|
+
sl.first[0].length / sl.first[1]
|
114
|
+
else
|
115
|
+
raise ArgumentError, "Unsupported slicer #{sl.inspect}"
|
116
|
+
end
|
117
|
+
end
|
118
|
+
|
119
|
+
def slicer_negproc(sl,len)
|
120
|
+
case sl
|
121
|
+
when NArray
|
122
|
+
if sl.min < 0
|
123
|
+
sls = sl.dup
|
124
|
+
sls[sl.lt(0)] += len
|
125
|
+
sls
|
126
|
+
else
|
127
|
+
sl
|
128
|
+
end
|
129
|
+
when Array
|
130
|
+
sl.collect{|i| i>=0 ? i : i+len}
|
131
|
+
when true
|
132
|
+
(0...len).collect{|i| i}
|
133
|
+
when Integer
|
134
|
+
sl += len if sl<0
|
135
|
+
sl
|
136
|
+
when Range
|
137
|
+
range_negproc(sl,len)
|
138
|
+
when Hash
|
139
|
+
{ range_negproc(sl.first[0],len) => sl.first[1] }
|
140
|
+
else
|
141
|
+
raise ArgumentError, "Unsupported slicer #{sl.inspect}"
|
142
|
+
end
|
143
|
+
end
|
144
|
+
|
145
|
+
def range_negproc(rg,len)
|
146
|
+
if ( (f=rg.first) < 0 or rg.last < 0 )
|
147
|
+
f += len if f < 0
|
148
|
+
l += len if (l=rg.last) < 0
|
149
|
+
if rg.exclude_end?
|
150
|
+
f...l
|
151
|
+
else
|
152
|
+
f..l
|
153
|
+
end
|
154
|
+
else
|
155
|
+
rg
|
156
|
+
end
|
157
|
+
end
|
158
|
+
|
159
|
+
def rubber_expansion( args, rank )
|
160
|
+
if (id = args.index(false)) # substitution into id
|
161
|
+
# false is incuded
|
162
|
+
alen = args.length
|
163
|
+
if args.rindex(false) != id
|
164
|
+
raise ArguemntError,"only one rubber dimension is permitted"
|
165
|
+
elsif alen > rank+1
|
166
|
+
raise ArgumentError, "too many args"
|
167
|
+
end
|
168
|
+
ar = ( id!=0 ? args[0..id-1] : [] )
|
169
|
+
args = ar + [true]*(rank-alen+1) + args[id+1..-1]
|
170
|
+
end
|
171
|
+
args
|
172
|
+
end
|
173
|
+
end
|
174
|
+
|
175
|
+
class Gtool3
|
176
|
+
|
177
|
+
include IndexMixin
|
178
|
+
|
179
|
+
FLDLEN = 16 # length of each header element
|
180
|
+
HEADLEN = 1024 # length a gtool3 header (64*16)
|
181
|
+
NFLD = 64 # number of fields
|
182
|
+
RLEN = {"UR4"=>4,"UR"=>4,"UR8"=>8} # length of float types in bytes
|
183
|
+
NATYP = {"UR4"=>NArray::SFLOAT,"UR"=>NArray::SFLOAT,"UR8"=>NArray::DFLOAT}
|
184
|
+
AXES_IGNORED = ["SFC1"] # special treatment (must be one-element axes)
|
185
|
+
|
186
|
+
@@default_calender = "360_day"
|
187
|
+
|
188
|
+
@@max_delimlen = 8 # maximum length of fortran unformated IO delimiter.
|
189
|
+
# actual length is found heulistically from files.
|
190
|
+
@@gtaxdir = ENV["GTAXDIR"]
|
191
|
+
|
192
|
+
@@fmtid = /(.*) (9009|9010)/
|
193
|
+
|
194
|
+
@@default_endian = :big
|
195
|
+
|
196
|
+
@@hditems = %w!IDFM DSET ITEM EDIT1 EDIT2 EDIT3 EDIT4 EDIT5 EDIT6 EDIT7 EDIT8 FNUM DNUM TITL1 TITL2 UNIT ETTL1 ETTL2 ETTL3 ETTL4 ETTL5 ETTL6 ETTL7 ETTL8 TIME UTIM DATE TDUR AITM1 ASTR1 AEND1 AITM2 ASTR2 AEND2 AITM3 ASTR3 AEND3 DFMT MISS DMIN DMAX DIVS DIVL STYP OPT1 OPT2 OPT3 MEMO1 MEMO2 MEMO3 MEMO4 MEMO5 MEMO6 MEMO7 MEMO8 MEMO9 MEMO10 MEMO11 MEMO12 CDATE CSIGN MDATE MSIGN SIZE!
|
197
|
+
@@intitems = %w!FNUM DNUM TIME TDUR ASTR1 AEND1 ASTR2 AEND2 ASTR3 AEND3 STYP SIZE!
|
198
|
+
@@fltitems = %w!MISS DMIN DMAX DIVS DIVL!
|
199
|
+
|
200
|
+
class << self
|
201
|
+
alias open new
|
202
|
+
|
203
|
+
def is_a_Gtool3?(path)
|
204
|
+
file = File.open(path,"rb")
|
205
|
+
head = file.read(FLDLEN + @@max_delimlen)
|
206
|
+
file.close
|
207
|
+
(@@fmtid=~head) and delimiter=head[0,$1.length]
|
208
|
+
end
|
209
|
+
|
210
|
+
def gtaxdir=(path)
|
211
|
+
@@gtaxdir = path
|
212
|
+
end
|
213
|
+
|
214
|
+
def gtaxdir
|
215
|
+
@@gtaxdir
|
216
|
+
end
|
217
|
+
|
218
|
+
def default_calender=(str)
|
219
|
+
@@default_calender = str
|
220
|
+
end
|
221
|
+
def default_calender
|
222
|
+
@@default_calender
|
223
|
+
end
|
224
|
+
end
|
225
|
+
|
226
|
+
def initialize(path, mode="r")
|
227
|
+
case(mode)
|
228
|
+
when /^r/
|
229
|
+
(delim=Gtool3.is_a_Gtool3?(path)) or raise("not a Gtool3 file: #{path}")
|
230
|
+
@file = File.open(path, "rb")
|
231
|
+
@delimlen, @bigendian = interpret_delim(delim)
|
232
|
+
@headlen = HEADLEN + @delimlen*2
|
233
|
+
@vars = @varh = @timeblock_lenb = nil # to be set in parse_file
|
234
|
+
@calender = @@default_calender # can be modified with Gtool3#calender
|
235
|
+
parse_file
|
236
|
+
else
|
237
|
+
raise ArgumentError, "Unsupported IO mode: #{mode}"
|
238
|
+
end
|
239
|
+
end
|
240
|
+
|
241
|
+
def calender=(str)
|
242
|
+
@calender = str
|
243
|
+
end
|
244
|
+
def calender
|
245
|
+
@calender
|
246
|
+
end
|
247
|
+
|
248
|
+
def close
|
249
|
+
@file.close
|
250
|
+
end
|
251
|
+
|
252
|
+
def path
|
253
|
+
@file.path
|
254
|
+
end
|
255
|
+
|
256
|
+
def nvars
|
257
|
+
@variables.length
|
258
|
+
end
|
259
|
+
|
260
|
+
def var( varname )
|
261
|
+
Gtool3Var.new(self,varname)
|
262
|
+
end
|
263
|
+
|
264
|
+
def var_names
|
265
|
+
@vars.collect{|var| var["ITEM"]} # use @vars to reflect the order in file
|
266
|
+
end
|
267
|
+
|
268
|
+
def has_var?(varname)
|
269
|
+
@varh.has_key?(varname)
|
270
|
+
end
|
271
|
+
|
272
|
+
def inspect
|
273
|
+
"<#{self.class}:#{path}>"
|
274
|
+
end
|
275
|
+
|
276
|
+
=begin
|
277
|
+
# subsetting of each dimension must be specified either
|
278
|
+
# with idx or (fst,lst,stp) -- idx has a higher precedence
|
279
|
+
def get(name, it, fst=[], lst=[], stp=[], idx=[])
|
280
|
+
var = @varh[name] or raise(ArgumentError,"vardiable #{name} is not found")
|
281
|
+
ld = var[:rankb] - 1 # last dimension of the block
|
282
|
+
id = ( idx[ld] || gen_idx(fst[ld],lst[ld],stp[ld],var[:shapeb][ld]) )
|
283
|
+
slb = 1
|
284
|
+
bl = @timeblock_lenb
|
285
|
+
(0..ld-1).each{|d| slb *= var[:shapeb][d]}
|
286
|
+
slb *= var[:rlen] # slb --> length of subblocks
|
287
|
+
id.each do |k|
|
288
|
+
@file.seek(it*bl + slb*k)
|
289
|
+
buf = @file.read(slb)
|
290
|
+
|
291
|
+
end
|
292
|
+
end
|
293
|
+
=end
|
294
|
+
|
295
|
+
# to redirect Gtool3Var#[sel] (the subsetting method) or Gtool3Var#get
|
296
|
+
# (for sel==nil)
|
297
|
+
def get(name, *sel)
|
298
|
+
var = @varh[name] or raise(ArgumentError,"vardiable #{name} is not found")
|
299
|
+
rk = var[:rank]
|
300
|
+
if sel.empty?
|
301
|
+
sel = [true]*rk
|
302
|
+
else
|
303
|
+
sel = rubber_expansion( sel, rk )
|
304
|
+
end
|
305
|
+
|
306
|
+
sb = var[:start_byte]
|
307
|
+
lb = @timeblock_lenb
|
308
|
+
|
309
|
+
if var[:time_seq]
|
310
|
+
tidx = slicer2idx( sel[rk-1], var[:shape][rk-1] )
|
311
|
+
#val = NArray.new(var[:natyp], *var[:shape])
|
312
|
+
val = nil
|
313
|
+
selb = sel[0...var[:rankb]]
|
314
|
+
if tidx.is_a?(Integer)
|
315
|
+
val = read_block(sb+tidx*lb,selb,var[:natyp],var[:rlen],var[:shapeb])
|
316
|
+
else
|
317
|
+
for i in 0...tidx.length
|
318
|
+
it = tidx[i]
|
319
|
+
vb = read_block(sb+it*lb,selb,var[:natyp],var[:rlen],var[:shapeb])
|
320
|
+
if val.nil?
|
321
|
+
shp = vb.shape + [tidx.length]
|
322
|
+
val = NArray.new(var[:natyp], *shp)
|
323
|
+
end
|
324
|
+
val[false,i] = vb
|
325
|
+
end
|
326
|
+
end
|
327
|
+
else
|
328
|
+
val = read_block(sb,sel,var[:natyp],var[:rlen],var[:shapeb])
|
329
|
+
end
|
330
|
+
NArrayMiss.to_nam_no_dup(val,val.ne(var["MISS"]))
|
331
|
+
end
|
332
|
+
|
333
|
+
def read_block(strb,selb,natyp,rlen,shapeb)
|
334
|
+
##print "***rb*** #{strb} #{selb.inspect}\n"
|
335
|
+
zidx = slicer2idx(selb[-1],shapeb[-1]) # z simbolically represents the last dim of block
|
336
|
+
if zidx.is_a?(Integer)
|
337
|
+
min = max = zidx
|
338
|
+
zidxoff = 0
|
339
|
+
else
|
340
|
+
min = zidx.min
|
341
|
+
max = zidx.max
|
342
|
+
zidxoff = zidx.collect{|i| i-min}
|
343
|
+
end
|
344
|
+
for i in 0...shapeb.length-1
|
345
|
+
selb[i] = slicer2idx(selb[i],shapeb[i]) if selb[i].is_a?(Hash)
|
346
|
+
end
|
347
|
+
|
348
|
+
#min,max = slicer_minmax(selb[-1]) # first and last of last dim in block
|
349
|
+
subblen = product(shapeb[0..-2])
|
350
|
+
offs = min*subblen*rlen
|
351
|
+
len = (max-min+1)*subblen*rlen # ie, read by [false,min..max]
|
352
|
+
@file.seek(strb+offs+@delimlen)
|
353
|
+
buf = @file.read(len)
|
354
|
+
zsubsh = shapeb[0..-2] + [max-min+1]
|
355
|
+
#p "$$$",len,product(zsubsh)*rlen,rlen,natyp
|
356
|
+
zsubsel = selb[0..-2] + [ zidxoff ]
|
357
|
+
#p "$$$",zidx, zsubsh,zsubsel
|
358
|
+
allint = true; zsubsel.each{|s| allint = false unless s.is_a?(Integer)}
|
359
|
+
zsubsel[-1] = [zsubsel[-1]..zsubsel[-1]] if allint
|
360
|
+
na = NArray.to_na(buf, natyp, *zsubsh)[*zsubsel]
|
361
|
+
if @bigendian
|
362
|
+
na.ntoh
|
363
|
+
else
|
364
|
+
na.vtoh
|
365
|
+
end
|
366
|
+
end
|
367
|
+
|
368
|
+
def varinfo(name)
|
369
|
+
@varh[name]
|
370
|
+
end
|
371
|
+
|
372
|
+
=begin
|
373
|
+
def get_performance_test
|
374
|
+
var = @vars[0]
|
375
|
+
sb = var[:start_byte]
|
376
|
+
nz = var[:shapeb][2]
|
377
|
+
nxy = var[:shapeb][0] * var[:shapeb][1]
|
378
|
+
bl = @timeblock_lenb
|
379
|
+
sz = File.size(@file.path)
|
380
|
+
nt = sz/bl
|
381
|
+
p nt,nz,nxy
|
382
|
+
for it in 0...nt
|
383
|
+
@file.seek(it*bl + sb)
|
384
|
+
for iz in 0..nz
|
385
|
+
#test 1
|
386
|
+
@file.read(nxy*RLEN[var["DFMT"]])
|
387
|
+
#test 2
|
388
|
+
# @file.read(4)
|
389
|
+
# @file.seek(nxy*RLEN[var["DFMT"]]-4, IO::SEEK_CUR)
|
390
|
+
#test 3
|
391
|
+
(nxy/20).times{@file.read(4*20)}
|
392
|
+
end
|
393
|
+
end
|
394
|
+
end
|
395
|
+
=end
|
396
|
+
|
397
|
+
########## private methods #############
|
398
|
+
private
|
399
|
+
def parse_file
|
400
|
+
@vars = Array.new
|
401
|
+
@varh = Hash.new # same as @vars but is a Hash to speed up to find
|
402
|
+
start_byte = 0
|
403
|
+
time_seq = false # initial setting
|
404
|
+
while(varinfo = read_header(@file)) do
|
405
|
+
iv = @vars.length
|
406
|
+
if iv==0 or @vars[-1]["ITEM"] != varinfo["ITEM"]
|
407
|
+
start_byte += @headlen
|
408
|
+
varinfo[:start_byte] = start_byte # start byte in time block
|
409
|
+
varinfo[:axes] = interpret_axes(varinfo)
|
410
|
+
varinfo[:rankb] = varinfo[:axes].length # rank of a block
|
411
|
+
varinfo[:shapeb] = varinfo[:axes].collect{|v| v["LOC"][:val].length}
|
412
|
+
@vars.push(varinfo)
|
413
|
+
varinfo[:rlen] = RLEN[varinfo["DFMT"]] or raise("Unsupported numerical format")
|
414
|
+
#p "*****",varinfo[:rlen]
|
415
|
+
varinfo[:natyp] = NATYP[varinfo["DFMT"]]
|
416
|
+
@varh[ varinfo["ITEM"] ] = varinfo
|
417
|
+
start_byte += skip_a_data_block(varinfo, @file) # shape�ƌ^�̗��p�ɂ�����ׂ�
|
418
|
+
else
|
419
|
+
time_seq = true # second turn --> regarded as a time sequence
|
420
|
+
break
|
421
|
+
end
|
422
|
+
end
|
423
|
+
@vars.each{|v| v[:time_seq] = time_seq} # for all var
|
424
|
+
@vars.each{|v| v[:rank] = (time_seq ? v[:rankb]+1 : v[:rankb])}
|
425
|
+
@timeblock_lenb = start_byte # lengh of a time block in bytes
|
426
|
+
if time_seq
|
427
|
+
bl = @timeblock_lenb
|
428
|
+
sz = File.size(@file.path)
|
429
|
+
nt = sz/bl
|
430
|
+
@vars.each{|v| v[:shape] = v[:shapeb] + [nt]}
|
431
|
+
timax = interpret_time_axis(varinfo)
|
432
|
+
@vars.each{|v| v[:axes].push(timax)}
|
433
|
+
else
|
434
|
+
@vars.each{|v| v[:shape] = v[:shapeb]}
|
435
|
+
end
|
436
|
+
|
437
|
+
end
|
438
|
+
|
439
|
+
def interpret_delim(delim)
|
440
|
+
length = delim.length
|
441
|
+
case length
|
442
|
+
when 0
|
443
|
+
bigendian = ( @@default_endian == :big )
|
444
|
+
when 4
|
445
|
+
if delim.unpack("N").first == HEADLEN
|
446
|
+
bigendian = true
|
447
|
+
elsif delim.unpack("V").first == HEADLEN
|
448
|
+
bigendian = false
|
449
|
+
else
|
450
|
+
raise "Cannot interpret the delimiter #{delim.inspect}"
|
451
|
+
end
|
452
|
+
when 8
|
453
|
+
if delim[4,4].unpack("N").first == HEADLEN
|
454
|
+
bigendian = true
|
455
|
+
elsif delim[0,4].unpack("V").first == HEADLEN
|
456
|
+
bigendian = false
|
457
|
+
else
|
458
|
+
raise "Cannot interpret the delimiter #{delim.inspect}"
|
459
|
+
end
|
460
|
+
else
|
461
|
+
raise "Unsupported fortran sequential IO delimiter length: #{length}"
|
462
|
+
end
|
463
|
+
[length, bigendian]
|
464
|
+
end
|
465
|
+
|
466
|
+
def read_header(file)
|
467
|
+
hdstr = file.read(@headlen)
|
468
|
+
if hdstr and (@@fmtid=~hdstr)
|
469
|
+
hdstr = hdstr[@delimlen, HEADLEN] if @delimlen!=0
|
470
|
+
head = Hash.new
|
471
|
+
(0...NFLD).each do |i|
|
472
|
+
head[@@hditems[i]] = hdstr[i*FLDLEN,FLDLEN].strip
|
473
|
+
end
|
474
|
+
@@intitems.each{|k| head[k] = head[k].to_i}
|
475
|
+
@@fltitems.each{|k| head[k] = head[k].to_f}
|
476
|
+
head["TITLE"] = head.delete("TITL1") + head.delete("TITL2")
|
477
|
+
head
|
478
|
+
else
|
479
|
+
nil
|
480
|
+
end
|
481
|
+
end
|
482
|
+
|
483
|
+
def read_axis_data(file, len, skip, fmt)
|
484
|
+
file.seek(@delimlen + RLEN[fmt]*skip, IO::SEEK_CUR)
|
485
|
+
val = NArray.to_na(file.read(RLEN[fmt]*len),NATYP[fmt])
|
486
|
+
file.seek(@delimlen, IO::SEEK_CUR)
|
487
|
+
if @bigendian
|
488
|
+
val.ntoh
|
489
|
+
else
|
490
|
+
val.vtoh
|
491
|
+
end
|
492
|
+
end
|
493
|
+
|
494
|
+
def skip_a_data_block(head, file)
|
495
|
+
len = head["SIZE"]
|
496
|
+
b = RLEN[head["DFMT"]] or raise("Unsupported numerical format")
|
497
|
+
lenb = len * b + @delimlen*2
|
498
|
+
file.seek(lenb, IO::SEEK_CUR)
|
499
|
+
lenb
|
500
|
+
end
|
501
|
+
|
502
|
+
## Use head["SIZE"] instead
|
503
|
+
# def datalen(head)
|
504
|
+
# shape3 = [ head["AEND1"] - head["ASTR1"] + 1, \
|
505
|
+
# head["AEND2"] - head["ASTR2"] + 1, \
|
506
|
+
# head["AEND3"] - head["ASTR3"] + 1 ]
|
507
|
+
# datalen = shape3[0] * shape3[1] * shape3[2]
|
508
|
+
# end
|
509
|
+
|
510
|
+
def interpret_axes(head)
|
511
|
+
axes = Array.new
|
512
|
+
["AITM1","AITM2","AITM3"].each do |dnm|
|
513
|
+
if ( (axnm = head[dnm]) != "" and !AXES_IGNORED.include?(axnm) )
|
514
|
+
ax = Hash.new
|
515
|
+
dim =dnm.sub(/^AITM/,"")
|
516
|
+
fst = head["ASTR#{dim}"]
|
517
|
+
len = head["AEND#{dim}"]-fst+1
|
518
|
+
["LOC","WGT"].each do |lw|
|
519
|
+
axv = ax[lw] = {"ITEM" => axnm}
|
520
|
+
if ( File.exist?(fn=File.dirname(@file.path)+"/GTAX#{lw}."+axnm) or
|
521
|
+
@@gtaxdir and File.exist?(fn=File.expand_path(@@gtaxdir)+"/GTAX#{lw}."+axnm) )
|
522
|
+
File.open(fn,"rb"){|axfile|
|
523
|
+
hd = read_header(axfile)
|
524
|
+
["UNIT","TITLE","DMIN","DMAX","STYP"].each{|k| axv[k] = hd[k]}
|
525
|
+
axv[:val] = read_axis_data(axfile,len,fst-1,hd["DFMT"])
|
526
|
+
}
|
527
|
+
elsif @@gtaxdir.nil?
|
528
|
+
#raise( "GTAX#{lw}.#{axnm} is not found. You may need to set " +
|
529
|
+
# "a directory using Gtool3.gtaxdir=" )
|
530
|
+
warn "#{__FILE__}:#{__LINE__}: GTAX#{lw}.#{axnm} is not found --> Use dummy indices (len:#{len}) (You may need to specify a directory by setting the environmental variable GTAXDIR or by using Gtool3.gtaxdir= )"
|
531
|
+
na = NArray.float(len)
|
532
|
+
axv[:val] = ( lw=="LOC" ? na.indgen!(fst-1) : na.fill(1) )
|
533
|
+
end
|
534
|
+
end
|
535
|
+
axes.push(ax)
|
536
|
+
end
|
537
|
+
end
|
538
|
+
axes
|
539
|
+
end
|
540
|
+
|
541
|
+
def interpret_time_axis(head)
|
542
|
+
time_ax = Hash.new
|
543
|
+
t0 = head["TIME"]
|
544
|
+
units = Units[head["UTIM"].downcase]
|
545
|
+
t0d = units.convert2(t0,"day")
|
546
|
+
if /^(\d\d\d\d)(\d\d)(\d\d) *(\d\d)(\d\d)(\d\d)/ =~ head["DATE"]
|
547
|
+
y4 = $1.to_i
|
548
|
+
mon = $2.to_i
|
549
|
+
day = $3.to_i
|
550
|
+
hr = $4.to_i
|
551
|
+
min = $5.to_i
|
552
|
+
sec = $6.to_i
|
553
|
+
date0 = DateTime.new(y4,mon,day,hr,min,sec)
|
554
|
+
un0 = UNumeric[ -t0d, Units["days since #{date0.to_s}"] ]
|
555
|
+
date_origin = un0.to_datetime(0.0, @calendar)
|
556
|
+
if date_origin
|
557
|
+
units = Units[ units.to_s + " since "+date_origin.to_s ]
|
558
|
+
end
|
559
|
+
end
|
560
|
+
timax = {"LOC"=>{"UNIT"=>units.to_s, "TITLE"=>"time", "ITEM"=>"time"}}
|
561
|
+
timax["LOC"][:val] = Gtool3TimeVal.new(@vars[0][:shape][-1],
|
562
|
+
@file, @delimlen, @timeblock_lenb)
|
563
|
+
timax
|
564
|
+
end
|
565
|
+
|
566
|
+
def product(ary)
|
567
|
+
prd = 1
|
568
|
+
ary.each{|x| prd *= x}
|
569
|
+
prd
|
570
|
+
end
|
571
|
+
end
|
572
|
+
|
573
|
+
class Gtool3Var
|
574
|
+
@@attkeys = %w!DSET ITEM TITLE UNIT TIME DATE UTIM TDUR MISS CDATE CSIGN MDATE MSIGN!
|
575
|
+
|
576
|
+
def initialize(file,name)
|
577
|
+
case file
|
578
|
+
when String
|
579
|
+
file = Gtool3.open(file)
|
580
|
+
when Gtool3
|
581
|
+
else
|
582
|
+
raise ArgumentError, "not a Gtool3 or a String #{file.inspect}"
|
583
|
+
end
|
584
|
+
raise("Var '#{name}' is not in (#{file.path})") unless file.has_var?(name)
|
585
|
+
@file = file
|
586
|
+
@name = name
|
587
|
+
@varinfo = file.varinfo(name)
|
588
|
+
end
|
589
|
+
|
590
|
+
def [](*sel)
|
591
|
+
@file.get(@name,*sel)
|
592
|
+
end
|
593
|
+
|
594
|
+
def get
|
595
|
+
self[]
|
596
|
+
end
|
597
|
+
|
598
|
+
def name
|
599
|
+
@name
|
600
|
+
end
|
601
|
+
|
602
|
+
def typecode
|
603
|
+
@varinfo[:natyp]
|
604
|
+
end
|
605
|
+
|
606
|
+
def rank
|
607
|
+
@varinfo[:rank]
|
608
|
+
end
|
609
|
+
|
610
|
+
def dim_names
|
611
|
+
@varinfo[:axes].collect{|ax| ax["ITEM"]}
|
612
|
+
end
|
613
|
+
|
614
|
+
def shape
|
615
|
+
@varinfo[:shape].dup
|
616
|
+
end
|
617
|
+
alias shape_current shape
|
618
|
+
|
619
|
+
def shape_ul0
|
620
|
+
if @varinfo[:time_seq]
|
621
|
+
sh = @varinfo[:shape].dup
|
622
|
+
sh[-1] = 0
|
623
|
+
sh
|
624
|
+
else
|
625
|
+
@varinfo[:shape].dup
|
626
|
+
end
|
627
|
+
end
|
628
|
+
|
629
|
+
def file
|
630
|
+
@file
|
631
|
+
end
|
632
|
+
|
633
|
+
def attr
|
634
|
+
att = Hash.new
|
635
|
+
@@attkeys.each{|k| att[k] = @varinfo[k]}
|
636
|
+
att
|
637
|
+
end
|
638
|
+
|
639
|
+
def axis(d)
|
640
|
+
@varinfo[:axes][d]
|
641
|
+
end
|
642
|
+
|
643
|
+
end
|
644
|
+
|
645
|
+
|
646
|
+
# Behave like a NArray (by using method_missing)
|
647
|
+
class Gtool3TimeVal
|
648
|
+
|
649
|
+
include IndexMixin
|
650
|
+
|
651
|
+
def initialize(len, file, delimlen, timblen)
|
652
|
+
@length = len
|
653
|
+
@boffset = 24*Gtool3::FLDLEN + delimlen
|
654
|
+
@timeblen = timblen
|
655
|
+
@file = file
|
656
|
+
@val = nil
|
657
|
+
end
|
658
|
+
|
659
|
+
attr_reader :length, :file
|
660
|
+
|
661
|
+
def get
|
662
|
+
if @val.nil?
|
663
|
+
@val = NArray.float(@length)
|
664
|
+
for i in 0...@length
|
665
|
+
@file.seek( @boffset + i*@timeblen )
|
666
|
+
@val[i] = @file.read(Gtool3::FLDLEN).to_i
|
667
|
+
end
|
668
|
+
end
|
669
|
+
@val
|
670
|
+
end
|
671
|
+
|
672
|
+
@@na_methods = Hash.new # Hash for fast lookup
|
673
|
+
NArray.float(1).methods.each{|nm| @@na_methods[nm.to_sym] = true}
|
674
|
+
|
675
|
+
def [](arg)
|
676
|
+
sl = slicer2idx(arg,@length)
|
677
|
+
if @val.nil? && sl.length <= @length/20
|
678
|
+
# if the request is only for a small portion, it would
|
679
|
+
# be better just read it, rather than to put data in cache.
|
680
|
+
val = NArray.float(@length)
|
681
|
+
for i in sl
|
682
|
+
@file.seek( @boffset + i*@timeblen )
|
683
|
+
val[i] = @file.read(Gtool3::FLDLEN).to_i
|
684
|
+
end
|
685
|
+
val
|
686
|
+
else
|
687
|
+
get[sl]
|
688
|
+
end
|
689
|
+
end
|
690
|
+
|
691
|
+
def method_missing(name, *args)
|
692
|
+
if @@na_methods[name]
|
693
|
+
get.__send__(name, *args)
|
694
|
+
else
|
695
|
+
super(name, *args)
|
696
|
+
end
|
697
|
+
end
|
698
|
+
end
|
699
|
+
|
700
|
+
end
|
701
|
+
|
702
|
+
if $0 == __FILE__
|
703
|
+
include NumRu
|
704
|
+
Gtool3.gtaxdir = File.expand_path("~/dennou/GTAXDIR")
|
705
|
+
path = ARGV[0]
|
706
|
+
varname = ARGV[1] or raise("Need two args")
|
707
|
+
file = Gtool3.open(File.expand_path(path))
|
708
|
+
#file.get_performance_test
|
709
|
+
#p file.get(varname,false).mean(0)
|
710
|
+
p file, file.var_names
|
711
|
+
p file.varinfo(varname)
|
712
|
+
var = file.var(varname)
|
713
|
+
# p var[] #.mean(0)
|
714
|
+
# p var.axis(0), var.attr
|
715
|
+
# p "******"
|
716
|
+
# p var.shape
|
717
|
+
# p var[0..4,0..2,0..2,0]
|
718
|
+
# p var[{0..4,2},{0..2,2},{0..3,2},0]
|
719
|
+
# p var[0,2,0,0]
|
720
|
+
(0...var.rank).each{|i| p var.axis(i)}
|
721
|
+
tax = var.axis(-1)
|
722
|
+
tv = tax["LOC"][:val]
|
723
|
+
p tv.get, tv.length, tv[0], tv[-1]
|
724
|
+
end
|
725
|
+
|
726
|
+
=begin
|
727
|
+
1 & IDFM & I10 #& �t�H�[�}�b�gid & 9009
|
728
|
+
2 & DSET & A16 #& �f�[�^�Z�b�g�� & AP01
|
729
|
+
3 & ITEM & A16 #& ���ʖ���(�ϐ���)& TMP
|
730
|
+
4 & EDIT1 & A16 #& �ҏW���L��(1) & TM1D
|
731
|
+
5 & EDIT2 & A16 #& �ҏW���L��(2) & XFK1
|
732
|
+
...
|
733
|
+
11 & EDIT8 & A16 #& �ҏW���L��(8) &
|
734
|
+
12 & FNUM & I10 #& �t�@�C���ԍ� & 1
|
735
|
+
13 & DNUM & I10 #& �f�[�^�ԍ� & 100
|
736
|
+
14 & TITL1 & A16 #& �^�C�g�� & Temperature
|
737
|
+
15 & TITL2 & A16 #& \ \ �V \ \ ���� &
|
738
|
+
16 & UNIT & A16 #& �P�� & K
|
739
|
+
17 & ETTL1 & A16 #& �ҏW�^�C�g��(1) & Dayly mean
|
740
|
+
18 & ETTL2 & A16 #& �ҏW�^�C�g��(2) & filter (X)
|
741
|
+
...
|
742
|
+
24 & ETTL8 & A16 #& �ҏW�^�C�g��(8) &
|
743
|
+
25 & TIME & I10 #& ����(�ʂ�) & 18769650900
|
744
|
+
27 & UTIM & A16 #& �����P�� & SEC
|
745
|
+
26 & DATE & A16 #& ����(yyyymmddhhmmss) & 19900813122800
|
746
|
+
28 & TDUR & I10 #& �f�[�^��\���� & 3600
|
747
|
+
29 & AITM1 & A16 #& ��1�̊i�q���ʖ��� & GLON128
|
748
|
+
30 & ASTR1 & I10 #& ��1�̊i�q�ԍ��n�� & 1
|
749
|
+
31 & AEND1 & I10 #& ��1�̊i�q�ԍ��I�� & 128
|
750
|
+
32 & AITM2 & A16 #& ��2�̊i�q���ʖ��� & GGLA64
|
751
|
+
33 & ASTR2 & I10 #& ��2�̊i�q�ԍ��n�� & 1
|
752
|
+
34 & AEND2 & I10 #& ��2�̊i�q�ԍ��I�� & 64
|
753
|
+
35 & AITM3 & A16 #& ��3�̊i�q���ʖ��� & SIGA12
|
754
|
+
36 & ASTR3 & I10 #& ��3�̊i�q�ԍ��n�� & 1
|
755
|
+
37 & AEND3 & I10 #& ��3�̊i�q�ԍ��I�� & 12
|
756
|
+
38 & DFMT & A16 #& �f�[�^�t�H�[�}�b�g & (32F12.5) or UR4
|
757
|
+
39 & MISS & E15.7 #& �����l�̒l & -9999.
|
758
|
+
40 & DMIN & E15.7 #& �����W(�ŏ�) & 100.
|
759
|
+
41 & DMAX & E15.7 #& �����W(�ő�) & 300.
|
760
|
+
42 & DIVS & E15.7 #& �Ԋu(��) & 10.
|
761
|
+
43 & DIVL & E15.7 #& �Ԋu(��) & 50.
|
762
|
+
44 & STYP & I10 #& �X�P�[�����O�^�C�v & 1
|
763
|
+
45--47& OPTNx & A16 #& �� &
|
764
|
+
48--59& MEMOxx & A16 #& ���� &
|
765
|
+
60 & CDATE & A16 #& �f�[�^�쐬���t & 19900813122800
|
766
|
+
61 & CSIGN & A16 #& �f�[�^�쐬�� & SWAMP
|
767
|
+
62 & MDATE & A16 #& �f�[�^�ύX���t & 19900926225422
|
768
|
+
63 & MSIGN & A16 #& �f�[�^�ύX�� & SWAMP
|
769
|
+
64 & SIZE & I10 #& �z��̃T�C�Y & 98304
|
770
|
+
|
771
|
+
=end
|