class FlightLogReader FLIGHT_LOG_LABELS = [ :Time, # GPS時刻(秒) :Longitude, :Latitude, :Altitude, :VNorth, :VEast, :VDown, :Yaw, :Pitch, :Roll, :Azimuth, :TAS, :AoAttack, :SideSlip, :Input, :Output, :AccX, # 加速度(m/s^2) x軸(前) :AccY, # y軸(右) :AccZ, # z軸(下) :RollRate, :PitchRate, :YawRate, :RollAccel, :PitchAccel, :YawAccel ] def FlightLogReader.read(input, denom = 10) data = [] line_no = 0 op = proc{|io| io.each{|line| temp = line.chop.split(/,/) if temp.size >= FLIGHT_LOG_LABELS::size then line_no += 1 if line_no % denom != 0 then next end # データを間引く temp.collect!{|item| item.to_f} from_index = 0 to_index = FLIGHT_LOG_LABELS.index(:Input) temp2 = temp[from_index...to_index] from_index = to_index to_index = to_index + 8 temp2 << temp[from_index...to_index] from_index = to_index to_index = to_index + 8 temp2 << temp[from_index...to_index] from_index = to_index temp2.push(*temp[from_index..-1]) if block_given? then next unless (temp2 = yield temp2) end data << temp2 end } } if input.kind_of?(String) # ファイル open(input){|fin| op.call(fin) } else op.call(input) # ストリーム end return data end end