Commits

Jordan Mirocha  committed 4dfb9d0 Merge

Merged.

  • Participants
  • Parent commits a3f5c60, 437d173

Comments (0)

Files changed (5)

File pyspeckit/spectrum/baseline.py

 
     def __call__(self, order=1, annotate=False, excludefit=False, save=True,
             exclude=None, exclusionlevel=0.01, interactive=False, 
-            LoudDebug=False, fit_original=False, **kwargs):
+            LoudDebug=False, fit_original=True, **kwargs):
         """
         Fit and remove a polynomial from the spectrum.  
         It will be saved in the variable "self.basespec"

File pyspeckit/spectrum/classes.py

         self.data = self.data[indices]
         self.error = self.error[indices]
 
+    def smooth(self,smooth,**kwargs):
+        """
+        Smooth the spectrum by factor "smooth".  Options are defined in sm.smooth
 
-class ObsBlock(Spectrum):
+        because 'Spectra' does not have a header attribute, don't do anything to it...
+        """
+        smooth = round(smooth)
+        self.data = sm.smooth(self.data,smooth,**kwargs)
+        self.xarr = self.xarr[::smooth]
+        if len(self.xarr) != len(self.data):
+            raise ValueError("Convolution resulted in different X and Y array lengths.  Convmode should be 'same'.")
+        self.error = sm.smooth(self.error,smooth,**kwargs)
+        self.baseline.downsample(smooth)
+        self.specfit.downsample(smooth)
+
+class ObsBlock(Spectra):
     """
     An Observation Block
 

File pyspeckit/spectrum/models/gaussfitter.py

         if isinstance(params,numpy.ndarray): params=params.tolist()
 
         # make sure all various things are the right length; if they're not, fix them using the defaults
-        # multigaussfit should process negamp directly if kwargs.has_key('negamp') is False: kwargs['negamp'] = None 
-        for parlist in (params,fixed,limitedmin,limitedmax,minpars,maxpars,tied):
+        # multiformaldehydefit should process negamp directly if kwargs.has_key('negamp') is False: kwargs['negamp'] = None 
+        pardict = {"params":params,"fixed":fixed,"limitedmin":limitedmin,"limitedmax":limitedmax,"minpars":minpars,"maxpars":maxpars,"tied":tied}
+        for parlistname in pardict:
+            parlist = pardict[parlistname]
             if len(parlist) != 3*self.npeaks:
                 # if you leave the defaults, or enter something that can be multiplied by 3 to get to the
-                # right number of gaussians, it will just replicate
+                # right number of formaldehydeians, it will just replicate
+                if veryverbose: print "Correcting length of parameter %s" % parlistname
                 if len(parlist) == 3: 
                     parlist *= self.npeaks 
-                # is any of this stuff valid?  I don't think so...
-                elif parlist==params:
+                elif parlistname=="params":
                     parlist[:] = [1,0,1] * self.npeaks
-                elif parlist==fixed:
+                elif parlistname=="fixed":
                     parlist[:] = [False,False,False] * self.npeaks
-                elif parlist==limitedmax:
+                elif parlistname=="limitedmax":
                     if negamp is None: parlist[:] = [False,False,False] * self.npeaks
                     elif negamp is False: parlist[:] = [False,False,False] * self.npeaks
                     else: parlist[:] = [True,False,False] * self.npeaks
-                elif parlist==limitedmin:
+                elif parlistname=="limitedmin":
                     if negamp is None: parlist[:] = [False,False,True] * self.npeaks  # Lines can't have negative width!
                     elif negamp is False: parlist[:] = [True,False,True] * self.npeaks
                     else: parlist[:] = [False,False,True] * self.npeaks                   
-                elif parlist==minpars or parlist==maxpars:
+                elif parlistname=="minpars" or parlistname=="maxpars":
                     parlist[:] = [0,0,0] * self.npeaks
-                elif parlist==tied:
+                elif parlistname=="tied":
                     parlist[:] = ['','',''] * self.npeaks
                     
         # mpfit doesn't recognize negamp, so get rid of it now that we're done setting limitedmin/max and min/maxpars

File pyspeckit/spectrum/plotters.py

 
 
     def __init__(self, Spectrum, autorefresh=True, title="", ylabel="",
-            xlabel="", **kwargs):
+            xlabel="", silent=False, **kwargs):
         self.figure = None
         self.axis = None
         self.Spectrum = Spectrum
         self.ymax = None
         self.ymin = None
         self.keyclick = None
+        self.silent = silent
 
     def __call__(self, figure=None, axis=None, clear=True, autorefresh=None, **kwargs):
         """
         self.plot(**kwargs)
 
     def plot(self, offset=0.0, color='k', linestyle='steps-mid', linewidth=0.5,
-            errstyle=None, erralpha=0.2, silent=False, **kwargs):
+            errstyle=None, erralpha=0.2, silent=None, **kwargs):
         """
         Plot the spectrum!
 
                         yerr=self.Spectrum.error, ecolor=color, fmt=None,
                         **kwargs)
 
-        self.reset_limits(silent=silent, **reset_kwargs)
+        if silent is not None:
+            self.silent = silent
+
+        self.reset_limits(**reset_kwargs)
 
         if self.autorefresh: self.refresh()
     
     def reset_limits(self,xmin=None, xmax=None, ymin=None, ymax=None,
             reset_xlimits=False, reset_ylimits=False, ypeakscale=1.2,
-            silent=False, **kwargs):
+            silent=None, **kwargs):
         """
         Automatically or manually reset the plot limits
         """
 
+        if silent is not None:
+            self.silent = silent
+
         if (self.Spectrum.xarr.max() < self.xmin or self.Spectrum.xarr.min() > self.xmax 
                 or reset_xlimits):
-            if not silent: print "Resetting X-axis min/max because the plot is out of bounds."
+            if not self.silent: print "Resetting X-axis min/max because the plot is out of bounds."
             self.xmin = None
             self.xmax = None
         if xmin is not None: self.xmin = xmin
         
         if (self.Spectrum.data.max() < self.ymin or self.Spectrum.data.min() > self.ymax
                 or reset_ylimits):
-            if not silent: print "Resetting Y-axis min/max because the plot is out of bounds."
+            if not self.silent: print "Resetting Y-axis min/max because the plot is out of bounds."
             self.ymin = None
             self.ymax = None
         if ymin is not None: self.ymin = ymin

File pyspeckit/wrappers/showspec_splat1d.py

         sp.units = units
 
     if dobaseline:
-        sp.baseline(order=order, exclude=exclude, annotate=annotatebaseline)
+        sp.baseline(order=order, exclude=exclude, annotate=annotatebaseline, subtract=False)
 
     if plotspectrum:
-        sp.plotter(figure=fignum, axis=axis, autorefresh=autorefresh, color=color, clear=clear, silent=quiet, reset_ylimits=True, title=title)
+        if color is None:
+            sp.plotter(figure=fignum, axis=axis, autorefresh=autorefresh, clear=clear, silent=quiet, reset_ylimits=True, title=title)
+        else:
+            sp.plotter(figure=fignum, axis=axis, autorefresh=autorefresh, color=color, clear=clear, silent=quiet, reset_ylimits=True, title=title)
 
     if savepre is not None:
         glon,glat = sp.header.get("GLON"),sp.header.get("GLAT")