Esempio n. 1
0
    def __del__(self):
        """
        
        Tidies up the DataModelPlotVisitor class.
        
        If a plot page is still open it is closed.

        """
        # Close the plot
        if self.fig is not None:
            self._close_page()
        mplt.close()
Esempio n. 2
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()
Esempio n. 3
0
    def plot(self,
             plotaxis=None,
             xlabel='',
             ylabel='',
             description='',
             **kwargs):
        """
 
        Plot efficiency as a function of wavelength.
         
        :Parameters:
         
        plotaxis: matplotlib axis object (optional)
            Axis on which to add the plot.
            If an axis is provided, the plot will be created within that
            axis. Providing an axis allows the caller to control exactly
            where a plot appears within a figure.
            If an axis is not provided, a new one will be created filling
            a new figure.
        xlabel: str (optional)
            An X label for the plot. The default is the name of the
            wavelength table array.
        ylabel: str (optional)
            A Y label for the plot. The default is the name of
            the efficiency table array.
        description: str (optional)
            Optional description to be appended to the plot title, if
            required.
            Note: If too much text is written on a plot it may
            overlap with other labels; especially when applied to
            subplots.
        \*\*kwargs:
            All other keyword arguments will be passed to matplotlib.plot
            For example label, linewidth, linestyle, color, marker, etc...
            See the matplotlib documentation for a full list.
 
        :Requires:
         
        miri.tools.miriplot
        matplotlib.pyplot
 
        """
        units = self.get_data_units('pce_table').split(", ")
        if not xlabel:
            units0 = units[0]
            units0 = units0.lstrip('(')
            units0 = units0.lstrip('"')
            units0 = units0.rstrip(')')
            units0 = units0.rstrip('"')
            if units0:
                xlabel = "%s (%s)" % (self.fieldnames[0], units0)
            else:
                xlabel = self.fieldnames[0]
        if not ylabel:
            units1 = units[1]
            units1 = units1.lstrip('(')
            units1 = units1.lstrip('"')
            units1 = units1.rstrip(')')
            units1 = units1.rstrip('"')
            if units1:
                ylabel = "%s (%s)" % (self.fieldnames[1], units1)
            else:
                ylabel = self.fieldnames[1]

        tstrg = self.get_title(underline=False)
        if description:
            tstrg += " - " + description
        else:
            tstrg += " - %s" % self.meta.etc.component

        mplt.plot_xy(self.wavelength,
                     self.efficiency,
                     plotaxis=plotaxis,
                     xlabel=xlabel,
                     ylabel=ylabel,
                     title=tstrg,
                     grid=True,
                     **kwargs)
        mplt.close()
Esempio n. 4
0
    # Define 64 x 72 test data (SUB64 subarray)
    ROWS = 64
    COLUMNS = 72
    SAMPLE_ROW = 16
    SAMPLE_LCOL = 16
    SAMPLE_RCOL = 48
    leftdata = np.zeros([ROWS, COLUMNS])
    leftdata[10:50, 14:20] = 1.0
    if PLOT_ILLUMINATION_DATA:
        mplt.plot_image(leftdata, title='leftdata')

    rightdata = np.zeros([ROWS, COLUMNS])
    rightdata[10:50, 44:50] = 1.0
    if PLOT_ILLUMINATION_DATA:
        mplt.plot_image(rightdata, title='rightdata')
        mplt.close()

# NOTE: FULL FRAME DATA SIMULATIONS USE A LOT OF MEMORY - MAY NEED TO LIMIT NGROUPS
#     # Define full frame test data
#     ROWS = 1024
#     COLUMNS = 1024
#     leftdata = np.zeros([ROWS,COLUMNS])
#     r1 = 32
#     c1 = 60
#     for cc in range(c1, COLUMNS, 256):
#         for rr in range(r1, ROWS, 256):
#             leftdata[rr:rr+192,cc:cc+16] = 1.0
#     if PLOT_ILLUMINATION_DATA:
#         mplt.plot_image(leftdata, title='leftdata')
#
#     rightdata = np.zeros([ROWS,COLUMNS])