Class: NumRu::GPhys::Grib::GribGDS

Inherits:
Object
  • Object
show all
Includes:
NumRu::GPhys::GribUtils
Defined in:
lib/numru/gphys/grib.rb

Overview

end definition of class GribPDS

Instance Method Summary collapse

Instance Method Details

#==(other) ⇒ Object



971
972
973
974
975
976
977
# File 'lib/numru/gphys/grib.rb', line 971

def ==(other)
  if GribGDS===other
    return other.eq?(@gds)
  else
    return false
  end
end

#eq?(str) ⇒ Boolean

Returns:

  • (Boolean)


968
969
970
# File 'lib/numru/gphys/grib.rb', line 968

def eq?(str)
  @gds==str
end

#existObject



870
871
872
873
874
# File 'lib/numru/gphys/grib.rb', line 870

def exist
  @gds = "\000"*41
  @gds[1,1] = uint2str(255,1)
  @sgm.is.update_total_length
end

#getObject



978
979
980
# File 'lib/numru/gphys/grib.rb', line 978

def get
  @gds && uint2str(length,3) << @gds
end

#gridObject



902
903
904
905
906
907
908
909
910
911
# File 'lib/numru/gphys/grib.rb', line 902

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_typeObject



899
900
901
# File 'lib/numru/gphys/grib.rb', line 899

def grid_type
  return GRID_TYPES[ gtype ]
end

#lengthObject



879
880
881
882
883
884
885
# File 'lib/numru/gphys/grib.rb', line 879

def length
  if @gds
    return @gds.length+3
  else
    return 0
  end
end

#list_plObject



956
957
958
959
# File 'lib/numru/gphys/grib.rb', line 956

def list_pl
  return @gds[pl-4..-1] if pl
  return nil
end

#list_pvObject



932
933
934
935
936
937
938
939
# File 'lib/numru/gphys/grib.rb', line 932

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_existObject



875
876
877
878
# File 'lib/numru/gphys/grib.rb', line 875

def not_exist
  @gds = nil
  @sgm.is.update_total_length
end

#nvObject



886
887
888
# File 'lib/numru/gphys/grib.rb', line 886

def nv
  return @gds.to_uint1
end

#plObject



894
895
896
897
898
# File 'lib/numru/gphys/grib.rb', line 894

def pl
  pl = @gds.to_uint1(1)
  return nil if pl==255
  return nv*4+pl
end

#pvObject



889
890
891
892
893
# File 'lib/numru/gphys/grib.rb', line 889

def pv
  pv = @gds.to_uint1(1)
  return nil if pv==255 || nv==0
  return pv
end

#set_grid(id, x, y, rev) ⇒ Object



912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
# File 'lib/numru/gphys/grib.rb', line 912

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



960
961
962
963
964
965
966
# File 'lib/numru/gphys/grib.rb', line 960

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=



940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
# File 'lib/numru/gphys/grib.rb', line 940

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