Class NumRu::HE5Gd
In: lib/hdfeos5.rb
Parent: Object
HE5Za HE5Gd HE5 HE5ZaField HE5GdField HE5Pt HE5SwField HE5Sw HE5PtField lib/hdfeos5.rb NumRu dot/m_0_0.png

HE5Grid クラスに関して

Methods

att_names   char_typecode   close   closed   create   def_var   detach   dim_names   get_att   get_grpatt   get_var   grpatt_names   inspect   ndims   nvars   open   var   var_names   vars  

Public Class methods

[Source]

     # File lib/hdfeos5.rb, line 817
817:        def create(file, gname, xdimsize, ydimsize, upleftpt, lowrightpt)
818:          if(file.is_a?(String))
819:            file = HE5.open(file, "w")
820:          elsif(!file.is_a?(HE5))
821:            raise TypeError,
822:                 "1st arg must be a HDF-EOS5 (file object) or a String (path)"
823:          end
824:          file.create_grid(gname, xdimsize, ydimsize, upleftpt, lowrightpt)
825:        end

[Source]

     # File lib/hdfeos5.rb, line 827
827:        def open(file, gname)
828:          if(file.is_a?(String))
829:            file = HE5.open(file, "r")
830:          elsif(!file.is_a?(HE5))
831:            raise TypeError,
832:                 "1st arg must be a HDF-EOS5 (file object) or a String (path)"
833:          end
834:          file.grid(gname)
835:        end

Public Instance methods

[Source]

     # File lib/hdfeos5.rb, line 903
903:     def att_names
904:       nattrs, attrnames, strbufsize = inqattrs()
905:       return attrnames.split(/,/)
906:     end

[Source]

     # File lib/hdfeos5.rb, line 919
919:     def char_typecode(typecode)
920:       case typecode
921:       when 1
922:        ctype = "short"
923:       when 2 
924:        ctype = "sint"
925:       when 3 
926:        ctype = "int"
927:       when 4 
928:        ctype = "sfloat"
929:       when 5 
930:        ctype = "float"
931:       else
932:        raise TypeError, "not match"
933:       end
934:       ctype
935:     end

close grid field & close HDF-EOS5 file

[Source]

     # File lib/hdfeos5.rb, line 843
843:     def close
844:       gddetach
845:       self.file.close
846:     end
closed()

Alias for detach

define HE5 Grid Field Object ( Data Field )

[Source]

     # File lib/hdfeos5.rb, line 858
858:     def def_var(name, datatype, dims, maxdim=nil, merge=0)
859:       if datatype.is_a?(Numeric)
860:         datatype = char_typecode(datatype)
861:       end
862:       maxdim = "NULL" if maxdim == nil
863:       deffield(name, dims, maxdim, datatype, merge)
864:     end

detach grid field

[Source]

     # File lib/hdfeos5.rb, line 838
838:     def detach
839:       gddetach
840:     end

return Dimension Name list

[Source]

     # File lib/hdfeos5.rb, line 881
881:     def dim_names
882:       ndims, dimlist, sizes, ntype = inqdims('HE5_HDFE_NENTDIM')
883:       return dimlist.split(/,/)
884:     end

[Source]

     # File lib/hdfeos5.rb, line 896
896:     def get_att(attname)
897:       if att_names.include?(attname)
898:         get_att_(attname)
899:       else
900:         nil
901:       end
902:     end

[Source]

     # File lib/hdfeos5.rb, line 907
907:     def get_grpatt(grpattname)
908:       if grpatt_names.include?(grpattname)
909:         get_grpatt_(grpattname)
910:       else
911:         nil
912:       end
913:     end

set HE5 Grid Field Object ( Data Field )

[Source]

     # File lib/hdfeos5.rb, line 891
891:     def get_var(varid)
892:       nflds, fieldlist, sizes, ntype = inqfields('HE5_HDFE_NENTDFLD')
893:       fieldname=fieldlist.split(",")[varid]
894:       return var(fieldname)
895:     end

[Source]

     # File lib/hdfeos5.rb, line 914
914:     def grpatt_names
915:       nattrs, attrnames, strbufsize = inqgrpattrs()
916:       return attrnames.split(/,/)
917:     end

[Source]

     # File lib/hdfeos5.rb, line 937
937:     def inspect
938:       'HE5Gd:'+name
939:     end

count Dimension Field

[Source]

     # File lib/hdfeos5.rb, line 848
848:     def ndims
849:       count, strbufsize = nentries('HE5_HDFE_NENTDIM')
850:       return count
851:     end

count Data Field

[Source]

     # File lib/hdfeos5.rb, line 853
853:     def nvars
854:       count, strbufsize = nentries('HE5_HDFE_NENTDFLD')
855:       return count
856:     end

set HE5 Grid Field Object ( Data Field )

[Source]

     # File lib/hdfeos5.rb, line 866
866:     def var(varname)
867:        setfield(varname)
868:     end

return Data Field Name list

[Source]

     # File lib/hdfeos5.rb, line 886
886:     def var_names
887:       nflds, fieldlist, sizes, ntype = inqfields('HE5_HDFE_NENTDFLD')
888:       return fieldlist.split(/,/)
889:     end

return HE5 Grid Field Object

[Source]

     # File lib/hdfeos5.rb, line 870
870:     def vars( names=nil )   # return all if names==nil
871:        if names == nil
872:           vars = (0..nvars()-1).collect{|varid| get_var(varid)}
873:        else
874:           raise TypeError, "names is not an array" if ! names.is_a?(Array)          
875:           vars = names.collect{|name| var(name)}
876:           raise ArgumentError, "One or more variables do not exist" if vars.include?(nil)
877:        end
878:        return vars
879:     end

[Validate]