13
13
from jdaviz .core .custom_traitlets import IntHandleEmpty , FloatHandleEmpty
14
14
from jdaviz .core .marks import PluginLine
15
15
16
- from astropy .nddata import NDData , StdDevUncertainty , VarianceUncertainty , UnknownUncertainty
17
- from specutils import Spectrum1D
16
+ from astropy .nddata import UnknownUncertainty
18
17
from specreduce import tracing
19
18
from specreduce import background
20
19
from specreduce import extract
@@ -644,18 +643,18 @@ def export_trace(self, add_data=False, **kwargs):
644
643
# being able to load back into the plugin)
645
644
orig_trace = self .trace_trace .selected_obj
646
645
if isinstance (orig_trace , tracing .FlatTrace ):
647
- trace = tracing .FlatTrace (self .trace_dataset .selected_obj . data ,
646
+ trace = tracing .FlatTrace (self .trace_dataset .selected_obj ,
648
647
orig_trace .trace_pos + self .trace_offset )
649
648
else :
650
- trace = tracing .ArrayTrace (self .trace_dataset .selected_obj . data ,
649
+ trace = tracing .ArrayTrace (self .trace_dataset .selected_obj ,
651
650
self .trace_trace .selected_obj .trace + self .trace_offset )
652
651
653
652
elif self .trace_type_selected == 'Flat' :
654
- trace = tracing .FlatTrace (self .trace_dataset .selected_obj . data ,
653
+ trace = tracing .FlatTrace (self .trace_dataset .selected_obj ,
655
654
self .trace_pixel )
656
655
657
656
elif self .trace_type_selected == 'Auto' :
658
- trace = tracing .KosmosTrace (self .trace_dataset .selected_obj . data ,
657
+ trace = tracing .KosmosTrace (self .trace_dataset .selected_obj ,
659
658
guess = self .trace_pixel ,
660
659
bins = int (self .trace_bins ),
661
660
window = self .trace_window ,
@@ -674,7 +673,7 @@ def vue_create_trace(self, *args):
674
673
675
674
def _get_bg_trace (self ):
676
675
if self .bg_type_selected == 'Manual' :
677
- trace = tracing .FlatTrace (self .trace_dataset .selected_obj . data ,
676
+ trace = tracing .FlatTrace (self .trace_dataset .selected_obj ,
678
677
self .bg_trace_pixel )
679
678
elif self .bg_trace_selected == 'From Plugin' :
680
679
trace = self .export_trace (add_data = False )
@@ -736,15 +735,15 @@ def export_bg(self, **kwargs):
736
735
trace = self ._get_bg_trace ()
737
736
738
737
if self .bg_type_selected == 'Manual' :
739
- bg = background .Background (self .bg_dataset .selected_obj . data ,
738
+ bg = background .Background (self .bg_dataset .selected_obj ,
740
739
[trace ], width = self .bg_width )
741
740
elif self .bg_type_selected == 'OneSided' :
742
- bg = background .Background .one_sided (self .bg_dataset .selected_obj . data ,
741
+ bg = background .Background .one_sided (self .bg_dataset .selected_obj ,
743
742
trace ,
744
743
self .bg_separation ,
745
744
width = self .bg_width )
746
745
elif self .bg_type_selected == 'TwoSided' :
747
- bg = background .Background .two_sided (self .bg_dataset .selected_obj . data ,
746
+ bg = background .Background .two_sided (self .bg_dataset .selected_obj ,
748
747
trace ,
749
748
self .bg_separation ,
750
749
width = self .bg_width )
@@ -763,10 +762,7 @@ def export_bg_img(self, add_data=False, **kwargs):
763
762
Whether to add the resulting image to the application, according to the options
764
763
defined in the plugin.
765
764
"""
766
- bg = self .export_bg (** kwargs )
767
-
768
- bg_spec = Spectrum1D (spectral_axis = self .bg_dataset .selected_obj .spectral_axis ,
769
- flux = bg .bkg_image ()* self .bg_dataset .selected_obj .flux .unit )
765
+ bg_spec = self .export_bg (** kwargs ).bkg_image ()
770
766
771
767
if add_data :
772
768
self .bg_add_results .add_results_from_plugin (bg_spec , replace = True )
@@ -792,8 +788,7 @@ def export_bg_spectrum(self, add_data=False, **kwargs):
792
788
Whether to add the resulting spectrum to the application, according to the options
793
789
defined in the plugin.
794
790
"""
795
- bg = self .export_bg (** kwargs )
796
- spec = bg .bkg_spectrum ()
791
+ spec = self .export_bg (** kwargs ).bkg_spectrum ()
797
792
798
793
if add_data :
799
794
self .bg_spec_add_results .add_results_from_plugin (spec , replace = False )
@@ -813,10 +808,7 @@ def export_bg_sub(self, add_data=False, **kwargs):
813
808
Whether to add the resulting image to the application, according to the options
814
809
defined in the plugin.
815
810
"""
816
- bg = self .export_bg (** kwargs )
817
-
818
- bg_sub_spec = Spectrum1D (spectral_axis = self .bg_dataset .selected_obj .spectral_axis ,
819
- flux = bg .sub_image ()* self .bg_dataset .selected_obj .flux .unit )
811
+ bg_sub_spec = self .export_bg (** kwargs ).sub_image ()
820
812
821
813
if add_data :
822
814
self .bg_sub_add_results .add_results_from_plugin (bg_sub_spec , replace = True )
@@ -867,13 +859,9 @@ def export_extract(self, **kwargs):
867
859
inp_sp2d = self ._get_ext_input_spectrum ()
868
860
869
861
if self .ext_type_selected == 'Boxcar' :
870
- ext = extract .BoxcarExtract (inp_sp2d . data , trace , width = self .ext_width )
862
+ ext = extract .BoxcarExtract (inp_sp2d , trace , width = self .ext_width )
871
863
elif self .ext_type_selected == 'Horne' :
872
- uncert = inp_sp2d .uncertainty if inp_sp2d .uncertainty is not None else VarianceUncertainty (np .ones_like (inp_sp2d .data )) # noqa
873
- if not hasattr (uncert , 'uncertainty_type' ):
874
- uncert = StdDevUncertainty (uncert )
875
- image = NDData (inp_sp2d .data , uncertainty = uncert )
876
- ext = extract .HorneExtract (image , trace )
864
+ ext = extract .HorneExtract (inp_sp2d , trace )
877
865
else :
878
866
raise NotImplementedError (f"extraction type '{ self .ext_type_selected } ' not supported" ) # noqa
879
867
@@ -892,13 +880,6 @@ def export_extract_spectrum(self, add_data=False, **kwargs):
892
880
extract = self .export_extract (** kwargs )
893
881
spectrum = extract .spectrum
894
882
895
- # Specreduce returns a spectral axis in pixels, so we'll replace with input spectral_axis
896
- # NOTE: this is currently disabled until proper handling of axes-limit linking between
897
- # the 2D spectrum image (plotted in pixels) and a 1D spectrum (plotted in freq or
898
- # wavelength) is implemented.
899
-
900
- # spectrum = Spectrum1D(spectral_axis=inp_sp2d.spectral_axis, flux=spectrum.flux)
901
-
902
883
if add_data :
903
884
self .ext_add_results .add_results_from_plugin (spectrum , replace = False )
904
885
0 commit comments