Module: SeisRuby::Data::Sac::Body
- Defined in:
- lib/seis_ruby/data/sac/body.rb
Class Method Summary collapse
Class Method Details
.body_for_dump(body, head) ⇒ Object
35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 |
# File 'lib/seis_ruby/data/sac/body.rb', line 35 def body_for_dump(body, head) case head[:iftype] when :itime # [y0, y1, ...] body when :ixy, :iamph # ixy: [[x0, y0], [x1, y1], ...] # iamph: [[theta0, amp0], [theta1, amp1], ...] body\ .transpose\ .reverse\ .flatten when :irlim # [(real0, imaginary0), (real1, imaginary1), ...] body\ .map{|c| [c.real, c.imaginary]}\ .transpose\ .flatten when :ixyz # z[ix][iy] body\ .transpose\ .flatten else raise ArgumentError, "Unknown iftype: #{head[:iftype].inspect}" end end |
.shape_body(body, head) ⇒ Object
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/seis_ruby/data/sac/body.rb', line 4 def shape_body(body, head) case head[:iftype] when :itime # [y0, y1, ...] body when :ixy, :iamph # ixy: [[x0, y0], [x1, y1], ...] # iamph: [[theta0, amp0], [theta1, amp1], ...] body\ .each_slice(body.size/2)\ .to_a\ .reverse\ .transpose when :irlim # [(real0, imaginary0), (real1, imaginary1), ...] body\ .each_slice(body.size/2)\ .to_a\ .transpose\ .map{|real, imaginary| Complex(real, imaginary)} when :ixyz # z[ix][iy] body\ .each_slice(head[:nxsize])\ .to_a\ .transpose else raise ArgumentError, "Unknown iftype: #{head[:iftype].inspect}" end end |