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
data/multibitIO.c
ADDED
|
@@ -0,0 +1,567 @@
|
|
|
1
|
+
#include <stdio.h>
|
|
2
|
+
#include <stdlib.h>
|
|
3
|
+
#include "ruby.h"
|
|
4
|
+
#include "narray.h"
|
|
5
|
+
|
|
6
|
+
#ifndef HAVE_INT32_T
|
|
7
|
+
typedef int int32_t;
|
|
8
|
+
#endif
|
|
9
|
+
|
|
10
|
+
/* for compatibility with ruby 1.6 */
|
|
11
|
+
#ifndef RARRAY_PTR
|
|
12
|
+
#define RARRAY_PTR(a) (RARRAY(a)->ptr)
|
|
13
|
+
#endif
|
|
14
|
+
#ifndef RARRAY_LEN
|
|
15
|
+
#define RARRAY_LEN(a) (RARRAY(a)->len)
|
|
16
|
+
#endif
|
|
17
|
+
#ifndef StringValueCStr
|
|
18
|
+
#define StringValueCStr(s) STR2CSTR(s)
|
|
19
|
+
#endif
|
|
20
|
+
#ifndef StringValuePtr
|
|
21
|
+
#define StringValuePtr(s) STR2CSTR(s)
|
|
22
|
+
#endif
|
|
23
|
+
|
|
24
|
+
struct multibit_IO {
|
|
25
|
+
FILE *fp;
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
static void
|
|
29
|
+
multibit_IO_closer(ptr)
|
|
30
|
+
struct multibit_IO *ptr;
|
|
31
|
+
{
|
|
32
|
+
if (ptr->fp)
|
|
33
|
+
fclose(ptr->fp);
|
|
34
|
+
free(ptr);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
/*
|
|
38
|
+
VALUE
|
|
39
|
+
multibit_IO_close(self)
|
|
40
|
+
VALUE self;
|
|
41
|
+
{
|
|
42
|
+
struct multibit_IO *ptr;
|
|
43
|
+
Data_Get_Struct(self, struct multibit_IO, ptr);
|
|
44
|
+
multibit_IO_closer(ptr);
|
|
45
|
+
return Qnil;
|
|
46
|
+
}
|
|
47
|
+
*/
|
|
48
|
+
|
|
49
|
+
static VALUE
|
|
50
|
+
multibit_IO_alloc(VALUE klass)
|
|
51
|
+
{
|
|
52
|
+
struct multibit_IO *ptr = ALLOC(struct multibit_IO);
|
|
53
|
+
return Data_Wrap_Struct(klass, 0, multibit_IO_closer, ptr);
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
static VALUE
|
|
58
|
+
multibit_IO_initialize(VALUE self, VALUE path)
|
|
59
|
+
{
|
|
60
|
+
struct multibit_IO *ptr;
|
|
61
|
+
Data_Get_Struct(self, struct multibit_IO, ptr);
|
|
62
|
+
ptr->fp = fopen(StringValueCStr(path),"rb");
|
|
63
|
+
if (!ptr->fp)
|
|
64
|
+
rb_raise(rb_eArgError, "Cannot open file: %s\n", StringValueCStr(path));
|
|
65
|
+
return Qnil;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
static int32_t *
|
|
69
|
+
multibit_read_2D(fp, pos, nbit, sh0, sh1, f0, l0, s0, f1, l1, s1, idx0, idx1,
|
|
70
|
+
ival)
|
|
71
|
+
// IN
|
|
72
|
+
FILE *fp; // binary file to read
|
|
73
|
+
long pos; // starting postion of the current 2D block in fp (bytes)
|
|
74
|
+
long nbit; // number of bits of each data element (>= 0, integer)
|
|
75
|
+
long sh0; // shape of the 2D array - lengths of the 1st D
|
|
76
|
+
long sh1; // shape of the 2D array - lengths of the 2nd D
|
|
77
|
+
long f0; // first index of the subset to read regarding the 1st D
|
|
78
|
+
long f1; // first index of the subset to read regarding the 2nd D
|
|
79
|
+
long l0; // last index of the subset to read regarding the 1st D
|
|
80
|
+
long l1; // last index of the subset to read regarding the 2nd D
|
|
81
|
+
long s0; // step of the subset to read regarding the 1st D
|
|
82
|
+
long s1; // step of the subset to read regarding the 2nd D
|
|
83
|
+
long *idx0;// If non-NULL, index map of the subset regarding the 1st D
|
|
84
|
+
// Then f0, s0, and l0 must be 0, 1 and len-1 of idx0
|
|
85
|
+
long *idx1;// If non-NULL, index map of the subset regarding the 2nd D
|
|
86
|
+
// Then f1, s1, and l1 must be 0, 1 and len-1 of idx1
|
|
87
|
+
// OUT
|
|
88
|
+
int32_t *ival; // to return (allocated if NULL)
|
|
89
|
+
{
|
|
90
|
+
long pf, pl, bskip;
|
|
91
|
+
unsigned char *buf;
|
|
92
|
+
long sz, size;
|
|
93
|
+
long len;
|
|
94
|
+
int status;
|
|
95
|
+
long i, i0, i1, ns, nl, k, j, ib;
|
|
96
|
+
int w, b;
|
|
97
|
+
unsigned char cn[5];
|
|
98
|
+
unsigned char mk[8] = {0xff,0x7f,0x3f,0x1f,0x0f,0x07,0x03,0x01};
|
|
99
|
+
// bit mask. in binary, 01111111, 00111111, 00011111,..., 00000001
|
|
100
|
+
unsigned int one = 1;
|
|
101
|
+
long fa0, fa1, la0, la1; // actual f0, f1, l0, l1
|
|
102
|
+
|
|
103
|
+
// << read the file >>
|
|
104
|
+
|
|
105
|
+
if(idx0 == NULL){
|
|
106
|
+
fa0 = f0;
|
|
107
|
+
la0 = l0;
|
|
108
|
+
} else {
|
|
109
|
+
fa0 = 0; // possible min val (to use actual min is impactless)
|
|
110
|
+
la0 = sh0-1; // possible max val (to use actual max is impactless)
|
|
111
|
+
}
|
|
112
|
+
if(idx1 == NULL){
|
|
113
|
+
fa1 = f1;
|
|
114
|
+
la1 = l1;
|
|
115
|
+
} else {
|
|
116
|
+
for( i=0, fa1=sh1-1, la1=0 ; i<=l1 ; i++){
|
|
117
|
+
if(idx1[i] < fa1){ fa1=idx1[i]; } // find actual minimum
|
|
118
|
+
if(idx1[i] > la1){ la1=idx1[i]; } // find actual maximum
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
bskip = (fa0+sh0*fa1) * nbit / 8;
|
|
123
|
+
pf = pos + bskip; // first file pos to read
|
|
124
|
+
pl = pos + ( (la0+sh0*la1+1)*nbit -1 ) / 8; // last file pos to read
|
|
125
|
+
|
|
126
|
+
size = pl-pf+1;
|
|
127
|
+
//printf("=== %d %d %d %d %d\n",pf,pl,size,sh0,la1);
|
|
128
|
+
buf = ALLOCA_N(unsigned char, size);
|
|
129
|
+
status = fseek(fp, pf, SEEK_SET);
|
|
130
|
+
if (status) { rb_raise(rb_eStandardError,
|
|
131
|
+
"Could not move to the specified position %d",pf); }
|
|
132
|
+
sz = fread(buf,1,size,fp);
|
|
133
|
+
if (sz!=size) { rb_raise(rb_eStandardError,
|
|
134
|
+
"Could not read %d bytes from %d",size,pf); }
|
|
135
|
+
|
|
136
|
+
// << multibit -> int32_t >>
|
|
137
|
+
|
|
138
|
+
if(ival==NULL){
|
|
139
|
+
len = ((l0-f0)/s0+1) * ((l1-f1)/s1+1); // total len of ival
|
|
140
|
+
ival = (int32_t *) xmalloc(len*sizeof(int32_t));
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
k = 0;
|
|
144
|
+
for(i1=f1; i1<=l1; i1+=s1){
|
|
145
|
+
for(i0=f0; i0<=l0; i0+=s0, k++){
|
|
146
|
+
if(idx0 == NULL && idx1 == NULL){
|
|
147
|
+
i = i0+sh0*i1;
|
|
148
|
+
} else if (idx0 == NULL) {
|
|
149
|
+
i = i0+sh0*idx1[i1];
|
|
150
|
+
} else if (idx1 == NULL) {
|
|
151
|
+
i = idx0[i0]+sh0*i1;
|
|
152
|
+
} else {
|
|
153
|
+
i = idx0[i0]+sh0*idx1[i1];
|
|
154
|
+
//printf("--- %d\n",i);
|
|
155
|
+
}
|
|
156
|
+
ib = i*nbit;
|
|
157
|
+
ns = ib / 8 - bskip; // start position i*nbit/8
|
|
158
|
+
nl = (ib+nbit-1) / 8 - bskip; // end position
|
|
159
|
+
w = ib % 8;
|
|
160
|
+
cn[0] = buf[ns] & mk[w]; // mask the first w bits
|
|
161
|
+
for(j=1; j<= nl-ns; j++){
|
|
162
|
+
cn[j] = buf[ns+j];
|
|
163
|
+
}
|
|
164
|
+
ival[k] = 0;
|
|
165
|
+
for(j=0; j<=nl-ns; j++){
|
|
166
|
+
b = w + nbit - (j+1)*8 ;
|
|
167
|
+
if (b>0) {
|
|
168
|
+
ival[k] += cn[j] * (one<<b); //cn[j]<<b (truncation-free)
|
|
169
|
+
} else if (b==0) {
|
|
170
|
+
ival[k] += cn[j];
|
|
171
|
+
} else {
|
|
172
|
+
ival[k] += cn[j] >> (-b);
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
//printf("%d %d\n",(int)k,ival[k]);
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
return(ival);
|
|
179
|
+
}
|
|
180
|
+
// Array -> C pointer with range checking (from Ruby-DCL)
|
|
181
|
+
static long *
|
|
182
|
+
ary2long(src, sh, len)
|
|
183
|
+
VALUE src;
|
|
184
|
+
long sh;
|
|
185
|
+
long *len;
|
|
186
|
+
{
|
|
187
|
+
VALUE *ptr;
|
|
188
|
+
long i;
|
|
189
|
+
long *rtn,x;
|
|
190
|
+
|
|
191
|
+
*len = RARRAY_LEN(src);
|
|
192
|
+
ptr = RARRAY_PTR(src);
|
|
193
|
+
rtn = ALLOC_N(long, *len);
|
|
194
|
+
for (i = 0; i < *len; i++) {
|
|
195
|
+
x = NUM2INT(ptr[i]);
|
|
196
|
+
if(x<-sh||x>=sh){rb_raise(rb_eArgError,
|
|
197
|
+
"%d-th index (%d) is not in the index range", i,x);}
|
|
198
|
+
if(x<0){x += sh;}
|
|
199
|
+
rtn[i] = x;
|
|
200
|
+
}
|
|
201
|
+
return rtn;
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
// NArray -> C pointer with range checking (from Ruby-DCL)
|
|
205
|
+
static long *
|
|
206
|
+
na2long(src, sh, len)
|
|
207
|
+
VALUE src;
|
|
208
|
+
long sh;
|
|
209
|
+
long *len;
|
|
210
|
+
{
|
|
211
|
+
VALUE chk;
|
|
212
|
+
long i;
|
|
213
|
+
long *rtn, x;
|
|
214
|
+
int32_t *ptr;
|
|
215
|
+
|
|
216
|
+
chk = rb_obj_is_kind_of(src, cNArray);
|
|
217
|
+
if (chk == Qfalse) {
|
|
218
|
+
rb_raise(rb_eTypeError, "expect an integer NArray");
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
src = na_cast_object(src, NA_LINT);
|
|
222
|
+
*len = NA_TOTAL(src);
|
|
223
|
+
ptr = NA_PTR_TYPE(src, int32_t *);
|
|
224
|
+
rtn = ALLOC_N(long, *len);
|
|
225
|
+
for (i = 0; i < *len; i++) {
|
|
226
|
+
x = (long)ptr[i];
|
|
227
|
+
if(x<-sh||x>=sh){rb_raise(rb_eArgError,
|
|
228
|
+
"%d-th index (%d) is not in the index range", i,x);}
|
|
229
|
+
if(x<0){x += sh;}
|
|
230
|
+
rtn[i] = x;
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
return rtn;
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
/*
|
|
237
|
+
= MultibitIO::read2D : A wrapper of multibit_read_2D.
|
|
238
|
+
|
|
239
|
+
In addtion to be a simple wrapper, a scaling facotor and
|
|
240
|
+
an offset can be specfied optionally:
|
|
241
|
+
The return value is sfloat NArray if factor and/or offset
|
|
242
|
+
is given (non-nil). Otherwise, it will be an integer NArray.
|
|
243
|
+
|
|
244
|
+
Also, [fls][01] can be nil if idx0 and/or idx1 is present.
|
|
245
|
+
*/
|
|
246
|
+
static VALUE
|
|
247
|
+
wrp_multibit_read_2D(self, pos, nbit, sh0, sh1, f0, l0, s0, f1, l1, s1,
|
|
248
|
+
idx0, idx1, factor, offset )
|
|
249
|
+
VALUE self;
|
|
250
|
+
VALUE pos; // starting postion of the current 2D block in fp (bytes)
|
|
251
|
+
VALUE nbit; // number of bits of each data element (>= 0, integer)
|
|
252
|
+
VALUE sh0; // shape of the 2D array - lengths of the 1st D
|
|
253
|
+
VALUE sh1; // shape of the 2D array - lengths of the 2nd D
|
|
254
|
+
VALUE f0; // first index of the subset to read regarding the 1st D.
|
|
255
|
+
// nil ok if idx0 is non-nil (same for l0, s0).
|
|
256
|
+
VALUE f1; // first index of the subset to read regarding the 2nd D.
|
|
257
|
+
// nil ok if idx1 is non-nil (same for l1, s1).
|
|
258
|
+
VALUE l0; // last index of the subset to read regarding the 1st D.
|
|
259
|
+
VALUE l1; // last index of the subset to read regarding the 2nd D.
|
|
260
|
+
VALUE s0; // step of the subset to read regarding the 1st D.
|
|
261
|
+
VALUE s1; // step of the subset to read regarding the 2nd D.
|
|
262
|
+
VALUE idx0; // If non-nil, index map of the subset regarding the 1st D
|
|
263
|
+
// Then f0, s0, and l0 are automatically set (so nil ok)
|
|
264
|
+
VALUE idx1; // If non-nil, index map of the subset regarding the 2nd D
|
|
265
|
+
// Then f1, s1, and l1 are automatically set (so nil ok)
|
|
266
|
+
VALUE factor; // (optional) nil or scale_factor (Numeric)
|
|
267
|
+
VALUE offset; // (optional) nil oradd_offset (Numeric)
|
|
268
|
+
{
|
|
269
|
+
VALUE na;
|
|
270
|
+
struct multibit_IO *ptr;
|
|
271
|
+
FILE *fp; // binary file to read
|
|
272
|
+
long Pos; // starting postion of the current 2D block in fp (bytes)
|
|
273
|
+
long Nbit; // number of bits of each data element (>= 0, integer)
|
|
274
|
+
long Sh0; // shape of the 2D array - lengths of the 1st D
|
|
275
|
+
long Sh1; // shape of the 2D array - lengths of the 2nd D
|
|
276
|
+
long F0; // first index of the subset to read regarding the 1st D
|
|
277
|
+
long F1; // first index of the subset to read regarding the 2nd D
|
|
278
|
+
long L0; // last index of the subset to read regarding the 1st D
|
|
279
|
+
long L1; // last index of the subset to read regarding the 2nd D
|
|
280
|
+
long S0; // step of the subset to read regarding the 1st D
|
|
281
|
+
long S1; // step of the subset to read regarding the 2nd D
|
|
282
|
+
long *Idx0; // If non-NULL, index map of the subset regarding the 1st D
|
|
283
|
+
// Then f0, s0, and l0 must be 0, 1 and len-1 of idx0
|
|
284
|
+
long *Idx1; // If non-NULL, index map of the subset regarding the 2nd D
|
|
285
|
+
// Then f1, s1, and l1 must be 0, 1 and len-1 of idx1
|
|
286
|
+
int lens[2];
|
|
287
|
+
long len;
|
|
288
|
+
int32_t *ival;
|
|
289
|
+
float *fval;
|
|
290
|
+
float Factor, Offset;
|
|
291
|
+
long i;
|
|
292
|
+
|
|
293
|
+
Data_Get_Struct(self, struct multibit_IO, ptr);
|
|
294
|
+
fp = ptr->fp;
|
|
295
|
+
|
|
296
|
+
Pos = NUM2INT(pos);
|
|
297
|
+
Nbit = NUM2INT(nbit);
|
|
298
|
+
Sh0 = NUM2INT(sh0);
|
|
299
|
+
Sh1 = NUM2INT(sh1);
|
|
300
|
+
if (idx0 == Qnil){
|
|
301
|
+
F0 = NUM2INT(f0);
|
|
302
|
+
if(F0<-Sh0||F0>=Sh0){rb_raise(rb_eArgError,
|
|
303
|
+
"f0 (=%d) is not in the index range of the 1st dim", f0);}
|
|
304
|
+
if(F0<0){F0 += Sh0;}
|
|
305
|
+
L0 = NUM2INT(l0);
|
|
306
|
+
if(L0<-Sh0||L0>=Sh0){rb_raise(rb_eArgError,
|
|
307
|
+
"l0 (=%d) is not in the index range of the 1st dim", l0);}
|
|
308
|
+
if(L0<0){L0 += Sh0;}
|
|
309
|
+
S0 = NUM2INT(s0);
|
|
310
|
+
if(S0<=0){rb_raise(rb_eArgError,"s0 (step) must be positive integer");}
|
|
311
|
+
Idx0 = NULL;
|
|
312
|
+
} else {
|
|
313
|
+
switch (TYPE(idx0)) {
|
|
314
|
+
case T_ARRAY:
|
|
315
|
+
Idx0 = ary2long(idx0, Sh0, &len);
|
|
316
|
+
break;
|
|
317
|
+
case T_DATA:
|
|
318
|
+
Idx0 = na2long(idx0, Sh0, &len);
|
|
319
|
+
break;
|
|
320
|
+
default:
|
|
321
|
+
rb_raise(rb_eTypeError, "idx0 must be Array or NArray");
|
|
322
|
+
break;
|
|
323
|
+
}
|
|
324
|
+
F0 = 0;
|
|
325
|
+
L0 = len-1;
|
|
326
|
+
S0 = 1;
|
|
327
|
+
}
|
|
328
|
+
|
|
329
|
+
if (idx1 == Qnil){
|
|
330
|
+
F1 = NUM2INT(f1);
|
|
331
|
+
if(F1<-Sh1||F1>=Sh1){rb_raise(rb_eArgError,
|
|
332
|
+
"f1 (=%d) is not in the index range of the 2nd dim", f1);}
|
|
333
|
+
if(F1<0){F1 += Sh1;}
|
|
334
|
+
L1 = NUM2INT(l1);
|
|
335
|
+
if(L1<-Sh1||L1>=Sh1){rb_raise(rb_eArgError,
|
|
336
|
+
"l1 (=%d) is not in the index range of the 2nd dim", l1);}
|
|
337
|
+
if(L1<0){L1 += Sh1;}
|
|
338
|
+
S1 = NUM2INT(s1);
|
|
339
|
+
if(S1<=0){rb_raise(rb_eArgError,"s1 (step) must be positive integer");}
|
|
340
|
+
Idx1 = NULL;
|
|
341
|
+
} else {
|
|
342
|
+
switch (TYPE(idx1)) {
|
|
343
|
+
case T_ARRAY:
|
|
344
|
+
Idx1 = ary2long(idx1, Sh1, &len);
|
|
345
|
+
break;
|
|
346
|
+
case T_DATA:
|
|
347
|
+
Idx1 = na2long(idx1, Sh1, &len);
|
|
348
|
+
break;
|
|
349
|
+
default:
|
|
350
|
+
rb_raise(rb_eTypeError, "idx1 must be Array or NArray");
|
|
351
|
+
break;
|
|
352
|
+
}
|
|
353
|
+
F1 = 0;
|
|
354
|
+
L1 = len-1;
|
|
355
|
+
S1 = 1;
|
|
356
|
+
}
|
|
357
|
+
|
|
358
|
+
lens[0] = (L0-F0)/S0+1;
|
|
359
|
+
lens[1] = (L1-F1)/S1+1;
|
|
360
|
+
|
|
361
|
+
if (factor==Qnil && offset==Qnil){
|
|
362
|
+
na = na_make_object(NA_LINT, 2, lens, cNArray);
|
|
363
|
+
ival = NA_PTR_TYPE(na, int32_t *);
|
|
364
|
+
} else {
|
|
365
|
+
na = na_make_object(NA_SFLOAT, 2, lens, cNArray);
|
|
366
|
+
ival = NULL; // then it is allocated in the following
|
|
367
|
+
fval = NA_PTR_TYPE(na, float *);
|
|
368
|
+
}
|
|
369
|
+
|
|
370
|
+
ival = multibit_read_2D(fp, Pos, Nbit, Sh0, Sh1, F0, L0, S0, F1, L1, S1,
|
|
371
|
+
Idx0,Idx1,ival);
|
|
372
|
+
|
|
373
|
+
if (factor!=Qnil || offset!=Qnil){
|
|
374
|
+
if (factor!=Qnil) {
|
|
375
|
+
Factor = NUM2DBL(factor);
|
|
376
|
+
} else {
|
|
377
|
+
Factor = 1.0;
|
|
378
|
+
}
|
|
379
|
+
if (offset!=Qnil) {
|
|
380
|
+
Offset = NUM2DBL(offset);
|
|
381
|
+
} else {
|
|
382
|
+
Offset = 0.0;
|
|
383
|
+
}
|
|
384
|
+
for(i=0; i<lens[0]*lens[1]; i++){
|
|
385
|
+
fval[i] = ival[i]*Factor + Offset;
|
|
386
|
+
}
|
|
387
|
+
free(ival);
|
|
388
|
+
}
|
|
389
|
+
|
|
390
|
+
|
|
391
|
+
return(na);
|
|
392
|
+
}
|
|
393
|
+
|
|
394
|
+
|
|
395
|
+
static uint
|
|
396
|
+
str_to_uint1(unsigned char *ptr)
|
|
397
|
+
{
|
|
398
|
+
uint i0 = ptr[0];
|
|
399
|
+
return i0;
|
|
400
|
+
}
|
|
401
|
+
static uint
|
|
402
|
+
str_to_uint2(unsigned char *ptr)
|
|
403
|
+
{
|
|
404
|
+
uint i0 = ptr[0];
|
|
405
|
+
uint i1 = ptr[1];
|
|
406
|
+
return (i0<<8) + i1;
|
|
407
|
+
}
|
|
408
|
+
static uint
|
|
409
|
+
str_to_uint3(unsigned char *ptr)
|
|
410
|
+
{
|
|
411
|
+
uint i0 = ptr[0];
|
|
412
|
+
uint i1 = ptr[1];
|
|
413
|
+
uint i2 = ptr[2];
|
|
414
|
+
return (i0<<16) + (i1<<8) + i2;
|
|
415
|
+
}
|
|
416
|
+
#define STR2UINT(num) \
|
|
417
|
+
static VALUE \
|
|
418
|
+
rb_str_to_uint##num(int argc, VALUE *argv, VALUE self) \
|
|
419
|
+
{ \
|
|
420
|
+
if (argc > 1) { \
|
|
421
|
+
rb_raise(rb_eArgError, "wrong number of arguments (%d for 0)", argc); \
|
|
422
|
+
} \
|
|
423
|
+
unsigned char *ptr = (unsigned char*)StringValuePtr(self); \
|
|
424
|
+
if (argc == 1) { \
|
|
425
|
+
unsigned long n = FIX2UINT(argv[0]); \
|
|
426
|
+
if (n >= RSTRING_LEN(self)) { \
|
|
427
|
+
rb_raise(rb_eArgError, "out of index"); \
|
|
428
|
+
} \
|
|
429
|
+
ptr += n; \
|
|
430
|
+
} \
|
|
431
|
+
uint i = str_to_uint##num(ptr); \
|
|
432
|
+
return UINT2NUM(i); \
|
|
433
|
+
}
|
|
434
|
+
STR2UINT(1)
|
|
435
|
+
STR2UINT(2)
|
|
436
|
+
STR2UINT(3)
|
|
437
|
+
|
|
438
|
+
|
|
439
|
+
void
|
|
440
|
+
init_gphys_multibitIO()
|
|
441
|
+
{
|
|
442
|
+
VALUE mNumRu;
|
|
443
|
+
VALUE cMultibitIO;
|
|
444
|
+
|
|
445
|
+
mNumRu = rb_define_module("NumRu");
|
|
446
|
+
cMultibitIO = rb_define_class_under(mNumRu,"MultibitIO", rb_cObject);
|
|
447
|
+
rb_define_alloc_func(cMultibitIO, multibit_IO_alloc);
|
|
448
|
+
rb_define_private_method(cMultibitIO, "initialize", multibit_IO_initialize, 1);
|
|
449
|
+
rb_define_method(cMultibitIO, "read2D", wrp_multibit_read_2D, 14);
|
|
450
|
+
// rb_define_method(cMultibitIO, "close", multibit_IO_close, 0);
|
|
451
|
+
///^^ conflicts with the multibit_IO_closer call by GC
|
|
452
|
+
|
|
453
|
+
rb_define_method(rb_cString, "to_uint1", rb_str_to_uint1, -1);
|
|
454
|
+
rb_define_method(rb_cString, "to_uint2", rb_str_to_uint2, -1);
|
|
455
|
+
rb_define_method(rb_cString, "to_uint3", rb_str_to_uint3, -1);
|
|
456
|
+
|
|
457
|
+
}
|
|
458
|
+
|
|
459
|
+
//-------------------------------
|
|
460
|
+
|
|
461
|
+
#ifdef MAKETESTDATA
|
|
462
|
+
|
|
463
|
+
/*-----------------------------------------------------------------
|
|
464
|
+
* Test part : To compile, remove -c option and add -DMAKETESTDATA
|
|
465
|
+
*----------------------------------------------------------------*/
|
|
466
|
+
|
|
467
|
+
static void
|
|
468
|
+
create(fp, headskip, nbit, sh0, sh1)
|
|
469
|
+
FILE *fp;
|
|
470
|
+
long headskip;
|
|
471
|
+
long nbit;
|
|
472
|
+
long sh0;
|
|
473
|
+
long sh1;
|
|
474
|
+
{
|
|
475
|
+
unsigned int *ival, iv;
|
|
476
|
+
unsigned char * buf, cn;
|
|
477
|
+
long sz, size;
|
|
478
|
+
long len;
|
|
479
|
+
long i, ns, nl, j, ib;
|
|
480
|
+
int w, b;
|
|
481
|
+
unsigned char mk[8] = {0xff,0x7f,0x3f,0x1f,0x0f,0x07,0x03,0x01};
|
|
482
|
+
// bit mask. in binary, 01111111, 00111111, 00011111,..., 00000001
|
|
483
|
+
unsigned int one = 1;
|
|
484
|
+
|
|
485
|
+
for(i=0; i<headskip; i++){
|
|
486
|
+
sz = fwrite("-",1,1,fp); // fill with "-" over headskip bytes
|
|
487
|
+
}
|
|
488
|
+
|
|
489
|
+
size = ( (sh0*sh1+1)*nbit -1 ) / 8 + 1;
|
|
490
|
+
buf = (unsigned char *) malloc( size );
|
|
491
|
+
|
|
492
|
+
len = sh0*sh1;
|
|
493
|
+
ival = (unsigned int *) malloc(len*sizeof(unsigned int));
|
|
494
|
+
|
|
495
|
+
for(i=0; i<len; i++){
|
|
496
|
+
ival[i] = (i%sh0) + i/sh0;
|
|
497
|
+
//printf("%x ",ival[i]);
|
|
498
|
+
}
|
|
499
|
+
//printf("\n");
|
|
500
|
+
|
|
501
|
+
for(i=0; i<len; i++){
|
|
502
|
+
ib = i*nbit;
|
|
503
|
+
ns = ib / 8; // start position i*nbit/8
|
|
504
|
+
nl = (ib+nbit-1) / 8; // end position
|
|
505
|
+
w = ib % 8;
|
|
506
|
+
//printf("%d: ",(int)i);
|
|
507
|
+
for(j=0; j<= nl-ns; j++){
|
|
508
|
+
b = w + nbit - (j+1)*8;
|
|
509
|
+
//printf(" (%d)",b);
|
|
510
|
+
if(b>=0){
|
|
511
|
+
cn = ival[i] / (one<<b);
|
|
512
|
+
} else{
|
|
513
|
+
cn = ival[i] * (one<<(-b));
|
|
514
|
+
}
|
|
515
|
+
if(j==0){
|
|
516
|
+
buf[ns] = (buf[ns] & ~mk[w]) + cn;
|
|
517
|
+
} else {
|
|
518
|
+
buf[ns+j] = cn;
|
|
519
|
+
}
|
|
520
|
+
//printf(" %d %x ",(int)(ns+j),buf[ns+j]);
|
|
521
|
+
}
|
|
522
|
+
//printf("\n");
|
|
523
|
+
}
|
|
524
|
+
|
|
525
|
+
sz = fwrite(buf,1,size,fp);
|
|
526
|
+
|
|
527
|
+
for(j=0; j<size; j++){
|
|
528
|
+
printf("%02x ",buf[j]);
|
|
529
|
+
}
|
|
530
|
+
printf("\n");
|
|
531
|
+
|
|
532
|
+
free(buf);
|
|
533
|
+
free(ival);
|
|
534
|
+
}
|
|
535
|
+
|
|
536
|
+
int main()
|
|
537
|
+
{
|
|
538
|
+
FILE *fp;
|
|
539
|
+
long headskip = 12;
|
|
540
|
+
long nbit = 15;
|
|
541
|
+
long sh0 = 100;
|
|
542
|
+
long sh1 = 100;
|
|
543
|
+
long pos;
|
|
544
|
+
char fnm[100] = "mltbit.dat";
|
|
545
|
+
long f0=1, l0=91, s0=10, f1=2, l1=5, s1=3;
|
|
546
|
+
long idx0[3] = {3,8,0};
|
|
547
|
+
long idx1[4] = {0,1,90,3};
|
|
548
|
+
int32_t *ival;
|
|
549
|
+
|
|
550
|
+
fp = fopen(fnm,"wb");
|
|
551
|
+
create(fp, headskip, nbit, sh0, sh1);
|
|
552
|
+
fclose(fp);
|
|
553
|
+
|
|
554
|
+
fp = fopen(fnm,"rb");
|
|
555
|
+
pos = headskip;
|
|
556
|
+
printf("-------------\n");
|
|
557
|
+
ival = multibit_read_2D(fp, pos, nbit, sh0, sh1, f0, l0, s0, f1, l1, s1,
|
|
558
|
+
NULL, NULL, NULL);
|
|
559
|
+
printf("-------------\n");
|
|
560
|
+
ival = multibit_read_2D(fp, pos, nbit, sh0, sh1, 0, 3-1, 1, 0, 4-1, 1,
|
|
561
|
+
idx0, idx1, NULL);
|
|
562
|
+
fclose(fp);
|
|
563
|
+
|
|
564
|
+
return(0);
|
|
565
|
+
}
|
|
566
|
+
|
|
567
|
+
#endif
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
=begin
|
|
2
|
+
=cira86_to_nc.rb
|
|
3
|
+
|
|
4
|
+
Read the CIRA86 data file, make corresponding GPhys objects,
|
|
5
|
+
and write into a NetCDF file.
|
|
6
|
+
|
|
7
|
+
==Usage
|
|
8
|
+
|
|
9
|
+
The following will create a NetCDF file 'cira86.nc' under the current
|
|
10
|
+
directory.
|
|
11
|
+
|
|
12
|
+
% ruby cira86_to_nc.rb
|
|
13
|
+
=end
|
|
14
|
+
|
|
15
|
+
require 'numru/gphys'
|
|
16
|
+
|
|
17
|
+
#<< read CIRA data >>
|
|
18
|
+
|
|
19
|
+
file = File.open('../testdata/cira86.dat')
|
|
20
|
+
|
|
21
|
+
nlat = 17
|
|
22
|
+
nht = 36
|
|
23
|
+
nmon = 12
|
|
24
|
+
cira_miss_val = 999.0
|
|
25
|
+
|
|
26
|
+
lat, lat_units = NArray.sfloat(nlat), 'degrees' # latitude
|
|
27
|
+
ht, ht_units = NArray.sfloat(nht), 'km' # height
|
|
28
|
+
mon, mon_units = NArray.sfloat(nmon), 'month' # month
|
|
29
|
+
prs, prs_units = NArray.sfloat(nht), 'hPa' # pressure
|
|
30
|
+
temp,temp_units = NArray.sfloat(nht,nlat,nmon), 'K' # temperature
|
|
31
|
+
gph, gph_units = NArray.sfloat(nht,nlat,nmon), 'km' # geopot. height
|
|
32
|
+
west,west_units = NArray.sfloat(nht,nlat,nmon),'m/s' #eastward(westerly) wind
|
|
33
|
+
|
|
34
|
+
mon.indgen!.add!(1) # => 1..12
|
|
35
|
+
lat=(lat.indgen!-8)*10 # => -80,-70,...,80
|
|
36
|
+
|
|
37
|
+
print "Reading the CIRA86 data file...\n"
|
|
38
|
+
for imon in 0...nmon
|
|
39
|
+
dummy = file.gets
|
|
40
|
+
for iht in 0...nht
|
|
41
|
+
data = file.gets.strip.split(/ +/).collect{|v| v.to_f}
|
|
42
|
+
ht[iht] = data.shift
|
|
43
|
+
prs[iht] = data.shift
|
|
44
|
+
temp[iht,true,imon] = data
|
|
45
|
+
end
|
|
46
|
+
dummy = file.gets
|
|
47
|
+
for iht in 0...nht
|
|
48
|
+
data = file.gets.strip.split(/ +/).collect{|v| v.to_f}
|
|
49
|
+
gph[iht,true,imon] = data[2..-1]
|
|
50
|
+
end
|
|
51
|
+
dummy = file.gets
|
|
52
|
+
for iht in 0...nht
|
|
53
|
+
data = file.gets.strip.split(/ +/).collect{|v| v.to_f}
|
|
54
|
+
west[iht,true,imon] = data[2..-1]
|
|
55
|
+
end
|
|
56
|
+
end
|
|
57
|
+
|
|
58
|
+
temp = temp.transpose(1,0,2) # => [lat,ht,mon]
|
|
59
|
+
gph = gph.transpose(1,0,2) # => [lat,ht,mon]
|
|
60
|
+
west = west.transpose(1,0,2) # => [lat,ht,mon]
|
|
61
|
+
|
|
62
|
+
#<< change missing value to a large value >>
|
|
63
|
+
|
|
64
|
+
gp_miss_val = 2e30
|
|
65
|
+
valid_max = 1e30
|
|
66
|
+
temp[temp.eq(cira_miss_val)] = gp_miss_val
|
|
67
|
+
gph[gph.eq(cira_miss_val)] = gp_miss_val
|
|
68
|
+
west[west.eq(cira_miss_val)] = gp_miss_val
|
|
69
|
+
|
|
70
|
+
#<< into GPhys >>
|
|
71
|
+
|
|
72
|
+
include NumRu
|
|
73
|
+
|
|
74
|
+
lat_ax = Axis.new.set_pos(
|
|
75
|
+
VArray.new(lat,nil,'lat').set_att('units',lat_units).
|
|
76
|
+
set_att('long_name','latitude')
|
|
77
|
+
)
|
|
78
|
+
ht_ax = Axis.new.set_pos(
|
|
79
|
+
VArray.new(ht,nil,'ht').set_att('units',ht_units).
|
|
80
|
+
set_att('long_name','height')
|
|
81
|
+
)
|
|
82
|
+
ht_ax.set_aux('pressure',
|
|
83
|
+
VArray.new(prs,nil,'prs').set_att('units',prs_units).
|
|
84
|
+
set_att('long_name','pressure')
|
|
85
|
+
)
|
|
86
|
+
mon_ax = Axis.new.set_pos(
|
|
87
|
+
VArray.new(mon,nil,'mon').set_att('units',mon_units).
|
|
88
|
+
set_att('long_name','calendar month')
|
|
89
|
+
)
|
|
90
|
+
|
|
91
|
+
grid = Grid.new(lat_ax, ht_ax, mon_ax)
|
|
92
|
+
|
|
93
|
+
gp_miss_val = NArray.sfloat(1).fill!(gp_miss_val)
|
|
94
|
+
valid_max = NArray.sfloat(1).fill!(valid_max)
|
|
95
|
+
|
|
96
|
+
temp_gp = GPhys.new( grid,
|
|
97
|
+
VArray.new(temp,nil,'temp').set_att('units',temp_units).
|
|
98
|
+
set_att('long_name','temperature').
|
|
99
|
+
set_att('valid_max',valid_max).set_att('missing_value',gp_miss_val)
|
|
100
|
+
)
|
|
101
|
+
gph_gp = GPhys.new( grid,
|
|
102
|
+
VArray.new(gph,nil,'gph').set_att('units',gph_units).
|
|
103
|
+
set_att('long_name','geoptential height').
|
|
104
|
+
set_att('valid_max',valid_max).set_att('missing_value',gp_miss_val)
|
|
105
|
+
)
|
|
106
|
+
west_gp = GPhys.new( grid,
|
|
107
|
+
VArray.new(west,nil,'west').set_att('units',west_units).
|
|
108
|
+
set_att('long_name','westerly wind').
|
|
109
|
+
set_att('valid_max',valid_max).set_att('missing_value',gp_miss_val)
|
|
110
|
+
)
|
|
111
|
+
print "...GPhys created: #{temp_gp.name}, #{gph_gp.name}, #{west_gp.name}\n"
|
|
112
|
+
|
|
113
|
+
#<<into a NetCDF file>>
|
|
114
|
+
|
|
115
|
+
ofilename = 'cira86.nc'
|
|
116
|
+
print "Writing into #{ofilename}...\n"
|
|
117
|
+
file = NetCDF.create(ofilename)
|
|
118
|
+
GPhys::NetCDF_IO.write(file,temp_gp)
|
|
119
|
+
GPhys::NetCDF_IO.write(file,gph_gp)
|
|
120
|
+
GPhys::NetCDF_IO.write(file,west_gp)
|
|
121
|
+
file.close
|
|
122
|
+
print "...done\n"
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
# druby_cli1.rb -- a sample dRuby client
|
|
2
|
+
#
|
|
3
|
+
# USAGE
|
|
4
|
+
# See ./druby_serv1.rb
|
|
5
|
+
|
|
6
|
+
require "drb/drb"
|
|
7
|
+
|
|
8
|
+
DRb.start_service
|
|
9
|
+
uri = ARGV.shift || raise("Usage: % #{$0} uri")
|
|
10
|
+
gp = DRbObject.new(nil, uri)
|
|
11
|
+
|
|
12
|
+
p gp.class, gp.name, gp.rank, gp.length
|
|
13
|
+
p gp.grid.axis(0).pos.name
|
|
14
|
+
|
|
15
|
+
gps = gp[0,true,true]
|
|
16
|
+
p gps.class, gps.name, gps.rank, gps.length
|
|
17
|
+
p gps.grid.axis(0).pos.name
|
|
18
|
+
|
|
19
|
+
gpmean = gp[true,true,0].mean(0)
|
|
20
|
+
p gpmean.class, gpmean.name, gpmean.rank, gpmean.length
|
|
21
|
+
p gpmean.grid.axis(0).pos.name
|