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,1207 @@
|
|
|
1
|
+
=begin
|
|
2
|
+
=class NumRu::GPhys
|
|
3
|
+
|
|
4
|
+
==Class Methods
|
|
5
|
+
|
|
6
|
+
---GPhys.new(grid, data)
|
|
7
|
+
Constructor.
|
|
8
|
+
|
|
9
|
+
ARGUMENTS
|
|
10
|
+
* grid (a Grid) : the grid
|
|
11
|
+
* data (a VArray) : the data. (('grid')) and (('data')) must have
|
|
12
|
+
the same shape.
|
|
13
|
+
|
|
14
|
+
RETURN VALUE
|
|
15
|
+
* a GPhys
|
|
16
|
+
|
|
17
|
+
NOTE
|
|
18
|
+
* the arguments are NOT duplicated to construct a GPhys.
|
|
19
|
+
|
|
20
|
+
---GPhys.each_along_dims(gphyses, *loopdims){...} # a block is expected
|
|
21
|
+
|
|
22
|
+
Iterator to process GPhys objects too big to read on memory at once.
|
|
23
|
+
|
|
24
|
+
Makes a loop (loops) by dividing the GPhys object(s) (((|gphyses|)))
|
|
25
|
+
with the dimension(s) specified by ((|loopdims|)).
|
|
26
|
+
If the return value of the block is an Array, it is assumed to consist
|
|
27
|
+
of GPhys objects, and the return value of this method is an Array
|
|
28
|
+
in which the whole of the results are reconstructed as if no
|
|
29
|
+
iteration is made, which is the same behavior as
|
|
30
|
+
((|GPhys::IO.each_along_dims_write|)). If the return value of
|
|
31
|
+
the block is not an Array, this methods returns nil.
|
|
32
|
+
|
|
33
|
+
WARNING: Unlike ((|GPhys::IO.each_along_dims_write|)),
|
|
34
|
+
the results of this method is NOT written in file(s),
|
|
35
|
+
so be careful about memory usage if you put an Array of GPhys as the
|
|
36
|
+
return value of the block. You will probably need to have the size
|
|
37
|
+
of them smaller than input data.
|
|
38
|
+
|
|
39
|
+
ARGUMENTS
|
|
40
|
+
* gphyses (GPhys or Array of GPhys): GPhys object(s) to be processed.
|
|
41
|
+
All of them must have dimensions specified with ((|loopdims|)),
|
|
42
|
+
and their lengths must not vary among files. Other dimensions
|
|
43
|
+
are arbitrary, so, for example, ((|gphyses|)) could be
|
|
44
|
+
[a(lon,lat,time), b(lat,time)] as long as loopdims==["time"].
|
|
45
|
+
* loopdims (Array of String or Integer) : name (when String) or
|
|
46
|
+
count starting from zero (when Integer)
|
|
47
|
+
* expected block : Number of arguments == number of GPhys objects in
|
|
48
|
+
((|gphyses|)).
|
|
49
|
+
|
|
50
|
+
RETURN VALUE
|
|
51
|
+
* If the return value of the block is an Array,
|
|
52
|
+
GPhys objects in which the whole results are written in
|
|
53
|
+
(the Array must consist of GPhys objects).
|
|
54
|
+
If the return value of the block is NOT an Array,
|
|
55
|
+
nil is returned.
|
|
56
|
+
|
|
57
|
+
ERRORS
|
|
58
|
+
|
|
59
|
+
The following raise exceptions (in addition to errors in arguments).
|
|
60
|
+
|
|
61
|
+
* Dimensions specified by ((|loopdims|)) are not shared among
|
|
62
|
+
GPhys objects in ((|gphyses|)).
|
|
63
|
+
* Return value of the block is an Array, but it does not consist of
|
|
64
|
+
GPhys objects.
|
|
65
|
+
* (Only when the return value of the block is an Array):
|
|
66
|
+
Dimension(s) used for looping (((|loopdims|))) is(are) eliminated
|
|
67
|
+
from the returned GPhys objects.
|
|
68
|
+
|
|
69
|
+
USAGE
|
|
70
|
+
|
|
71
|
+
See the manual of ((|GPhys::IO.each_along_dims_write|)).
|
|
72
|
+
|
|
73
|
+
==Instance Methods
|
|
74
|
+
---data
|
|
75
|
+
Returns the data object
|
|
76
|
+
|
|
77
|
+
RETURN VALUE
|
|
78
|
+
* a VArray
|
|
79
|
+
|
|
80
|
+
NOTE
|
|
81
|
+
* the data object is NOT duplicated.
|
|
82
|
+
|
|
83
|
+
---grid_copy
|
|
84
|
+
Returns a copy (deep clone) of the grid object.
|
|
85
|
+
|
|
86
|
+
RETURN VALUE
|
|
87
|
+
* a Grid
|
|
88
|
+
|
|
89
|
+
NOTE
|
|
90
|
+
* There is a PROTECTED method (('grid')), which returns
|
|
91
|
+
the grid object without duplicating.
|
|
92
|
+
|
|
93
|
+
---copy
|
|
94
|
+
Make a deep clone onto memory
|
|
95
|
+
|
|
96
|
+
RETURN VALUE
|
|
97
|
+
* a GPhys
|
|
98
|
+
|
|
99
|
+
---name
|
|
100
|
+
Returns the name of the GPhys object, which is equal to the
|
|
101
|
+
name of the data object in the GPhys object.
|
|
102
|
+
|
|
103
|
+
RETURN VALUE
|
|
104
|
+
* a String
|
|
105
|
+
|
|
106
|
+
---name=(nm)
|
|
107
|
+
|
|
108
|
+
Set the name of the GPhys object.
|
|
109
|
+
|
|
110
|
+
ARGUMENTS
|
|
111
|
+
* nm (String)
|
|
112
|
+
|
|
113
|
+
RETURN VALUE
|
|
114
|
+
* nm (the argument)
|
|
115
|
+
|
|
116
|
+
---rename(nm)
|
|
117
|
+
|
|
118
|
+
Same as ((<name=>)), but (('self')) is returned.
|
|
119
|
+
|
|
120
|
+
ARGUMENTS
|
|
121
|
+
* nm (String)
|
|
122
|
+
|
|
123
|
+
RETURN VALUE
|
|
124
|
+
* self
|
|
125
|
+
|
|
126
|
+
---val
|
|
127
|
+
Returns data values
|
|
128
|
+
|
|
129
|
+
RETURN VALUE
|
|
130
|
+
* a NArray or NArrayMiss. It is always a copy and to write in it
|
|
131
|
+
will not affect self.
|
|
132
|
+
|
|
133
|
+
---val=(v)
|
|
134
|
+
Writes in data values.
|
|
135
|
+
|
|
136
|
+
ARGUMENTS
|
|
137
|
+
* v (NArray, NArrayMiss, or Numeric) : data to be written in.
|
|
138
|
+
|
|
139
|
+
RETURN VALUE
|
|
140
|
+
* v (the argument)
|
|
141
|
+
|
|
142
|
+
NOTE
|
|
143
|
+
* the contents of (('v')) are copied in, unlike ((<replace_val>))
|
|
144
|
+
|
|
145
|
+
---replace_val(v)
|
|
146
|
+
Replace the data values.
|
|
147
|
+
|
|
148
|
+
ARGUMENTS
|
|
149
|
+
* v (NArray or NArrayMiss) : data to be written in.
|
|
150
|
+
|
|
151
|
+
RETURN VALUE
|
|
152
|
+
* self
|
|
153
|
+
|
|
154
|
+
NOTE
|
|
155
|
+
* This method is similar to ((<val=>)), but
|
|
156
|
+
the whole numeric data object is replaced with (('v')).
|
|
157
|
+
It is not very meaningful if the data is in a file:
|
|
158
|
+
the file is not modified, but you just get an GPhys object on memory.
|
|
159
|
+
|
|
160
|
+
---att_names
|
|
161
|
+
Returns attribute names of the data object.
|
|
162
|
+
|
|
163
|
+
RETURN VALUE
|
|
164
|
+
* Array of String
|
|
165
|
+
|
|
166
|
+
---get_att(name)
|
|
167
|
+
Get the value of the attribute named (('name')).
|
|
168
|
+
|
|
169
|
+
ARGUMENTS
|
|
170
|
+
* name (String)
|
|
171
|
+
|
|
172
|
+
RETURN VALUE
|
|
173
|
+
* String, NArray, or nil
|
|
174
|
+
|
|
175
|
+
---set_att(name, val)
|
|
176
|
+
---put_att(name, val)
|
|
177
|
+
|
|
178
|
+
Set an attribute of the data object
|
|
179
|
+
|
|
180
|
+
ARGUMENTS
|
|
181
|
+
* name (String)
|
|
182
|
+
* val (String, NArray, or nil)
|
|
183
|
+
|
|
184
|
+
RETURN VALUE
|
|
185
|
+
* self
|
|
186
|
+
|
|
187
|
+
---del_att(name)
|
|
188
|
+
Delete an attribute of the data object.
|
|
189
|
+
|
|
190
|
+
ARGUMENTS
|
|
191
|
+
* name (String)
|
|
192
|
+
|
|
193
|
+
RETURN VALUE
|
|
194
|
+
* self
|
|
195
|
+
|
|
196
|
+
---ntype
|
|
197
|
+
Returns the numeric type of the data object.
|
|
198
|
+
|
|
199
|
+
RETURN VALUE
|
|
200
|
+
* String such as "float", and "sfloat"
|
|
201
|
+
|
|
202
|
+
NOTE
|
|
203
|
+
* See also ((<typecode>)).
|
|
204
|
+
|
|
205
|
+
---typecode
|
|
206
|
+
Returns the numeric type of the data object.
|
|
207
|
+
|
|
208
|
+
RETURN VALUE
|
|
209
|
+
* NArray constants such as NArray::FLOAT and NArray::SFLOAT.
|
|
210
|
+
|
|
211
|
+
NOTE
|
|
212
|
+
* See also ((<ntype>)).
|
|
213
|
+
|
|
214
|
+
---units
|
|
215
|
+
Returns the units of the data object
|
|
216
|
+
|
|
217
|
+
RETURN VALUE
|
|
218
|
+
* a Units
|
|
219
|
+
|
|
220
|
+
---units=(units)
|
|
221
|
+
Changes the units of the data object
|
|
222
|
+
|
|
223
|
+
ARGUMENTS
|
|
224
|
+
* units (Units or String)
|
|
225
|
+
|
|
226
|
+
RETURN VALUE
|
|
227
|
+
* units (the argument)
|
|
228
|
+
|
|
229
|
+
---convert_units(to)
|
|
230
|
+
Convert the units of the data object
|
|
231
|
+
|
|
232
|
+
ARGUMENTS
|
|
233
|
+
* to (a Units)
|
|
234
|
+
|
|
235
|
+
RETURN VALUE
|
|
236
|
+
* a GPhys
|
|
237
|
+
|
|
238
|
+
---long_name
|
|
239
|
+
Returns the "long_name" attribute the data object
|
|
240
|
+
|
|
241
|
+
RETURN VALUE
|
|
242
|
+
* a String
|
|
243
|
+
---long_name=(to)
|
|
244
|
+
|
|
245
|
+
Changes/sets the "long_name" attribute the data object
|
|
246
|
+
|
|
247
|
+
ARGUMENTS
|
|
248
|
+
* to (a String)
|
|
249
|
+
|
|
250
|
+
RETURN VALUE
|
|
251
|
+
* to (the argument)
|
|
252
|
+
|
|
253
|
+
---[]
|
|
254
|
+
Returns a subset.
|
|
255
|
+
|
|
256
|
+
ARGUMENTS
|
|
257
|
+
* Same as those for NArray#[], NetCDFVar#[], etc.
|
|
258
|
+
|
|
259
|
+
RETURN VALUE
|
|
260
|
+
* a GPhys
|
|
261
|
+
|
|
262
|
+
---[]=
|
|
263
|
+
Sets values of a subset
|
|
264
|
+
|
|
265
|
+
RETURN VALUE
|
|
266
|
+
* the data object on the rhs
|
|
267
|
+
|
|
268
|
+
---cut
|
|
269
|
+
Similar to ((<[]>)), but the subset is specified by physical coordinate.
|
|
270
|
+
|
|
271
|
+
ARGUMENTS
|
|
272
|
+
* pattern 1: similar to those for ((<[]>)), where the first
|
|
273
|
+
argument specifies a subset for the first dimension.
|
|
274
|
+
* pattern 2: by a Hash, in which keys are axis names.
|
|
275
|
+
|
|
276
|
+
EXAMPLES
|
|
277
|
+
* Pattern 1
|
|
278
|
+
gphys.cut(135.5,0..20.5,false)
|
|
279
|
+
* Pattern 2
|
|
280
|
+
gphys.cut({'lon'=>135.5,'lat'=>0..20})
|
|
281
|
+
|
|
282
|
+
RETURN VALUE
|
|
283
|
+
* a GPhys
|
|
284
|
+
|
|
285
|
+
---cut_rank_conserving
|
|
286
|
+
Similar to ((<cut>)), but the rank is conserved by not eliminating
|
|
287
|
+
any dimension (whose length could be one).
|
|
288
|
+
|
|
289
|
+
---axnames
|
|
290
|
+
Returns the names of the axes
|
|
291
|
+
|
|
292
|
+
RETURN VALUE
|
|
293
|
+
* an Array of String
|
|
294
|
+
|
|
295
|
+
---rank
|
|
296
|
+
Returns the rank
|
|
297
|
+
|
|
298
|
+
RETURN VALUE
|
|
299
|
+
* an Integer
|
|
300
|
+
|
|
301
|
+
---axis(dim)
|
|
302
|
+
Returns the Axis object of a dimension.
|
|
303
|
+
|
|
304
|
+
ARGEMENTS
|
|
305
|
+
* dim (Integer or String)
|
|
306
|
+
|
|
307
|
+
RETURN VALUE
|
|
308
|
+
* an Axis
|
|
309
|
+
|
|
310
|
+
---coord(dim)
|
|
311
|
+
---coordinate(dim)
|
|
312
|
+
|
|
313
|
+
Returns the coordinate variable
|
|
314
|
+
|
|
315
|
+
ARGUMENTS
|
|
316
|
+
* dim (Integer or String)
|
|
317
|
+
|
|
318
|
+
RETURN VALUE
|
|
319
|
+
* a VArray
|
|
320
|
+
|
|
321
|
+
NOTE
|
|
322
|
+
* (('coord(dim)')) is equivalent to (('axis(dim).pos'))
|
|
323
|
+
|
|
324
|
+
---lost_axes
|
|
325
|
+
Returns info on axes eliminated during operations.
|
|
326
|
+
|
|
327
|
+
Useful for annotation in plots, for example (See the code of GGraph
|
|
328
|
+
for an application).
|
|
329
|
+
|
|
330
|
+
RETURN VALUE
|
|
331
|
+
* an Array of String
|
|
332
|
+
|
|
333
|
+
---dim_index( dimname )
|
|
334
|
+
Returns the integer id (count from zero) of the dimension
|
|
335
|
+
|
|
336
|
+
ARGUMENT
|
|
337
|
+
* dimname (String or Integer) : this method is trivial if is is an integer
|
|
338
|
+
|
|
339
|
+
RETURN VALUE
|
|
340
|
+
* an Integer
|
|
341
|
+
|
|
342
|
+
---integrate(dim)
|
|
343
|
+
Integration along a dimension.
|
|
344
|
+
|
|
345
|
+
RETURN VALUE
|
|
346
|
+
* a GPhys
|
|
347
|
+
|
|
348
|
+
NOTE
|
|
349
|
+
* Algorithm implementation is done in Axis class.
|
|
350
|
+
|
|
351
|
+
---average(dim)
|
|
352
|
+
Averaging along a dimension.
|
|
353
|
+
|
|
354
|
+
RETURN VALUE
|
|
355
|
+
* a GPhys
|
|
356
|
+
|
|
357
|
+
NOTE
|
|
358
|
+
* Algorithm implementation is done in Axis class.
|
|
359
|
+
|
|
360
|
+
|
|
361
|
+
---eddy(*dim)
|
|
362
|
+
Deviation from mean
|
|
363
|
+
|
|
364
|
+
ARGUMENT
|
|
365
|
+
* a list of dimensions (including none) [Integer or String] along which
|
|
366
|
+
the mean is taken.
|
|
367
|
+
|
|
368
|
+
RETURN VALUE
|
|
369
|
+
* a GPhys
|
|
370
|
+
|
|
371
|
+
NOTE
|
|
372
|
+
* Simply defined as
|
|
373
|
+
|
|
374
|
+
def eddy(*dim)
|
|
375
|
+
self - self.mean(*dim)
|
|
376
|
+
end
|
|
377
|
+
|
|
378
|
+
---first1D
|
|
379
|
+
Returns a 1D subset selecting the first elements of 2nd, 3rd, ..
|
|
380
|
+
dimensions, i.e., self[true, 0, 0, ...]. (For graphics)
|
|
381
|
+
|
|
382
|
+
ARGUMENTS
|
|
383
|
+
* (none)
|
|
384
|
+
|
|
385
|
+
RETURN VALUE
|
|
386
|
+
* a GPhys
|
|
387
|
+
|
|
388
|
+
---first2D
|
|
389
|
+
Returns a 2D subset selecting the first elements of 3rd, 4th, ..
|
|
390
|
+
dimensions, i.e., self[true, true, 0, 0, ...]. (For graphics)
|
|
391
|
+
|
|
392
|
+
ARGUMENTS
|
|
393
|
+
* (none)
|
|
394
|
+
|
|
395
|
+
RETURN VALUE
|
|
396
|
+
* a GPhys
|
|
397
|
+
|
|
398
|
+
---first3D
|
|
399
|
+
Returns a 3D subset selecting the first elements of 4th, 5th, ..
|
|
400
|
+
dimensions, i.e., self[true, true, true, 0, ...]. (For graphics)
|
|
401
|
+
|
|
402
|
+
ARGUMENTS
|
|
403
|
+
* (none)
|
|
404
|
+
|
|
405
|
+
RETURN VALUE
|
|
406
|
+
* a GPhys
|
|
407
|
+
|
|
408
|
+
---coerce(other)
|
|
409
|
+
((|You know what it is.|))
|
|
410
|
+
|
|
411
|
+
---shape_coerce(other)
|
|
412
|
+
Like ((<coerce>)), but just changes shape without changing numeric type.
|
|
413
|
+
|
|
414
|
+
---transpose(*dims)
|
|
415
|
+
Transpose.
|
|
416
|
+
|
|
417
|
+
ARGUMENTS
|
|
418
|
+
* dims (integers) : for example, [1,0] to transpose a 2D object.
|
|
419
|
+
For 3D objects, [1,0,2], [2,1,0], etc.etc.
|
|
420
|
+
|
|
421
|
+
RETURN VALUE
|
|
422
|
+
* a GPhys
|
|
423
|
+
|
|
424
|
+
---shape_current
|
|
425
|
+
Returns the current shape of the GPhys object.
|
|
426
|
+
|
|
427
|
+
RETURN VALUE
|
|
428
|
+
* an Array of Integer
|
|
429
|
+
|
|
430
|
+
---shape
|
|
431
|
+
Aliased to ((<shape_current>))
|
|
432
|
+
|
|
433
|
+
---cyclic_ext(dim_or_dimname, modulo)
|
|
434
|
+
Extend a dimension cyclically.
|
|
435
|
+
|
|
436
|
+
The extension is done only when adding one grid point makes a full circle.
|
|
437
|
+
Thus, data at coordinate values [0,90,180,270] with modulo 360 are extended
|
|
438
|
+
(to at [0,90,180,270,360]), but data at [0,90,180] are not extended with
|
|
439
|
+
the same modulo: in this case, self is returned.
|
|
440
|
+
|
|
441
|
+
ARGUMENTS
|
|
442
|
+
* dim_or_dimname (String or Integer)
|
|
443
|
+
* modulo (Numeric)
|
|
444
|
+
|
|
445
|
+
RETURN VALUE
|
|
446
|
+
* a GPhys (possibly self)
|
|
447
|
+
|
|
448
|
+
|
|
449
|
+
=== Math functions (instance methods)
|
|
450
|
+
|
|
451
|
+
====sqrt, exp, log, log10, log2, sin, cos, tan, sinh, cosh, tanh, asin, acos, atan, asinh, acosh, atanh, csc, sec, cot, csch, sech, coth, acsc, asec, acot, acsch, asech, acoth
|
|
452
|
+
|
|
453
|
+
=== Binary operators
|
|
454
|
+
|
|
455
|
+
====-, +, *, /, %, **, .add!, .sub!, .mul!, .div!, mod!, >, >=, <, <=, &, |, ^, .eq, .ne, .gt, .ge, .lt, .le, .and, .or, .xor, .not
|
|
456
|
+
|
|
457
|
+
=== Unary operators
|
|
458
|
+
|
|
459
|
+
====~ - +
|
|
460
|
+
|
|
461
|
+
=== Mean etc (instance methods)
|
|
462
|
+
|
|
463
|
+
====mean, sum, stddev, min, max, median
|
|
464
|
+
|
|
465
|
+
=== Other instance methods
|
|
466
|
+
|
|
467
|
+
These methods returns a NArray (not a GPhys).
|
|
468
|
+
|
|
469
|
+
====all?, any?, none?, where, where2, floor, ceil, round, to_f, to_i, to_a
|
|
470
|
+
|
|
471
|
+
|
|
472
|
+
|
|
473
|
+
=end
|
|
474
|
+
|
|
475
|
+
require "numru/gphys/grid"
|
|
476
|
+
require "numru/misc/md_iterators"
|
|
477
|
+
require "numru/gphys/narray_ext"
|
|
478
|
+
|
|
479
|
+
module NumRu
|
|
480
|
+
class GPhys
|
|
481
|
+
|
|
482
|
+
include NumRu::Misc::MD_Iterators
|
|
483
|
+
|
|
484
|
+
def initialize(grid, data)
|
|
485
|
+
raise ArgumentError,"1st arg not a Grid" if ! grid.is_a?(Grid)
|
|
486
|
+
raise ArgumentError,"2nd arg not a VArray" if ! data.is_a?(VArray)
|
|
487
|
+
if ( grid.shape_current != data.shape_current )
|
|
488
|
+
raise ArgumentError, "Shapes of grid and data do not agree. " +
|
|
489
|
+
"#{grid.shape_current.inspect} vs #{data.shape_current.inspect}"
|
|
490
|
+
end
|
|
491
|
+
@grid = grid
|
|
492
|
+
@data = data
|
|
493
|
+
end
|
|
494
|
+
|
|
495
|
+
attr_reader :grid, :data
|
|
496
|
+
protected :grid
|
|
497
|
+
|
|
498
|
+
def grid_copy
|
|
499
|
+
# deep clone of the grid
|
|
500
|
+
@grid.copy
|
|
501
|
+
end
|
|
502
|
+
|
|
503
|
+
def copy
|
|
504
|
+
# deep clone onto memory
|
|
505
|
+
GPhys.new( @grid.copy, @data.copy )
|
|
506
|
+
end
|
|
507
|
+
|
|
508
|
+
def inspect
|
|
509
|
+
"<GPhys grid=#{@grid.inspect}\n data=#{@data.inspect}>"
|
|
510
|
+
end
|
|
511
|
+
|
|
512
|
+
def name
|
|
513
|
+
data.name
|
|
514
|
+
end
|
|
515
|
+
def name=(nm)
|
|
516
|
+
data.name=nm
|
|
517
|
+
end
|
|
518
|
+
def rename(nm)
|
|
519
|
+
data.name=nm
|
|
520
|
+
self
|
|
521
|
+
end
|
|
522
|
+
|
|
523
|
+
def val
|
|
524
|
+
@data.val
|
|
525
|
+
end
|
|
526
|
+
def val=(v)
|
|
527
|
+
@data.val= v
|
|
528
|
+
end
|
|
529
|
+
def replace_val(v)
|
|
530
|
+
raise(ArgumentError,"Shape miss-match") if @grid.shape != v.shape
|
|
531
|
+
@data.replace_val(v)
|
|
532
|
+
self
|
|
533
|
+
end
|
|
534
|
+
|
|
535
|
+
def att_names
|
|
536
|
+
@data.att_names
|
|
537
|
+
end
|
|
538
|
+
def get_att(name)
|
|
539
|
+
@data.get_att(name)
|
|
540
|
+
end
|
|
541
|
+
def set_att(name, val)
|
|
542
|
+
@data.set_att(name, val)
|
|
543
|
+
self
|
|
544
|
+
end
|
|
545
|
+
def del_att(name)
|
|
546
|
+
@data.del_att(name)
|
|
547
|
+
self
|
|
548
|
+
end
|
|
549
|
+
alias put_att set_att
|
|
550
|
+
|
|
551
|
+
def ntype
|
|
552
|
+
@data.ntype
|
|
553
|
+
end
|
|
554
|
+
|
|
555
|
+
def units
|
|
556
|
+
@data.units
|
|
557
|
+
end
|
|
558
|
+
def units=(units)
|
|
559
|
+
@data.units= units
|
|
560
|
+
end
|
|
561
|
+
|
|
562
|
+
def convert_units(to)
|
|
563
|
+
# ==NOTE:
|
|
564
|
+
# * VArray#convert_units does not copy data if to == @data.units
|
|
565
|
+
# * @grid is shared with self (no duplication)
|
|
566
|
+
# Thus, use GPhys#copy to separate all sub-objects (deep clone).
|
|
567
|
+
data = @data.convert_units(to)
|
|
568
|
+
GPhys.new(@grid, data)
|
|
569
|
+
end
|
|
570
|
+
|
|
571
|
+
def long_name
|
|
572
|
+
@data.long_name
|
|
573
|
+
end
|
|
574
|
+
def long_name=(long_name)
|
|
575
|
+
@data.long_name= long_name
|
|
576
|
+
end
|
|
577
|
+
|
|
578
|
+
def [](*slicer)
|
|
579
|
+
if slicer.length==1 && slicer[0].is_a?(Hash) &&
|
|
580
|
+
slicer[0].keys[0].is_a?(String)
|
|
581
|
+
slicer = __process_hash_slicer(slicer[0])
|
|
582
|
+
else
|
|
583
|
+
slicer = __rubber_expansion( slicer )
|
|
584
|
+
end
|
|
585
|
+
GPhys.new( @grid[*slicer], @data[*slicer] )
|
|
586
|
+
end
|
|
587
|
+
|
|
588
|
+
def []=(*args)
|
|
589
|
+
val = args.pop
|
|
590
|
+
slicer = args
|
|
591
|
+
if slicer.length==1 && slicer[0].is_a?(Hash) &&
|
|
592
|
+
slicer[0].keys[0].is_a?(String)
|
|
593
|
+
slicer = __process_hash_slicer(slicer[0])
|
|
594
|
+
else
|
|
595
|
+
slicer = __rubber_expansion( slicer )
|
|
596
|
+
end
|
|
597
|
+
val = val.data if val.respond_to?(:grid) #.is_a?(GPhys)
|
|
598
|
+
@data[*slicer] = val
|
|
599
|
+
end
|
|
600
|
+
|
|
601
|
+
def __process_hash_slicer(hash)
|
|
602
|
+
raise ArgumentError, "Expect a Hash" if !hash.is_a?(Hash)
|
|
603
|
+
if (hash.keys - axnames).length > 0
|
|
604
|
+
raise ArgumentError,"One or more of the hash keys "+
|
|
605
|
+
"(#{hash.keys.inspect}) are not found in the axis names "+
|
|
606
|
+
"(#{axnames.inspect})."
|
|
607
|
+
end
|
|
608
|
+
axnames.collect{|nm| hash[nm] || true} # slicer for []/[]=
|
|
609
|
+
end
|
|
610
|
+
private :__process_hash_slicer
|
|
611
|
+
|
|
612
|
+
def cut( *args )
|
|
613
|
+
if has_assoccoord? && args.length==1 && ((spec=args[0]).is_a?(Hash)) &&
|
|
614
|
+
( acnms = (spec.keys & assoccoordnames ) ).length > 0
|
|
615
|
+
acspec = Hash.new
|
|
616
|
+
acnms.each{|nm| acspec[nm] = spec.delete(nm)}
|
|
617
|
+
grid, sl = @grid.cut_assoccoord(acspec)
|
|
618
|
+
gphys = GPhys.new( grid, self.data[*sl] )
|
|
619
|
+
else
|
|
620
|
+
gphys = self
|
|
621
|
+
end
|
|
622
|
+
newgrid, slicer = gphys.grid.cut( *args )
|
|
623
|
+
GPhys.new( newgrid, gphys.data[ *slicer ] )
|
|
624
|
+
end
|
|
625
|
+
|
|
626
|
+
def cut_rank_conserving( *args )
|
|
627
|
+
newgrid, slicer = @grid.cut_rank_conserving( *args )
|
|
628
|
+
GPhys.new( newgrid, @data[ *slicer ] )
|
|
629
|
+
end
|
|
630
|
+
|
|
631
|
+
Axis.defined_operations.each do |method|
|
|
632
|
+
eval <<-EOS, nil, __FILE__, __LINE__+1
|
|
633
|
+
def #{method}(dim_or_dimname, *extra_args)
|
|
634
|
+
vary, grid = @grid.#{method}(@data, dim_or_dimname, *extra_args)
|
|
635
|
+
if grid
|
|
636
|
+
GPhys.new( grid, vary )
|
|
637
|
+
else
|
|
638
|
+
vary # scalar
|
|
639
|
+
end
|
|
640
|
+
end
|
|
641
|
+
EOS
|
|
642
|
+
end
|
|
643
|
+
|
|
644
|
+
def axnames
|
|
645
|
+
@grid.axnames
|
|
646
|
+
end
|
|
647
|
+
def rank
|
|
648
|
+
@grid.rank
|
|
649
|
+
end
|
|
650
|
+
def axis(i)
|
|
651
|
+
@grid.axis(i)
|
|
652
|
+
end
|
|
653
|
+
def coord(i)
|
|
654
|
+
@grid.coord(i)
|
|
655
|
+
end
|
|
656
|
+
def assoc_coord_gphys(name)
|
|
657
|
+
@grid.assoc_coord_gphys(name)
|
|
658
|
+
end
|
|
659
|
+
alias coordinate coord
|
|
660
|
+
def lost_axes
|
|
661
|
+
@grid.lost_axes
|
|
662
|
+
end
|
|
663
|
+
def set_lost_axes( lost )
|
|
664
|
+
@grid.set_lost_axes( lost )
|
|
665
|
+
self
|
|
666
|
+
end
|
|
667
|
+
def add_lost_axes( lost )
|
|
668
|
+
@grid.add_lost_axes( lost )
|
|
669
|
+
self
|
|
670
|
+
end
|
|
671
|
+
def dim_index( dimname )
|
|
672
|
+
@grid.dim_index( dimname )
|
|
673
|
+
end
|
|
674
|
+
def coordnames
|
|
675
|
+
@grid.coordnames
|
|
676
|
+
end
|
|
677
|
+
def has_axis?(name)
|
|
678
|
+
@grid.has_axis?(name)
|
|
679
|
+
end
|
|
680
|
+
def has_assoccoord?(*arg)
|
|
681
|
+
@grid.has_assoccoord?(*arg)
|
|
682
|
+
end
|
|
683
|
+
def has_coord?(name)
|
|
684
|
+
@grid.has_coord?(name)
|
|
685
|
+
end
|
|
686
|
+
def assoccoordnames
|
|
687
|
+
@grid.assoccoordnames
|
|
688
|
+
end
|
|
689
|
+
def set_assoc_coords(assoc_crds)
|
|
690
|
+
@grid.set_assoc_coords(assoc_crds)
|
|
691
|
+
end
|
|
692
|
+
def assoc_coords=(assoc_coords)
|
|
693
|
+
@grid.assoc_coords=assoc_coords
|
|
694
|
+
end
|
|
695
|
+
def assoc_coords
|
|
696
|
+
@grid.assoc_coords
|
|
697
|
+
end
|
|
698
|
+
|
|
699
|
+
## Basic numerical operations that are not defined on the VArray level
|
|
700
|
+
|
|
701
|
+
def eddy(*dim)
|
|
702
|
+
self - self.mean(*dim)
|
|
703
|
+
end
|
|
704
|
+
|
|
705
|
+
## For graphics -->
|
|
706
|
+
def first3D
|
|
707
|
+
raise "rank less than 3" if rank < 3
|
|
708
|
+
self[true,true,*([0]*(rank-3))]
|
|
709
|
+
end
|
|
710
|
+
def first2D
|
|
711
|
+
raise "rank less than 2" if rank < 2
|
|
712
|
+
self[true,true,*([0]*(rank-2))]
|
|
713
|
+
end
|
|
714
|
+
def first1D
|
|
715
|
+
raise "rank less than 1" if rank < 1
|
|
716
|
+
self[true,*([0]*(rank-1))]
|
|
717
|
+
end
|
|
718
|
+
## <-- For graphics
|
|
719
|
+
|
|
720
|
+
def coerce(other)
|
|
721
|
+
case other
|
|
722
|
+
when Numeric
|
|
723
|
+
##na_other = self.data.val.fill(other) # Not efficient!
|
|
724
|
+
va_other, = self.data.coerce(other)
|
|
725
|
+
c_other = GPhys.new( @grid[ *([0..0]*self.rank) ],
|
|
726
|
+
va_other.reshape!( *([1]*self.rank) ) )
|
|
727
|
+
c_other.put_att('units',nil) # should be treated as such, not 1
|
|
728
|
+
when Array, NArray
|
|
729
|
+
va_other, = self.data.coerce(other)
|
|
730
|
+
c_other = GPhys.new( @grid, va_other )
|
|
731
|
+
c_other.put_att('units',nil) # should be treated as such, not 1
|
|
732
|
+
when VArray
|
|
733
|
+
c_other = GPhys.new( @grid, other )
|
|
734
|
+
else
|
|
735
|
+
raise "Cannot coerse #{other.class}"
|
|
736
|
+
end
|
|
737
|
+
[c_other, self]
|
|
738
|
+
end
|
|
739
|
+
|
|
740
|
+
def shape_coerce(other)
|
|
741
|
+
#
|
|
742
|
+
# for binary operations
|
|
743
|
+
#
|
|
744
|
+
if self.rank == other.rank
|
|
745
|
+
# nothing to do
|
|
746
|
+
[other, self]
|
|
747
|
+
else
|
|
748
|
+
if self.rank < other.rank
|
|
749
|
+
shorter = self
|
|
750
|
+
longer = other
|
|
751
|
+
i_am_the_shorter = true
|
|
752
|
+
else
|
|
753
|
+
shorter = other
|
|
754
|
+
longer = self
|
|
755
|
+
i_am_the_shorter = false
|
|
756
|
+
end
|
|
757
|
+
reshape_args =
|
|
758
|
+
__shape_matching( shorter.shape_current, longer.shape_current,
|
|
759
|
+
shorter.axnames, longer.axnames )
|
|
760
|
+
shorter = shorter.data.copy.reshape!(*reshape_args)
|
|
761
|
+
##def shorter.data; self; end # singular method!
|
|
762
|
+
if i_am_the_shorter
|
|
763
|
+
[longer, shorter]
|
|
764
|
+
else
|
|
765
|
+
[shorter, longer]
|
|
766
|
+
end
|
|
767
|
+
end
|
|
768
|
+
end
|
|
769
|
+
|
|
770
|
+
def transpose(*dims)
|
|
771
|
+
grid = @grid.transpose(*dims)
|
|
772
|
+
data = @data.transpose(*dims)
|
|
773
|
+
GPhys.new( grid, data )
|
|
774
|
+
end
|
|
775
|
+
|
|
776
|
+
for f in VArray::Math_funcs
|
|
777
|
+
eval <<-EOS, nil, __FILE__, __LINE__+1
|
|
778
|
+
#def GPhys.#{f}(gphys)
|
|
779
|
+
# raise ArgumentError, "Not a GPhys" if !gphys.is_a?(GPhys)
|
|
780
|
+
# GPhys.new( gphys.grid, VArray.#{f}(gphys.data) )
|
|
781
|
+
#end
|
|
782
|
+
def #{f}(*arg)
|
|
783
|
+
GPhys.new( self.grid, self.data.#{f}(*arg) )
|
|
784
|
+
end
|
|
785
|
+
EOS
|
|
786
|
+
end
|
|
787
|
+
for f in VArray::Binary_operators
|
|
788
|
+
eval <<-EOS, nil, __FILE__, __LINE__+1
|
|
789
|
+
def #{f.delete(".")}(other)
|
|
790
|
+
if other.respond_to?(:grid) #.is_a?(GPhys)
|
|
791
|
+
other, myself = self.shape_coerce(other)
|
|
792
|
+
if myself.respond_to?(:grid) #.is_a?(GPhys)
|
|
793
|
+
if other.respond_to?(:grid) #.is_a?(GPhys)
|
|
794
|
+
vary = myself.data#{f} other.data
|
|
795
|
+
newgrid = myself.grid.merge(other.grid)
|
|
796
|
+
else
|
|
797
|
+
vary = myself.data#{f} other
|
|
798
|
+
newgrid = myself.grid_copy
|
|
799
|
+
end
|
|
800
|
+
GPhys.new( newgrid, vary )
|
|
801
|
+
else
|
|
802
|
+
if other.respond_to?(:grid) #.is_a?(GPhys)
|
|
803
|
+
vary = myself#{f} other.data
|
|
804
|
+
else
|
|
805
|
+
vary = myself#{f} other
|
|
806
|
+
end
|
|
807
|
+
GPhys.new( other.grid.copy, vary )
|
|
808
|
+
end
|
|
809
|
+
else
|
|
810
|
+
vary = self.data#{f} other
|
|
811
|
+
GPhys.new( @grid.copy, vary )
|
|
812
|
+
end
|
|
813
|
+
end
|
|
814
|
+
EOS
|
|
815
|
+
end
|
|
816
|
+
for f in VArray::Binary_operatorsL
|
|
817
|
+
eval <<-EOS, nil, __FILE__, __LINE__+1
|
|
818
|
+
def #{f.delete(".")}(other)
|
|
819
|
+
# returns NArray
|
|
820
|
+
self.data#{f}(other.respond_to?(:grid) ? other.data : other)
|
|
821
|
+
end
|
|
822
|
+
EOS
|
|
823
|
+
end
|
|
824
|
+
for f in VArray::Unary_operators
|
|
825
|
+
eval <<-EOS, nil, __FILE__, __LINE__+1
|
|
826
|
+
def #{f}
|
|
827
|
+
vary = #{f.delete("@")} self.data
|
|
828
|
+
GPhys.new( @grid.copy, vary )
|
|
829
|
+
end
|
|
830
|
+
EOS
|
|
831
|
+
end
|
|
832
|
+
for f in VArray::NArray_type1_methods
|
|
833
|
+
eval <<-EOS, nil, __FILE__, __LINE__+1
|
|
834
|
+
def #{f}(*args)
|
|
835
|
+
GPhys.new( self.grid.copy, self.data.#{f}(*args) )
|
|
836
|
+
end
|
|
837
|
+
EOS
|
|
838
|
+
end
|
|
839
|
+
for f in VArray::NArray_type2_methods
|
|
840
|
+
eval <<-EOS, nil, __FILE__, __LINE__+1
|
|
841
|
+
def #{f}(*args)
|
|
842
|
+
self.data.#{f}(*args)
|
|
843
|
+
end
|
|
844
|
+
EOS
|
|
845
|
+
end
|
|
846
|
+
for f in VArray::NArray_type3_methods
|
|
847
|
+
eval <<-EOS, nil, __FILE__, __LINE__+1
|
|
848
|
+
def #{f}(*args)
|
|
849
|
+
args = args.collect{|i| @grid.dim_index(i)}
|
|
850
|
+
result = self.data.#{f}(*args)
|
|
851
|
+
if Numeric===result || UNumeric===result
|
|
852
|
+
result
|
|
853
|
+
else
|
|
854
|
+
GPhys.new( self.grid.delete_axes(args, "#{f}"), result )
|
|
855
|
+
end
|
|
856
|
+
end
|
|
857
|
+
EOS
|
|
858
|
+
end
|
|
859
|
+
|
|
860
|
+
def shape_current
|
|
861
|
+
@data.shape_current
|
|
862
|
+
end
|
|
863
|
+
alias shape shape_current
|
|
864
|
+
|
|
865
|
+
def cyclic_ext(dim_or_dimname, modulo)
|
|
866
|
+
# Cyclic extention to push the first element after the last element
|
|
867
|
+
# if appropriate.
|
|
868
|
+
|
|
869
|
+
# <<developper's memo by horinout, 2005/01>>
|
|
870
|
+
# in future modulo should be read based on conventions if nil
|
|
871
|
+
|
|
872
|
+
vx = coord(dim_or_dimname)
|
|
873
|
+
return self if vx.length <= 1
|
|
874
|
+
|
|
875
|
+
vvx = vx.val
|
|
876
|
+
width = (vvx[-1] - vvx[0]).abs
|
|
877
|
+
dx = width / (vx.length-1)
|
|
878
|
+
eps = 1e-4
|
|
879
|
+
modulo = modulo.abs
|
|
880
|
+
extendible = ( ((width+dx) - modulo).abs < eps*modulo )
|
|
881
|
+
|
|
882
|
+
if extendible
|
|
883
|
+
dim = @grid.dim_index(dim_or_dimname)
|
|
884
|
+
newgp = self.copy[false, [0...vx.length, 0], *([true]*(rank-1-dim))]
|
|
885
|
+
vx = newgp.coord(dim).copy
|
|
886
|
+
vx[-1] = vx[-1].val + modulo
|
|
887
|
+
newgp.axis(dim).set_pos(vx)
|
|
888
|
+
return newgp
|
|
889
|
+
else
|
|
890
|
+
return self
|
|
891
|
+
end
|
|
892
|
+
end
|
|
893
|
+
|
|
894
|
+
def self.each_along_dims(gphyses, loopdims)
|
|
895
|
+
if !gphyses.is_a?(Array)
|
|
896
|
+
gphyses = [gphyses] # put in an Array (if a single GPhys)
|
|
897
|
+
end
|
|
898
|
+
gp = gphyses[0]
|
|
899
|
+
|
|
900
|
+
if !loopdims.is_a?(Array)
|
|
901
|
+
loopdims = [loopdims] # put in an Array (if a single Integer/String)
|
|
902
|
+
end
|
|
903
|
+
if loopdims.length == 0
|
|
904
|
+
#raise ArgumentError, "No loop dimension is specified "+
|
|
905
|
+
# " -- In that case, you don't need this iterator."
|
|
906
|
+
|
|
907
|
+
return yield(*gphyses) # trivial case supported just for generality
|
|
908
|
+
end
|
|
909
|
+
|
|
910
|
+
#if loopdims.min<0 || loopdims.max>=gp.rank
|
|
911
|
+
# raise ArguemntError,"Invalid dims #{loopdims.inspect} for #{gp.rank}D array"
|
|
912
|
+
#end
|
|
913
|
+
|
|
914
|
+
loopdimids = Array.new
|
|
915
|
+
loopdimnames = Array.new
|
|
916
|
+
loopdims.each{|d|
|
|
917
|
+
case d
|
|
918
|
+
when Integer
|
|
919
|
+
if d < 0
|
|
920
|
+
d += gp.rank
|
|
921
|
+
end
|
|
922
|
+
loopdimids.push( d )
|
|
923
|
+
loopdimnames.push( gp.axis(d).name )
|
|
924
|
+
when String
|
|
925
|
+
loopdimids.push( gp.dim_index(d) )
|
|
926
|
+
loopdimnames.push( d )
|
|
927
|
+
else
|
|
928
|
+
raise ArgumentError,"loopdims must consist of Integer and/or String"
|
|
929
|
+
end
|
|
930
|
+
}
|
|
931
|
+
|
|
932
|
+
sh = Array.new
|
|
933
|
+
len = 1
|
|
934
|
+
loopdimids.each{|i|
|
|
935
|
+
sh.push(gp.shape[i])
|
|
936
|
+
len *= gp.shape[i]
|
|
937
|
+
}
|
|
938
|
+
|
|
939
|
+
gphyses.each do |g|
|
|
940
|
+
for i in 1...gphyses.length
|
|
941
|
+
loopdimnames.each_with_index do |nm,i|
|
|
942
|
+
if !g.axnames.include?( nm )
|
|
943
|
+
raise ArgumentError,"#{i+1}-th GPhys do not have dim '#{nm}'"
|
|
944
|
+
end
|
|
945
|
+
if g.coord(nm).length != sh[i]
|
|
946
|
+
raise ArgumentError,"loop dimensions must have the same lengths(#{nm}; #{sh[i]} vs #{g.coord(nm).length})"
|
|
947
|
+
end
|
|
948
|
+
end
|
|
949
|
+
end
|
|
950
|
+
end
|
|
951
|
+
|
|
952
|
+
to_return = nil
|
|
953
|
+
|
|
954
|
+
cs = [1]
|
|
955
|
+
(1...sh.length).each{|i| cs[i] = sh[i-1]*cs[i-1]}
|
|
956
|
+
idx_hash = Hash.new
|
|
957
|
+
for i in 0...len do
|
|
958
|
+
loopdimnames.each_with_index{|d,j|
|
|
959
|
+
idx_hash[d] = ((i/cs[j])%sh[j])..((i/cs[j])%sh[j]) # rank preserved
|
|
960
|
+
}
|
|
961
|
+
subs = gphyses.collect{|g| g[idx_hash] }
|
|
962
|
+
results = yield(*subs)
|
|
963
|
+
if results.is_a?(Array) # then it must consist of GPhys objects
|
|
964
|
+
if i == 0
|
|
965
|
+
to_return = results_whole = Array.new
|
|
966
|
+
for j in 0...results.length
|
|
967
|
+
rs = results[j]
|
|
968
|
+
grid = rs.grid_copy
|
|
969
|
+
loopdimnames.each{|nm|
|
|
970
|
+
# replaces with original axes (full length)
|
|
971
|
+
if !grid.axnames.include?( nm )
|
|
972
|
+
raise "Dimension '#{nm}' has been eliminated. "+
|
|
973
|
+
"You must keep all loop dimensions."
|
|
974
|
+
end
|
|
975
|
+
grid.set_axis(nm,gphyses[0].axis(nm))
|
|
976
|
+
}
|
|
977
|
+
if ( (vtst=rs.data[0..0,false].val).respond_to?(:set_mask) )
|
|
978
|
+
# DEVELOPPER'S NOTE (2006/08/15 horinout).
|
|
979
|
+
# Here, [0..0,false] is to take the minimum subset,
|
|
980
|
+
# and respond_to?(:set_mask) is used to check whether
|
|
981
|
+
# the data array is compatible to NArrayMiss
|
|
982
|
+
vary = VArray.new(NArrayMiss.new(vtst.typecode, *grid.shape),
|
|
983
|
+
rs.data)
|
|
984
|
+
else
|
|
985
|
+
vary = VArray.new(NArray.new(vtst.typecode, *grid.shape), rs.data)
|
|
986
|
+
end
|
|
987
|
+
results_whole.push( GPhys.new( grid, vary ) )
|
|
988
|
+
end
|
|
989
|
+
end
|
|
990
|
+
for j in 0...results.length
|
|
991
|
+
rs = results[j]
|
|
992
|
+
results_whole[j][idx_hash] = rs.data
|
|
993
|
+
end
|
|
994
|
+
else
|
|
995
|
+
to_return = nil
|
|
996
|
+
end
|
|
997
|
+
end
|
|
998
|
+
return to_return
|
|
999
|
+
|
|
1000
|
+
end
|
|
1001
|
+
|
|
1002
|
+
def marshal_dump
|
|
1003
|
+
[@data.copy, @grid.copy]
|
|
1004
|
+
end
|
|
1005
|
+
|
|
1006
|
+
def marshal_load(ary)
|
|
1007
|
+
@data = ary[0]
|
|
1008
|
+
@grid = ary[1]
|
|
1009
|
+
end
|
|
1010
|
+
|
|
1011
|
+
############## < private methods > ##############
|
|
1012
|
+
|
|
1013
|
+
private
|
|
1014
|
+
def __rubber_expansion( args )
|
|
1015
|
+
if (id = args.index(false)) # substitution into id
|
|
1016
|
+
# false is incuded
|
|
1017
|
+
alen = args.length
|
|
1018
|
+
if args.rindex(false) != id
|
|
1019
|
+
raise ArguemntError,"only one rubber dimension is permitted"
|
|
1020
|
+
elsif alen > rank+1
|
|
1021
|
+
raise ArgumentError, "too many args"
|
|
1022
|
+
end
|
|
1023
|
+
ar = ( id!=0 ? args[0..id-1] : [] )
|
|
1024
|
+
args = ar + [true]*(rank-alen+1) + args[id+1..-1]
|
|
1025
|
+
end
|
|
1026
|
+
args
|
|
1027
|
+
end
|
|
1028
|
+
|
|
1029
|
+
def __shape_matching( shs, shl, axnms, axnml )
|
|
1030
|
+
# shs : shape of the shorter
|
|
1031
|
+
# shl : shape of the longer
|
|
1032
|
+
# axnms : axis names of the shorter
|
|
1033
|
+
# axnml : axis names of the longer
|
|
1034
|
+
#
|
|
1035
|
+
# Return value is reshape_args, which is to be used
|
|
1036
|
+
# as shorter.reshape( *reshape_args )
|
|
1037
|
+
|
|
1038
|
+
# < matching from the first element >
|
|
1039
|
+
shlc = shl.dup
|
|
1040
|
+
table = Array.new
|
|
1041
|
+
last_idx=-1
|
|
1042
|
+
shs.each do |len|
|
|
1043
|
+
i = shlc.index(len)
|
|
1044
|
+
if !i
|
|
1045
|
+
raise "cannot match shapes #{shs.inspect} and #{shl.inspect}"
|
|
1046
|
+
end
|
|
1047
|
+
idx = i+last_idx+1
|
|
1048
|
+
table.push(idx)
|
|
1049
|
+
(i+1).times{ shlc.shift }
|
|
1050
|
+
last_idx = idx
|
|
1051
|
+
end
|
|
1052
|
+
|
|
1053
|
+
# < matching from the last element >
|
|
1054
|
+
shlc = shl.dup
|
|
1055
|
+
rtable = Array.new
|
|
1056
|
+
shs.reverse_each do |len|
|
|
1057
|
+
i = shlc.rindex(len)
|
|
1058
|
+
if !i
|
|
1059
|
+
raise "cannot match shapes #{shs.inspect} and #{shl.inspect}"
|
|
1060
|
+
end
|
|
1061
|
+
idx = i
|
|
1062
|
+
rtable.push(idx)
|
|
1063
|
+
(shlc.length-idx).times{ shlc.pop }
|
|
1064
|
+
end
|
|
1065
|
+
rtable.reverse!
|
|
1066
|
+
|
|
1067
|
+
if table != rtable
|
|
1068
|
+
# < matching ambiguous => try to match by name >
|
|
1069
|
+
|
|
1070
|
+
real_table = table.dup # just to start with.
|
|
1071
|
+
# rtable will be merged in the following
|
|
1072
|
+
|
|
1073
|
+
shs.each_index do |i|
|
|
1074
|
+
#print axnms[i]," ",axnml[ table[i] ]," ",axnml[ rtable[i] ],"\n"
|
|
1075
|
+
if axnms[i] == axnml[ rtable[i] ]
|
|
1076
|
+
real_table[i] = rtable[i]
|
|
1077
|
+
elsif axnms[i] != axnml[ table[i] ]
|
|
1078
|
+
raise "Both matchings by orders and by names failed for the #{i}-th axis #{axnms[i]}."
|
|
1079
|
+
end
|
|
1080
|
+
end
|
|
1081
|
+
|
|
1082
|
+
table = real_table
|
|
1083
|
+
|
|
1084
|
+
end
|
|
1085
|
+
|
|
1086
|
+
# < derive the argument for the reshape method >
|
|
1087
|
+
|
|
1088
|
+
reshape_args = Array.new
|
|
1089
|
+
shl.length.times{ reshape_args.push(1) }
|
|
1090
|
+
for i in 0...table.length
|
|
1091
|
+
reshape_args[ table[i] ] = shs[i]
|
|
1092
|
+
end
|
|
1093
|
+
|
|
1094
|
+
reshape_args
|
|
1095
|
+
end
|
|
1096
|
+
|
|
1097
|
+
end
|
|
1098
|
+
end
|
|
1099
|
+
|
|
1100
|
+
|
|
1101
|
+
######################################################
|
|
1102
|
+
## < test >
|
|
1103
|
+
if $0 == __FILE__
|
|
1104
|
+
include NumRu
|
|
1105
|
+
vx = VArray.new( NArray.float(10).indgen! + 0.5 ).rename("x")
|
|
1106
|
+
vy = VArray.new( NArray.float(6).indgen! ).rename("y")
|
|
1107
|
+
xax = Axis.new().set_pos(vx)
|
|
1108
|
+
yax = Axis.new(true).set_cell_guess_bounds(vy).set_pos_to_center
|
|
1109
|
+
grid = Grid.new(xax, yax)
|
|
1110
|
+
|
|
1111
|
+
z = VArray.new( NArray.float(vx.length, vy.length).indgen! )
|
|
1112
|
+
p z.val
|
|
1113
|
+
w = VArray.new( NArray.float(vx.length, vy.length).indgen!/10 ) # .random!
|
|
1114
|
+
|
|
1115
|
+
gpz = GPhys.new(grid,z)
|
|
1116
|
+
gg = gpz[true,[0,2,1]]
|
|
1117
|
+
p '###',gg.val
|
|
1118
|
+
p gg[true,1].val
|
|
1119
|
+
p gg['y'=>1].val
|
|
1120
|
+
gg['y'=>1] = 999
|
|
1121
|
+
p gg.val
|
|
1122
|
+
p gg.coord(0).val, gg.coord(1).val
|
|
1123
|
+
p gg.cut([1.2,3.8],1.1).val
|
|
1124
|
+
|
|
1125
|
+
gpw = GPhys.new(grid,w)
|
|
1126
|
+
p '@@@',gpw.average(1).val
|
|
1127
|
+
p ( (gpz + gpw).val )
|
|
1128
|
+
|
|
1129
|
+
vz = VArray.new( NArray.float(6).indgen! ).rename("z")
|
|
1130
|
+
zax = Axis.new().set_pos(vz)
|
|
1131
|
+
|
|
1132
|
+
grid3 = Grid.new(xax,yax,zax)
|
|
1133
|
+
gridz = Grid.new(zax)
|
|
1134
|
+
z3 = VArray.new( NArray.float(vx.length, vy.length, vz.length).indgen! )
|
|
1135
|
+
q = VArray.new( NArray.float(vz.length).indgen!*100 )
|
|
1136
|
+
gpz3 = GPhys.new(grid3,z3)
|
|
1137
|
+
gpq = GPhys.new(gridz,q)
|
|
1138
|
+
p ( (gpz3 + gpq).val )
|
|
1139
|
+
p ( (gpz + gpq).val )
|
|
1140
|
+
p ( (gpz3 + gpz).val )
|
|
1141
|
+
|
|
1142
|
+
print "#######\n"
|
|
1143
|
+
p gpz.val, gpz[2..5,2..3].val
|
|
1144
|
+
gpz[2..5,2..3]=999
|
|
1145
|
+
p gpz.val
|
|
1146
|
+
p gpz
|
|
1147
|
+
p gpz.sort.val
|
|
1148
|
+
|
|
1149
|
+
print "*****\n"
|
|
1150
|
+
gpz.each_subary_at_dims(1){|sub|
|
|
1151
|
+
p sub.val
|
|
1152
|
+
}
|
|
1153
|
+
print "===\n"
|
|
1154
|
+
gpz_m0=gpz.mean(0)
|
|
1155
|
+
p gpz.val, gpz_m0.val, gpz_m0.lost_axes
|
|
1156
|
+
p gpz.mean, gpz.max
|
|
1157
|
+
p gpz.mean("x").val
|
|
1158
|
+
|
|
1159
|
+
print "transpose\n"
|
|
1160
|
+
p gpz3.axnames, gpz3.val,
|
|
1161
|
+
gpz3.transpose(2,0,1).axnames, gpz3.transpose(2,0,1).val
|
|
1162
|
+
|
|
1163
|
+
print "manual cyclic extention\n"
|
|
1164
|
+
p(sp=gpz3.shape)
|
|
1165
|
+
gpz3_cext = gpz3[ [0...sp[0],0], false ]
|
|
1166
|
+
p gpz3_cext.coord(0).val, gpz3_cext.val
|
|
1167
|
+
|
|
1168
|
+
print "cyclic extention if appropriate\n"
|
|
1169
|
+
gpz3_cext = gpz3.cyclic_ext(0,10.0)
|
|
1170
|
+
p gpz3_cext.coord(0).val, gpz3_cext.val
|
|
1171
|
+
|
|
1172
|
+
print "axis to gphys\n"
|
|
1173
|
+
ax = gpz3.axis(1)
|
|
1174
|
+
p ax.to_gphys
|
|
1175
|
+
p ax.to_gphys( ax.cell_bounds[0..-2].copy )
|
|
1176
|
+
|
|
1177
|
+
print "convert units\n"
|
|
1178
|
+
gpz3.units = 'm'
|
|
1179
|
+
p gpz3.units
|
|
1180
|
+
gpz3k = gpz3.convert_units('km')
|
|
1181
|
+
p gpz3k.units, gpz3.val, gpz3k.val
|
|
1182
|
+
|
|
1183
|
+
print "each_along_dims\n"
|
|
1184
|
+
p gpz3.mean(0,1).val
|
|
1185
|
+
x = GPhys.each_along_dims(gpz3,-1) do |sub|
|
|
1186
|
+
p sub.mean # non-Array return obj of the block --> nil returned
|
|
1187
|
+
end
|
|
1188
|
+
p x # must be nil
|
|
1189
|
+
gpz3mn, = GPhys.each_along_dims(gpz3,-1) do |sub|
|
|
1190
|
+
[ sub.mean(0) ] # return obj of block is Array -> concat sub GPhys objs
|
|
1191
|
+
end
|
|
1192
|
+
p gpz3mn.val, gpz3mn.mean(0).val
|
|
1193
|
+
|
|
1194
|
+
# trivial case (with no loop)
|
|
1195
|
+
gpz3mn, = GPhys.each_along_dims(gpz3, []) do |sub|
|
|
1196
|
+
[ sub.mean(0) ]
|
|
1197
|
+
end
|
|
1198
|
+
p( (gpz3mn - gpz3.mean(0)).abs.max )
|
|
1199
|
+
|
|
1200
|
+
# test marshaling
|
|
1201
|
+
p gpz
|
|
1202
|
+
mar = Marshal.dump(gpz)
|
|
1203
|
+
p mar.class, mar.length
|
|
1204
|
+
g = Marshal.load(mar)
|
|
1205
|
+
p g
|
|
1206
|
+
|
|
1207
|
+
end
|