class Labcom3::ArcSamples
Authors-
S.imazu
Version-
25.2.0
Date-
2024-11-20
[ 説明 ]¶ ↑
-
サンプリングデータクラス
-
計測データは、binary stringで保持する。
[ メンバー ]¶ ↑
block_bin_str(string)-
バイナリデータ(binary string)
image_type(string)-
データ型
na_type(int)-
Numo::NArrayデータ型
bytes_per_sample(int)-
1サンプルのバイト数
[ クラスメソッド ]¶ ↑
-
new( dtype=nil, data=nil, bsize=nil)
[ インスタンスメソッド ]¶ ↑
-
valWithThinning( n_thinning) -
set_val( dtype, data, bsize=nil)
[ UPDATE履歴 ]¶ ↑
- 23.0.0
- 25.2.0
-
NArray to Numo::NArray
Attributes
block_bin_str[R]
bytes_per_sample[R]
image_type[R]
na_type[R]
Public Class Methods
new( dtype=nil, data=nil, bsize=nil)
click to toggle source
- 引 数
- dtype(string)
-
データ型
- data(string)
-
データ配列(binary string)
- bsize(int)
-
有効データバイト数
- 返 値
-
なし
- 説 明
-
コンストラクタ
# File lib/labcom3/ArcSamples.rb, line 54 def initialize( dtype=nil, data=nil, bsize=nil) if nil != dtype then @image_type = dtype @na_type = Labcom3::to_narray_type( dtype) @bytes_per_sample = Labcom3::to_bytes_per_sample( dtype) else @image_type = nil @na_type = nil @bytes_per_sample = 1 end if nil != data then if nil == bsize then @block_bin_str = data else @block_bin_str = data[0..bsize-1] end else @block_bin_str = nil end end
Public Instance Methods
num()
click to toggle source
- 引 数
-
なし
- 返 値
-
データ件数(int)
- 説 明
-
サンプリングデータのデータ件数を戻す。
バイトサイズではない。
# File lib/labcom3/ArcSamples.rb, line 91 def num() return nil if( nil == @block_bin_str ) return @block_bin_str.length/@bytes_per_sample end
set_val( dtype, data, bsize=nil)
click to toggle source
- 引 数
- data(string)
-
データ配列(binary string)
- dtype(string)
-
データ型
- bsize(int)
-
有効データバイト数
- 返 値
-
なし
- 説 明
-
メンバー変数にサンプリングデータを設定する。
データ型 : ‘INT8’, ‘INT16’, ‘INT16’, ‘FLT32’, ‘FLT32’,‘INT64’
# File lib/labcom3/ArcSamples.rb, line 159 def set_val( dtype, data, bsize=nil) @image_type = dtype @na_type = Labcom3::to_narray_type( dtype) @bytes_per_sample = Labcom3::to_bytes_per_sample( dtype) if nil == bsize then @block_bin_str = data else @block_bin_str = data[0..bsize-1] end end
val()
click to toggle source
- 引 数
-
なし
- 返 値
-
配列データ(Numo::NArray)
- 説 明
-
バイナリデータをNumo::NArrayクラスのオブジェクトに変換し戻す。
# File lib/labcom3/ArcSamples.rb, line 107 def val() num_sample = num() return nil if( nil == num_sample ) # ary = NArray.to_na( @block_bin_str , @na_type, num_sample) ary = Labcom3::to_narray( @block_bin_str , @na_type) return ary end
valWithThinning( n_thinning=1 )
click to toggle source
- 引 数
- n_thinning(integer)
-
間引き 1/n
- 返 値
-
配列データ(Numo::NArray)
- 説 明
-
バイナリデータをNumo::NArrayクラスのオブジェクトに変換し戻す。
# File lib/labcom3/ArcSamples.rb, line 128 def valWithThinning( n_thinning=1 ) num_sample = num() return nil if( nil == num_sample ) if( 2 > n_thinning ) then #ary = NArray.to_na( @block_bin_str , @na_type, num_sample) ary = Labcom3::to_narray( @block_bin_str , @na_type) else thin_ary = Retrieve.data_thinning( @block_bin_str , @block_bin_str.length, @bytes_per_sample, n_thinning) #ary = NArray.to_na( thin_ary , @na_type, thin_ary.length/@bytes_per_sample) ary = Labcom3::to_narray( thin_ary , @na_type) end return ary end