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



964
965
966
967
968
969
970
# File 'lib/numru/gphys/grib.rb', line 964

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

#eq?(str) ⇒ Boolean

Returns:

  • (Boolean)


961
962
963
# File 'lib/numru/gphys/grib.rb', line 961

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

#existObject



863
864
865
866
867
# File 'lib/numru/gphys/grib.rb', line 863

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

#getObject



971
972
973
# File 'lib/numru/gphys/grib.rb', line 971

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

#gridObject



895
896
897
898
899
900
901
902
903
904
# File 'lib/numru/gphys/grib.rb', line 895

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



892
893
894
# File 'lib/numru/gphys/grib.rb', line 892

def grid_type
  return GRID_TYPES[ gtype ]
end

#lengthObject



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

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

#list_plObject



949
950
951
952
# File 'lib/numru/gphys/grib.rb', line 949

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

#list_pvObject



925
926
927
928
929
930
931
932
# File 'lib/numru/gphys/grib.rb', line 925

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



868
869
870
871
# File 'lib/numru/gphys/grib.rb', line 868

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

#nvObject



879
880
881
# File 'lib/numru/gphys/grib.rb', line 879

def nv
  return @gds.to_uint1
end

#plObject



887
888
889
890
891
# File 'lib/numru/gphys/grib.rb', line 887

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

#pvObject



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

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

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



905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
# File 'lib/numru/gphys/grib.rb', line 905

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



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

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=



933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
# File 'lib/numru/gphys/grib.rb', line 933

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