コード例 #1
0
ファイル: spectraldata.py プロジェクト: mwregan2/MiriTE
    def plot_spectrum(self, plotaxis=None, errorbars=True, description=''):
        """
        
        Plot the spectrum as several pages of a series of overlaid 1-D plots
        (with optional error bars)
        
        """
        # Define fixed labels
        tstrg, xlabel, ylabel = self._get_plot_labels(description)

        # Create a new plot for each beta plane.
        for plane in range(0, self.data.shape[1]):
            ptitle = tstrg
            ptitle += " - alpha positions 1 to %d" % self.data.shape[2]
            ptitle += "\n- beta position %d -" % (plane + 1)

            # Create a matplotlib figure and axis.
            fig = mplt.new_figure(1, stitle=ptitle)
            ax = mplt.add_subplot(fig, 1, 1, 1)

            # The plots will cycle around these defined line formats,
            linefmtlist = ['bo', 'rx', 'g+', 'ko', \
                           'bx', 'r+', 'go', 'kx', \
                           'b+', 'ro', 'gx', 'k+' ]

            # Cycle through the list of spectra, remembering that the
            # wavelength is the [0] axis
            # TODO: Can some of this duplicated code be packed up?
            for slc in range(0, self.data.shape[2]):
                spectrum = self.data_filled[:, plane, slc]

                ifmt = slc % len(linefmtlist)
                lfmt = linefmtlist[ifmt]

                # Plot each spectrum as an XY plot overlaid on the same axis.
                if errorbars and self.has_dataarray('ERR'):
                    errors = self.err_filled[:, plane, slc]
                    mplt.plot_xy(self.wavelength,
                                 spectrum,
                                 yerr=errors,
                                 plotfig=fig,
                                 plotaxis=ax,
                                 linefmt=lfmt,
                                 xlabel=xlabel,
                                 ylabel=ylabel,
                                 title='')
                else:
                    mplt.plot_xy(self.wavelength,
                                 spectrum,
                                 plotfig=fig,
                                 plotaxis=ax,
                                 linefmt=lfmt,
                                 xlabel=xlabel,
                                 ylabel=ylabel,
                                 title='')
            mplt.show_plot()
コード例 #2
0
ファイル: plotting.py プロジェクト: mwregan2/MiriTE
 def _open_page(self):
     """
     
     Open a new plot page.
    
     """
     if self.subno > 0:
         self._close_page()
     self.page += 1
     self.subno = 0
     self.fig = mplt.new_figure(self.page,
                                figsize=(10, 10),
                                stitle=self.supertitle)
コード例 #3
0
    def plot_srf(self, description=''):
        """
        
        Plot a graph showing the SRF as a function of wavelength.
        
        :Parameters:
        
        description: string, optional
            Additional description to be shown on the plot, if required. 
            
        :Requires:
        
        miri.tools.miriplot
        matplotlib.pyplot
            
        """
        # TODO: TO BE COMPLETED PROPERLY USING VISITOR CLASS
        
        # Import the miri.tools plotting module.
        import miri.tools.miriplot as mplt

        # Extract wavelength and SRF arrays from the flux_table.
        wavlist = []
        srflist = []
        errlist = []
        for (wavelength, srf, srf_error) in self.flux_table:
            wavlist.append(wavelength)
            srflist.append(srf)
            errlist.append(srf_error)

        # Create a new figure
        tstrg = self.__class__.__name__
        if description:
            tstrg += " - " + description
        fig = mplt.new_figure(1, stitle=tstrg)
        ax = mplt.add_subplot(fig, 1, 1, 1)

        # Plot SRF against wavelength
        xlabel = "Wavelength"
        ylabel = 'SRF'
        title = self.get_data_title('flux_table')
        # Plot each ramp as an XY plot overlaid on the same axis.
        mplt.plot_xy(wavlist, srflist, xlabel=xlabel, ylabel=ylabel,
                     title=title)
        mplt.show_plot()
        mplt.close()