gentooboontoo-gphys 0.6.1.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/ChangeLog +1255 -0
- data/README +32 -0
- data/bin/gdir_client +9 -0
- data/bin/gdir_server +123 -0
- data/bin/gpaop +134 -0
- data/bin/gpcat +140 -0
- data/bin/gpcut +94 -0
- data/bin/gpedit +196 -0
- data/bin/gplist +67 -0
- data/bin/gpmath +114 -0
- data/bin/gpmaxmin +127 -0
- data/bin/gpprint +57 -0
- data/bin/gpvect +657 -0
- data/bin/gpview +603 -0
- data/bin/grads2nc_with_gphys +56 -0
- data/doc/attribute.html +19 -0
- data/doc/attributenetcdf.html +15 -0
- data/doc/axis.html +368 -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 +33 -0
- data/doc/ggraph.html +1332 -0
- data/doc/gpcat.html +27 -0
- data/doc/gpcut.html +27 -0
- data/doc/gphys.html +501 -0
- data/doc/gphys_fft.html +183 -0
- data/doc/gphys_grads_io.html +69 -0
- data/doc/gphys_grib_io.html +82 -0
- data/doc/gphys_io.html +96 -0
- data/doc/gphys_io_common.html +18 -0
- data/doc/gphys_netcdf_io.html +283 -0
- data/doc/gplist.html +23 -0
- data/doc/gpmath.html +34 -0
- data/doc/gpmaxmin.html +30 -0
- data/doc/gpprint.html +32 -0
- data/doc/gpview.html +187 -0
- data/doc/grads2nc_with_gphys.html +23 -0
- data/doc/grads_gridded.html +307 -0
- data/doc/grib.html +101 -0
- data/doc/grid.html +240 -0
- data/doc/index.html +125 -0
- data/doc/index.rd +121 -0
- data/doc/netcdf_convention.html +136 -0
- data/doc/unumeric.html +127 -0
- data/doc/update +64 -0
- data/doc/varray.html +293 -0
- data/doc/varraycomposite.html +67 -0
- data/lib/numru/dclext_datetime_ax.rb +220 -0
- data/lib/numru/derivative.rb +298 -0
- data/lib/numru/gdir.rb +1038 -0
- data/lib/numru/gdir_connect_ftp-like.rb +149 -0
- data/lib/numru/ggraph.rb +4604 -0
- data/lib/numru/ggraph_on_merdional_section.rb +178 -0
- data/lib/numru/gphys/attribute.rb +130 -0
- data/lib/numru/gphys/attributenetcdf.rb +80 -0
- data/lib/numru/gphys/axis.rb +958 -0
- data/lib/numru/gphys/coordmapping.rb +286 -0
- data/lib/numru/gphys/coordtransform.rb +209 -0
- data/lib/numru/gphys/derivative.rb +297 -0
- data/lib/numru/gphys/ep_flux.rb +868 -0
- data/lib/numru/gphys/gpcommon.rb +52 -0
- data/lib/numru/gphys/gphys.rb +1121 -0
- data/lib/numru/gphys/gphys_fft.rb +538 -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_io.rb +363 -0
- data/lib/numru/gphys/gphys_io_common.rb +126 -0
- data/lib/numru/gphys/gphys_netcdf_io.rb +767 -0
- data/lib/numru/gphys/gphys_nusdas_io.rb +78 -0
- data/lib/numru/gphys/grads_gridded.rb +1539 -0
- data/lib/numru/gphys/grib.rb +2005 -0
- data/lib/numru/gphys/grib_params.rb +1270 -0
- data/lib/numru/gphys/grid.rb +602 -0
- data/lib/numru/gphys/netcdf_convention.rb +366 -0
- data/lib/numru/gphys/subsetmapping.rb +332 -0
- data/lib/numru/gphys/unumeric.rb +452 -0
- data/lib/numru/gphys/varray.rb +1079 -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/varraynetcdf.rb +348 -0
- data/lib/numru/gphys/varraynusdas.rb +59 -0
- data/lib/numru/gphys.rb +7 -0
- data/lib/numru/htdir.rb +170 -0
- data/lib/numru/vizshot.rb +697 -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/test/test_ep_flux.rb +533 -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/cira86.dat +1332 -0
- metadata +527 -0
@@ -0,0 +1,366 @@
|
|
1
|
+
require "numru/netcdf"
|
2
|
+
require "numru/netcdf_miss"
|
3
|
+
require "numru/gphys/varray" # for constants of VArray
|
4
|
+
|
5
|
+
=begin
|
6
|
+
|
7
|
+
==INDEX
|
8
|
+
* ((<module NumRu::NetCDF_Conventions>))
|
9
|
+
* ((<module NumRu::NetCDF_Convention_Users_Guide>))
|
10
|
+
* ((<module NumRu::NetCDF_Convention_Users_Guide::Attribute_Mixin>))
|
11
|
+
* ((<module NumRu::NetCDF_Convention_Users_Guide::VArray_Mixin>))
|
12
|
+
* ((<module NumRu::NetCDF_Convention_Wind_Profiler>))
|
13
|
+
|
14
|
+
=module NumRu::NetCDF_Conventions
|
15
|
+
|
16
|
+
NetCDF_Conventions is the general handler of NetCDF conventions for the
|
17
|
+
GPhys library.
|
18
|
+
|
19
|
+
==Module Functions
|
20
|
+
|
21
|
+
---find( netcdf )
|
22
|
+
|
23
|
+
Figures out what NetCDF convention a netcdf file is following.
|
24
|
+
|
25
|
+
ARGUMENTS
|
26
|
+
* ((|netcdf|)) (NetCDF): the file
|
27
|
+
|
28
|
+
RETURN VALUE
|
29
|
+
* a Module (NumRu::NetCDF_Convention_Users_Guide etc.)
|
30
|
+
|
31
|
+
REMARK
|
32
|
+
* The convention is figured out from the 'Conventions' global attribute.
|
33
|
+
You can instead fix the convention by using ((<fix_to>)).
|
34
|
+
|
35
|
+
---fix_to( convention )
|
36
|
+
|
37
|
+
Fix the convention to be returned by ((<find>)) regardless the value
|
38
|
+
of the 'Conventions' attribute.
|
39
|
+
|
40
|
+
ARGUMENTS
|
41
|
+
* ((|convention|)) (Module): NumRu::NetCDF_Convention_Users_Guide etc.
|
42
|
+
|
43
|
+
RETURN VALUE
|
44
|
+
* convention
|
45
|
+
|
46
|
+
---add_history(netcdf, str=nil)
|
47
|
+
|
48
|
+
Adds a line to the 'history' global convention of ((|netcdf|)).
|
49
|
+
The line consists of date, time, user name, and ((|str|))
|
50
|
+
if present (e.g., '2004-03-02 17:52:25 JST horinout> '+str).
|
51
|
+
|
52
|
+
ARGUMENTS
|
53
|
+
* ((|netcdf|)) (NetCDF): the file in which the history is updated
|
54
|
+
* ((|str|)) (nil or String): if present, added to the end of the line.
|
55
|
+
|
56
|
+
=module NumRu::NetCDF_Convention_Users_Guide
|
57
|
+
|
58
|
+
The NetCDF Users Guide Convention
|
59
|
+
(http://www.unidata.ucar.edu/packages/netcdf/docs.html).
|
60
|
+
|
61
|
+
==Constants
|
62
|
+
|
63
|
+
---Attribute_Mixin
|
64
|
+
|
65
|
+
See below: ((<module NumRu::NetCDF_Convention_Users_Guide::Attribute_Mixin>)).
|
66
|
+
|
67
|
+
---VArray_Mixin
|
68
|
+
|
69
|
+
See below: ((<module NumRu::NetCDF_Convention_Users_Guide::VArray_Mixin>)).
|
70
|
+
|
71
|
+
|
72
|
+
==Module Functions
|
73
|
+
|
74
|
+
---to_s
|
75
|
+
Returns a string to be used as representing the convention.
|
76
|
+
The Users Guide Convention does not have one, so a string
|
77
|
+
was tentatively assigned by Horinouchi.
|
78
|
+
|
79
|
+
---coord_var_names(ncvar)
|
80
|
+
Returns the names of coordinate variables for all the dimensions
|
81
|
+
of ((|ncvar|)).
|
82
|
+
|
83
|
+
ARGUMENTS
|
84
|
+
* ((|ncvar|)) (NetCDFVar)
|
85
|
+
|
86
|
+
RETURN VALUE
|
87
|
+
* Array of strings, whose length is the rank of ((|ncvar|)).
|
88
|
+
|
89
|
+
---cell_bounds?(coord_var)
|
90
|
+
Document to be written. (returns false&nil in this convention.)
|
91
|
+
Might be reorganized in future when the gtool4 convention is supported.
|
92
|
+
|
93
|
+
---cell_center?(coord_var)
|
94
|
+
Document to be written. (returns false&nil in this convention.)
|
95
|
+
Might be reorganized in future when the gtool4 convention is supported.
|
96
|
+
|
97
|
+
--------------------------------------------------
|
98
|
+
==module NumRu::NetCDF_Convention_Users_Guide::Attribute_Mixin
|
99
|
+
|
100
|
+
The module to be mixed in NumRu::AttributeNetCDF.
|
101
|
+
|
102
|
+
===Instance Methods
|
103
|
+
|
104
|
+
Methods below will become sigular methods of NumRu::AttributeNetCDF.
|
105
|
+
|
106
|
+
---copy(to=nil)
|
107
|
+
Same as (('super')) (the one overridden by this method),
|
108
|
+
but edits some standard attributes if (('to')) is nil (copy onto memory)):
|
109
|
+
* scale_factor, add_offset: removed, since data copying includes
|
110
|
+
"unpaking" by interpreting them
|
111
|
+
* valid_*, missing_value: unpacked if packed.
|
112
|
+
* _FillValue, FORTRAN_format, C_format: eliminated
|
113
|
+
|
114
|
+
---------------------------------------------------
|
115
|
+
==module NumRu::NetCDF_Convention_Users_Guide::VArray_Mixin
|
116
|
+
|
117
|
+
The module to be mixed in NumRu::VArrayNetCDF.
|
118
|
+
|
119
|
+
===Instance Methods
|
120
|
+
|
121
|
+
Currently none, meaning is that no modification is made
|
122
|
+
in VArrayNetCDF.
|
123
|
+
|
124
|
+
---------------------------------------------------------------------
|
125
|
+
=module NumRu::NetCDF_Convention_Wind_Profiler
|
126
|
+
|
127
|
+
The Wind Profiler convention
|
128
|
+
(http://www.kurasc.kyoto-u.ac.jp/radar-group/wind_profiler_conventions/).
|
129
|
+
|
130
|
+
Inherits NetCDF_Convention_Users_Guide and makes appropriate redefinitions.
|
131
|
+
See ((<module NumRu::NetCDF_Convention_Users_Guide>)) for the description
|
132
|
+
of constants and module functions.
|
133
|
+
|
134
|
+
=end
|
135
|
+
|
136
|
+
module NumRu
|
137
|
+
|
138
|
+
## /// COMMON -->
|
139
|
+
|
140
|
+
class NetCDFVar
|
141
|
+
alias get get_with_miss_and_scaling
|
142
|
+
alias put put_with_miss_and_scaling
|
143
|
+
end
|
144
|
+
|
145
|
+
# Other implicit convention
|
146
|
+
#
|
147
|
+
# * to use the "units" attribute to indicate the physical units
|
148
|
+
# (which is assumed in VArray, the super class of VArrayNetCDF).
|
149
|
+
|
150
|
+
module NetCDF_Conventions
|
151
|
+
module_function
|
152
|
+
|
153
|
+
@@fixed = nil
|
154
|
+
def fix_to( convention )
|
155
|
+
@@fixed == convention
|
156
|
+
end
|
157
|
+
|
158
|
+
def find( netcdf )
|
159
|
+
# netcdf is assumed to be a NetCDF
|
160
|
+
if @@fixed
|
161
|
+
@@fixed
|
162
|
+
else
|
163
|
+
convention = (att=netcdf.att('Conventions')) && att.get
|
164
|
+
case convention
|
165
|
+
#when /gtool/
|
166
|
+
# raise "Sorry, the gtool convention is yet to be supported"
|
167
|
+
when /^Wind Profiler/
|
168
|
+
NetCDF_Convention_Wind_Profiler
|
169
|
+
else
|
170
|
+
NetCDF_Convention_Users_Guide
|
171
|
+
end
|
172
|
+
end
|
173
|
+
end
|
174
|
+
|
175
|
+
def add_history(netcdf, str=nil)
|
176
|
+
hstatt = netcdf.att('history')
|
177
|
+
if hstatt
|
178
|
+
history = hstatt.get.chomp + "\n"
|
179
|
+
else
|
180
|
+
history = ''
|
181
|
+
end
|
182
|
+
time = Time.now
|
183
|
+
history += ( time.respond_to?(:strftime) ?
|
184
|
+
time.strftime('%Y-%m-%d %H:%M:%S %Z ') : time.to_s ) +
|
185
|
+
( ENV['USER'] || '' ) + '>'
|
186
|
+
history += (' '+str) if str
|
187
|
+
netcdf.put_att('history', history)
|
188
|
+
end
|
189
|
+
|
190
|
+
end
|
191
|
+
|
192
|
+
## <-- COMMON ///
|
193
|
+
|
194
|
+
######################################################
|
195
|
+
## Indivisual Conventions --- Can be figured out by
|
196
|
+
## NetCDF_Conventions.find( netcdf )
|
197
|
+
######################################################
|
198
|
+
|
199
|
+
|
200
|
+
module NetCDF_Convention_Users_Guide
|
201
|
+
# NetCDF Convention of the NetCDF User's Guide
|
202
|
+
# To be used by (not to be included in) NetCDF_IO.
|
203
|
+
|
204
|
+
module Attribute_Mixin
|
205
|
+
|
206
|
+
def _unpack_missing_specification(attr)
|
207
|
+
# -- private method --
|
208
|
+
# unpack missing data specification
|
209
|
+
# if the missing data type is in the external data type)
|
210
|
+
|
211
|
+
ao = attr['add_offset'] # must be narray or nil
|
212
|
+
sf = attr['scale_factor'] # must be narray or nil
|
213
|
+
if ao || sf
|
214
|
+
raise "add_offset is not a numeric" if ao.is_a?(String)
|
215
|
+
raise "scale_factor is not a numeric" if sf.is_a?(String)
|
216
|
+
satyp = ( ao || sf ).typecode
|
217
|
+
extyp = @nv.typecode
|
218
|
+
sf = 1 if !sf
|
219
|
+
ao = 0 if !ao
|
220
|
+
if (x=attr['valid_range']) && (x.typecode==extyp ||x.typecode!=satyp)
|
221
|
+
attr['valid_range'] = x * sf + ao
|
222
|
+
end
|
223
|
+
if (x=attr['valid_min']) && (x.typecode==extyp || x.typecode!=satyp)
|
224
|
+
attr['valid_min'] = x * sf + ao
|
225
|
+
end
|
226
|
+
if (x=attr['valid_max']) && (x.typecode==extyp || x.typecode!=satyp)
|
227
|
+
attr['valid_max'] = x * sf + ao
|
228
|
+
end
|
229
|
+
if (x=attr['missing_value']) && (x.typecode==extyp || x.typecode!=satyp)
|
230
|
+
attr['missing_value'] = x * sf + ao
|
231
|
+
end
|
232
|
+
attr
|
233
|
+
end
|
234
|
+
end
|
235
|
+
private :_unpack_missing_specification
|
236
|
+
|
237
|
+
def _op_attr_edit( attr )
|
238
|
+
# -- private method --
|
239
|
+
|
240
|
+
attr.delete('C_format')
|
241
|
+
attr.delete('FORTRAN_format')
|
242
|
+
|
243
|
+
_unpack_missing_specification(attr)
|
244
|
+
attr.delete('add_offset')
|
245
|
+
attr.delete('scale_factor')
|
246
|
+
attr.delete('_FillValue')
|
247
|
+
##attr.delete('long_name')
|
248
|
+
|
249
|
+
attr
|
250
|
+
end
|
251
|
+
private :_op_attr_edit
|
252
|
+
|
253
|
+
def copy(to=nil)
|
254
|
+
newattr = super
|
255
|
+
newattr = _op_attr_edit(newattr) if !to
|
256
|
+
newattr
|
257
|
+
end
|
258
|
+
|
259
|
+
end # module Attribute_Mixin
|
260
|
+
|
261
|
+
module VArray_Mixin
|
262
|
+
# currently none
|
263
|
+
end # module VArray_Mixin
|
264
|
+
|
265
|
+
####################
|
266
|
+
module_function
|
267
|
+
|
268
|
+
def to_s
|
269
|
+
"NetCDF User's Guide"
|
270
|
+
end
|
271
|
+
|
272
|
+
def coord_var_names(ncvar)
|
273
|
+
# name of the coordinate variables (to be the "pos" object in Axis)
|
274
|
+
ncvar.dim_names
|
275
|
+
end
|
276
|
+
|
277
|
+
def cell_bounds?(coord_var)
|
278
|
+
# whether the coordinate variale represent grid cell bounds.
|
279
|
+
# coordvar (VArray)
|
280
|
+
# return value:
|
281
|
+
result = false # Always false, because User's guide does not define it
|
282
|
+
cell_center_name = nil
|
283
|
+
[result, cell_center_name]
|
284
|
+
end
|
285
|
+
|
286
|
+
def cell_center?(coord_var)
|
287
|
+
# whether the coordinate variale represent grid cell centers.
|
288
|
+
# coordvar (VArray)
|
289
|
+
# return value:
|
290
|
+
# false if not
|
291
|
+
# true if true and the corresponding cell bounds are not identified.
|
292
|
+
# a VArray if true and the bounds are found (returns it)
|
293
|
+
result = false # Always false, because User's guide does not define it
|
294
|
+
cell_bounds_name = nil
|
295
|
+
[result, cell_bounds_name]
|
296
|
+
end
|
297
|
+
|
298
|
+
def aux_var_names(coord_var)
|
299
|
+
nil # no rule for that
|
300
|
+
end
|
301
|
+
|
302
|
+
end
|
303
|
+
|
304
|
+
module NetCDF_Convention_Wind_Profiler
|
305
|
+
# Wind Profiler Convention
|
306
|
+
# http://www.kurasc.kyoto-u.ac.jp/radar-group/wind_profiler_conventions/
|
307
|
+
|
308
|
+
module Attribute_Mixin
|
309
|
+
include NetCDF_Convention_Users_Guide::Attribute_Mixin
|
310
|
+
end # module Attribute_Mixin
|
311
|
+
|
312
|
+
module VArray_Mixin
|
313
|
+
include NetCDF_Convention_Users_Guide::VArray_Mixin
|
314
|
+
end # module VArray_Mixin
|
315
|
+
|
316
|
+
########################
|
317
|
+
module_function
|
318
|
+
extend NetCDF_Convention_Users_Guide
|
319
|
+
public_class_method :cell_bounds?, :cell_center?
|
320
|
+
|
321
|
+
def to_s
|
322
|
+
"Wind Profiler (http://www.kurasc.kyoto-u.ac.jp/radar-group/wind_profiler_conventions/)"
|
323
|
+
end
|
324
|
+
|
325
|
+
def coord_var_names(ncvar)
|
326
|
+
if (c=ncvar.att('coordinates'))
|
327
|
+
coordinates = c.get.split(/ +/)
|
328
|
+
elsif (ct=ncvar.att('t_coordinates')) || (cz=ncvar.att('z_coordinates'))
|
329
|
+
coordinates = Array.new
|
330
|
+
coordinates.push(ct.get) if ct
|
331
|
+
coordinates.push(cz.get) if cz
|
332
|
+
else
|
333
|
+
coordinates = nil
|
334
|
+
end
|
335
|
+
dimnames = ncvar.dim_names
|
336
|
+
if coordinates
|
337
|
+
cdvnames = []
|
338
|
+
coordinates.each{ |varname|
|
339
|
+
var = ncvar.file.var(varname)
|
340
|
+
raise "#{var.inspect} is not 1D" unless var.rank==1
|
341
|
+
dimnm = var.dim(0).name
|
342
|
+
idx = dimnames.index(dimnm)
|
343
|
+
if idx
|
344
|
+
cdvnames[idx] = varname
|
345
|
+
else
|
346
|
+
raise "#{varname} cannot be a coordinate variable -- "+
|
347
|
+
"#{ncvar.file.path} not comply with the Wind Profiler convention"
|
348
|
+
end
|
349
|
+
}
|
350
|
+
for i in 0...dimnames.length
|
351
|
+
cdvnames[i] = dimnames[i] if !cdvnames[i] #if not found, use dimname
|
352
|
+
end
|
353
|
+
cdvnames
|
354
|
+
else
|
355
|
+
# follow the users guide convention
|
356
|
+
dimnames
|
357
|
+
end
|
358
|
+
end
|
359
|
+
|
360
|
+
def aux_var_names(coord_var)
|
361
|
+
Hash['coordinate', coord_var.dim_names[0] ]
|
362
|
+
end
|
363
|
+
|
364
|
+
end
|
365
|
+
|
366
|
+
end # module NumRu
|
@@ -0,0 +1,332 @@
|
|
1
|
+
require "narray"
|
2
|
+
|
3
|
+
module NumRu
|
4
|
+
|
5
|
+
class SubsetMapping
|
6
|
+
|
7
|
+
def initialize(shape, slicer, mapping1Ds=nil)
|
8
|
+
#USAGE:
|
9
|
+
# SubsetMapping.new(shape, slicer)
|
10
|
+
# or
|
11
|
+
# SubsetMapping.new(nil, nil, mapping1Ds)
|
12
|
+
#
|
13
|
+
# shape [Array]: shape of the array onto which mapping is made
|
14
|
+
# slicer [Array]: mapping specification for each dim.
|
15
|
+
# (shape and slicer are used to create SubsetMapping1D's)
|
16
|
+
# mapping1Ds [Array]: collected SubsetMapping1D's
|
17
|
+
#
|
18
|
+
# NOTE shape.length must be equal to mappings.length
|
19
|
+
if mapping1Ds
|
20
|
+
@maps = mapping1Ds
|
21
|
+
len = mapping1Ds.length
|
22
|
+
else
|
23
|
+
len=shape.length
|
24
|
+
|
25
|
+
if slicer.length == 0
|
26
|
+
@maps = Array.new
|
27
|
+
for i in 0...len do
|
28
|
+
p shape[i],0..-1
|
29
|
+
@maps[i] = SubsetMapping1D.new(shape[i],0..-1)
|
30
|
+
end
|
31
|
+
else
|
32
|
+
if len != slicer.length
|
33
|
+
raise "lengths of shape and slicer do not agree (#{len} vs #{slicer.length})"
|
34
|
+
end
|
35
|
+
@maps = Array.new
|
36
|
+
for i in 0...len do
|
37
|
+
@maps[i] = SubsetMapping1D.new(shape[i],slicer[i])
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
@dims_retained = Array.new
|
42
|
+
@dims_collapsed = Array.new
|
43
|
+
for i in 0...len do
|
44
|
+
@maps[i].collapsed ? @dims_collapsed.push(i) : @dims_retained.push(i)
|
45
|
+
end
|
46
|
+
@rank = @dims_retained.length
|
47
|
+
@shape = Array.new
|
48
|
+
@maps.each{|mp| @shape.push(mp.length) if ! mp.collapsed}
|
49
|
+
end
|
50
|
+
|
51
|
+
attr_reader :shape, :rank, :maps
|
52
|
+
protected :maps
|
53
|
+
|
54
|
+
def total
|
55
|
+
tt=1
|
56
|
+
@shape.each{|i| tt *= i}
|
57
|
+
tt
|
58
|
+
end
|
59
|
+
alias length total
|
60
|
+
|
61
|
+
def slicer
|
62
|
+
@maps.collect{|mp| mp.slicer}
|
63
|
+
end
|
64
|
+
|
65
|
+
def composite( other )
|
66
|
+
if @rank != (other.maps.length)
|
67
|
+
raise ArgumentError, "the original rank (#{other.maps.length}) must agree with the rank of this mapping (#{@rank})"
|
68
|
+
end
|
69
|
+
newmap = Array.new()
|
70
|
+
for i in 0...@rank do
|
71
|
+
id = @dims_retained[i]
|
72
|
+
newmap[id] = @maps[id].composite( other.maps[i] )
|
73
|
+
end
|
74
|
+
@dims_collapsed.each{ |i| newmap[i] = @maps[i] }
|
75
|
+
SubsetMapping.new(nil,nil,newmap)
|
76
|
+
end
|
77
|
+
|
78
|
+
def map( *indices_sub )
|
79
|
+
# map an index to an element in the subset to that in the original
|
80
|
+
if @rank != (indices_sub.length)
|
81
|
+
raise ArgumentError, "number of arguments (#{indices_sub.length}) must agree with the rank of this mapping (#{@rank})"
|
82
|
+
end
|
83
|
+
indices_mapped = Array.new
|
84
|
+
for i in 0...@rank do
|
85
|
+
id = @dims_retained[i]
|
86
|
+
indices_mapped[id] = @maps[id].map(indices_sub[i])
|
87
|
+
end
|
88
|
+
@dims_collapsed.each{ |i| indices_mapped[i] = @maps[i].first }
|
89
|
+
indices_mapped
|
90
|
+
end
|
91
|
+
def imap( *indices_mapped )
|
92
|
+
# inverse operation of the map method
|
93
|
+
if @maps.length != (indices_mapped.length)
|
94
|
+
raise ArgumentError, "number of arguments (#{indies_mapped.length}) must agree with the rank of the array mapped to (#{@maps.length})"
|
95
|
+
end
|
96
|
+
work = Array.new
|
97
|
+
indices_mapped.each_index{|i|
|
98
|
+
work[i] = @maps[i].imap( indices_mapped[i] )
|
99
|
+
}
|
100
|
+
if work.include?(nil)
|
101
|
+
indices_sub = nil
|
102
|
+
else
|
103
|
+
# indices_sub = work.indices( *@dims_retained ) # indices: obsolete in ruby 1.8
|
104
|
+
indices_sub = work.values_at( *@dims_retained )
|
105
|
+
end
|
106
|
+
indices_sub
|
107
|
+
end
|
108
|
+
end
|
109
|
+
|
110
|
+
class SubsetMapping1D
|
111
|
+
|
112
|
+
attr_reader :slicer,
|
113
|
+
:regular,
|
114
|
+
:collapsed,
|
115
|
+
:first,
|
116
|
+
:step,
|
117
|
+
:index_array
|
118
|
+
|
119
|
+
class << self
|
120
|
+
alias new0 new
|
121
|
+
end
|
122
|
+
def initialize()
|
123
|
+
# To complete the initialization, use initialize_regular
|
124
|
+
# or initialize_irregular later.
|
125
|
+
@slicer = nil
|
126
|
+
@regular = nil
|
127
|
+
@collapsed = false
|
128
|
+
@first = nil
|
129
|
+
@length = nil
|
130
|
+
@step = nil
|
131
|
+
@index_array = nil
|
132
|
+
end
|
133
|
+
|
134
|
+
def initialize_irregular(index_array)
|
135
|
+
@slicer = index_array
|
136
|
+
@regular = false
|
137
|
+
@collapsed = false
|
138
|
+
@first = nil
|
139
|
+
@length = nil
|
140
|
+
@step = nil
|
141
|
+
@index_array = index_array
|
142
|
+
self
|
143
|
+
end
|
144
|
+
|
145
|
+
def initialize_regular(slicer, collapsed, first, length, step)
|
146
|
+
@slicer = slicer
|
147
|
+
@regular = true
|
148
|
+
@collapsed = collapsed
|
149
|
+
@first = first
|
150
|
+
@length = length
|
151
|
+
@step = step
|
152
|
+
@index_array = nil
|
153
|
+
self
|
154
|
+
end
|
155
|
+
|
156
|
+
def SubsetMapping1D.new(dim_len, slicer, no_collapse=false)
|
157
|
+
case slicer
|
158
|
+
when Integer
|
159
|
+
idx = slicer
|
160
|
+
if idx < 0; idx += dim_len; end
|
161
|
+
if idx < 0 || idx >= dim_len
|
162
|
+
raise "mapping #{slicer} is out of range (dim_len=#{dim_len})"
|
163
|
+
end
|
164
|
+
first=idx
|
165
|
+
length=step=1
|
166
|
+
collapsed = no_collapse ? false : true
|
167
|
+
SubsetMapping1D.new0.initialize_regular(slicer, collapsed,
|
168
|
+
first, length, step)
|
169
|
+
when Range, Hash, true
|
170
|
+
if (Range === slicer)
|
171
|
+
range = slicer
|
172
|
+
step = 1
|
173
|
+
elsif (true === slicer)
|
174
|
+
range = 0..-1
|
175
|
+
step = 1
|
176
|
+
else # Hash
|
177
|
+
if slicer.length != 1; raise "not 1-key-val Hash"; end
|
178
|
+
range, step = slicer.to_a[0]
|
179
|
+
end
|
180
|
+
first = range.first
|
181
|
+
last = range.exclude_end? ? range.last-1 : range.last
|
182
|
+
if first < 0; first += dim_len; end
|
183
|
+
if last < 0; last += dim_len; end
|
184
|
+
if first<0 || first>=dim_len || last<0 || last>=dim_len || step==0
|
185
|
+
raise "mapping #{slicer.inspect} is invalid (dim_len=#{dim_len})"
|
186
|
+
end
|
187
|
+
first = first
|
188
|
+
step = -step if ( (last-first)*step < 0 )
|
189
|
+
length = (last-first) / step + 1
|
190
|
+
SubsetMapping1D.new0.initialize_regular(slicer, false,
|
191
|
+
first, length, step)
|
192
|
+
else
|
193
|
+
index_array = NArray.int(1).coerce(slicer)[0]
|
194
|
+
if index_array.min < 0 || index_array.max >= dim_len
|
195
|
+
raise "array index mapping out of range (dim_len=#{dim_len})"
|
196
|
+
end
|
197
|
+
slicer = index_array
|
198
|
+
SubsetMapping1D.new0.initialize_irregular(index_array)
|
199
|
+
end
|
200
|
+
end
|
201
|
+
|
202
|
+
def composite(mapping)
|
203
|
+
# derive the composite mapping (mappig * self), where self is
|
204
|
+
# applied first. ('*' here is meant to be a circle)
|
205
|
+
if @regular
|
206
|
+
if mapping.regular
|
207
|
+
fst = @first + @step * mapping.first
|
208
|
+
len = mapping.length
|
209
|
+
if len > @length; raise "length too large"; end
|
210
|
+
stp = @step * mapping.step
|
211
|
+
slicer = __make_regular_slicer((scl=mapping.collapsed),fst,len,stp)
|
212
|
+
SubsetMapping1D.new0.initialize_regular(slicer,scl,fst,len,stp)
|
213
|
+
else
|
214
|
+
mida = mapping.index_array
|
215
|
+
if mida.min < 0 || mida.max >= @length
|
216
|
+
raise "array index mapping out of range"
|
217
|
+
end
|
218
|
+
idxary = @first + @step * mida
|
219
|
+
SubsetMapping1D.new0.initialize_irregular(idxary)
|
220
|
+
end
|
221
|
+
else
|
222
|
+
if mapping.regular
|
223
|
+
mida = mapping.first +
|
224
|
+
mapping.step * NArray.int(mapping.length).indgen!
|
225
|
+
else
|
226
|
+
mida = mapping.index_array
|
227
|
+
end
|
228
|
+
if mida.length < 0 || mida.max >= length
|
229
|
+
raise "array index mapping out of range"
|
230
|
+
end
|
231
|
+
idxary = @index_array[mida]
|
232
|
+
if idxary.length==1
|
233
|
+
fst = idxary[0]
|
234
|
+
len = step = 1
|
235
|
+
slicer = __make_regular_slicer((scl=mapping.collapsed),fst,len,stp)
|
236
|
+
SubsetMapping1D.new0.initialize_regular(slicer,scl,fst,len,stp)
|
237
|
+
else
|
238
|
+
SubsetMapping1D.new0.initialize_irregular(idxary)
|
239
|
+
end
|
240
|
+
end
|
241
|
+
end
|
242
|
+
|
243
|
+
def length
|
244
|
+
@length || @index_array.length
|
245
|
+
end
|
246
|
+
|
247
|
+
def map(i)
|
248
|
+
# map an index value
|
249
|
+
# i: shoud be Integer or Array of Integer
|
250
|
+
raise ArgumentError, "Integer required" if ! i.is_a?(Integer)
|
251
|
+
if @regular
|
252
|
+
i += @length if i<0
|
253
|
+
@first + @step * i
|
254
|
+
else
|
255
|
+
@index_array[i]
|
256
|
+
end
|
257
|
+
end
|
258
|
+
|
259
|
+
def imap(i)
|
260
|
+
# inversely map an index value
|
261
|
+
raise ArgumentError, "Integer required" if ! i.is_a?(Integer)
|
262
|
+
if @regular
|
263
|
+
if ( (i-@first) % @step == 0 )
|
264
|
+
imp = (i-@first)/@step
|
265
|
+
if imp >= 0 && imp < @length
|
266
|
+
imp
|
267
|
+
else
|
268
|
+
nil
|
269
|
+
end
|
270
|
+
else
|
271
|
+
nil # not included
|
272
|
+
end
|
273
|
+
else
|
274
|
+
@index_array.index(i) # returns nil if not included
|
275
|
+
end
|
276
|
+
end
|
277
|
+
|
278
|
+
####### / private methods --> #######
|
279
|
+
private
|
280
|
+
def __make_regular_slicer(collapsed, first, length, step)
|
281
|
+
if collapsed
|
282
|
+
first
|
283
|
+
else
|
284
|
+
last = first + (length-1)*step
|
285
|
+
if step == 1
|
286
|
+
first..last
|
287
|
+
else
|
288
|
+
{(first..last) => step}
|
289
|
+
end
|
290
|
+
end
|
291
|
+
end
|
292
|
+
|
293
|
+
end
|
294
|
+
|
295
|
+
end
|
296
|
+
|
297
|
+
####################################
|
298
|
+
## test program
|
299
|
+
|
300
|
+
if $0 == __FILE__
|
301
|
+
include NumRu
|
302
|
+
m = SubsetMapping1D.new(40,{(1..-2) => 2})
|
303
|
+
p '%%',m.slicer,m.regular,m.collapsed,m.first,m.length,m.step,m.index_array
|
304
|
+
m2 = SubsetMapping1D.new(10,{(1..9) => 4})
|
305
|
+
print "+++ #{m.map(0)} #{m.map(1)} #{m.imap(0)} #{m.imap(1)}\n"
|
306
|
+
p '##',m2.slicer,m2.regular,m2.collapsed,m2.first,m2.length,m2.step,m2.index_array
|
307
|
+
m = m.composite(m2)
|
308
|
+
p '%%',m.slicer,m.regular,m.collapsed,m.first,m.length,m.step,m.index_array
|
309
|
+
|
310
|
+
print "########\n"
|
311
|
+
m = SubsetMapping1D.new(40,{(-2..1) => -2})
|
312
|
+
p '%%',m.slicer,m.regular,m.collapsed,m.first,m.length,m.step,m.index_array
|
313
|
+
m2 = SubsetMapping1D.new(10,{(1..9) => 4})
|
314
|
+
print "+++ #{m.map(0)} #{m.map(1)} #{m.imap(0)} #{m.imap(1)}\n"
|
315
|
+
p '##',m2.slicer,m2.regular,m2.collapsed,m2.first,m2.length,m2.step,m2.index_array
|
316
|
+
m = m.composite(m2)
|
317
|
+
p '%%',m.slicer,m.regular,m.collapsed,m.first,m.length,m.step,m.index_array
|
318
|
+
|
319
|
+
print "########\n"
|
320
|
+
m = SubsetMapping1D.new(10,[0..9,4])
|
321
|
+
p '##',m.slicer,m.regular,m.collapsed,m.first,m.length,m.step,m.index_array
|
322
|
+
mm = SubsetMapping.new([5,6,6],[1..3, -1, 3..-1])
|
323
|
+
p '@@@@',mm,mm.shape
|
324
|
+
p '@@', mp=mm.map( -1, -2 ), mm.imap(*mp)
|
325
|
+
mmx = SubsetMapping.new([3,3],[0,0..1])
|
326
|
+
p '@',mm.composite(mmx)
|
327
|
+
mm2 = SubsetMapping.new(nil,nil,[m,m2])
|
328
|
+
p '++++',mm2, mm2.shape, mm2.slicer.class, mm2.slicer
|
329
|
+
mm3 = SubsetMapping.new(mm.shape,[1..2, 0..1])
|
330
|
+
p 'xxxx',mm3
|
331
|
+
p mmc = mm.composite(mm3), mmc.slicer
|
332
|
+
end
|