gphys 1.1.1a
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- 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,452 @@
|
|
|
1
|
+
require "numru/gphys/gphys_netcdf_io"
|
|
2
|
+
require "numru/gphys/gphys_grads_io"
|
|
3
|
+
require "numru/gphys/gphys_grib_io"
|
|
4
|
+
require "numru/gphys/gphys_nusdas_io"
|
|
5
|
+
require "numru/gphys/gphys_gtool3_io"
|
|
6
|
+
begin
|
|
7
|
+
require "numru/gphys/gphys_hdfeos5_io"
|
|
8
|
+
rescue LoadError
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
=begin
|
|
13
|
+
=module NumRu::GPhys::IO
|
|
14
|
+
|
|
15
|
+
A module to handle file IO regarding GPhys.
|
|
16
|
+
|
|
17
|
+
Many of the functionality of this module is implemented in the modules
|
|
18
|
+
for specific file types such as NumRu::GPhys::NetCDF_IO, to which this
|
|
19
|
+
module directs operations.
|
|
20
|
+
|
|
21
|
+
For example, (('GPhys::IO.open(file, name)')) simply calls
|
|
22
|
+
(('GPhys::*_IO.open(file, name)')), where '(('*'))' is
|
|
23
|
+
(('NetCDF')), (('GrADS')), or (('grib')).
|
|
24
|
+
|
|
25
|
+
==Module functions
|
|
26
|
+
|
|
27
|
+
---open(files, varname)
|
|
28
|
+
---write(file, gphys, name=nil)
|
|
29
|
+
---write_grid(file, grid_or_gphys)
|
|
30
|
+
---each_along_dims_write(gphyses, files, *loopdims){...} # a block is expected
|
|
31
|
+
---var_names(file)
|
|
32
|
+
---var_names_except_coordinates(file)
|
|
33
|
+
See the manual of (('NumRu::GPhys::NetCDF_IO')) for the methods listed above.
|
|
34
|
+
|
|
35
|
+
---file2type(file)
|
|
36
|
+
Figures out the file type supported in this module.
|
|
37
|
+
|
|
38
|
+
ARGUMENTS
|
|
39
|
+
* file (String, Regexp, NetCDF, Grib, or GrADS_Gridded) :
|
|
40
|
+
What to return is of course obvious if it is
|
|
41
|
+
NetCDF, Grib, or GrADS_Gridded. If it is a String,
|
|
42
|
+
it is assumed to be a path of a file, and the file type
|
|
43
|
+
is determined by its suffix when 'nc', 'ctl', or 'grib';
|
|
44
|
+
In other cases, the type is figured out by reading in
|
|
45
|
+
a few bytes from the beginning. If Regexp, currently,
|
|
46
|
+
a NetCDF is assumed, since only NetCDF_IO.open supports
|
|
47
|
+
Regexp.
|
|
48
|
+
|
|
49
|
+
RETURN VALUE
|
|
50
|
+
* GPhys::IO::NETCDF, GPhys::IO::GRIB, or GPhys::IO::GRADS,
|
|
51
|
+
which are string constants.
|
|
52
|
+
|
|
53
|
+
---file2specific_module(file)
|
|
54
|
+
Same as ((<file2type>)), but returns GPhys::NetCDF_IO,
|
|
55
|
+
GPhys::GrADS_IO, or GPhys::Grib_IO.
|
|
56
|
+
|
|
57
|
+
---file2file_class(file)
|
|
58
|
+
Same as ((<file2type>)), but returns NetCDF,
|
|
59
|
+
GrADS_Gridded, or Grib.
|
|
60
|
+
|
|
61
|
+
---parse_gturl(gturl)
|
|
62
|
+
Parses GTOOL4-type URLs to specify path, variable name,
|
|
63
|
+
and optionally subsets, whose format is
|
|
64
|
+
(('path@varname[,dimname=pos1[:pos2[:thinning_intv]][,dimname=...]]'))
|
|
65
|
+
|
|
66
|
+
ARGUMENTS
|
|
67
|
+
* gturl (String) GTOOL4 URL, whose format is
|
|
68
|
+
(('path@varname[,dimname=pos1[:pos2[:thinning_intv]][,dimname=...]]'))
|
|
69
|
+
|
|
70
|
+
RETURN VALUES
|
|
71
|
+
* An Array consisting of [file, var, slice, cut_slice, thinning], where
|
|
72
|
+
* file (String) : path
|
|
73
|
+
* var (String) : variable name
|
|
74
|
+
* slice (Array) : subset specifier by the grid numbers
|
|
75
|
+
to be used as (('GPhys#[slice]')).
|
|
76
|
+
* cut_slice (Array) : subset specifier in physical coordinate
|
|
77
|
+
to be used as (('GPhys#cut[cut_slice]')).
|
|
78
|
+
* thinning (Array) : additional subset specifier for thinning
|
|
79
|
+
with uniform intervals if needed to be used (('GPhys#[thinning]'))
|
|
80
|
+
after appling (('GPhys#cut')).
|
|
81
|
+
|
|
82
|
+
---open_gturl(gturl)
|
|
83
|
+
a GPhys constructor from a Gtool4-type URL.
|
|
84
|
+
See ((<parse_gturl>)) for its format.
|
|
85
|
+
|
|
86
|
+
RETURN VALUE
|
|
87
|
+
* a GPhys
|
|
88
|
+
|
|
89
|
+
---str2gphys(str)
|
|
90
|
+
Open a GPhys from a slash("/")-separated String
|
|
91
|
+
such as "U.nc/U" and "U.nc".
|
|
92
|
+
* Aimed to help quick jobs with interactive sessions
|
|
93
|
+
-- This method do not handle a GPhys across multiple files.
|
|
94
|
+
* if the variable path is ommited such as "U.nc",
|
|
95
|
+
try to find the variable in it -- read the file and if
|
|
96
|
+
only one variable is found, assume that is the
|
|
97
|
+
variable specified; otherwise, an exception is raised.
|
|
98
|
+
* URL is accepted, but it's only thru NetCDF assuming OPeNDAP.
|
|
99
|
+
|
|
100
|
+
ARGUMENTS
|
|
101
|
+
* a String (file_path[/variable_path])
|
|
102
|
+
e.g. "U.nc/U", "U.nc", "http://.../U.nc/U"
|
|
103
|
+
|
|
104
|
+
RETURN VALUE
|
|
105
|
+
* a GPhys
|
|
106
|
+
|
|
107
|
+
==Module constants
|
|
108
|
+
|
|
109
|
+
---GTURLfmt
|
|
110
|
+
The format of Gtool4URL.
|
|
111
|
+
|
|
112
|
+
=end
|
|
113
|
+
|
|
114
|
+
module NumRu
|
|
115
|
+
class GPhys
|
|
116
|
+
module IO
|
|
117
|
+
module_function
|
|
118
|
+
|
|
119
|
+
## // module functions to be defined in specific IO modules -->
|
|
120
|
+
def open(file, varname)
|
|
121
|
+
file2specific_module(file)::open(file, varname)
|
|
122
|
+
end
|
|
123
|
+
|
|
124
|
+
def write(file, gphys, name=nil)
|
|
125
|
+
file2specific_module(file)::write(file, gphys, name)
|
|
126
|
+
end
|
|
127
|
+
|
|
128
|
+
def write_grid(file, grid_or_gphys)
|
|
129
|
+
# usually not needed (internally called by write)
|
|
130
|
+
file2specific_module(file)::write_grid(file, grid_or_gphys)
|
|
131
|
+
end
|
|
132
|
+
|
|
133
|
+
def each_along_dims_write(gphyses, files, *loopdims, &block)
|
|
134
|
+
|
|
135
|
+
files = [files] if !files.is_a?(Array)
|
|
136
|
+
files.each do |fl|
|
|
137
|
+
if fl.is_a?(NetCDF)
|
|
138
|
+
NetCDF_Conventions.add_history(fl, "#{File.basename($0)}")
|
|
139
|
+
end
|
|
140
|
+
end
|
|
141
|
+
|
|
142
|
+
IO_Common::each_along_dims_write(gphyses, files, loopdims,
|
|
143
|
+
file2specific_module(files), &block)
|
|
144
|
+
end
|
|
145
|
+
## <-- module functions to be defined in specific IO modules //
|
|
146
|
+
|
|
147
|
+
## // file type selctor -->
|
|
148
|
+
NETCDF = "NETCDF"
|
|
149
|
+
GRADS = "GRADS"
|
|
150
|
+
GRIB = "GRIB"
|
|
151
|
+
NUSDAS = "NUSDAS"
|
|
152
|
+
He5 = "He5"
|
|
153
|
+
GTOOL3 = "GTOOL3"
|
|
154
|
+
@@iomdl = {NETCDF => GPhys::NetCDF_IO,
|
|
155
|
+
GRADS => GPhys::GrADS_IO,
|
|
156
|
+
GRIB => GPhys::Grib_IO,
|
|
157
|
+
NUSDAS => GPhys::NuSDaS_IO,
|
|
158
|
+
GTOOL3 => GPhys::Gtool3_IO}
|
|
159
|
+
@@file_class = {NETCDF => NetCDF,
|
|
160
|
+
GRADS => GrADS_Gridded,
|
|
161
|
+
GRIB => Grib,
|
|
162
|
+
NUSDAS => NuSDaS,
|
|
163
|
+
GTOOL3 => Gtool3}
|
|
164
|
+
@@nc_pattern = [/\.nc$/]
|
|
165
|
+
@@grad_pattern = [/\.ctl$/]
|
|
166
|
+
@@grib_pattern = [/\.grib$/, /\.grb$/]
|
|
167
|
+
@@nus_pattern = [/\.nus$/]
|
|
168
|
+
|
|
169
|
+
@@has_he5 = defined?(HE5)
|
|
170
|
+
if @@has_he5
|
|
171
|
+
@@iomdl[He5] = GPhys::HE5_IO
|
|
172
|
+
@@file_class [He5] = HE5
|
|
173
|
+
@@he5_pattern = [/\.he5$/]
|
|
174
|
+
end
|
|
175
|
+
|
|
176
|
+
def file2type(file)
|
|
177
|
+
case file
|
|
178
|
+
when Array, NArray
|
|
179
|
+
return file2type(file[0]) # inspect the first element (ignoring the rest)
|
|
180
|
+
when NetCDF
|
|
181
|
+
return NETCDF
|
|
182
|
+
when GrADS_Gridded
|
|
183
|
+
return GRADS
|
|
184
|
+
when Grib
|
|
185
|
+
return GRIB
|
|
186
|
+
when NuSDaS
|
|
187
|
+
return NUSDAS
|
|
188
|
+
when Gtool3
|
|
189
|
+
return GTOOL3
|
|
190
|
+
when Regexp
|
|
191
|
+
return NETCDF # So far, only NetCDF_IO supports Regexp.
|
|
192
|
+
when *@@nc_pattern
|
|
193
|
+
return NETCDF
|
|
194
|
+
when *@@grad_pattern
|
|
195
|
+
return GRADS
|
|
196
|
+
when *@@grib_pattern
|
|
197
|
+
return GRIB
|
|
198
|
+
when *@@nus_pattern
|
|
199
|
+
return NUSDAS
|
|
200
|
+
when String
|
|
201
|
+
return NETCDF if /^http:\/\// =~ file # assume a DODS URL
|
|
202
|
+
return nil unless File.exist?(file)
|
|
203
|
+
return NETCDF if NetCDF_IO.is_a_NetCDF?(file)
|
|
204
|
+
return GRADS if GrADS_IO.is_a_GrADS?(file)
|
|
205
|
+
return GRIB if Grib_IO.is_a_Grib?(file)
|
|
206
|
+
return NUSDAS if NuSDaS_IO.is_a_NuSDaS?(file)
|
|
207
|
+
return GTOOL3 if Gtool3_IO.is_a_Gtool3?(file)
|
|
208
|
+
end
|
|
209
|
+
if @@has_he5
|
|
210
|
+
case file
|
|
211
|
+
when HE5, HE5Sw
|
|
212
|
+
return He5
|
|
213
|
+
when *@@he5_pattern
|
|
214
|
+
return He5
|
|
215
|
+
when String
|
|
216
|
+
return He5 if HE5_IO.is_a_HE5?(file)
|
|
217
|
+
end
|
|
218
|
+
end
|
|
219
|
+
return nil
|
|
220
|
+
end
|
|
221
|
+
|
|
222
|
+
def file2specific_module(file)
|
|
223
|
+
@@iomdl[ file2type(file) ]
|
|
224
|
+
end
|
|
225
|
+
|
|
226
|
+
def file2file_class(file)
|
|
227
|
+
@@file_class[ file2type(file) ]
|
|
228
|
+
end
|
|
229
|
+
|
|
230
|
+
types = ['nc','grad','grib','nus','he5']
|
|
231
|
+
types.each{|c|
|
|
232
|
+
eval <<-EOS
|
|
233
|
+
def add_#{c}_pattern(*regexps)
|
|
234
|
+
regexps.each{ |regexp|
|
|
235
|
+
raise TypeError,"Regexp expected" unless Regexp===regexp
|
|
236
|
+
@@#{c}_pattern.push(regexp)
|
|
237
|
+
}
|
|
238
|
+
nil
|
|
239
|
+
end
|
|
240
|
+
EOS
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
types.each{|c|
|
|
244
|
+
eval <<-EOS
|
|
245
|
+
def set_#{c}_pattern(*regexps)
|
|
246
|
+
regexps.each{ |regexp|
|
|
247
|
+
raise TypeError,"Regexp expected" unless Regexp===regexp
|
|
248
|
+
}
|
|
249
|
+
@@#{c}_pattern = regexps
|
|
250
|
+
nil
|
|
251
|
+
end
|
|
252
|
+
EOS
|
|
253
|
+
}
|
|
254
|
+
## <-- file type selctor //
|
|
255
|
+
|
|
256
|
+
def var_names(file)
|
|
257
|
+
file2specific_module(file).var_names(file)
|
|
258
|
+
end
|
|
259
|
+
def var_names_except_coordinates(file)
|
|
260
|
+
file2specific_module(file).var_names_except_coordinates(file)
|
|
261
|
+
end
|
|
262
|
+
|
|
263
|
+
GTURLfmt = "path@varname[,dimname=pos1[:pos2[:thinning_intv]][,dimname=...]]"
|
|
264
|
+
|
|
265
|
+
def parse_gturl(gturl)
|
|
266
|
+
if /(.*)@(.*)/ =~ gturl
|
|
267
|
+
file = $1
|
|
268
|
+
var = $2
|
|
269
|
+
else
|
|
270
|
+
raise "invalid URL: '@' between path & variable is not found\n\n" +
|
|
271
|
+
"URL format: " + GTURLfmt
|
|
272
|
+
end
|
|
273
|
+
if /,/ =~ var
|
|
274
|
+
slice = Hash.new
|
|
275
|
+
cut_slice = Hash.new
|
|
276
|
+
thinning = Hash.new
|
|
277
|
+
var_descr = var.split(/,/)
|
|
278
|
+
var = var_descr.shift
|
|
279
|
+
var_descr.each do |s|
|
|
280
|
+
if /(.*)=(.*)/ =~ s
|
|
281
|
+
dimname = $1
|
|
282
|
+
subset = $2
|
|
283
|
+
case subset
|
|
284
|
+
when /\^(.*):(.*):(.*)/
|
|
285
|
+
slice[dimname] = ($1.to_i)..($2.to_i)
|
|
286
|
+
thinning[dimname] = {(0..-1) => $3.to_i}
|
|
287
|
+
when /\^(.*):(.*)/
|
|
288
|
+
slice[dimname] = ($1.to_i)..($2.to_i)
|
|
289
|
+
when /\^(.*)/
|
|
290
|
+
slice[dimname] = $1.to_i
|
|
291
|
+
when /(.*):(.*):(.*)/
|
|
292
|
+
cut_slice[dimname] = ($1.to_f)..($2.to_f)
|
|
293
|
+
thinning[dimname] = {(0..-1) => $3.to_i}
|
|
294
|
+
when /(.*):(.*)/
|
|
295
|
+
cut_slice[dimname] = ($1.to_f)..($2.to_f)
|
|
296
|
+
else
|
|
297
|
+
cut_slice[dimname] = subset.to_f
|
|
298
|
+
end
|
|
299
|
+
else
|
|
300
|
+
raise "invalid URL: variable subset specification error\n\n" +
|
|
301
|
+
"URL format: " + GTURLfmt
|
|
302
|
+
end
|
|
303
|
+
end
|
|
304
|
+
slice = nil if slice.length == 0
|
|
305
|
+
cut_slice = nil if cut_slice.length == 0
|
|
306
|
+
thinning = nil if thinning.length == 0
|
|
307
|
+
else
|
|
308
|
+
slice = nil
|
|
309
|
+
cut_slice = nil
|
|
310
|
+
thinning = nil
|
|
311
|
+
end
|
|
312
|
+
[file, var, slice, cut_slice, thinning]
|
|
313
|
+
end # def parse_gturl
|
|
314
|
+
|
|
315
|
+
def open_gturl(gturl)
|
|
316
|
+
file, var, slice, cut_slice, thinning = GPhys::IO.parse_gturl(gturl)
|
|
317
|
+
gp = GPhys::IO.open(file,var)
|
|
318
|
+
gp = gp[slice] if slice
|
|
319
|
+
gp = gp.cut(cut_slice) if cut_slice
|
|
320
|
+
gp = gp[thinning] if thinning
|
|
321
|
+
gp
|
|
322
|
+
end # def open_gturl
|
|
323
|
+
|
|
324
|
+
def str2gphys(str)
|
|
325
|
+
|
|
326
|
+
case str
|
|
327
|
+
when /^https?:\/\//
|
|
328
|
+
file_tester = Proc.new{|fname| NetCDF.open(fname) rescue false}
|
|
329
|
+
when
|
|
330
|
+
file_tester = Proc.new{|fname| File.exists?(fname)}
|
|
331
|
+
end
|
|
332
|
+
fname = str; vname = nil # initial value
|
|
333
|
+
while fname
|
|
334
|
+
if file_tester.call(fname)
|
|
335
|
+
break
|
|
336
|
+
else
|
|
337
|
+
if /(.*)\/([^\/]+)/ =~ fname
|
|
338
|
+
fname = $1
|
|
339
|
+
if vname.nil?
|
|
340
|
+
vname = $2
|
|
341
|
+
else
|
|
342
|
+
vname = $2 + "/" + vname
|
|
343
|
+
end
|
|
344
|
+
else
|
|
345
|
+
raise "Not found: #{str}"
|
|
346
|
+
end
|
|
347
|
+
end
|
|
348
|
+
end
|
|
349
|
+
if vname.nil?
|
|
350
|
+
vns = var_names_except_coordinates(fname)
|
|
351
|
+
if vns.length==1
|
|
352
|
+
vname=vns.first
|
|
353
|
+
else
|
|
354
|
+
raise "#{str} has multiple variables #{vns.inspect}. Specify one."
|
|
355
|
+
end
|
|
356
|
+
end
|
|
357
|
+
open(fname,vname)
|
|
358
|
+
end
|
|
359
|
+
|
|
360
|
+
end # module IO
|
|
361
|
+
end # class GPhys
|
|
362
|
+
end # module NumRu
|
|
363
|
+
|
|
364
|
+
######################################################
|
|
365
|
+
if $0 == __FILE__
|
|
366
|
+
include NumRu
|
|
367
|
+
|
|
368
|
+
puts "\n** test str2gphys **\n"
|
|
369
|
+
p GPhys::IO.str2gphys("../../../testdata/T.jan.nc/T")
|
|
370
|
+
p GPhys::IO.str2gphys("../../../testdata/T.jan.nc")
|
|
371
|
+
exit
|
|
372
|
+
|
|
373
|
+
puts "\n** test NETCDF **\n"
|
|
374
|
+
|
|
375
|
+
file = "../../../testdata/T.jan.nc"
|
|
376
|
+
temp = GPhys::IO.open(file,"T")
|
|
377
|
+
p temp.name, temp.shape_current
|
|
378
|
+
p temp.val.class
|
|
379
|
+
temp2 = temp[true,true,2]
|
|
380
|
+
p temp2.name, temp2.shape_current
|
|
381
|
+
|
|
382
|
+
temp_xmean = temp.average(0)
|
|
383
|
+
p temp.val
|
|
384
|
+
|
|
385
|
+
temp_edy = ( temp - temp_xmean )
|
|
386
|
+
p '###',temp_edy.name,temp_edy.val[0,true,true]
|
|
387
|
+
p 'deleted attributes:', temp.data.att_names - temp_edy.data.att_names
|
|
388
|
+
p '@@@',temp
|
|
389
|
+
p '///',temp.copy
|
|
390
|
+
p '+++',temp2
|
|
391
|
+
|
|
392
|
+
puts "\n** test write (tmp.nc) **"
|
|
393
|
+
file2 = NetCDF.create('tmp.nc')
|
|
394
|
+
p v = temp_edy.axis(0).pos[0..-2].copy.rename('lonlon')
|
|
395
|
+
temp_edy.axis(0).set_aux('test',v)
|
|
396
|
+
temp_edy.axis(0).set_aux('test2',(v/2).rename('lonlon2'))
|
|
397
|
+
temp_edy.axis(0).set_aux('test2',(v/2).rename('lonlon3')[0..-2])
|
|
398
|
+
GPhys::IO.write(file2,temp_edy)
|
|
399
|
+
file2.close
|
|
400
|
+
file3 = NetCDF.create('tmp2.nc')
|
|
401
|
+
GPhys::IO.write(file2,temp_xmean)
|
|
402
|
+
file3.close
|
|
403
|
+
|
|
404
|
+
p '** test each_along_dims* **'
|
|
405
|
+
|
|
406
|
+
f=NetCDF.create('tmpE1.nc')
|
|
407
|
+
GPhys::IO.each_along_dims_write( temp, f, 1, 2 ){|sub|
|
|
408
|
+
[sub.mean(0)]
|
|
409
|
+
}
|
|
410
|
+
f.close
|
|
411
|
+
f=NetCDF.create('tmpE2.nc')
|
|
412
|
+
GPhys::IO.each_along_dims_write([temp,temp_edy], f, "level"){|s1,s2|
|
|
413
|
+
[s1.mean(0),s2.mean(1).rename('T_edy')]
|
|
414
|
+
}
|
|
415
|
+
f.close
|
|
416
|
+
f=NetCDF.create('tmpE0.nc')
|
|
417
|
+
GPhys::IO.write( f, temp.mean(0) )
|
|
418
|
+
f.close
|
|
419
|
+
|
|
420
|
+
print `ncdump tmpE0.nc > tmpE0; ncdump tmpE1.nc > tmpE1 ; diff -u tmpE[01]`
|
|
421
|
+
|
|
422
|
+
puts "\n** test GRADS (and write into NETCDF) **\n"
|
|
423
|
+
|
|
424
|
+
file = "../../../testdata/T.jan.ctl"
|
|
425
|
+
temp = GPhys::IO.open(file,"T")
|
|
426
|
+
p temp.name, temp.shape_current
|
|
427
|
+
temp2 = temp[true,true,2,0]
|
|
428
|
+
p temp2.name, temp2.shape_current
|
|
429
|
+
|
|
430
|
+
temp_xmean = temp.average(0)
|
|
431
|
+
p temp.val
|
|
432
|
+
|
|
433
|
+
temp_edy = ( temp - temp_xmean )
|
|
434
|
+
p '$$$',temp_edy.name,temp_edy.val[0,true,true,0]
|
|
435
|
+
p '@@@',temp
|
|
436
|
+
p '///',temp.copy
|
|
437
|
+
p '+++',temp2
|
|
438
|
+
|
|
439
|
+
puts "\n** test write (tmp.nc) **"
|
|
440
|
+
require "numru/gphys/gphys_netcdf_io"
|
|
441
|
+
file2 = NetCDF.create('tmp.nc')
|
|
442
|
+
p v = temp_edy.axis(0).pos[0..-2].copy.rename('lonlon')
|
|
443
|
+
temp_edy.axis(0).set_aux('test',v)
|
|
444
|
+
temp_edy.axis(0).set_aux('test2',(v/2).rename('lonlon2'))
|
|
445
|
+
temp_edy.axis(0).set_aux('test2',(v/2).rename('lonlon3')[0..-2])
|
|
446
|
+
GPhys::IO.write(file2,temp_edy)
|
|
447
|
+
file2.close
|
|
448
|
+
file3 = NetCDF.create('tmp2.nc')
|
|
449
|
+
GPhys::IO.write(file2,temp_xmean)
|
|
450
|
+
file3.close
|
|
451
|
+
|
|
452
|
+
end
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
=begin
|
|
2
|
+
=module NumRu::GPhys::IO_Common
|
|
3
|
+
|
|
4
|
+
THIS MODULE IS ONLY FOR INTERNAL USAGE.
|
|
5
|
+
(Does not work stand alone.)
|
|
6
|
+
|
|
7
|
+
Functions independent of specific file formart.
|
|
8
|
+
To be used by IO, NetCDF_IO, GrADS_IO etc.
|
|
9
|
+
|
|
10
|
+
A test program is included in gphys_netcdf.rb
|
|
11
|
+
|
|
12
|
+
=end
|
|
13
|
+
|
|
14
|
+
module NumRu
|
|
15
|
+
class GPhys
|
|
16
|
+
module IO_Common
|
|
17
|
+
|
|
18
|
+
module_function
|
|
19
|
+
|
|
20
|
+
def each_along_dims_write(gphyses, files, loopdims, io_module)
|
|
21
|
+
if !gphyses.is_a?(Array)
|
|
22
|
+
gphyses = [gphyses] # put in an Array (if a single GPhys)
|
|
23
|
+
end
|
|
24
|
+
gp = gphyses[0]
|
|
25
|
+
|
|
26
|
+
if !files.is_a?(Array)
|
|
27
|
+
files = [files] # put in an Array (if a single File)
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
if !loopdims.is_a?(Array)
|
|
31
|
+
loopdims = [loopdims] # put in an Array (if a single Integer/String)
|
|
32
|
+
end
|
|
33
|
+
if loopdims.length == 0
|
|
34
|
+
raise ArgumentError, "No loop dimension is specified "+
|
|
35
|
+
" -- In that case, you don't need this iterator."
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
#if loopdims.min<0 || loopdims.max>=gp.rank
|
|
39
|
+
# raise ArguemntError,"Invalid dims #{loopdims.inspect} for #{gp.rank}D array"
|
|
40
|
+
#end
|
|
41
|
+
|
|
42
|
+
loopdimids = Array.new
|
|
43
|
+
loopdimnames = Array.new
|
|
44
|
+
loopdims.each{|d|
|
|
45
|
+
case d
|
|
46
|
+
when Integer
|
|
47
|
+
if d < 0
|
|
48
|
+
d += gp.rank
|
|
49
|
+
end
|
|
50
|
+
loopdimids.push( d )
|
|
51
|
+
loopdimnames.push( gp.axis(d).name )
|
|
52
|
+
when String
|
|
53
|
+
loopdimids.push( gp.dim_index(d) )
|
|
54
|
+
loopdimnames.push( d )
|
|
55
|
+
else
|
|
56
|
+
raise ArgumentError,"loopdims must consist of Integer and/or String"
|
|
57
|
+
end
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
sh = Array.new
|
|
61
|
+
len = 1
|
|
62
|
+
loopdimids.each{|i|
|
|
63
|
+
sh.push(gp.shape[i])
|
|
64
|
+
len *= gp.shape[i]
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
gphyses.each do |g|
|
|
68
|
+
for i in 1...gphyses.length
|
|
69
|
+
loopdimnames.each_with_index do |nm,i|
|
|
70
|
+
if !g.axnames.include?( nm )
|
|
71
|
+
raise ArgumentError,"#{i+1}-th GPhys do not have dim '#{nm}'"
|
|
72
|
+
end
|
|
73
|
+
if g.coord(nm).length != sh[i]
|
|
74
|
+
raise ArgumentError,"loop dimensions must have the same lengths(#{nm}; #{sh[i]} vs #{g.coord(nm).length})"
|
|
75
|
+
end
|
|
76
|
+
end
|
|
77
|
+
end
|
|
78
|
+
end
|
|
79
|
+
|
|
80
|
+
cs = [1]
|
|
81
|
+
(1...sh.length).each{|i| cs[i] = sh[i-1]*cs[i-1]}
|
|
82
|
+
idx_hash = Hash.new
|
|
83
|
+
for i in 0...len do
|
|
84
|
+
loopdimnames.each_with_index{|d,j|
|
|
85
|
+
idx_hash[d] = ((i/cs[j])%sh[j])..((i/cs[j])%sh[j]) # rank preserved
|
|
86
|
+
}
|
|
87
|
+
subs = gphyses.collect{|g| g[idx_hash] }
|
|
88
|
+
results = yield(*subs)
|
|
89
|
+
if !results.is_a?(Array)
|
|
90
|
+
raise "The return value of the block must be an Array of GPhys"
|
|
91
|
+
end
|
|
92
|
+
if i == 0
|
|
93
|
+
fl = files.shift
|
|
94
|
+
results_whole = Array.new
|
|
95
|
+
for j in 0...results.length
|
|
96
|
+
rs = results[j]
|
|
97
|
+
grid = rs.grid_copy
|
|
98
|
+
loopdimnames.each{|nm|
|
|
99
|
+
# replaces with original axes (full length)
|
|
100
|
+
if !grid.axnames.include?( nm )
|
|
101
|
+
raise "Dimension '#{nm}' has been eliminated. "+
|
|
102
|
+
"You must keep all loop dimensions."
|
|
103
|
+
end
|
|
104
|
+
grid.set_axis(nm,gphyses[0].axis(nm))
|
|
105
|
+
}
|
|
106
|
+
grid_new = io_module.write_grid(fl, grid)
|
|
107
|
+
results_whole.push(
|
|
108
|
+
GPhys.new( grid_new,
|
|
109
|
+
io_module.def_var(fl, rs.name, rs.data.ntype,
|
|
110
|
+
grid_new.axnames, rs.data)
|
|
111
|
+
)
|
|
112
|
+
)
|
|
113
|
+
fl = files.shift if files.length >= 1
|
|
114
|
+
end
|
|
115
|
+
end
|
|
116
|
+
for j in 0...results.length
|
|
117
|
+
rs = results[j]
|
|
118
|
+
results_whole[j][idx_hash] = rs.data
|
|
119
|
+
end
|
|
120
|
+
end
|
|
121
|
+
return results_whole
|
|
122
|
+
|
|
123
|
+
end
|
|
124
|
+
end # module IO_Common
|
|
125
|
+
end # class GPhys
|
|
126
|
+
end # module NumRu
|