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,800 @@
|
|
1
|
+
require "numru/gphys/gphys"
|
2
|
+
require "numru/gphys/gphys_io_common"
|
3
|
+
|
4
|
+
=begin
|
5
|
+
=module NumRu::GPhys::NetCDF_Convention_Users_Guide
|
6
|
+
|
7
|
+
(To be written.)
|
8
|
+
|
9
|
+
=module NumRu::GPhys::NetCDF_IO
|
10
|
+
|
11
|
+
a NetCDF read/write helper by automatically interpreting conventions
|
12
|
+
|
13
|
+
==Module functions
|
14
|
+
---is_a_NetCDF?(filename)
|
15
|
+
test whether the file is a NetCDF file.
|
16
|
+
|
17
|
+
ARGUMENTS
|
18
|
+
* filename (String): filename to test.
|
19
|
+
|
20
|
+
RETURN VALUE
|
21
|
+
* true/false
|
22
|
+
|
23
|
+
---open(files, varname)
|
24
|
+
a GPhys constructor from a NetCDF file (or multiple NetCDF files).
|
25
|
+
|
26
|
+
ARGUMENTS
|
27
|
+
* files (String, NetCDF, NArray, or Regexp): file specifier.
|
28
|
+
A single file is specified by a String (containing the path),
|
29
|
+
of a NetCDF. Multiple files can be specified by a NArray of
|
30
|
+
String or NetCDF or by a Regexp to match paths. In that case,
|
31
|
+
data and axes are represented by VArrayComposite.
|
32
|
+
* varname (String): name of the variable.
|
33
|
+
|
34
|
+
RETURN VALUE
|
35
|
+
* a GPhys
|
36
|
+
|
37
|
+
EXAMPLES
|
38
|
+
* From a single file:
|
39
|
+
file = NetCDF.open('hogehoge.nc')
|
40
|
+
gphys = GPhys::NetCDF_IO(file, 'temp')
|
41
|
+
|
42
|
+
file = NetCDF.open('hogehoge.nc', 'a') # writable
|
43
|
+
gphys = GPhys::NetCDF_IO(file, 'temp')
|
44
|
+
|
45
|
+
* From a single file:
|
46
|
+
gphys = GPhys::NetCDF_IO('hogehoge.nc', 'temp')
|
47
|
+
|
48
|
+
gphys = GPhys::NetCDF_IO('/data/netcdf/hogehoge.nc', 'temp')
|
49
|
+
|
50
|
+
If you use a String to specify a file path, the file is opened as
|
51
|
+
read-only.
|
52
|
+
|
53
|
+
* To use data separated into multiple files. Suppose that you have
|
54
|
+
hoge_yr2000.nc, hoge_yr2001.nc, and hoge_yr2002.nc in the current
|
55
|
+
directory. You can open it by using a regular expression as follows:
|
56
|
+
|
57
|
+
gphys = GPhys::NetCDF_IO(/hoge_yr(\d\d\d\d).nc/, 'temp')
|
58
|
+
|
59
|
+
Here, the parentheses to enclose \d\d\d\d is NEEDED.
|
60
|
+
|
61
|
+
The same thing can be done as follows by using Array or NArray:
|
62
|
+
|
63
|
+
files = ['hoge_yr2000.nc', 'hoge_yr2001.nc', 'hoge_yr2002.nc']
|
64
|
+
gphys = GPhys::NetCDF_IO(files, 'temp')
|
65
|
+
|
66
|
+
files = NArray['hoge_yr2000.nc', 'hoge_yr2001.nc', 'hoge_yr2002.nc']
|
67
|
+
gphys = GPhys::NetCDF_IO(files, 'temp')
|
68
|
+
|
69
|
+
* Same as above but to use the full path:
|
70
|
+
|
71
|
+
gphys = GPhys::NetCDF_IO(/\/data\/nc\/hoge_yr(\d\d\d\d).nc/, 'temp')
|
72
|
+
|
73
|
+
Here, the directory separator '/' is escaped as '\/'.
|
74
|
+
|
75
|
+
* To use data separated into multiple files. Suppose that you have
|
76
|
+
hoge_x0y0.nc, hoge_x1y0.nc, hoge_x0y1.nc, hoge_x1y1.nc, where
|
77
|
+
the data is separated 2 dimensionally into 2*2 = 4 files.
|
78
|
+
|
79
|
+
gphys = GPhys::NetCDF_IO(/hoge_x(\d)y(\d).nc/, 'temp')
|
80
|
+
|
81
|
+
Note that 2 pairs of parentheses are needed here. Alternatively,
|
82
|
+
you can also do it like this:
|
83
|
+
|
84
|
+
files = NArray[ ['hoge_x0y0.nc', 'hoge_x1y0.nc'],
|
85
|
+
['hoge_x0y1.nc', 'hoge_x1y1.nc'] ]
|
86
|
+
gphys = GPhys::NetCDF_IO(files, 'temp')
|
87
|
+
|
88
|
+
---write(file, gphys, name=nil)
|
89
|
+
|
90
|
+
Write a GPhys into a NetCDF file. The whole data under the GPhys
|
91
|
+
(such as coordinate vars) are written self-descriptively.
|
92
|
+
|
93
|
+
ARGUMENTS
|
94
|
+
* file (NetCDF): the NetCDF file to write in. Must be writable of course.
|
95
|
+
* gphys (GPhys): the GPhys to write.
|
96
|
+
* name (String): (optional) name in the new file -- if you want to save
|
97
|
+
with a different variable name than that of gphys.
|
98
|
+
|
99
|
+
RETURN VALUE
|
100
|
+
* nil
|
101
|
+
|
102
|
+
---write_grid(file, grid_or_gphys)
|
103
|
+
|
104
|
+
Same as ((<write>)) but for writing only the contents of the grid.
|
105
|
+
(Used in ((<write>)).)
|
106
|
+
|
107
|
+
ARGUMENTS
|
108
|
+
* file (NetCDF): the NetCDF file to write in. Must be writable of course.
|
109
|
+
* grid_or_gphys (Grid or GPhys):
|
110
|
+
|
111
|
+
RETURN VALUE
|
112
|
+
* a Grid, in which all VArrays in the original grid are replaced
|
113
|
+
with the new ones in the file.
|
114
|
+
|
115
|
+
---each_along_dims_write(gphyses, files, *loopdims){...} # a block is expected
|
116
|
+
|
117
|
+
Iterator to process GPhys objects too big to read on memory at once.
|
118
|
+
Makes a loop (loops) by dividing the GPhys object(s) (((|gphyses|)))
|
119
|
+
with the dimension(s) specified by ((|loopdims|)), and the results
|
120
|
+
(which is the return value of the block) are written in ((|files|)).
|
121
|
+
|
122
|
+
ARGUMENTS
|
123
|
+
* gphyses (GPhys or Array of GPhys): GPhys object(s) to be processed.
|
124
|
+
All of them must have dimensions spcified with ((|loopdims|)),
|
125
|
+
and their lengths must not vary among files. Other dimensions
|
126
|
+
are aribtary, so, for example, ((|gphyses|)) could be
|
127
|
+
[a(lon,lat,time), b(lat,time)] as long as loopdims==["time"].
|
128
|
+
* files (NetCDF or Array of NetCDF): the file in which the results are
|
129
|
+
written. The number of the file must be smaller than or equalt to
|
130
|
+
the number of resultant GPhys objects (following the multiple assignment
|
131
|
+
rule of Ruby).
|
132
|
+
* loopdims (Array of String or Integer) : name (when String) or
|
133
|
+
count starting from zero (when Integer)
|
134
|
+
* expected block : Number of arguments == number of GPhys objects in
|
135
|
+
((|gphyses|)). Expected return value is an Array of GPhys objects
|
136
|
+
to be written ((|files|)).
|
137
|
+
|
138
|
+
RETURN VALUE
|
139
|
+
* GPhys objects in which the results are written
|
140
|
+
|
141
|
+
ERRORS
|
142
|
+
|
143
|
+
The following raise exceptions (in adition to errors in arguments).
|
144
|
+
|
145
|
+
* Dimensions specified by ((|loopdims|)) are not shared among
|
146
|
+
GPhys objects in ((|gphyses|)).
|
147
|
+
* Return value of the block is not an Array of GPhys.
|
148
|
+
* Dimension(s) used for looping (((|loopdims|))) is(are) eliminated
|
149
|
+
from the retunred GPhys objects.
|
150
|
+
|
151
|
+
USAGE
|
152
|
+
|
153
|
+
* EXAMPLE 1
|
154
|
+
|
155
|
+
Suppose that you want to do the following:
|
156
|
+
|
157
|
+
in = GPhys::NetCDF_IO.open(infile, varname)
|
158
|
+
ofile = NetCDF.create(ofilename)
|
159
|
+
out = in.mean(0)
|
160
|
+
GPhys::NetCDF_IO.write( ofile, out )
|
161
|
+
ofile.close
|
162
|
+
|
163
|
+
The data object (((|in|))) is read on memory and an averagin is made.
|
164
|
+
If the size of the data is too big to read on memory at once, you can
|
165
|
+
divid this process by using this iterator. The following gives the
|
166
|
+
same result as above, but the processing is made for each subset
|
167
|
+
divided at the last dimension (represented by -1, as in the negative
|
168
|
+
indexing of Array).
|
169
|
+
|
170
|
+
in = GPhys::NetCDF_IO.open(infile, varname)
|
171
|
+
ofile = NetCDF.create(ofilename)
|
172
|
+
out = GPhys::NetCDF_IO.each_along_dims_write(in, ofile, -1){|in_sub|
|
173
|
+
[ in_sub.mean(0) ]
|
174
|
+
}
|
175
|
+
ofile.close
|
176
|
+
|
177
|
+
In this case, each_along_dims_write makes a loop by substituting
|
178
|
+
((|in[false,0..0]|)), ((|in[false,1..1]|)), ((|in[false,2..2]|)),..
|
179
|
+
into the argument of the block (((|in_sub|))). Thus, the return
|
180
|
+
value of the block (here, ((|[ in_sub.mean(0) ]|))) consists of
|
181
|
+
((|in[false,0..0].mean(0)|)), ((|in[false,1..1].mean(0)|)),.. .
|
182
|
+
This iterator creates a GPhys object in ((|out|)) that
|
183
|
+
represents the whole part of the results (here, ((|in.mean(0)|))), and
|
184
|
+
write the resultant subsets in it one by one. Therefore, the output file
|
185
|
+
is filled correctly when exiting the iterator.
|
186
|
+
|
187
|
+
Note that the subset (((|in_sub|))) retains the last dimension
|
188
|
+
but the length is 1 becasue of the slicing by Range (0..0, 1..1,..).
|
189
|
+
Therefore, the subset has the same rank as the original.
|
190
|
+
The output GPhys objects, as given by the return value of the block,
|
191
|
+
must have the dimension retained, since the dimension (whose length
|
192
|
+
is one) is replaced by the original one when written in the file.
|
193
|
+
Therefore, THE FOLLOWING CAUSE AN ERROR (an exception is raised):
|
194
|
+
|
195
|
+
out = GPhys::NetCDF_IO.each_along_dims_write(in, ofile, 0){|in_sub|
|
196
|
+
[ in_sub.mean(0) ]
|
197
|
+
}
|
198
|
+
|
199
|
+
Here, looping is made by the first dimension (0), but it is eliminated
|
200
|
+
from the result by averaging with the same dimension. (Also, note
|
201
|
+
that this averaging is non-sense, since the length of the first
|
202
|
+
dimension of the subset is 1).
|
203
|
+
|
204
|
+
* EXAMPLE 2
|
205
|
+
|
206
|
+
You can specify mutiple dimensions for looping to further
|
207
|
+
decrease the size of data to read on memory:
|
208
|
+
|
209
|
+
GPhys::NetCDF_IO.each_along_dims_write(in, ofile, -2, -1){|in_sub|
|
210
|
+
...
|
211
|
+
}
|
212
|
+
|
213
|
+
Also, you can specify the loop dimension(s) by name(s):
|
214
|
+
|
215
|
+
GPhys::NetCDF_IO.each_along_dims_write(in, ofile, "y"){|in_sub|
|
216
|
+
...
|
217
|
+
}
|
218
|
+
|
219
|
+
GPhys::NetCDF_IO.each_along_dims_write(in, ofile, "y", "z"){|in_sub|
|
220
|
+
...
|
221
|
+
}
|
222
|
+
|
223
|
+
* EXAMPLE 3
|
224
|
+
|
225
|
+
You can give multiple objects in the iterotor if they
|
226
|
+
have the same shape (in future, this restriction may been loosened),
|
227
|
+
as follows:
|
228
|
+
|
229
|
+
in1 = GPhys::NetCDF_IO.open(infile1, varname1)
|
230
|
+
in2 = GPhys::NetCDF_IO.open(infile2, varname2)
|
231
|
+
in3 = GPhys::NetCDF_IO.open(infile3, varname3)
|
232
|
+
ofile = NetCDF.create(ofilename)
|
233
|
+
outA, outB = \
|
234
|
+
GPhys::NetCDF_IO.each_along_dims_write([in1,in2,in3], ofile, -1){
|
235
|
+
|isub1,isub2,isub3|
|
236
|
+
osubA = (isub1*isub2).mean(0)
|
237
|
+
osubB = (isub2*isub3).mean(1)
|
238
|
+
[ osubA, osubB ]
|
239
|
+
}
|
240
|
+
ofile.close
|
241
|
+
|
242
|
+
In this case, two output objects (outA and outB) are made
|
243
|
+
from the three input objects (in1,in2,in3) and written in a
|
244
|
+
single file (ofile). If you want to separate into two files,
|
245
|
+
you can do it like this:
|
246
|
+
|
247
|
+
in1 = GPhys::NetCDF_IO.open(infile1, varname1)
|
248
|
+
in2 = GPhys::NetCDF_IO.open(infile2, varname2)
|
249
|
+
in3 = GPhys::NetCDF_IO.open(infile3, varname3)
|
250
|
+
ofile1 = NetCDF.create(ofilename1)
|
251
|
+
ofile2 = NetCDF.create(ofilename2)
|
252
|
+
outA, outB = \
|
253
|
+
GPhys::NetCDF_IO.each_along_dims_write([in1,in2,in3], [ofile1,ofile2], -1){
|
254
|
+
|isub1,isub2,isub3|
|
255
|
+
osubA = (isub1*isub2).mean(0)
|
256
|
+
osubB = (isub2*isub3).mean(1)
|
257
|
+
[ osubA, osubB ]
|
258
|
+
}
|
259
|
+
ofile.close
|
260
|
+
|
261
|
+
---set_convention(convention)
|
262
|
+
Set a NetCDF convention to be interpreted.
|
263
|
+
|
264
|
+
ARGUMENTS
|
265
|
+
* convention (Module): the convention
|
266
|
+
|
267
|
+
RETURN VALUE
|
268
|
+
* convention (Module)
|
269
|
+
|
270
|
+
---convention
|
271
|
+
Returns the current NetCDF convention to be interpreted.
|
272
|
+
|
273
|
+
RETURN VALUE
|
274
|
+
* convention (Module)
|
275
|
+
|
276
|
+
---var_names(file)
|
277
|
+
ARGUMENTS
|
278
|
+
* file (NetCDF or String): if string,
|
279
|
+
it must be the name (path) of a NetCDF file.
|
280
|
+
|
281
|
+
RETURN VALUE
|
282
|
+
* names of variables (Array): this return the names of variables
|
283
|
+
which the file has.
|
284
|
+
|
285
|
+
---var_names_except_coordinate(file)
|
286
|
+
ARGUMENTS
|
287
|
+
* file (NetCDF or String): if string,
|
288
|
+
it must be the name (path) of a NetCDF file.
|
289
|
+
|
290
|
+
RETURN VALUE
|
291
|
+
* names of variables (Array): this return the names of variables
|
292
|
+
which the file has, except variables for coordinate.
|
293
|
+
|
294
|
+
=end
|
295
|
+
|
296
|
+
module NumRu
|
297
|
+
|
298
|
+
class GPhys
|
299
|
+
|
300
|
+
module NetCDF_IO
|
301
|
+
|
302
|
+
module_function
|
303
|
+
|
304
|
+
def is_a_NetCDF?(filename)
|
305
|
+
file = nil
|
306
|
+
begin
|
307
|
+
file = File.open(filename,"rb")
|
308
|
+
str = file.read(3)
|
309
|
+
ensure
|
310
|
+
file.close if file
|
311
|
+
end
|
312
|
+
return str=="CDF"
|
313
|
+
end
|
314
|
+
|
315
|
+
def open(files, varname)
|
316
|
+
files, ncvar0 = __interpret_files( files, varname )
|
317
|
+
data = __files2varray( files, varname )
|
318
|
+
convention = NetCDF_Conventions.find( ncvar0.file )
|
319
|
+
axposnames = convention::coord_var_names( ncvar0 )
|
320
|
+
rank = data.rank
|
321
|
+
bare_index = [ false ] * rank # will be true if coord var is not found
|
322
|
+
|
323
|
+
axes = Array.new
|
324
|
+
var_names = ncvar0.file.var_names
|
325
|
+
for i in 0...rank
|
326
|
+
if var_names.include?(axposnames[i])
|
327
|
+
axpos = __files2varray( files, axposnames[i], i )
|
328
|
+
else
|
329
|
+
bare_index[i]=true
|
330
|
+
na = NArray.float(ncvar0.shape_current[i]).indgen!
|
331
|
+
axpos = VArray.new( na )
|
332
|
+
axpos.name = axposnames[i] # added by S. OTSUKA
|
333
|
+
end
|
334
|
+
cell_center, cell_bounds_name = convention::cell_center?( axpos )
|
335
|
+
cell_bounds, cell_center_name = convention::cell_bounds?( axpos )
|
336
|
+
cell = cell_center || cell_bounds
|
337
|
+
axis = Axis.new(cell,bare_index[i])
|
338
|
+
if !cell
|
339
|
+
axis.set_pos( axpos )
|
340
|
+
else
|
341
|
+
if cell_center
|
342
|
+
if cell_bounds_name
|
343
|
+
varray_cell_bounds = __files2varray(files, cell_bounds_name, i)
|
344
|
+
axis.set_cell(axpos, varray_cell_bounds).set_pos_to_center
|
345
|
+
else
|
346
|
+
p "cell bounds are guessed"
|
347
|
+
axis.set_cell_guess_bounds(axpos).set_pos_to_center
|
348
|
+
end
|
349
|
+
else # then it is cell_bounds
|
350
|
+
if cell_center_name
|
351
|
+
varray_cell_center = __files2varray(files, cell_center_name, i)
|
352
|
+
axis.set_cell(varray_cell_center, axpos).set_pos_to_bounds
|
353
|
+
else
|
354
|
+
p "cell center is guessed"
|
355
|
+
axis.set_cell_guess_center(axpos).set_pos_to_bounds
|
356
|
+
end
|
357
|
+
end
|
358
|
+
end
|
359
|
+
|
360
|
+
aux = convention::aux_var_names( axpos )
|
361
|
+
if aux
|
362
|
+
aux.each{|k,varname|
|
363
|
+
axis.set_aux( k, __files2varray(files,varname,i) )
|
364
|
+
}
|
365
|
+
end
|
366
|
+
|
367
|
+
axes[i] = axis
|
368
|
+
end
|
369
|
+
|
370
|
+
grid = Grid.new( *axes )
|
371
|
+
|
372
|
+
if (nms = convention::assoc_coord_names(data)) && !(nms.include?(varname))
|
373
|
+
if files.is_a?(NArray)
|
374
|
+
assoc_crds = nms.collect{|nm|
|
375
|
+
index_files_assoc = [0]*(files.rank)
|
376
|
+
tmp_assoc = GPhys::NetCDF_IO.open(files[0],nm)
|
377
|
+
tmp_assoc.rank.times{|i_assoc|
|
378
|
+
axes.length.times{|i_axes|
|
379
|
+
if tmp_assoc.axis(i_assoc).name == axes[i_axes].name
|
380
|
+
index_files_assoc[i_axes] = true
|
381
|
+
end
|
382
|
+
}
|
383
|
+
}
|
384
|
+
GPhys::NetCDF_IO.open(files[*(index_files_assoc)],nm)
|
385
|
+
}
|
386
|
+
else
|
387
|
+
assoc_crds = nms.collect{|nm| GPhys::NetCDF_IO.open(files,nm)}
|
388
|
+
end
|
389
|
+
grid.set_assoc_coords(assoc_crds)
|
390
|
+
end
|
391
|
+
|
392
|
+
GPhys.new(grid,data)
|
393
|
+
end
|
394
|
+
|
395
|
+
def write_grid(file, grid_or_gphys)
|
396
|
+
newaxes = Array.new
|
397
|
+
(0...(grid_or_gphys.rank)).each{|i|
|
398
|
+
ax = grid_or_gphys.axis(i)
|
399
|
+
dimname = ax.pos.name
|
400
|
+
length = ax.pos.length
|
401
|
+
isfx = 0
|
402
|
+
altdimnames = Hash.new
|
403
|
+
newax = ax.collect{ |va|
|
404
|
+
if va.length == length
|
405
|
+
dimnames = [dimname]
|
406
|
+
else
|
407
|
+
if (nm=altdimnames[va.length])
|
408
|
+
dimnames = [nm]
|
409
|
+
else
|
410
|
+
dimnames = [ (altdimnames[va.length] = dimname+isfx.to_s) ]
|
411
|
+
isfx += 1
|
412
|
+
end
|
413
|
+
end
|
414
|
+
if !(already=file.var(va.name))
|
415
|
+
newva = VArrayNetCDF.write(file, va, nil, dimnames )
|
416
|
+
else
|
417
|
+
#< var with the same name exists --> check it >
|
418
|
+
if va.shape_current != already.shape_current
|
419
|
+
raise "#{va.name} exisits but the shape is different"
|
420
|
+
#elsif va[0].val != already[0].val #(not allowed in the def mode)
|
421
|
+
# raise "#{va.name} exisits but the first element doesn't agree"
|
422
|
+
else
|
423
|
+
newva = VArrayNetCDF.new(already)
|
424
|
+
end
|
425
|
+
end
|
426
|
+
newva
|
427
|
+
}
|
428
|
+
newaxes.push( newax )
|
429
|
+
}
|
430
|
+
if acnms = grid_or_gphys.assoccoordnames
|
431
|
+
acnms.each{|nm|
|
432
|
+
acgp = grid_or_gphys.assoc_coord_gphys(nm)
|
433
|
+
VArrayNetCDF.write(file, acgp.data, nil, acgp.axnames)
|
434
|
+
}
|
435
|
+
end
|
436
|
+
Grid.new( *newaxes )
|
437
|
+
end
|
438
|
+
|
439
|
+
def def_var(file, name, ntype, dimensions, vary=nil)
|
440
|
+
VArrayNetCDF.def_var(file, name, ntype, dimensions, vary)
|
441
|
+
end
|
442
|
+
|
443
|
+
def write(file, gphys, name=nil)
|
444
|
+
write_grid(file, gphys)
|
445
|
+
NetCDF_Conventions.add_history(file, "#{File.basename($0)} wrote "+gphys.name)
|
446
|
+
data = gphys.data
|
447
|
+
if gphys.has_assoccoord?
|
448
|
+
if data.class != VArray
|
449
|
+
data = data.copy
|
450
|
+
end
|
451
|
+
data.put_att("coordinates",gphys.assoccoordnames.join(' '))
|
452
|
+
end
|
453
|
+
VArrayNetCDF.write(file, data, name, gphys.axnames)
|
454
|
+
nil
|
455
|
+
end
|
456
|
+
|
457
|
+
def each_along_dims_write(gphyses, files, *loopdims, &block)
|
458
|
+
files = [files] if !files.is_a?(Array)
|
459
|
+
files.each do |fl|
|
460
|
+
NetCDF_Conventions.add_history(fl, "#{File.basename($0)}")
|
461
|
+
end
|
462
|
+
IO_Common::each_along_dims_write(gphyses, files, loopdims, NetCDF_IO,
|
463
|
+
&block)
|
464
|
+
end
|
465
|
+
|
466
|
+
def var_names(files)
|
467
|
+
case files
|
468
|
+
when NetCDF
|
469
|
+
file = files
|
470
|
+
opened = true
|
471
|
+
when String
|
472
|
+
file = NetCDF.open(files)
|
473
|
+
opened = false
|
474
|
+
when NArray, Array, Regexp
|
475
|
+
files = NArray[ *files ] if files.is_a?(Array)
|
476
|
+
files = GPhys::NetCDF_IO.__to_na_of_netcdf( files )
|
477
|
+
files = GPhys::NetCDF_IO.__files_dim_matching( files, varname )
|
478
|
+
file = files[0]
|
479
|
+
files.length.times{|i|
|
480
|
+
files[i].close unless i==0
|
481
|
+
}
|
482
|
+
opened = false
|
483
|
+
else
|
484
|
+
raise TypeError, "argument files: not a NetCDF, String, NArray, Array, or Regexp"
|
485
|
+
end
|
486
|
+
var_names = file.var_names
|
487
|
+
file.close unless opened
|
488
|
+
return var_names
|
489
|
+
end
|
490
|
+
def var_names_except_coordinates(files)
|
491
|
+
case files
|
492
|
+
when NetCDF
|
493
|
+
file = files
|
494
|
+
opened = true
|
495
|
+
when String
|
496
|
+
file = NetCDF.open(files)
|
497
|
+
opened = false
|
498
|
+
when NArray, Array, Regexp
|
499
|
+
files = NArray[ *files ] if files.is_a?(Array)
|
500
|
+
files = GPhys::NetCDF_IO.__to_na_of_netcdf( files )
|
501
|
+
files = GPhys::NetCDF_IO.__files_dim_matching( files, varname )
|
502
|
+
file = files[0]
|
503
|
+
files.length.times{|i|
|
504
|
+
files[i].close unless i==0
|
505
|
+
}
|
506
|
+
opened = false
|
507
|
+
else
|
508
|
+
raise TypeError, "argument files: not a NetCDF, String, NArray, Array, or Regexp"
|
509
|
+
end
|
510
|
+
var_names = Array.new
|
511
|
+
file.var_names.each{|name|
|
512
|
+
f,var = __interpret_files( files, name )
|
513
|
+
if var.rank>1 || var.name!=var.dim_names[0]
|
514
|
+
var_names.push(name)
|
515
|
+
end
|
516
|
+
}
|
517
|
+
file.close unless opened
|
518
|
+
return var_names
|
519
|
+
end
|
520
|
+
|
521
|
+
############################################################
|
522
|
+
|
523
|
+
def __files2varray( files, varname, dim=nil )
|
524
|
+
if files.is_a?(NetCDF)
|
525
|
+
# Single file. Returns a VArrayNetCDF. dim is ignored.
|
526
|
+
file = files
|
527
|
+
var = file.var( varname )
|
528
|
+
raise "variable '#{varname}' not found in #{file}" if !var
|
529
|
+
VArrayNetCDF.new( var )
|
530
|
+
elsif files.is_a?(NArray)
|
531
|
+
# Suppose that files is a NArray of NetCDF. Returns a VArrayCompsite.
|
532
|
+
if dim.is_a?(Integer) && dim>=0 && dim<files.rank
|
533
|
+
files = files[ *([0]*dim+[true]+[0]*(files.rank-dim-1)) ]
|
534
|
+
end
|
535
|
+
varys = NArray.object( *files.shape )
|
536
|
+
for i in 0...files.length
|
537
|
+
var = files[i].var( varname )
|
538
|
+
raise "variable '#{varname}' not found in #{files[i].path}" if !var
|
539
|
+
varys[i] = VArrayNetCDF.new( var )
|
540
|
+
end
|
541
|
+
if files.length != 1
|
542
|
+
VArrayComposite.new( varys )
|
543
|
+
else
|
544
|
+
varys[0]
|
545
|
+
end
|
546
|
+
else
|
547
|
+
raise TypeError, "not a NetCDF or NArray"
|
548
|
+
end
|
549
|
+
end
|
550
|
+
|
551
|
+
def __interpret_files( files, varname )
|
552
|
+
case files
|
553
|
+
when NetCDF
|
554
|
+
ncvar0 = files.var( varname )
|
555
|
+
when String
|
556
|
+
files = NetCDF.open(files)
|
557
|
+
ncvar0 = files.var( varname )
|
558
|
+
when NArray, Array, Regexp
|
559
|
+
files = NArray[ *files ] if files.is_a?(Array)
|
560
|
+
files = GPhys::NetCDF_IO.__to_na_of_netcdf( files )
|
561
|
+
files = GPhys::NetCDF_IO.__files_dim_matching( files, varname )
|
562
|
+
ncvar0 = files[0].var( varname )
|
563
|
+
else
|
564
|
+
raise TypeError, "argument files: not a NetCDF, String, NArray, Array, or Regexp"
|
565
|
+
end
|
566
|
+
[files, ncvar0]
|
567
|
+
end
|
568
|
+
|
569
|
+
def __files_dim_matching( files, varname )
|
570
|
+
# files: NArray of NetCDF
|
571
|
+
|
572
|
+
# < read the first file and check its rank >
|
573
|
+
|
574
|
+
file0 = files[0]
|
575
|
+
ncvar0 = file0.var(varname)
|
576
|
+
if files.rank > ncvar0.rank
|
577
|
+
raise ArgumentError, "rank of files > rank of data"
|
578
|
+
end
|
579
|
+
convention = NetCDF_Conventions.find( ncvar0.file )
|
580
|
+
axposnames = convention::coord_var_names(ncvar0)
|
581
|
+
|
582
|
+
#< find correspoding dimensions >
|
583
|
+
|
584
|
+
j2i = Array.new
|
585
|
+
|
586
|
+
for ifl in 0...files.rank
|
587
|
+
for jdt in 0...ncvar0.rank
|
588
|
+
axpos_last = nil
|
589
|
+
for kfl in 0...files.shape[ifl]
|
590
|
+
nvax = files[*([0]*ifl+[kfl]+[0]*(files.rank-ifl-1))].var(axposnames[jdt])
|
591
|
+
raise "No coordinate variable: #{axposname}' not found" if !nvax
|
592
|
+
axpos = VArrayNetCDF.new( nvax )
|
593
|
+
if kfl > 0
|
594
|
+
if axpos.length != axpos_last.length
|
595
|
+
# not equal ==> this is the dimension looking for
|
596
|
+
j2i[jdt] = ifl
|
597
|
+
break
|
598
|
+
else
|
599
|
+
axv0 = axpos.val[0]
|
600
|
+
axv_last0 = axpos_last.val[0]
|
601
|
+
if axv0 != axv_last0
|
602
|
+
# not equal ==> this is the dimension looking for
|
603
|
+
j2i[jdt] = ifl
|
604
|
+
break
|
605
|
+
end
|
606
|
+
end
|
607
|
+
end
|
608
|
+
axpos_last = axpos
|
609
|
+
end
|
610
|
+
break if j2i.include?(ifl)
|
611
|
+
end
|
612
|
+
if files.shape[ifl]>1 && !j2i.include?(ifl)
|
613
|
+
raise "No dimension correpodence found for #{ifl}th dim"
|
614
|
+
end
|
615
|
+
end
|
616
|
+
|
617
|
+
for d in files.rank...ncvar0.rank
|
618
|
+
j2i[ (j2i.index(nil) || files.rank) ] = d
|
619
|
+
files.newdim!(d)
|
620
|
+
end
|
621
|
+
files = files.transpose(*j2i)
|
622
|
+
|
623
|
+
files
|
624
|
+
end
|
625
|
+
|
626
|
+
def __to_na_of_netcdf( files )
|
627
|
+
case files
|
628
|
+
when NArray
|
629
|
+
case files[0]
|
630
|
+
when NetCDF
|
631
|
+
files.each{|f|
|
632
|
+
raise TypeError, "non-NetCDF obj included" if !f.is_a?(NetCDF)
|
633
|
+
}
|
634
|
+
when String
|
635
|
+
files.each{|f|
|
636
|
+
raise TypeError, "non-String obj included" if !f.is_a?(String)
|
637
|
+
}
|
638
|
+
for i in 0...files.length
|
639
|
+
files[i] = NetCDF.open(files[i])
|
640
|
+
end
|
641
|
+
end
|
642
|
+
when Regexp
|
643
|
+
pat = files
|
644
|
+
if /^(.*)\\?\/(.*)$/ =~ (pat.source)
|
645
|
+
d=$1
|
646
|
+
f=$2
|
647
|
+
dir = d.gsub(/\\/,'') + '/'
|
648
|
+
pat = Regexp.new(f)
|
649
|
+
else
|
650
|
+
dir = './'
|
651
|
+
end
|
652
|
+
match_data = Array.new
|
653
|
+
fnames = Array.new
|
654
|
+
first_time = true
|
655
|
+
Dir.open(dir).each{|fn|
|
656
|
+
if pat =~ fn
|
657
|
+
fnames.push(fn)
|
658
|
+
ary = Regexp.last_match.to_a
|
659
|
+
ary.shift # ==> ary == [$1,$2,...]
|
660
|
+
ary.each_with_index{|v,i|
|
661
|
+
match_data[i] = Array.new if !match_data[i]
|
662
|
+
match_data[i].push(v) if !match_data[i].include?(v)
|
663
|
+
}
|
664
|
+
if first_time
|
665
|
+
body = fn
|
666
|
+
|
667
|
+
first_time = false
|
668
|
+
end
|
669
|
+
end
|
670
|
+
}
|
671
|
+
if match_data.length == 0
|
672
|
+
raise ArgumentError, "found no files that matches #{files.source}"
|
673
|
+
end
|
674
|
+
match_data.each{|ary| ary.sort!}
|
675
|
+
shape = match_data.collect{|ary| ary.length}
|
676
|
+
files = NArray.object(*shape)
|
677
|
+
fnames.each{|fn|
|
678
|
+
pat =~ fn
|
679
|
+
ary = Regexp.last_match.to_a
|
680
|
+
ary.shift # ==> ary == [$1,$2,...]
|
681
|
+
index = Array.new
|
682
|
+
ary.each_with_index{|v,i|
|
683
|
+
index[i] = match_data[i].index(v)
|
684
|
+
}
|
685
|
+
files[*index] = NetCDF.open(dir+fn)
|
686
|
+
}
|
687
|
+
else
|
688
|
+
raise TypeError, "unsupported type #{pat.class}"
|
689
|
+
end
|
690
|
+
files
|
691
|
+
end
|
692
|
+
|
693
|
+
end
|
694
|
+
end
|
695
|
+
end
|
696
|
+
|
697
|
+
######################################################
|
698
|
+
if $0 == __FILE__
|
699
|
+
include NumRu
|
700
|
+
|
701
|
+
file = NetCDF.open("../../../testdata/T.jan.nc")
|
702
|
+
|
703
|
+
temp = GPhys::NetCDF_IO.open(file,"T")
|
704
|
+
p temp.name, temp.shape_current
|
705
|
+
p temp.val.class
|
706
|
+
temp2 = temp[true,true,2]
|
707
|
+
p temp2.name, temp2.shape_current
|
708
|
+
|
709
|
+
temp_xmean = temp.average(0)
|
710
|
+
p temp.val
|
711
|
+
|
712
|
+
temp_edy = ( temp - temp_xmean )
|
713
|
+
p '###',temp_edy.name,temp_edy.val[0,true,true]
|
714
|
+
p 'deleted attributes:', temp.data.att_names - temp_edy.data.att_names
|
715
|
+
p '@@@',temp
|
716
|
+
p '///',temp.copy
|
717
|
+
p '+++',temp2
|
718
|
+
|
719
|
+
puts "\n** test write (tmp.nc) **"
|
720
|
+
file2 = NetCDF.create('tmp.nc')
|
721
|
+
p v = temp_edy.axis(0).pos[0..-2].copy.rename('lonlon')
|
722
|
+
temp_edy.axis(0).set_aux('test',v)
|
723
|
+
temp_edy.axis(0).set_aux('test2',(v/2).rename('lonlon2'))
|
724
|
+
temp_edy.axis(0).set_aux('test2',(v/2).rename('lonlon3')[0..-2])
|
725
|
+
GPhys::NetCDF_IO.write(file2,temp_edy)
|
726
|
+
file2.close
|
727
|
+
file3 = NetCDF.create('tmp2.nc')
|
728
|
+
GPhys::NetCDF_IO.write(file2,temp_xmean)
|
729
|
+
file3.close
|
730
|
+
|
731
|
+
p '** test composite **'
|
732
|
+
|
733
|
+
temp = GPhys::NetCDF_IO.open(file,"T")
|
734
|
+
GPhys::NetCDF_IO.write( f=NetCDF.create('tmp00.nc'), temp[0..5,0..9,true] )
|
735
|
+
f.close
|
736
|
+
GPhys::NetCDF_IO.write( f=NetCDF.create('tmp01.nc'), temp[0..5,10..15,true])
|
737
|
+
f.close
|
738
|
+
GPhys::NetCDF_IO.write( f=NetCDF.create('tmp10.nc'), temp[6..9,0..9,true])
|
739
|
+
f.close
|
740
|
+
GPhys::NetCDF_IO.write( f=NetCDF.create('tmp11.nc'), temp[6..9,10..15,true])
|
741
|
+
f.close
|
742
|
+
files = /tmp(\d)(\d).nc/
|
743
|
+
p gpcompo = GPhys::NetCDF_IO.open( files, 'T' )
|
744
|
+
p gpcompo.coord(0).val
|
745
|
+
p gpcompo[false,0].val
|
746
|
+
|
747
|
+
|
748
|
+
p '** test each_along_dims* **'
|
749
|
+
|
750
|
+
f=NetCDF.create('tmpE1.nc')
|
751
|
+
GPhys::NetCDF_IO.each_along_dims_write( temp, f, 1, 2 ){|sub|
|
752
|
+
[sub.mean(0)]
|
753
|
+
}
|
754
|
+
f.close
|
755
|
+
f=NetCDF.create('tmpE0.nc')
|
756
|
+
GPhys::NetCDF_IO.write( f, temp.mean(0) )
|
757
|
+
f.close
|
758
|
+
|
759
|
+
print `ncdump tmpE0.nc > tmpE0; ncdump tmpE1.nc > tmpE1 ; diff -u tmpE[01]`
|
760
|
+
|
761
|
+
f=NetCDF.create('tmpE2.nc')
|
762
|
+
GPhys::NetCDF_IO.each_along_dims_write([temp,temp_edy], f, "level"){|s1,s2|
|
763
|
+
[s1.mean(0),s2.mean(1).rename('T_edy')]
|
764
|
+
}
|
765
|
+
f.close
|
766
|
+
|
767
|
+
f=NetCDF.create('tmpE3.nc')
|
768
|
+
GPhys::NetCDF_IO.each_along_dims_write([temp,temp_xmean], f, "level"){|s1,s2|
|
769
|
+
[s1.mean(1),s2.rename('T_x_mean'),s2.mean(0).rename('T_xy_mean')]
|
770
|
+
}
|
771
|
+
f.close
|
772
|
+
|
773
|
+
print "\n\n** PACKED DATA TREATMENT **\n\n"
|
774
|
+
|
775
|
+
file = NetCDF.open("../../../testdata/T.jan.packed.withmiss.nc")
|
776
|
+
temp = GPhys::NetCDF_IO.open(file,"T")
|
777
|
+
temp.att_names.each{|nm| p nm,temp.get_att(nm) if /(scale|offs)/ =~ nm}
|
778
|
+
p( mls=temp.copy.att_names )
|
779
|
+
p( (temp*10).att_names - mls )
|
780
|
+
p( temp[0,false].copy.att_names - mls )
|
781
|
+
|
782
|
+
print "\n\n** copying with write_grid **\n\n"
|
783
|
+
f=NetCDF.create('tmpE4.nc')
|
784
|
+
grid = GPhys::NetCDF_IO.write_grid(f,temp)
|
785
|
+
p grid,grid.axis(0).pos.val
|
786
|
+
f.close
|
787
|
+
|
788
|
+
print "\n\n** axis conventions **\n\n"
|
789
|
+
x = temp.axis(0).copy.to_gphys
|
790
|
+
x.coord(0).set_att('topology','circular')
|
791
|
+
x.coord(0).set_att('modulo',[360.0])
|
792
|
+
p x
|
793
|
+
f=NetCDF.create('tmpE5.nc')
|
794
|
+
GPhys::NetCDF_IO.write_grid(f,x)
|
795
|
+
f.close
|
796
|
+
f=NetCDF.open('tmpE5.nc')
|
797
|
+
x=GPhys::NetCDF_IO.open(f,'lon')
|
798
|
+
p x.coord(0).axis_cyclic?
|
799
|
+
p x.coord(0).axis_modulo
|
800
|
+
end
|