<commit_before>
################################################################################
#This software was developed by the University of Tennessee as part of the
#Distributed Data Analysis of Neutron Scattering Experiments (DANSE)
#project funded by the US National Science Foundation. 
#
#See the license text in license.txt
#
#copyright 2009, University of Tennessee
################################################################################

"""
Dialog panel to explore the P(r) inversion results for a range
of D_max value. User picks a number of points and a range of
distances, then can toggle between inversion outputs and see
their distribution as a function of D_max.
"""
    

import wx
import numpy
import math
import logging
import sys

# Avoid Matplotlib complaining about the lack of legend on the plot 
import warnings
warnings.simplefilter("ignore")

# Import plotting classes
from danse.common.plottools.PlotPanel import PlotPanel
from danse.common.plottools import Theory1D as Model1D
from danse.common.plottools.plottables import Graph

from pr_widgets import PrTextCtrl

# Default number of points on the output plot
DEFAULT_NPTS = 10
# Default output parameter to plot
DEFAULT_OUTPUT = 'Chi2/dof'

class OutputPlot(PlotPanel):
    """
    Plot panel used to show the selected results as a function
    of D_max
    """
    def __init__(self, d_min, d_max, parent, id = -1, color = None,\
        dpi = None, style = wx.NO_FULL_REPAINT_ON_RESIZE, **kwargs):
        """
        Initialization. The parameters added to PlotPanel are:
        
        :param d_min: Minimum value of D_max to explore
        :param d_max: Maximum value of D_max to explore
        
        """
        PlotPanel.__init__(self, parent, id = id, style = style, **kwargs)

        self.parent = parent
        self.min = d_min
        self.max = d_max
        self.npts = DEFAULT_NPTS

        step = (self.max-self.min)/(self.npts-1)
        self.x = numpy.arange(self.min, self.max+step*0.01, step)
        dx = numpy.zeros(len(self.x))
        y = numpy.ones(len(self.x))
        dy = numpy.zeros(len(self.x))
 
        # Plot area
        self.plot = Model1D(self.x, y=y, dy=dy)
        self.plot.name = DEFAULT_OUTPUT

        # Graph        
        self.graph = Graph()
        self.graph.xaxis("\\rm{D_{max}}", 'A')
        self.graph.yaxis("\\rm{%s}" % DEFAULT_OUTPUT,"")
        self.graph.add(self.plot)
        self.graph.render(self)

    def onContextMenu(self, event):
        """
        Default context menu for the plot panel
        
        :TODO: Would be nice to add printing and log/linear scales.
            The current verison of plottools no longer plays well with 
            plots outside of guiframe. Guiframe team needs to fix this. 
        """
        # Slicer plot popup menu
        id = wx.NewId()
        slicerpop = wx.Menu()
        slicerpop.Append(id, '&Save image', 'Save image as PNG')
        wx.EVT_MENU(self, id, self.onSaveImage)
        
        id = wx.NewId()
        slicerpop.AppendSeparator()
        slicerpop.Append(id, '&Reset Graph')<commit_msg>changed theory1d to data1d for dialog plots<commit_after>
################################################################################
#This software was developed by the University of Tennessee as part of the
#Distributed Data Analysis of Neutron Scattering Experiments (DANSE)
#project funded by the US National Science Foundation. 
#
#See the license text in license.txt
#
#copyright 2009, University of Tennessee
################################################################################

"""
Dialog panel to explore the P(r) inversion results for a range
of D_max value. User picks a number of points and a range of
distances, then can toggle between inversion outputs and see
their distribution as a function of D_max.
"""
    

import wx
import numpy
import math
import logging
import sys

# Avoid Matplotlib complaining about the lack of legend on the plot 
import warnings
warnings.simplefilter("ignore")

# Import plotting classes
from danse.common.plottools.PlotPanel import PlotPanel
from danse.common.plottools import Data1D as Model1D
from danse.common.plottools.plottables import Graph

from pr_widgets import PrTextCtrl

# Default number of points on the output plot
DEFAULT_NPTS = 10
# Default output parameter to plot
DEFAULT_OUTPUT = 'Chi2/dof'

class OutputPlot(PlotPanel):
    """
    Plot panel used to show the selected results as a function
    of D_max
    """
    def __init__(self, d_min, d_max, parent, id = -1, color = None,\
        dpi = None, style = wx.NO_FULL_REPAINT_ON_RESIZE, **kwargs):
        """
        Initialization. The parameters added to PlotPanel are:
        
        :param d_min: Minimum value of D_max to explore
        :param d_max: Maximum value of D_max to explore
        
        """
        PlotPanel.__init__(self, parent, id = id, style = style, **kwargs)

        self.parent = parent
        self.min = d_min
        self.max = d_max
        self.npts = DEFAULT_NPTS

        step = (self.max-self.min)/(self.npts-1)
        self.x = numpy.arange(self.min, self.max+step*0.01, step)
        dx = numpy.zeros(len(self.x))
        y = numpy.ones(len(self.x))
        dy = numpy.zeros(len(self.x))
 
        # Plot area
        self.plot = Model1D(self.x, y=y, dy=dy)
        self.plot.name = DEFAULT_OUTPUT
        self.plot.symbol = 13

        # Graph        
        self.graph = Graph()
        self.graph.xaxis("\\rm{D_{max}}", 'A')
        self.graph.yaxis("\\rm{%s}" % DEFAULT_OUTPUT,"")
        self.graph.add(self.plot)
        self.graph.render(self)

    def onContextMenu(self, event):
        """
        Default context menu for the plot panel
        
        :TODO: Would be nice to add printing and log/linear scales.
            The current verison of plottools no longer plays well with 
            plots outside of guiframe. Guiframe team needs to fix this. 
        """
        # Slicer plot popup menu
        id = wx.NewId()
        slicerpop = wx.Menu()
        slicerpop.Append(id, '&Save image', 'Save image as PNG')
        wx.EVT_MENU(self, id, self.onSaveImage)
        
        id = wx.NewId()
        slicerpop.AppendSeparator()
        slicerpop.Append(id, '&Reset Graph')
{'fraction_non_alphanumeric': 0.13525111252383978, 'fraction_numerical': 0.00540368722186904, 'mean_word_length': 2.768263473053892, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '253053', 'n_tokens_mistral': 1855, 'n_tokens_neox': 1781, 'n_words': 613}