@@ -502,7 +502,7 @@ def fit_tilts(self, trc_tilt_dict, thismask, slit_cen, spat_order, spec_order, s
502502 return self .all_fit_dict [slit_idx ]['coeff2' ]
503503
504504 def trace_tilts (self , arcimg , lines_spec , lines_spat , thismask , slit_cen , fwhm ,
505- debug_pca = False , show_tracefits = False ):
505+ spat_order , debug_pca = False , show_tracefits = False ):
506506 """
507507 Trace the tilts
508508
@@ -525,6 +525,8 @@ def trace_tilts(self, arcimg, lines_spec, lines_spat, thismask, slit_cen, fwhm,
525525 Integer index indicating the slit in question.
526526 fwhm (:obj:`float`):
527527 FWHM of the arc lines.
528+ spat_order (:obj:`int`):
529+ Order of the legendre polynomial that will be fit to the tilts.
528530 debug_pca (:obj:`bool`, optional):
529531 Show the PCA modeling QA plots.
530532 show_tracefits (:obj:`bool`, optional):
@@ -537,7 +539,7 @@ def trace_tilts(self, arcimg, lines_spec, lines_spat, thismask, slit_cen, fwhm,
537539 """
538540 trace_dict = tracewave .trace_tilts (arcimg , lines_spec , lines_spat , thismask , slit_cen ,
539541 inmask = self .gpm , fwhm = fwhm ,
540- spat_order = self . par [ ' spat_order' ] ,
542+ spat_order = spat_order ,
541543 maxdev_tracefit = self .par ['maxdev_tracefit' ],
542544 sigrej_trace = self .par ['sigrej_trace' ],
543545 debug_pca = debug_pca , show_tracefits = show_tracefits )
@@ -766,8 +768,11 @@ def run(self, doqa=True, debug=False, show=False):
766768 # function of spatial position resulting in 1D traces for
767769 # each line.
768770 msgs .info ('Trace the tilts' )
771+ # fill in spat_order and spec_order arrays for this slit first
772+ self .spat_order [slit_idx ] = self ._parse_param (self .par , 'spat_order' , slit_idx )
773+ self .spec_order [slit_idx ] = self ._parse_param (self .par , 'spec_order' , slit_idx )
769774 self .trace_dict = self .trace_tilts (_mstilt , self .lines_spec , self .lines_spat ,
770- thismask , self .slitcen [:, slit_idx ], fwhm )
775+ thismask , self .slitcen [:, slit_idx ], fwhm , self . spat_order [ slit_idx ] )
771776 # IF there are < 2 usable arc lines for tilt tracing, PCA fit does not work and the reduction crushes
772777 # TODO investigate why some slits have <2 usable arc lines
773778 if np .sum (self .trace_dict ['use_tilt' ]) < 2 :
@@ -789,8 +794,6 @@ def run(self, doqa=True, debug=False, show=False):
789794
790795 # TODO: Show the traces before running the 2D fit
791796
792- self .spat_order [slit_idx ] = self ._parse_param (self .par , 'spat_order' , slit_idx )
793- self .spec_order [slit_idx ] = self ._parse_param (self .par , 'spec_order' , slit_idx )
794797 # 2D model of the tilts, includes construction of QA
795798 # NOTE: This also fills in self.all_fit_dict and self.all_trace_dict
796799 coeff_out = self .fit_tilts (self .trace_dict , thismask , self .slitcen [:,slit_idx ],
0 commit comments