@@ -31,3 +31,35 @@ function Base.show(io::IO, spec::Spectrum)
3131 print (io, " \n $key : $val " )
3232 end
3333end
34+
35+ struct EchelleSpectrum{W <: Number ,F <: Number } <: AbstractSpectrum{W,F}
36+ wave:: Matrix{W}
37+ flux:: Matrix{F}
38+ meta:: Dict{Symbol,Any}
39+ end
40+
41+ EchelleSpectrum (wave, flux, meta:: Dict{Symbol,Any} ) = EchelleSpectrum (collect (wave), collect (flux), meta)
42+
43+ function Base. show (io:: IO , spec:: EchelleSpectrum )
44+ println (io, " EchelleSpectrum($(eltype (spec. wave)) , $(eltype (spec. flux)) )" )
45+ print (io, " # orders: $(size (spec, 1 )) " )
46+ for (key, val) in spec. meta
47+ print (io, " \n $key : $val " )
48+ end
49+ end
50+
51+ function Base. getindex (spec:: EchelleSpectrum , i:: Integer )
52+ wave = spec. wave[i, :]
53+ flux = spec. flux[i, :]
54+ meta = merge (Dict (:Order => i), spec. meta)
55+ return Spectrum (wave, flux, meta)
56+ end
57+
58+ function Base. getindex (spec:: EchelleSpectrum , I:: AbstractVector )
59+ waves = spec. wave[I, :]
60+ flux = spec. flux[I, :]
61+ meta = merge (Dict (:Orders => (first (I), last (I))), spec. meta)
62+ return EchelleSpectrum (waves, flux, meta)
63+ end
64+
65+ Base. lastindex (spec:: EchelleSpectrum ) = lastindex (spec. flux, 1 )
0 commit comments