Class: NumRu::GPhys::Grib::GribGDS
- Inherits:
-
Object
- Object
- NumRu::GPhys::Grib::GribGDS
- Includes:
- NumRu::GPhys::GribUtils
- Defined in:
- lib/numru/gphys/grib.rb
Overview
end definition of class GribPDS
Instance Method Summary collapse
- #==(other) ⇒ Object
- #eq?(str) ⇒ Boolean
- #exist ⇒ Object
- #get ⇒ Object
- #grid ⇒ Object
- #grid_type ⇒ Object
- #length ⇒ Object
- #list_pl ⇒ Object
- #list_pv ⇒ Object
- #not_exist ⇒ Object
- #nv ⇒ Object
- #pl ⇒ Object
- #pv ⇒ Object
- #set_grid(id, x, y, rev) ⇒ Object
- #set_list_pl(list) ⇒ Object
- #set_list_pv(list) ⇒ Object (also: #list_pv=)
Instance Method Details
#==(other) ⇒ Object
958 959 960 961 962 963 964 |
# File 'lib/numru/gphys/grib.rb', line 958 def ==(other) if GribGDS===other return other.eq?(@gds) else return false end end |
#eq?(str) ⇒ Boolean
955 956 957 |
# File 'lib/numru/gphys/grib.rb', line 955 def eq?(str) @gds==str end |
#exist ⇒ Object
857 858 859 860 861 |
# File 'lib/numru/gphys/grib.rb', line 857 def exist @gds = "\000"*41 @gds[1,1] = uint2str(255,1) @sgm.is.update_total_length end |
#get ⇒ Object
965 966 967 |
# File 'lib/numru/gphys/grib.rb', line 965 def get @gds && uint2str(length,3)<<@gds end |
#grid ⇒ Object
889 890 891 892 893 894 895 896 897 898 |
# File 'lib/numru/gphys/grib.rb', line 889 def grid if gtype==3||gtype==1 grid = @gds[3..38] elsif gtype==90 grid = @gds[3..40] else grid = @gds[3..28] end return get_x_y(grid) end |
#grid_type ⇒ Object
886 887 888 |
# File 'lib/numru/gphys/grib.rb', line 886 def grid_type return GRID_TYPES[ gtype ] end |
#length ⇒ Object
866 867 868 869 870 871 872 |
# File 'lib/numru/gphys/grib.rb', line 866 def length if @gds return @gds.length+3 else return 0 end end |
#list_pl ⇒ Object
943 944 945 946 |
# File 'lib/numru/gphys/grib.rb', line 943 def list_pl return @gds[pl-4..-1] if pl return nil end |
#list_pv ⇒ Object
919 920 921 922 923 924 925 926 |
# File 'lib/numru/gphys/grib.rb', line 919 def list_pv return nil unless pv list = NArray.sfloat(nv) nv.times{|n| list[n] = float_value( @gds[pv-4+n*4...pv-4+(n+1)*4] ) } return list end |
#not_exist ⇒ Object
862 863 864 865 |
# File 'lib/numru/gphys/grib.rb', line 862 def not_exist @gds = nil @sgm.is.update_total_length end |
#nv ⇒ Object
873 874 875 |
# File 'lib/numru/gphys/grib.rb', line 873 def nv return @gds.to_uint1 end |
#pl ⇒ Object
881 882 883 884 885 |
# File 'lib/numru/gphys/grib.rb', line 881 def pl pl = @gds.to_uint1(1) return nil if pl==255 return nv*4+pl end |
#pv ⇒ Object
876 877 878 879 880 |
# File 'lib/numru/gphys/grib.rb', line 876 def pv pv = @gds.to_uint1(1) return nil if pv==255 || nv==0 return pv end |
#set_grid(id, x, y, rev) ⇒ Object
899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 |
# File 'lib/numru/gphys/grib.rb', line 899 def set_grid(id,x,y,rev) @gds[2..2] = uint2str(id,1) if id==3||id==1 str = grid2str(id,x,y,rev) str.length==36 || raise("length is not correct") @gds[3..38] = str @sgm.is.update_total_length elsif id==90 str = grid2str(id,x,y,rev) str.length==38 || raise("length is not correct") @gds[3..40] = str @sgm.is.update_total_length else str = grid2str(id,x,y,rev) str.length==26 || raise("length is not correct") @gds[3..28] = str @sgm.is.update_total_length end return [id,x,y] end |
#set_list_pl(list) ⇒ Object
947 948 949 950 951 952 953 |
# File 'lib/numru/gphys/grib.rb', line 947 def set_list_pl(list) raise "not defined yet" pl = nv*4+pv @gds[1..1] = uint2str(pl,1) @gds[pl-4..-1] = list return true end |
#set_list_pv(list) ⇒ Object Also known as: list_pv=
927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 |
# File 'lib/numru/gphys/grib.rb', line 927 def set_list_pv(list) nv = list.length/4 @gds[0..0] = uint2str(nv,1) raise "not defined yet" if gtype==3||gtype==1 pv = 43 elsif gtype==90 pv = 45 else pv = 33 end @gds[1..1] = uint2str(pv,1) @gds[pv-4..-1] = list return true end |