Changeset 1256 for tags


Ignore:
Timestamp:
09/11/06 14:17:47 (18 years ago)
Author:
mar637
Message:

turned return without warning into exceptions. changed default rotation to 90 degrees. Added habdling of all 'Hz' based units.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • tags/Release2.1.0b/python/asapplotter.py

    r1252 r1256  
    412412        if self._data: self.plot(self._data)
    413413
    414     def plot_lines(self, linecat=None, doppler=0.0, deltachan=10, rotate=0.0,
     414    def plot_lines(self, linecat=None, doppler=0.0, deltachan=10, rotate=90.0,
    415415                   location=None):
    416416        """
     
    421421            deltachan:    the number of channels to include each side of the
    422422                          line to determine a local maximum/minimum
    423             rotate:       the rotation for the text label
     423            rotate:       the rotation (in degrees) )for the text label (default 90.0)
    424424            location:     the location of the line annotation from the 'top',
    425425                          'bottom' or alternate (None - the default)
     
    427427        If the spectrum is flagged no line will be drawn in that location.
    428428        """
    429         if not self._data: return
     429        if not self._data:
     430            raise RuntimeError("No scantable has been plotted yet.")
    430431        from asap._asap import linecatalog
    431         if not isinstance(linecat, linecatalog): return
    432         if not self._data.get_unit().endswith("GHz"): return
     432        if not isinstance(linecat, linecatalog):
     433            raise ValueError("'linecat' isn't of type linecatalog.")
     434        if not self._data.get_unit().endswith("Hz"):
     435            raise RuntimeError("Can only overlay linecatalogs when data is in frequency.")
    433436        from matplotlib.numerix import ma
    434437        for j in range(len(self._plotter.subplots)):
     
    436439            lims = self._plotter.axes.get_xlim()
    437440            for row in range(linecat.nrow()):
    438                 restf = linecat.get_frequency(row)/1000.0
     441                # get_frequency returns MHz
     442                base = { "GHz": 1000.0, "MHz": 1.0, "Hz": 1.0e-6 }
     443                restf = linecat.get_frequency(row)/base[self._data.get_unit()]
    439444                c = 299792.458
    440445                freq = restf*(1.0-doppler/c)
Note: See TracChangeset for help on using the changeset viewer.