gphys 1.1.1a
Sign up to get free protection for your applications and to get access to all the features.
- data/ChangeLog +1777 -0
- data/LICENSE.txt +34 -0
- data/README +33 -0
- data/Rakefile +57 -0
- data/TODO_ep_flux +6 -0
- data/bin/gdir_client +27 -0
- data/bin/gdir_server +129 -0
- data/bin/gpaop +146 -0
- data/bin/gpcat +148 -0
- data/bin/gpcut +102 -0
- data/bin/gpedit +228 -0
- data/bin/gplist +68 -0
- data/bin/gpmath +120 -0
- data/bin/gpmaxmin +128 -0
- data/bin/gpprint +60 -0
- data/bin/gpvect +706 -0
- data/bin/gpview +704 -0
- data/bin/grads2nc_with_gphys +61 -0
- data/doc/attribute.html +19 -0
- data/doc/attributenetcdf.html +15 -0
- data/doc/axis.html +376 -0
- data/doc/coordmapping.html +111 -0
- data/doc/coordtransform.html +36 -0
- data/doc/derivative/gphys-derivative.html +80 -0
- data/doc/derivative/index.html +21 -0
- data/doc/derivative/index.rd +14 -0
- data/doc/derivative/math-doc/document/document.css +30 -0
- data/doc/derivative/math-doc/document/document.html +57 -0
- data/doc/derivative/math-doc/document/images.aux +1 -0
- data/doc/derivative/math-doc/document/images.log +385 -0
- data/doc/derivative/math-doc/document/images.pl +186 -0
- data/doc/derivative/math-doc/document/images.tex +364 -0
- data/doc/derivative/math-doc/document/img1.png +0 -0
- data/doc/derivative/math-doc/document/img10.png +0 -0
- data/doc/derivative/math-doc/document/img11.png +0 -0
- data/doc/derivative/math-doc/document/img12.png +0 -0
- data/doc/derivative/math-doc/document/img13.png +0 -0
- data/doc/derivative/math-doc/document/img14.png +0 -0
- data/doc/derivative/math-doc/document/img15.png +0 -0
- data/doc/derivative/math-doc/document/img16.png +0 -0
- data/doc/derivative/math-doc/document/img17.png +0 -0
- data/doc/derivative/math-doc/document/img18.png +0 -0
- data/doc/derivative/math-doc/document/img19.png +0 -0
- data/doc/derivative/math-doc/document/img2.png +0 -0
- data/doc/derivative/math-doc/document/img20.png +0 -0
- data/doc/derivative/math-doc/document/img21.png +0 -0
- data/doc/derivative/math-doc/document/img22.png +0 -0
- data/doc/derivative/math-doc/document/img23.png +0 -0
- data/doc/derivative/math-doc/document/img24.png +0 -0
- data/doc/derivative/math-doc/document/img25.png +0 -0
- data/doc/derivative/math-doc/document/img26.png +0 -0
- data/doc/derivative/math-doc/document/img27.png +0 -0
- data/doc/derivative/math-doc/document/img28.png +0 -0
- data/doc/derivative/math-doc/document/img29.png +0 -0
- data/doc/derivative/math-doc/document/img3.png +0 -0
- data/doc/derivative/math-doc/document/img30.png +0 -0
- data/doc/derivative/math-doc/document/img4.png +0 -0
- data/doc/derivative/math-doc/document/img5.png +0 -0
- data/doc/derivative/math-doc/document/img6.png +0 -0
- data/doc/derivative/math-doc/document/img7.png +0 -0
- data/doc/derivative/math-doc/document/img8.png +0 -0
- data/doc/derivative/math-doc/document/img9.png +0 -0
- data/doc/derivative/math-doc/document/index.html +57 -0
- data/doc/derivative/math-doc/document/labels.pl +13 -0
- data/doc/derivative/math-doc/document/next.png +0 -0
- data/doc/derivative/math-doc/document/next_g.png +0 -0
- data/doc/derivative/math-doc/document/node1.html +238 -0
- data/doc/derivative/math-doc/document/node2.html +75 -0
- data/doc/derivative/math-doc/document/prev.png +0 -0
- data/doc/derivative/math-doc/document/prev_g.png +0 -0
- data/doc/derivative/math-doc/document/up.png +0 -0
- data/doc/derivative/math-doc/document/up_g.png +0 -0
- data/doc/derivative/math-doc/document.pdf +0 -0
- data/doc/derivative/math-doc/document.tex +158 -0
- data/doc/derivative/numru-derivative.html +129 -0
- data/doc/ep_flux/ep_flux.html +469 -0
- data/doc/ep_flux/ggraph_on_merdional_section.html +71 -0
- data/doc/ep_flux/index.html +31 -0
- data/doc/ep_flux/index.rd +24 -0
- data/doc/ep_flux/math-doc/document/WARNINGS +1 -0
- data/doc/ep_flux/math-doc/document/contents.png +0 -0
- data/doc/ep_flux/math-doc/document/crossref.png +0 -0
- data/doc/ep_flux/math-doc/document/document.css +30 -0
- data/doc/ep_flux/math-doc/document/document.html +101 -0
- data/doc/ep_flux/math-doc/document/images.aux +1 -0
- data/doc/ep_flux/math-doc/document/images.log +1375 -0
- data/doc/ep_flux/math-doc/document/images.pl +1328 -0
- data/doc/ep_flux/math-doc/document/images.tex +1471 -0
- data/doc/ep_flux/math-doc/document/img1.png +0 -0
- data/doc/ep_flux/math-doc/document/img10.png +0 -0
- data/doc/ep_flux/math-doc/document/img100.png +0 -0
- data/doc/ep_flux/math-doc/document/img101.png +0 -0
- data/doc/ep_flux/math-doc/document/img102.png +0 -0
- data/doc/ep_flux/math-doc/document/img103.png +0 -0
- data/doc/ep_flux/math-doc/document/img104.png +0 -0
- data/doc/ep_flux/math-doc/document/img105.png +0 -0
- data/doc/ep_flux/math-doc/document/img106.png +0 -0
- data/doc/ep_flux/math-doc/document/img107.png +0 -0
- data/doc/ep_flux/math-doc/document/img108.png +0 -0
- data/doc/ep_flux/math-doc/document/img109.png +0 -0
- data/doc/ep_flux/math-doc/document/img11.png +0 -0
- data/doc/ep_flux/math-doc/document/img110.png +0 -0
- data/doc/ep_flux/math-doc/document/img111.png +0 -0
- data/doc/ep_flux/math-doc/document/img112.png +0 -0
- data/doc/ep_flux/math-doc/document/img113.png +0 -0
- data/doc/ep_flux/math-doc/document/img114.png +0 -0
- data/doc/ep_flux/math-doc/document/img115.png +0 -0
- data/doc/ep_flux/math-doc/document/img116.png +0 -0
- data/doc/ep_flux/math-doc/document/img117.png +0 -0
- data/doc/ep_flux/math-doc/document/img118.png +0 -0
- data/doc/ep_flux/math-doc/document/img119.png +0 -0
- data/doc/ep_flux/math-doc/document/img12.png +0 -0
- data/doc/ep_flux/math-doc/document/img120.png +0 -0
- data/doc/ep_flux/math-doc/document/img121.png +0 -0
- data/doc/ep_flux/math-doc/document/img122.png +0 -0
- data/doc/ep_flux/math-doc/document/img123.png +0 -0
- data/doc/ep_flux/math-doc/document/img124.png +0 -0
- data/doc/ep_flux/math-doc/document/img125.png +0 -0
- data/doc/ep_flux/math-doc/document/img126.png +0 -0
- data/doc/ep_flux/math-doc/document/img127.png +0 -0
- data/doc/ep_flux/math-doc/document/img128.png +0 -0
- data/doc/ep_flux/math-doc/document/img129.png +0 -0
- data/doc/ep_flux/math-doc/document/img13.png +0 -0
- data/doc/ep_flux/math-doc/document/img130.png +0 -0
- data/doc/ep_flux/math-doc/document/img131.png +0 -0
- data/doc/ep_flux/math-doc/document/img132.png +0 -0
- data/doc/ep_flux/math-doc/document/img133.png +0 -0
- data/doc/ep_flux/math-doc/document/img134.png +0 -0
- data/doc/ep_flux/math-doc/document/img135.png +0 -0
- data/doc/ep_flux/math-doc/document/img136.png +0 -0
- data/doc/ep_flux/math-doc/document/img137.png +0 -0
- data/doc/ep_flux/math-doc/document/img138.png +0 -0
- data/doc/ep_flux/math-doc/document/img139.png +0 -0
- data/doc/ep_flux/math-doc/document/img14.png +0 -0
- data/doc/ep_flux/math-doc/document/img140.png +0 -0
- data/doc/ep_flux/math-doc/document/img141.png +0 -0
- data/doc/ep_flux/math-doc/document/img142.png +0 -0
- data/doc/ep_flux/math-doc/document/img143.png +0 -0
- data/doc/ep_flux/math-doc/document/img144.png +0 -0
- data/doc/ep_flux/math-doc/document/img145.png +0 -0
- data/doc/ep_flux/math-doc/document/img146.png +0 -0
- data/doc/ep_flux/math-doc/document/img147.png +0 -0
- data/doc/ep_flux/math-doc/document/img148.png +0 -0
- data/doc/ep_flux/math-doc/document/img149.png +0 -0
- data/doc/ep_flux/math-doc/document/img15.png +0 -0
- data/doc/ep_flux/math-doc/document/img150.png +0 -0
- data/doc/ep_flux/math-doc/document/img151.png +0 -0
- data/doc/ep_flux/math-doc/document/img152.png +0 -0
- data/doc/ep_flux/math-doc/document/img153.png +0 -0
- data/doc/ep_flux/math-doc/document/img154.png +0 -0
- data/doc/ep_flux/math-doc/document/img155.png +0 -0
- data/doc/ep_flux/math-doc/document/img156.png +0 -0
- data/doc/ep_flux/math-doc/document/img157.png +0 -0
- data/doc/ep_flux/math-doc/document/img158.png +0 -0
- data/doc/ep_flux/math-doc/document/img159.png +0 -0
- data/doc/ep_flux/math-doc/document/img16.png +0 -0
- data/doc/ep_flux/math-doc/document/img160.png +0 -0
- data/doc/ep_flux/math-doc/document/img161.png +0 -0
- data/doc/ep_flux/math-doc/document/img162.png +0 -0
- data/doc/ep_flux/math-doc/document/img163.png +0 -0
- data/doc/ep_flux/math-doc/document/img164.png +0 -0
- data/doc/ep_flux/math-doc/document/img165.png +0 -0
- data/doc/ep_flux/math-doc/document/img166.png +0 -0
- data/doc/ep_flux/math-doc/document/img167.png +0 -0
- data/doc/ep_flux/math-doc/document/img168.png +0 -0
- data/doc/ep_flux/math-doc/document/img169.png +0 -0
- data/doc/ep_flux/math-doc/document/img17.png +0 -0
- data/doc/ep_flux/math-doc/document/img170.png +0 -0
- data/doc/ep_flux/math-doc/document/img171.png +0 -0
- data/doc/ep_flux/math-doc/document/img172.png +0 -0
- data/doc/ep_flux/math-doc/document/img173.png +0 -0
- data/doc/ep_flux/math-doc/document/img174.png +0 -0
- data/doc/ep_flux/math-doc/document/img175.png +0 -0
- data/doc/ep_flux/math-doc/document/img176.png +0 -0
- data/doc/ep_flux/math-doc/document/img177.png +0 -0
- data/doc/ep_flux/math-doc/document/img178.png +0 -0
- data/doc/ep_flux/math-doc/document/img179.png +0 -0
- data/doc/ep_flux/math-doc/document/img18.png +0 -0
- data/doc/ep_flux/math-doc/document/img180.png +0 -0
- data/doc/ep_flux/math-doc/document/img181.png +0 -0
- data/doc/ep_flux/math-doc/document/img182.png +0 -0
- data/doc/ep_flux/math-doc/document/img183.png +0 -0
- data/doc/ep_flux/math-doc/document/img184.png +0 -0
- data/doc/ep_flux/math-doc/document/img185.png +0 -0
- data/doc/ep_flux/math-doc/document/img186.png +0 -0
- data/doc/ep_flux/math-doc/document/img187.png +0 -0
- data/doc/ep_flux/math-doc/document/img188.png +0 -0
- data/doc/ep_flux/math-doc/document/img189.png +0 -0
- data/doc/ep_flux/math-doc/document/img19.png +0 -0
- data/doc/ep_flux/math-doc/document/img190.png +0 -0
- data/doc/ep_flux/math-doc/document/img191.png +0 -0
- data/doc/ep_flux/math-doc/document/img192.png +0 -0
- data/doc/ep_flux/math-doc/document/img193.png +0 -0
- data/doc/ep_flux/math-doc/document/img194.png +0 -0
- data/doc/ep_flux/math-doc/document/img195.png +0 -0
- data/doc/ep_flux/math-doc/document/img196.png +0 -0
- data/doc/ep_flux/math-doc/document/img197.png +0 -0
- data/doc/ep_flux/math-doc/document/img198.png +0 -0
- data/doc/ep_flux/math-doc/document/img199.png +0 -0
- data/doc/ep_flux/math-doc/document/img2.png +0 -0
- data/doc/ep_flux/math-doc/document/img20.png +0 -0
- data/doc/ep_flux/math-doc/document/img200.png +0 -0
- data/doc/ep_flux/math-doc/document/img21.png +0 -0
- data/doc/ep_flux/math-doc/document/img22.png +0 -0
- data/doc/ep_flux/math-doc/document/img23.png +0 -0
- data/doc/ep_flux/math-doc/document/img24.png +0 -0
- data/doc/ep_flux/math-doc/document/img25.png +0 -0
- data/doc/ep_flux/math-doc/document/img26.png +0 -0
- data/doc/ep_flux/math-doc/document/img27.png +0 -0
- data/doc/ep_flux/math-doc/document/img28.png +0 -0
- data/doc/ep_flux/math-doc/document/img29.png +0 -0
- data/doc/ep_flux/math-doc/document/img3.png +0 -0
- data/doc/ep_flux/math-doc/document/img30.png +0 -0
- data/doc/ep_flux/math-doc/document/img31.png +0 -0
- data/doc/ep_flux/math-doc/document/img32.png +0 -0
- data/doc/ep_flux/math-doc/document/img33.png +0 -0
- data/doc/ep_flux/math-doc/document/img34.png +0 -0
- data/doc/ep_flux/math-doc/document/img35.png +0 -0
- data/doc/ep_flux/math-doc/document/img36.png +0 -0
- data/doc/ep_flux/math-doc/document/img37.png +0 -0
- data/doc/ep_flux/math-doc/document/img38.png +0 -0
- data/doc/ep_flux/math-doc/document/img39.png +0 -0
- data/doc/ep_flux/math-doc/document/img4.png +0 -0
- data/doc/ep_flux/math-doc/document/img40.png +0 -0
- data/doc/ep_flux/math-doc/document/img41.png +0 -0
- data/doc/ep_flux/math-doc/document/img42.png +0 -0
- data/doc/ep_flux/math-doc/document/img43.png +0 -0
- data/doc/ep_flux/math-doc/document/img44.png +0 -0
- data/doc/ep_flux/math-doc/document/img45.png +0 -0
- data/doc/ep_flux/math-doc/document/img46.png +0 -0
- data/doc/ep_flux/math-doc/document/img47.png +0 -0
- data/doc/ep_flux/math-doc/document/img48.png +0 -0
- data/doc/ep_flux/math-doc/document/img49.png +0 -0
- data/doc/ep_flux/math-doc/document/img5.png +0 -0
- data/doc/ep_flux/math-doc/document/img50.png +0 -0
- data/doc/ep_flux/math-doc/document/img51.png +0 -0
- data/doc/ep_flux/math-doc/document/img52.png +0 -0
- data/doc/ep_flux/math-doc/document/img53.png +0 -0
- data/doc/ep_flux/math-doc/document/img54.png +0 -0
- data/doc/ep_flux/math-doc/document/img55.png +0 -0
- data/doc/ep_flux/math-doc/document/img56.png +0 -0
- data/doc/ep_flux/math-doc/document/img57.png +0 -0
- data/doc/ep_flux/math-doc/document/img58.png +0 -0
- data/doc/ep_flux/math-doc/document/img59.png +0 -0
- data/doc/ep_flux/math-doc/document/img6.png +0 -0
- data/doc/ep_flux/math-doc/document/img60.png +0 -0
- data/doc/ep_flux/math-doc/document/img61.png +0 -0
- data/doc/ep_flux/math-doc/document/img62.png +0 -0
- data/doc/ep_flux/math-doc/document/img63.png +0 -0
- data/doc/ep_flux/math-doc/document/img64.png +0 -0
- data/doc/ep_flux/math-doc/document/img65.png +0 -0
- data/doc/ep_flux/math-doc/document/img66.png +0 -0
- data/doc/ep_flux/math-doc/document/img67.png +0 -0
- data/doc/ep_flux/math-doc/document/img68.png +0 -0
- data/doc/ep_flux/math-doc/document/img69.png +0 -0
- data/doc/ep_flux/math-doc/document/img7.png +0 -0
- data/doc/ep_flux/math-doc/document/img70.png +0 -0
- data/doc/ep_flux/math-doc/document/img71.png +0 -0
- data/doc/ep_flux/math-doc/document/img72.png +0 -0
- data/doc/ep_flux/math-doc/document/img73.png +0 -0
- data/doc/ep_flux/math-doc/document/img74.png +0 -0
- data/doc/ep_flux/math-doc/document/img75.png +0 -0
- data/doc/ep_flux/math-doc/document/img76.png +0 -0
- data/doc/ep_flux/math-doc/document/img77.png +0 -0
- data/doc/ep_flux/math-doc/document/img78.png +0 -0
- data/doc/ep_flux/math-doc/document/img79.png +0 -0
- data/doc/ep_flux/math-doc/document/img8.png +0 -0
- data/doc/ep_flux/math-doc/document/img80.png +0 -0
- data/doc/ep_flux/math-doc/document/img81.png +0 -0
- data/doc/ep_flux/math-doc/document/img82.png +0 -0
- data/doc/ep_flux/math-doc/document/img83.png +0 -0
- data/doc/ep_flux/math-doc/document/img84.png +0 -0
- data/doc/ep_flux/math-doc/document/img85.png +0 -0
- data/doc/ep_flux/math-doc/document/img86.png +0 -0
- data/doc/ep_flux/math-doc/document/img87.png +0 -0
- data/doc/ep_flux/math-doc/document/img88.png +0 -0
- data/doc/ep_flux/math-doc/document/img89.png +0 -0
- data/doc/ep_flux/math-doc/document/img9.png +0 -0
- data/doc/ep_flux/math-doc/document/img90.png +0 -0
- data/doc/ep_flux/math-doc/document/img91.png +0 -0
- data/doc/ep_flux/math-doc/document/img92.png +0 -0
- data/doc/ep_flux/math-doc/document/img93.png +0 -0
- data/doc/ep_flux/math-doc/document/img94.png +0 -0
- data/doc/ep_flux/math-doc/document/img95.png +0 -0
- data/doc/ep_flux/math-doc/document/img96.png +0 -0
- data/doc/ep_flux/math-doc/document/img97.png +0 -0
- data/doc/ep_flux/math-doc/document/img98.png +0 -0
- data/doc/ep_flux/math-doc/document/img99.png +0 -0
- data/doc/ep_flux/math-doc/document/index.html +101 -0
- data/doc/ep_flux/math-doc/document/internals.pl +258 -0
- data/doc/ep_flux/math-doc/document/labels.pl +265 -0
- data/doc/ep_flux/math-doc/document/next.png +0 -0
- data/doc/ep_flux/math-doc/document/next_g.png +0 -0
- data/doc/ep_flux/math-doc/document/node1.html +104 -0
- data/doc/ep_flux/math-doc/document/node10.html +164 -0
- data/doc/ep_flux/math-doc/document/node11.html +86 -0
- data/doc/ep_flux/math-doc/document/node12.html +166 -0
- data/doc/ep_flux/math-doc/document/node13.html +897 -0
- data/doc/ep_flux/math-doc/document/node14.html +1065 -0
- data/doc/ep_flux/math-doc/document/node15.html +72 -0
- data/doc/ep_flux/math-doc/document/node16.html +81 -0
- data/doc/ep_flux/math-doc/document/node2.html +82 -0
- data/doc/ep_flux/math-doc/document/node3.html +91 -0
- data/doc/ep_flux/math-doc/document/node4.html +149 -0
- data/doc/ep_flux/math-doc/document/node5.html +330 -0
- data/doc/ep_flux/math-doc/document/node6.html +99 -0
- data/doc/ep_flux/math-doc/document/node7.html +98 -0
- data/doc/ep_flux/math-doc/document/node8.html +83 -0
- data/doc/ep_flux/math-doc/document/node9.html +140 -0
- data/doc/ep_flux/math-doc/document/prev.png +0 -0
- data/doc/ep_flux/math-doc/document/prev_g.png +0 -0
- data/doc/ep_flux/math-doc/document/up.png +0 -0
- data/doc/ep_flux/math-doc/document/up_g.png +0 -0
- data/doc/ep_flux/math-doc/document.pdf +0 -0
- data/doc/ep_flux/math-doc/document.tex +2018 -0
- data/doc/gdir.html +412 -0
- data/doc/gdir_client.html +16 -0
- data/doc/gdir_connect_ftp-like.html +61 -0
- data/doc/gdir_server.html +45 -0
- data/doc/ggraph.html +1615 -0
- data/doc/gpcat.html +44 -0
- data/doc/gpcut.html +41 -0
- data/doc/gphys.html +532 -0
- data/doc/gphys_fft.html +324 -0
- data/doc/gphys_grads_io.html +69 -0
- data/doc/gphys_grib_io.html +82 -0
- data/doc/gphys_io.html +120 -0
- data/doc/gphys_io_common.html +18 -0
- data/doc/gphys_netcdf_io.html +283 -0
- data/doc/gplist.html +24 -0
- data/doc/gpmath.html +51 -0
- data/doc/gpmaxmin.html +31 -0
- data/doc/gpprint.html +34 -0
- data/doc/gpview.html +270 -0
- data/doc/grads2nc_with_gphys.html +21 -0
- data/doc/grads_gridded.html +307 -0
- data/doc/grib.html +144 -0
- data/doc/grid.html +212 -0
- data/doc/index.html +133 -0
- data/doc/index.rd +127 -0
- data/doc/netcdf_convention.html +136 -0
- data/doc/unumeric.html +176 -0
- data/doc/update +64 -0
- data/doc/varray.html +299 -0
- data/doc/varraycomposite.html +67 -0
- data/ext_coord.c +209 -0
- data/ext_init.c +7 -0
- data/extconf.rb +42 -0
- data/install.rb +130 -0
- data/interpo.c +497 -0
- data/lib/numru/dcl_mouse.rb +71 -0
- data/lib/numru/dclext_datetime_ax.rb +220 -0
- data/lib/numru/derivative.rb +348 -0
- data/lib/numru/ganalysis/covariance.rb +154 -0
- data/lib/numru/ganalysis/eof.rb +298 -0
- data/lib/numru/ganalysis/histogram.rb +252 -0
- data/lib/numru/ganalysis/met.rb +317 -0
- data/lib/numru/ganalysis/planet.rb +182 -0
- data/lib/numru/ganalysis.rb +7 -0
- data/lib/numru/gdir.rb +1038 -0
- data/lib/numru/gdir_connect_ftp-like.rb +149 -0
- data/lib/numru/ggraph.rb +5838 -0
- data/lib/numru/ggraph_on_merdional_section.rb +178 -0
- data/lib/numru/gphys/assoccoords.rb +359 -0
- data/lib/numru/gphys/attribute.rb +129 -0
- data/lib/numru/gphys/attributenetcdf.rb +80 -0
- data/lib/numru/gphys/axis.rb +963 -0
- data/lib/numru/gphys/coordmapping.rb +286 -0
- data/lib/numru/gphys/coordtransform.rb +209 -0
- data/lib/numru/gphys/derivative.rb +314 -0
- data/lib/numru/gphys/ep_flux.rb +868 -0
- data/lib/numru/gphys/gpcommon.rb +52 -0
- data/lib/numru/gphys/gphys.rb +1207 -0
- data/lib/numru/gphys/gphys_fft.rb +886 -0
- data/lib/numru/gphys/gphys_grads_io.rb +212 -0
- data/lib/numru/gphys/gphys_grib_io.rb +214 -0
- data/lib/numru/gphys/gphys_gtool3_io.rb +162 -0
- data/lib/numru/gphys/gphys_hdfeos5_io.rb +672 -0
- data/lib/numru/gphys/gphys_io.rb +452 -0
- data/lib/numru/gphys/gphys_io_common.rb +126 -0
- data/lib/numru/gphys/gphys_netcdf_io.rb +800 -0
- data/lib/numru/gphys/gphys_nusdas_io.rb +132 -0
- data/lib/numru/gphys/grads_gridded.rb +1638 -0
- data/lib/numru/gphys/grib.rb +2049 -0
- data/lib/numru/gphys/grib_params.rb +1465 -0
- data/lib/numru/gphys/grid.rb +723 -0
- data/lib/numru/gphys/gtool3.rb +771 -0
- data/lib/numru/gphys/interpolate.rb +854 -0
- data/lib/numru/gphys/narray_ext.rb +34 -0
- data/lib/numru/gphys/netcdf_convention.rb +406 -0
- data/lib/numru/gphys/subsetmapping.rb +332 -0
- data/lib/numru/gphys/unumeric.rb +522 -0
- data/lib/numru/gphys/varray.rb +1109 -0
- data/lib/numru/gphys/varraycomposite.rb +415 -0
- data/lib/numru/gphys/varraygrads.rb +225 -0
- data/lib/numru/gphys/varraygrib.rb +177 -0
- data/lib/numru/gphys/varraygtool3.rb +226 -0
- data/lib/numru/gphys/varrayhdfeos5.rb +451 -0
- data/lib/numru/gphys/varraynetcdf.rb +350 -0
- data/lib/numru/gphys/varraynusdas.rb +59 -0
- data/lib/numru/gphys.rb +9 -0
- data/lib/numru/htdir.rb +170 -0
- data/multibitIO.c +567 -0
- data/sample/cira86_to_nc.rb +122 -0
- data/sample/druby_cli1.rb +21 -0
- data/sample/druby_cli2.rb +34 -0
- data/sample/druby_serv1.rb +30 -0
- data/sample/druby_serv2.rb +64 -0
- data/sample/ep_flux/demo_NCEP_1.rb +48 -0
- data/sample/ep_flux/demo_NCEP_2.rb +57 -0
- data/sample/ep_flux/demo_NCEP_3.rb +81 -0
- data/sample/ggraph_latlon_labelling_dr002690.rb +159 -0
- data/sample/ggraph_mapfit-axes_dr002687.rb +131 -0
- data/sample/map_projection.rb +121 -0
- data/sample/ncep_theta_coord.rb +79 -0
- data/test/eof_slp.rb +28 -0
- data/test/mltbit.dat +0 -0
- data/test/test_ep_flux.rb +533 -0
- data/test/test_multibitIO.rb +19 -0
- data/testdata/T.jan.ctl +12 -0
- data/testdata/T.jan.dat +0 -0
- data/testdata/T.jan.grib +0 -0
- data/testdata/T.jan.nc +0 -0
- data/testdata/T.jan.packed.withmiss.nc +0 -0
- data/testdata/UV.jan.nc +0 -0
- data/testdata/assoc_crds.nc +0 -0
- data/testdata/cira86.dat +1332 -0
- metadata +621 -0
data/install.rb
ADDED
@@ -0,0 +1,130 @@
|
|
1
|
+
require 'rbconfig'
|
2
|
+
require 'find'
|
3
|
+
include Config
|
4
|
+
if CONFIG["MINOR"].to_i > 6 then $rb_18 = true else $rb_18 = false end
|
5
|
+
if $rb_18
|
6
|
+
require 'fileutils'
|
7
|
+
else
|
8
|
+
require 'ftools'
|
9
|
+
end
|
10
|
+
|
11
|
+
=begin
|
12
|
+
$version = CONFIG["MAJOR"]+"."+CONFIG["MINOR"]
|
13
|
+
$libdir = File.join(CONFIG["libdir"], "ruby", $version)
|
14
|
+
# $archdir = File.join($libdir, CONFIG["arch"])
|
15
|
+
$site_libdir = $:.find {|x| x =~ /site_ruby$/}
|
16
|
+
if !$site_libdir
|
17
|
+
$site_libdir = File.join($libdir, "site_ruby")
|
18
|
+
elsif Regexp.compile($site_libdir) !~ Regexp.quote($version)
|
19
|
+
$site_libdir = File.join($site_libdir, $version)
|
20
|
+
end
|
21
|
+
|
22
|
+
default_destdir = $site_libdir
|
23
|
+
=end
|
24
|
+
default_destdir = CONFIG["sitelibdir"]
|
25
|
+
|
26
|
+
default_bindir = CONFIG["bindir"]
|
27
|
+
|
28
|
+
def install_rb(srcdir, destdir)
|
29
|
+
libdir = "lib"
|
30
|
+
libdir = File.join(srcdir, libdir) if srcdir
|
31
|
+
path = []
|
32
|
+
dir = []
|
33
|
+
Find.find(libdir) do |f|
|
34
|
+
next unless FileTest.file?(f)
|
35
|
+
next if (f = f[libdir.length+1..-1]) == nil
|
36
|
+
next if (/CVS$/ =~ File.dirname(f))
|
37
|
+
path.push f
|
38
|
+
dir |= [File.dirname(f)]
|
39
|
+
end
|
40
|
+
for f in dir
|
41
|
+
next if f == "."
|
42
|
+
next if f == "CVS"
|
43
|
+
if $rb_18
|
44
|
+
FileUtils.makedirs(File.join(destdir, f))
|
45
|
+
else
|
46
|
+
File::makedirs(File.join(destdir, f))
|
47
|
+
end
|
48
|
+
end
|
49
|
+
for f in path
|
50
|
+
next if (/\~$/ =~ f)
|
51
|
+
next if (/^\./ =~ File.basename(f))
|
52
|
+
if $rb_18
|
53
|
+
FileUtils.install(File.join(libdir, f), File.join(destdir, f), {:mode => 0644, :verbose => true})
|
54
|
+
else
|
55
|
+
File::install(File.join(libdir, f), File.join(destdir, f), 0644, true)
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
def install_bin(srcdir, destbindir)
|
61
|
+
localbindir = "bin"
|
62
|
+
localbindir = File.join(srcdir, localbindir) if srcdir
|
63
|
+
path = []
|
64
|
+
dir = []
|
65
|
+
Find.find(localbindir) do |f|
|
66
|
+
next unless FileTest.file?(f)
|
67
|
+
next if (f = f[localbindir.length+1..-1]) == nil
|
68
|
+
next if (/CVS$/ =~ File.dirname(f))
|
69
|
+
path.push f
|
70
|
+
#dir |= [File.dirname(f)]
|
71
|
+
end
|
72
|
+
#for f in dir
|
73
|
+
# next if f == "."
|
74
|
+
# next if f == "CVS"
|
75
|
+
# File::makedirs(File.join(destbindir, f))
|
76
|
+
#end
|
77
|
+
for f in path
|
78
|
+
next if (/\~$/ =~ f)
|
79
|
+
next if (/^\./ =~ File.basename(f))
|
80
|
+
if $rb_18
|
81
|
+
FileUtils.install(File.join(localbindir, f), File.join(destbindir, f), {:mode => 0755, :verbose => true})
|
82
|
+
else
|
83
|
+
File::install(File.join(localbindir, f), File.join(destbindir, f), 0755, true)
|
84
|
+
end
|
85
|
+
end
|
86
|
+
end
|
87
|
+
|
88
|
+
def ARGV.switch
|
89
|
+
return nil if self.empty?
|
90
|
+
arg = self.shift
|
91
|
+
return nil if arg == '--'
|
92
|
+
if arg =~ /^-(.)(.*)/
|
93
|
+
return arg if $1 == '-'
|
94
|
+
raise 'unknown switch "-"' if $2.index('-')
|
95
|
+
self.unshift "-#{$2}" if $2.size > 0
|
96
|
+
"-#{$1}"
|
97
|
+
else
|
98
|
+
self.unshift arg
|
99
|
+
nil
|
100
|
+
end
|
101
|
+
end
|
102
|
+
|
103
|
+
def ARGV.req_arg
|
104
|
+
self.shift || raise('missing argument')
|
105
|
+
end
|
106
|
+
|
107
|
+
destdir = default_destdir
|
108
|
+
bindir = default_bindir
|
109
|
+
|
110
|
+
begin
|
111
|
+
while switch = ARGV.switch
|
112
|
+
case switch
|
113
|
+
when '-d', '--destdir'
|
114
|
+
destdir = ARGV.req_arg
|
115
|
+
when '-b', '--bindir'
|
116
|
+
bindir = ARGV.req_arg
|
117
|
+
else
|
118
|
+
raise "unknown switch #{switch.dump}"
|
119
|
+
end
|
120
|
+
end
|
121
|
+
rescue
|
122
|
+
STDERR.puts $!.to_s
|
123
|
+
STDERR.puts File.basename($0) +
|
124
|
+
" -d <destdir> -b <bindir>"
|
125
|
+
exit 1
|
126
|
+
end
|
127
|
+
|
128
|
+
install_rb(nil, destdir)
|
129
|
+
install_bin(nil, bindir)
|
130
|
+
|
data/interpo.c
ADDED
@@ -0,0 +1,497 @@
|
|
1
|
+
/* interpo.c : Extention library regarding interpolation of GPhys
|
2
|
+
*/
|
3
|
+
|
4
|
+
#include<stdio.h>
|
5
|
+
#include<string.h>
|
6
|
+
#include "ruby.h"
|
7
|
+
#include "narray.h"
|
8
|
+
|
9
|
+
#ifndef RARRAY_PTR
|
10
|
+
# define RARRAY_PTR(ary) (RARRAY(ary)->ptr)
|
11
|
+
#endif
|
12
|
+
#ifndef RARRAY_LEN
|
13
|
+
# define RARRAY_LEN(ary) (RARRAY(ary)->len)
|
14
|
+
#endif
|
15
|
+
|
16
|
+
static VALUE
|
17
|
+
interpo_do(obj, shape_to, idxmap, val_from, missval)
|
18
|
+
VALUE obj;
|
19
|
+
VALUE shape_to; // [Array] shape of the new grid
|
20
|
+
VALUE idxmap; // [Array] index mapping
|
21
|
+
VALUE val_from; // [NArray] values to be interpolated
|
22
|
+
VALUE missval; // [nil or Float] missing value if Float
|
23
|
+
{
|
24
|
+
VALUE val_to;
|
25
|
+
VALUE chk , ary;
|
26
|
+
struct NARRAY *naf;
|
27
|
+
VALUE vm;
|
28
|
+
int natype;
|
29
|
+
int *sht; // shape to (could be size_t if NArray is changed)
|
30
|
+
int *shf; // shape from (could be size_t if NArray is changed)
|
31
|
+
size_t cshf;
|
32
|
+
size_t rankf, rankt, lent;
|
33
|
+
double *pt, *pf;
|
34
|
+
int nomiss;
|
35
|
+
double vmiss;
|
36
|
+
size_t i, it, kf, j, k, l;
|
37
|
+
int *mtyp;
|
38
|
+
size_t *dm, *dm2, *dm2f, *dm3, *dm3f, *dm4, *dm4f;
|
39
|
+
int **di, nid, nic;
|
40
|
+
double **df, *f, a;
|
41
|
+
size_t *idf, idfc, *idt;
|
42
|
+
|
43
|
+
// check arguments
|
44
|
+
|
45
|
+
if (TYPE(shape_to) != T_ARRAY){
|
46
|
+
rb_raise(rb_eTypeError, "1st arg must be an array");
|
47
|
+
}
|
48
|
+
if (TYPE(idxmap) != T_ARRAY){
|
49
|
+
rb_raise(rb_eTypeError, "2nd arg must be an array");
|
50
|
+
}
|
51
|
+
|
52
|
+
chk = rb_obj_is_kind_of(val_from, cNArray);
|
53
|
+
if (chk == Qfalse) {
|
54
|
+
rb_raise(rb_eTypeError, "3rd arg must be an NArray");
|
55
|
+
}
|
56
|
+
|
57
|
+
// read argument (shape_to)
|
58
|
+
|
59
|
+
rankt = RARRAY_LEN(shape_to);
|
60
|
+
sht = ALLOCA_N(int, rankt);
|
61
|
+
for(i=0; i<rankt; i++){
|
62
|
+
sht[i] = NUM2INT( RARRAY_PTR(shape_to)[i] );
|
63
|
+
}
|
64
|
+
|
65
|
+
// read argument (val_from)
|
66
|
+
|
67
|
+
natype = NA_TYPE(val_from); // saved
|
68
|
+
val_from = na_cast_object(val_from, NA_DFLOAT);
|
69
|
+
rankf = NA_RANK(val_from);
|
70
|
+
GetNArray(val_from, naf);
|
71
|
+
shf = naf->shape;
|
72
|
+
pf = NA_PTR_TYPE(val_from, double *);
|
73
|
+
|
74
|
+
// read argument (missval)
|
75
|
+
|
76
|
+
nomiss = (missval == Qnil);
|
77
|
+
if (!nomiss){
|
78
|
+
vmiss = NUM2DBL(missval);
|
79
|
+
}
|
80
|
+
|
81
|
+
// read argument (idxmap)
|
82
|
+
|
83
|
+
if (RARRAY_LEN(idxmap) != rankf){
|
84
|
+
rb_raise(rb_eArgError, "length of 2nd arg and rank of 3rd arg must agree");
|
85
|
+
}
|
86
|
+
|
87
|
+
mtyp = ALLOCA_N(int, rankf);
|
88
|
+
dm = ALLOCA_N(size_t, rankf);
|
89
|
+
dm2 = ALLOCA_N(size_t, rankf);
|
90
|
+
dm2f = ALLOCA_N(size_t, rankf);
|
91
|
+
dm3 = ALLOCA_N(size_t, rankf);
|
92
|
+
dm3f = ALLOCA_N(size_t, rankf);
|
93
|
+
dm4 = ALLOCA_N(size_t, rankf);
|
94
|
+
dm4f = ALLOCA_N(size_t, rankf);
|
95
|
+
di = ALLOCA_N(int *, rankf);
|
96
|
+
df = ALLOCA_N(double *, rankf);
|
97
|
+
nid = 0;
|
98
|
+
for(i=0; i<rankf; i++){
|
99
|
+
vm = RARRAY_PTR(idxmap)[i];
|
100
|
+
if (RARRAY_LEN(vm) == 1) {
|
101
|
+
mtyp[i] = 0; // simple copying
|
102
|
+
dm[i] = NUM2INT( RARRAY_PTR(vm)[0] );
|
103
|
+
} else if ( RARRAY_PTR(vm)[1] == Qnil ) {
|
104
|
+
mtyp[i] = 1; // mapping from 1D
|
105
|
+
dm[i] = NUM2INT( RARRAY_PTR(vm)[0] );
|
106
|
+
di[i] = NA_PTR_TYPE( RARRAY_PTR(vm)[2], int *);
|
107
|
+
df[i] = NA_PTR_TYPE( RARRAY_PTR(vm)[3], double *);
|
108
|
+
nid++;
|
109
|
+
} else {
|
110
|
+
dm[i] = NUM2INT( RARRAY_PTR(vm)[0] );
|
111
|
+
ary = RARRAY_PTR(vm)[1];
|
112
|
+
mtyp[i] = RARRAY_LEN(ary)+1; // mapping from multi-D
|
113
|
+
switch( mtyp[i] ){
|
114
|
+
case 4: // do not break
|
115
|
+
dm4[i] = NUM2INT( RARRAY_PTR(ary)[2] );
|
116
|
+
dm4f[i]= sht[NUM2INT( RARRAY_PTR(ary)[1] )];
|
117
|
+
case 3: // do not break
|
118
|
+
dm3[i] = NUM2INT( RARRAY_PTR(ary)[1] );
|
119
|
+
dm3f[i]= sht[NUM2INT( RARRAY_PTR(ary)[0] )];
|
120
|
+
case 2:
|
121
|
+
dm2[i] = NUM2INT( RARRAY_PTR(ary)[0] );
|
122
|
+
dm2f[i]= sht[dm[i]];
|
123
|
+
}
|
124
|
+
di[i] = NA_PTR_TYPE( RARRAY_PTR(vm)[2], int *);
|
125
|
+
df[i] = NA_PTR_TYPE( RARRAY_PTR(vm)[3], double *);
|
126
|
+
nid++;
|
127
|
+
}
|
128
|
+
}
|
129
|
+
|
130
|
+
f = ALLOCA_N(double, nid);
|
131
|
+
nic = 1 << nid ; // ==> 2**nid
|
132
|
+
|
133
|
+
// prepare output object
|
134
|
+
|
135
|
+
val_to = na_make_object(NA_DFLOAT, rankt, sht, cNArray); // double for a momnent
|
136
|
+
lent = NA_TOTAL(val_to);
|
137
|
+
pt = NA_PTR_TYPE(val_to, double *);
|
138
|
+
|
139
|
+
|
140
|
+
// do interpolation
|
141
|
+
|
142
|
+
idt = ALLOCA_N(size_t, rankt);
|
143
|
+
idf = ALLOCA_N(size_t, rankf);
|
144
|
+
|
145
|
+
for(it=0; it<lent; it++){
|
146
|
+
l = it;
|
147
|
+
for(j=0; j<rankt; j++){
|
148
|
+
idt[j] = l % sht[j];
|
149
|
+
l /= sht[j];
|
150
|
+
}
|
151
|
+
k = 0;
|
152
|
+
for(j=0; j<rankf; j++){
|
153
|
+
switch(mtyp[j]){
|
154
|
+
case 0:
|
155
|
+
idf[j] = idt[dm[j]];
|
156
|
+
break;
|
157
|
+
case 1:
|
158
|
+
idf[j] = di[j][ idt[dm[j]] ];
|
159
|
+
f[k] = df[j][ idt[dm[j]] ];
|
160
|
+
k++;
|
161
|
+
break;
|
162
|
+
case 2:
|
163
|
+
idf[j] = di[j][ idt[dm[j]] + dm2f[j]*idt[dm2[j]] ];
|
164
|
+
f[k] = df[j][ idt[dm[j]] + dm2f[j]*idt[dm2[j]] ];
|
165
|
+
k++;
|
166
|
+
break;
|
167
|
+
case 3:
|
168
|
+
idf[j] = di[j][ idt[dm[j]] +
|
169
|
+
dm2f[j]*(idt[dm2[j]] + dm3f[j]*idt[dm3[j]]) ];
|
170
|
+
f[k] = df[j][ idt[dm[j]] +
|
171
|
+
dm2f[j]*(idt[dm2[j]] + dm3f[j]*idt[dm3[j]]) ];
|
172
|
+
k++;
|
173
|
+
break;
|
174
|
+
case 4:
|
175
|
+
idf[j] = di[j][ idt[dm[j]] +
|
176
|
+
dm2f[j]*(idt[dm2[j]] + dm3f[j]*
|
177
|
+
(idt[dm3[j]]+dm4f[j]*idt[dm4[j]])) ];
|
178
|
+
f[k] = df[j][ idt[dm[j]] +
|
179
|
+
dm2f[j]*(idt[dm2[j]] + dm3f[j]*
|
180
|
+
(idt[dm3[j]]+dm4f[j]*idt[dm4[j]])) ];
|
181
|
+
k++;
|
182
|
+
break;
|
183
|
+
}
|
184
|
+
}
|
185
|
+
pt[it] = 0.0;
|
186
|
+
for(l=0; l<nic; l++){ // loop for 2**nid times
|
187
|
+
a = 1.0;
|
188
|
+
for(k=0; k<nid; k++){
|
189
|
+
a = ( (l>>k)%2 ? a*f[k] : a*(1.0 - f[k]) );
|
190
|
+
}
|
191
|
+
cshf=1;
|
192
|
+
kf = 0;
|
193
|
+
k = 0;
|
194
|
+
for(j=0; j<rankf; j++){
|
195
|
+
idfc = idf[j];
|
196
|
+
if(mtyp[j]>0){
|
197
|
+
if ( (l>>k)%2 && idfc<shf[j]-1 ){
|
198
|
+
idfc += 1;
|
199
|
+
}
|
200
|
+
k++;
|
201
|
+
}
|
202
|
+
kf += idfc*cshf;
|
203
|
+
cshf *= shf[j];
|
204
|
+
}
|
205
|
+
if (nomiss || pf[kf] != vmiss){
|
206
|
+
pt[it] += a*pf[kf];
|
207
|
+
} else {
|
208
|
+
pt[it] = vmiss;
|
209
|
+
break;
|
210
|
+
}
|
211
|
+
}
|
212
|
+
}
|
213
|
+
|
214
|
+
// finish
|
215
|
+
val_to = na_cast_object(val_to, natype);
|
216
|
+
return val_to;
|
217
|
+
}
|
218
|
+
|
219
|
+
static void
|
220
|
+
__interpo_find_loc_1D(N, P, n, p, ids, f)
|
221
|
+
double *P, *p; // INPUT
|
222
|
+
size_t N, n; // INPUT
|
223
|
+
int *ids; // OUTPUT
|
224
|
+
double *f; // OUTPUT
|
225
|
+
{
|
226
|
+
size_t i, j, il, ir;
|
227
|
+
int down;
|
228
|
+
|
229
|
+
// first time finding : use a simple looping
|
230
|
+
j = 0;
|
231
|
+
for(i=0; i<n-1; i++){
|
232
|
+
if ( (p[i]-P[j])*(P[j]-p[i+1]) >= 0 ){
|
233
|
+
break;
|
234
|
+
}
|
235
|
+
}
|
236
|
+
if (i<n-1){
|
237
|
+
// found
|
238
|
+
ids[j] = i;
|
239
|
+
} else {
|
240
|
+
// not found --> to be extrapolated
|
241
|
+
if ( (P[j]-p[0])*(p[0]-p[n-1]) >= 0 ){
|
242
|
+
ids[j] = i = 0;
|
243
|
+
} else {
|
244
|
+
ids[j] = i = n-2;
|
245
|
+
}
|
246
|
+
}
|
247
|
+
f[j] = (p[i]-P[j])/(p[i]-p[i+1]);
|
248
|
+
|
249
|
+
// second or later time finding : start from the previous position
|
250
|
+
for(j=1; j<N; j++){
|
251
|
+
down = 1; // true : move i downward next time
|
252
|
+
il = ir = i;
|
253
|
+
while (1){
|
254
|
+
if ( (p[i]-P[j])*(P[j]-p[i+1]) >= 0 ) {
|
255
|
+
break;
|
256
|
+
} else {
|
257
|
+
if ( il>0 && ( down || ir==n-1 ) ){
|
258
|
+
il--;
|
259
|
+
i = il;
|
260
|
+
down = 0; // false
|
261
|
+
} else if ( ir<n-1 && ( !down || il==0 ) ){
|
262
|
+
ir++;
|
263
|
+
i = ir;
|
264
|
+
down = 1; // true
|
265
|
+
} else {
|
266
|
+
// not found --> to be extrapolated
|
267
|
+
if ( (P[j]-p[0])*(p[0]-p[n-1]) >= 0 ){
|
268
|
+
i = 0;
|
269
|
+
} else {
|
270
|
+
i = n-2;
|
271
|
+
}
|
272
|
+
break;
|
273
|
+
}
|
274
|
+
}
|
275
|
+
}
|
276
|
+
ids[j] = i;
|
277
|
+
f[j] = (p[i]-P[j])/(p[i]-p[i+1]);
|
278
|
+
}
|
279
|
+
}
|
280
|
+
|
281
|
+
static VALUE
|
282
|
+
interpo_find_loc_1D(obj, X, x)
|
283
|
+
VALUE obj;
|
284
|
+
VALUE X; // [NArray(1D)] coordinate values onto which interpolation is made
|
285
|
+
VALUE x; // [NArray(1D)] coordinate values of original data
|
286
|
+
{
|
287
|
+
VALUE na_ids, na_f;
|
288
|
+
VALUE chk;
|
289
|
+
size_t N, n;
|
290
|
+
struct NARRAY *na;
|
291
|
+
double *P, *p;
|
292
|
+
int *ids;
|
293
|
+
double *f;
|
294
|
+
int shape[1]; // could be size_t if NArray is changed
|
295
|
+
|
296
|
+
// check and unwrap the input arguments
|
297
|
+
|
298
|
+
chk = rb_obj_is_kind_of(X, cNArray);
|
299
|
+
if (chk == Qfalse) {rb_raise(rb_eTypeError, "expect NArray (1st arg)");}
|
300
|
+
|
301
|
+
chk = rb_obj_is_kind_of(x, cNArray);
|
302
|
+
if (chk == Qfalse) {rb_raise(rb_eTypeError, "expect NArray (2nd arg)");}
|
303
|
+
|
304
|
+
X = na_cast_object(X, NA_DFLOAT);
|
305
|
+
GetNArray(X, na);
|
306
|
+
N = na->total;
|
307
|
+
P = (double *)NA_PTR(na, 0);
|
308
|
+
|
309
|
+
x = na_cast_object(x, NA_DFLOAT);
|
310
|
+
GetNArray(x, na);
|
311
|
+
n = na->total;
|
312
|
+
p = (double *)NA_PTR(na, 0);
|
313
|
+
|
314
|
+
// prepare output NArrays
|
315
|
+
|
316
|
+
shape[0] = N;
|
317
|
+
na_ids = na_make_object(NA_LINT, 1, shape, cNArray);
|
318
|
+
GetNArray(na_ids, na);
|
319
|
+
ids = (int *) NA_PTR(na, 0);
|
320
|
+
na_f = na_make_object(NA_DFLOAT, 1, shape, cNArray);
|
321
|
+
GetNArray(na_f, na);
|
322
|
+
f = (double *) NA_PTR(na, 0);
|
323
|
+
|
324
|
+
// Do the job
|
325
|
+
|
326
|
+
__interpo_find_loc_1D(N, P, n, p, ids, f);
|
327
|
+
|
328
|
+
// Return
|
329
|
+
|
330
|
+
return rb_ary_new3(2, na_ids, na_f);
|
331
|
+
}
|
332
|
+
|
333
|
+
/* To apply interpo_find_loc_1D multi-dimensionally
|
334
|
+
*/
|
335
|
+
static VALUE
|
336
|
+
interpo_find_loc_1D_MD(obj, X, x, dimc)
|
337
|
+
VALUE obj;
|
338
|
+
VALUE X; // [NArray(1D)] coordinate values onto which interpolation is made
|
339
|
+
VALUE x; // [NArray(multi-D)] coordinate values of original data
|
340
|
+
VALUE dimc; // [Integer] the dimension in x except which mapping has been set
|
341
|
+
{
|
342
|
+
VALUE na_ids, na_f;
|
343
|
+
VALUE chk;
|
344
|
+
size_t N, n1;
|
345
|
+
struct NARRAY *na;
|
346
|
+
double *P, *p, *p1;
|
347
|
+
int *ids, *ids1;
|
348
|
+
double *f, *f1;
|
349
|
+
int *shr; // shape of the result (could be size_t if NArray is changed)
|
350
|
+
int *shl; // shape of multi-D loop (could be size_t if NArray is changed)
|
351
|
+
int *shx; // shape of x (could be size_t if NArray is changed)
|
352
|
+
int dmc; // dimc
|
353
|
+
int rank, dl, dc;
|
354
|
+
size_t *cshxl, *cshrl, *cshl; // cumulative shapes for looping
|
355
|
+
size_t fxl; // same but only for the dimension treated here
|
356
|
+
size_t il, i, j, ix, ir, totl;
|
357
|
+
|
358
|
+
// check and unwrap the input arguments
|
359
|
+
|
360
|
+
chk = rb_obj_is_kind_of(X, cNArray);
|
361
|
+
if (chk == Qfalse) {rb_raise(rb_eTypeError, "expect NArray (1st arg)");}
|
362
|
+
|
363
|
+
chk = rb_obj_is_kind_of(x, cNArray);
|
364
|
+
if (chk == Qfalse) {rb_raise(rb_eTypeError, "expect NArray (2nd arg)");}
|
365
|
+
|
366
|
+
X = na_cast_object(X, NA_DFLOAT);
|
367
|
+
GetNArray(X, na);
|
368
|
+
N = na->total;
|
369
|
+
P = (double *)NA_PTR(na, 0);
|
370
|
+
|
371
|
+
dmc = NUM2INT( dimc );
|
372
|
+
|
373
|
+
x = na_cast_object(x, NA_DFLOAT);
|
374
|
+
GetNArray(x, na);
|
375
|
+
p = (double *)NA_PTR(na, 0);
|
376
|
+
shx = na->shape;
|
377
|
+
n1 = shx[dmc];
|
378
|
+
|
379
|
+
rank = NA_RANK(x);
|
380
|
+
|
381
|
+
if (dmc<0 || dmc>=rank){
|
382
|
+
rb_raise(rb_eArgError, "Specified dimension (4th argument) is outside the dims of the multi-D coordinate variable");
|
383
|
+
}
|
384
|
+
|
385
|
+
// prepare output NArrays
|
386
|
+
|
387
|
+
shl = ALLOCA_N(int, rank-1);
|
388
|
+
shr = ALLOCA_N(int, rank);
|
389
|
+
shr[0] = N;
|
390
|
+
totl = 1;
|
391
|
+
for(dl=0,dc=0; dl<rank-1; dl++,dc++){
|
392
|
+
if(dc==dmc){dc++;} // to skip shx[dmc]
|
393
|
+
shr[dl+1] = shl[dl] = shx[dc];
|
394
|
+
totl *= shl[dl];
|
395
|
+
}
|
396
|
+
|
397
|
+
cshl = ALLOCA_N(size_t, rank-1);
|
398
|
+
cshl[0] = 1;
|
399
|
+
for(dl=1; dl<rank-1; dl++){
|
400
|
+
cshl[dl] = cshl[dl-1]*shl[dl-1];
|
401
|
+
}
|
402
|
+
|
403
|
+
cshxl = ALLOCA_N(size_t, rank-1);
|
404
|
+
if(dmc==0) {
|
405
|
+
fxl = 1;
|
406
|
+
cshxl[0] = shx[0];
|
407
|
+
} else {
|
408
|
+
fxl = shx[0];
|
409
|
+
cshxl[0] = 1;
|
410
|
+
}
|
411
|
+
|
412
|
+
for(dl=1,dc=1; dl<rank-1; dl++,dc++){
|
413
|
+
if(dc==dmc){
|
414
|
+
fxl = cshxl[dl-1]*shx[dc-1];
|
415
|
+
dc++;
|
416
|
+
cshxl[dl] = fxl*shx[dc-1];
|
417
|
+
} else {
|
418
|
+
cshxl[dl] = cshxl[dl-1]*shx[dc-1];
|
419
|
+
}
|
420
|
+
}
|
421
|
+
if (dmc==rank-1){
|
422
|
+
fxl = cshxl[rank-2]*shx[rank-2];
|
423
|
+
}
|
424
|
+
|
425
|
+
cshrl = ALLOCA_N(size_t, rank-1);
|
426
|
+
cshrl[0] = shr[0];
|
427
|
+
for(dl=1; dl<rank-1; dl++){
|
428
|
+
cshrl[dl] = cshrl[dl-1]*shr[dl];
|
429
|
+
}
|
430
|
+
|
431
|
+
na_ids = na_make_object(NA_LINT, rank, shr, cNArray);
|
432
|
+
GetNArray(na_ids, na);
|
433
|
+
ids = (int *) NA_PTR(na, 0);
|
434
|
+
na_f = na_make_object(NA_DFLOAT, rank, shr, cNArray);
|
435
|
+
GetNArray(na_f, na);
|
436
|
+
f = (double *) NA_PTR(na, 0);
|
437
|
+
|
438
|
+
// Do the job
|
439
|
+
|
440
|
+
p1 = ALLOCA_N(double, n1);
|
441
|
+
ids1 = ALLOCA_N(int, N);
|
442
|
+
f1 = ALLOCA_N(double, N);
|
443
|
+
for(il=0; il<totl; il++){
|
444
|
+
|
445
|
+
// put a 1D subset of p into p1 (p1 = p[..., true,...])
|
446
|
+
|
447
|
+
ix = 0;
|
448
|
+
ir = 0;
|
449
|
+
for(dl=0; dl<rank-1; dl++){
|
450
|
+
i = (il/cshl[dl]) % shl[dl];
|
451
|
+
ix += cshxl[dl]*i;
|
452
|
+
ir += cshrl[dl]*i;
|
453
|
+
}
|
454
|
+
|
455
|
+
for(j=0; j<n1; j++){
|
456
|
+
p1[j] = p[ix+fxl*j];
|
457
|
+
}
|
458
|
+
|
459
|
+
// find loc in 1D
|
460
|
+
|
461
|
+
__interpo_find_loc_1D(N, P, n1, p1, ids1, f1);
|
462
|
+
|
463
|
+
// substitute ids1 and f1 (1D) into ids and f (multi-D)
|
464
|
+
|
465
|
+
for(j=0; j<N; j++){
|
466
|
+
ids[ir+j] = ids1[j];
|
467
|
+
f[ir+j] = f1[j];
|
468
|
+
//printf(" %d %f\n",ids1[j],f1[j]);
|
469
|
+
}
|
470
|
+
//printf("\n");
|
471
|
+
|
472
|
+
}
|
473
|
+
|
474
|
+
// Return
|
475
|
+
|
476
|
+
return rb_ary_new3(2, na_ids, na_f);
|
477
|
+
}
|
478
|
+
|
479
|
+
|
480
|
+
void
|
481
|
+
init_gphys_interpo()
|
482
|
+
{
|
483
|
+
static VALUE mNumRu;
|
484
|
+
static VALUE cGPhys;
|
485
|
+
|
486
|
+
// rb_require("narray"); // it does not work
|
487
|
+
mNumRu = rb_define_module("NumRu");
|
488
|
+
cGPhys = rb_define_class_under(mNumRu, "GPhys", rb_cObject);
|
489
|
+
rb_define_private_method(cGPhys, "c_interpo_find_loc_1D", interpo_find_loc_1D, 2);
|
490
|
+
rb_define_private_method(cGPhys, "c_interpo_find_loc_1D_MD", interpo_find_loc_1D_MD, 3);
|
491
|
+
|
492
|
+
rb_define_private_method(cGPhys, "c_interpo_do", interpo_do, 4);
|
493
|
+
|
494
|
+
// to make "find loc" methods available outside GPhys as class methods
|
495
|
+
rb_define_singleton_method(cGPhys, "interpo_find_loc_1D", interpo_find_loc_1D, 2);
|
496
|
+
rb_define_singleton_method(cGPhys, "interpo_find_loc_1D_MD", interpo_find_loc_1D_MD, 3);
|
497
|
+
}
|
@@ -0,0 +1,71 @@
|
|
1
|
+
require "numru/dcl"
|
2
|
+
|
3
|
+
module NumRu
|
4
|
+
|
5
|
+
class DCLMousePt
|
6
|
+
@@t_thres = 0.05 # threshold of time delay [in sec] to judge interaction
|
7
|
+
def initialize
|
8
|
+
ta = Time.now
|
9
|
+
wx = wy = nil
|
10
|
+
while(true)
|
11
|
+
wx, wy, mb = DCL.swqpnt
|
12
|
+
tb = Time.now
|
13
|
+
if (tb-ta > @@t_thres) # OK if it takes a short time
|
14
|
+
break
|
15
|
+
else # Too fast. It must be due to previous clicks. Take one again.
|
16
|
+
ta = tb
|
17
|
+
end
|
18
|
+
end
|
19
|
+
@rx, @ry = NumRu::DCL.stiwtr(wx, wy)
|
20
|
+
@vx, @vy = NumRu::DCL.stipr2(rx, ry)
|
21
|
+
@ux, @uy = NumRu::DCL.stitrf(vx, vy)
|
22
|
+
@wx = wx
|
23
|
+
@wy = wy
|
24
|
+
end
|
25
|
+
|
26
|
+
attr_accessor :ux, :uy, :vx, :vy, :rx, :ry, :wx, :wy
|
27
|
+
|
28
|
+
def uxy
|
29
|
+
[@ux, @uy]
|
30
|
+
end
|
31
|
+
|
32
|
+
def vxy
|
33
|
+
[@vx, @vy]
|
34
|
+
end
|
35
|
+
|
36
|
+
def rxy
|
37
|
+
[@rx, @ry]
|
38
|
+
end
|
39
|
+
|
40
|
+
def mark(type=2,index=1,size=0.02)
|
41
|
+
DCL.uumrkz([@ux], [@uy], type, index, size)
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
class DCLMouseLine
|
46
|
+
def initialize(num=2)
|
47
|
+
raise("Number of points must be 2 or greater") if num<2
|
48
|
+
@p = Array.new
|
49
|
+
num.times{@p.push(DCLMousePt.new)}
|
50
|
+
@ux = @p.collect{|p| p.ux}
|
51
|
+
@uy = @p.collect{|p| p.uy}
|
52
|
+
@vx = @p.collect{|p| p.vx}
|
53
|
+
@vy = @p.collect{|p| p.vy}
|
54
|
+
@rx = @p.collect{|p| p.rx}
|
55
|
+
@ry = @p.collect{|p| p.ry}
|
56
|
+
@wx = @p.collect{|p| p.wx}
|
57
|
+
@wy = @p.collect{|p| p.wy}
|
58
|
+
end
|
59
|
+
|
60
|
+
attr_accessor :ux, :uy, :vx, :vy, :rx, :ry, :wx, :wy
|
61
|
+
|
62
|
+
# Drawn in the V coordinate so that it will be a straight line
|
63
|
+
# on the display
|
64
|
+
def draw(type=1,index=1)
|
65
|
+
DCL.sgplzv(vx,vy,type,index)
|
66
|
+
end
|
67
|
+
|
68
|
+
end
|
69
|
+
|
70
|
+
end
|
71
|
+
|