Пример #1
0
    def plot(self,
             xMin=None,
             xMax=None,
             yMin=None,
             yMax=None,
             xylog=0,
             xLabel=None,
             yLabel=None,
             title=None,
             style="lines"):
        """Plots the fluxes

xylog meanings::
    xylog   plot-type
   -----------------------
      0     linear-linear
      1     log-linear
      2     linear-log
      3     log-log"""

        if (xLabel == None): xLabel = 'Energy (MeV)'
        if (yLabel == None): yLabel = 'A. U.'
        dt = plotbase.parsePlotOptions(xMin, xMax, yMin, yMax, xLabel, yLabel,
                                       title)
        f = fudgeFileMisc.fudgeTempFile()
        for lGroup in self.EF_l:
            for p in lGroup:
                f.write('   '.join(map(str, p)) + '\n')
            f.write('\n')
        f.close()
        p = os.path.join(
            __file__.split('fudge/processing/')[0], "fudge", "vis", "gnuplot",
            "endl2dplot.py")
        s = ['python', p, 'xylog', str(xylog)] + dt + [f.getName()]
        subprocessing.spawn(s)
Пример #2
0
    def plot(self,
             xMin=None,
             xMax=None,
             yMin=None,
             yMax=None,
             xylog=0,
             xLabel=None,
             yLabel=None,
             title=None,
             style="lines"):
        """Plots the group boundaries.

xylog meanings::
    xylog   plot-type
   -----------------------
      0     linear-linear
      1     log-linear
      2     linear-log
      3     log-log"""

        if (xLabel is None): xLabel = 'Energy (MeV)'
        if (yLabel is None): yLabel = 'A. U.'
        dt = plotbase.parsePlotOptions(xMin, xMax, yMin, yMax, xLabel, yLabel,
                                       title)
        f = fudgeFileMisc.fudgeTempFile()
        for p in self.gb:
            f.write("%15.7e 0.1\n%15.7e 10.\n\n" % (p, p))
        f.close()
        p = os.path.join(
            __file__.split('fudge/processing/')[0], "fudge", "vis", "gnuplot",
            "endl2dplot.py")
        s = ['python', p, 'xylog', str(xylog)] + dt + [f.getName()]
        subprocessing.spawn(s)
Пример #3
0
def multiPlot( datasets, xylog = 0, xMin = None, xMax = None, yMin = None, yMax = None, xLabel = "Energy (MeV)",
        yLabel = "Cross section (barn)", title = None, lineWidth = 1, fontSize = None ) :
    """This routine sends all data objects of the first argument, datasets, to the module fudge2dMultiPlot for interactive plotting. 
Here, datasets must be a list or tuple, and each element must be an object at has the method copyDataToXYs. The copyDataToXYs
must return the [x, y] pairs of data to plot as a python list of [x_i,y_i] pairs.  The legend for each data element of datasets 
is taken from that object's label member."

See module fudge2dMultiPlot for a description of the following parameters::
    xylog    xMin     xMax     yMin     
    yMax     xLabel   yLabel   title    

Currently, lineWitdh and fontSize are not implemented.

Examples of usages where d1, d2 and d3 are endl2dmath objects.

>>> d2.label = "Bad data from boss"                     # Sets the legend for d2 to "Bad data from boss".
>>> multiPlot( ( d1, d2, d3 ), xylog = 3 )
>>> I0Data = za.findDatas( I = 0, C = ( 12, 13, 14 ) )  # za is an endlZA object.
>>> multiPlot( I0Data )

Also see the routine qmultiPlot.
"""

    if( len( datasets ) == 0 ) : return
    if( ( type( datasets ) != type( [] ) ) and ( type( datasets ) != type( () ) ) ) : datasets = [ datasets ]
    fs = []
    for dataset in datasets :
        isInstance = ( type( dataset ) == types.InstanceType )
        if( hasattr( dataset, '__class__' ) ) : isInstance |= ( type( dataset ) == dataset.__class__ )    # New style class instance.
        if( isInstance ) :
            Msg = "cannot plot object of type %s" % dataset.__class__.__name__
            try :
                xys = dataset.copyDataToXYs( )
            except :
                print "Warning in multiPlot: cannot plot object named %s" % dataset.__class__.__name__
                continue
            f = fudgeFileMisc.fudgeTempFile( )
            for x, y in xys : f.write( "%.10e %14.8e\n" % ( x, y ) )
            f.close( )
            fs.append( f.getName( ) )
            if( hasattr( dataset, 'label' ) ) :
                if( isinstance( dataset.label, str ) ) : fs += [ 'title', dataset.label ]
        else :
            raise Exception( "\nError in multiPlot: cannot plot none instance object" )

    o = plotbase.parsePlotOptions( xMin, xMax, yMin, yMax, xLabel, yLabel, title )
    p = fudgemisc.findPythonFile( os.sep.join( __path__ + [ "vis", "gnuplot", "fudge2dMultiPlot.py" ] ) )
    s = [ 'python', p, 'xylog', str( xylog ) ] + o + [ 'files' ] + fs
    subprocessing.spawn( s )
Пример #4
0
def plot3dFrom4d(data, i, options, xyzlog=0):
    "For internal use only."

    ly_etal = data[i][1]
    f = fudgeFileMisc.fudgeTempFile()
    for y_etal in ly_etal:
        y = "%15.7e" % y_etal[0]
        for etal in y_etal[1]:
            f.write("%s %14.6e %14.6e\n" % (y, etal[0], etal[1]))
    f.close()
    p = os.path.join(
        __file__.split('/fudge/core/')[0], "fudge", "vis", "gnuplot",
        "endl3dplot.py")
    s = ["python", p, 'xyzlog', str(xyzlog)] + options + [f.getName()]
    subprocessing.spawn(s)
Пример #5
0
def multiPlot3d( dataList, xyzlog = 0, xMin = None, xMax = None, yMin = None, yMax = None, zMin = None, zMax = None, xLabel = None,
        yLabel = None, zLabel = None, title = None, lineWidth = 1, fontSize = None ) :
    """
    This routine sends all data objects of the first argument, dataList, to the module fudge3dMultiPlot for interactive plotting.
    Here, dataList must be a list or tuple, and each element must be an endl3dmath object or subclass of it.
    The legend for each data element of dataList is taken from that object's label member."

    See module fudge3dMultiPlot for a description of the following parameters::
        xyzlog   xMin     xMax     yMin     yMax
        zMin     zMax     xLabel   yLabel   zLabel
        title

    Currently, lineWitdh and fontSize are not implemented.

    Examples of usages where d1, d2 and d3 are endl3dmath objects.

    >>> d2.label = "Bad data from boss"                     # Sets the legend for d2 to "Bad data from boss".
    >>> multiPlot3d( ( d1, d2, d3 ), xyzlog = 3 )           # x log, y log and z linear.
    >>> I1Data = za.findDatas( I = 1, C = ( 12, 13, 14 ) )  # za is an endlZA object.
    >>> multiPlot( I1Data )
    """

    def getLabel( self, labelName, labelStr ) :

        if( labelStr is not None ) : return( labelStr )
        if( hasattr( self, labelName ) ) : return( getattr( self, labelName ) )
        return( labelStr )

    if( len( dataList ) == 0 ) : return
    if( not( isinstance( dataList, ( list, tuple ) ) ) ) : dataList = [ dataList ]
    fs = []
    for dataset in dataList :
        w_xys = dataset.copyDataToW_XYs( )
        xLabel = getLabel( dataset, 'xLabel', xLabel )
        yLabel = getLabel( dataset, 'yLabel', yLabel )
        zLabel = getLabel( dataset, 'zLabel', zLabel )
        f = fudgeFileMisc.fudgeTempFile( )
        fs += [ f.getName( ) ]
        if( hasattr( dataset, 'label' ) ) : fs += [ 'title', dataset.label ]
        for x, yz in w_xys :
            xs = "%.10e" % x
            for y, z in yz : f.write( "%s %.10e %14.8e\n" % ( xs, y, z ) )
            f.write( "\n" )
        f.close( )
    o = plotbase.parsePlotOptions( xMin, xMax, yMin, yMax, xLabel, yLabel, title, zMin, zMax, zLabel )
    p = fudgemisc.findPythonFile( os.sep.join( __path__ + [ "vis", "gnuplot", "fudge3dMultiPlot.py" ] ) )
    s = [ 'python', p, 'xyzlog', str( xyzlog ) ] + o + [ 'files' ] + fs
    subprocessing.spawn( s )
Пример #6
0
    def plot(self,
             xMin=None,
             xMax=None,
             yMin=None,
             yMax=None,
             zMin=None,
             zMax=None,
             xyzlog=0,
             xLabel=None,
             yLabel=None,
             zLabel=None,
             title=None,
             xrot=None,
             zrot=None):
        """
        Plots the data.

        xyzlog values and meaning::

            xyzlog   plot-type for x-y-z axis
           -----------------------------------
              0     linear-linear-linear
              1     log-linear-linear
              2     linear-log-linear
              3     log-log-linear
              4     linear-linear-log
              5     log-linear-log
              6     linear-log-log
              7     log-log-log
        """

        if (xLabel == None) and (self.xLabel != None): xLabel = self.xLabel
        if (yLabel == None) and (self.yLabel != None): yLabel = self.yLabel
        if (zLabel == None) and (self.zLabel != None): zLabel = self.zLabel
        dt = plotbase.parsePlotOptions( xMin, xMax, yMin, yMax, xLabel, yLabel, title, zMin = zMin, zMax = zMax, zLabel = zLabel, \
            xrot = xrot, zrot = zrot )
        f = fudgeFileMisc.fudgeTempFile()
        f.write(endl3dmath.__repr__(self))
        f.close()
        p = os.path.join(
            __file__.split('fudge/legacy/')[0], "fudge", "vis", "gnuplot",
            "endl3dplot.py")
        s = ['python', p, 'xyzlog', str(xyzlog)] + dt + [f.getName()]
        subprocessing.spawn(s)
Пример #7
0
    def plot(self,
             xMin=None,
             xMax=None,
             yMin=None,
             yMax=None,
             xylog=0,
             xLabel=None,
             yLabel=None,
             title=None):
        """
        This routine is like qplot (quick plot) except it spawns an interactive plot.  qplot is faster while plot is more flexible.

        ===== =============
        xylog   plot-type
        ===== =============
        0     linear-linear
        1     log-linear
        2     linear-log
        3     log-log
        ===== =============
        """

        if (xLabel is None): xLabel = 'indice'
        if (yLabel is None): yLabel = self.yLabel
        dt = plotbase.parsePlotOptions(xMin, xMax, yMin, yMax, xLabel, yLabel,
                                       title)
        f = fudgeFileMisc.fudgeTempFile()
        i = 0
        for v in self.data:
            f.write("%d %14.8e\n" % (i, v))
            i += 1
        f.close()
        p = os.path.join(
            __file__.split('/fudge/core/')[0], "fudge", "vis", "gnuplot",
            "endl2dplot.py")
        s = ['python', p, 'xylog', str(xylog)] + dt + [f.getName()]
        subprocessing.spawn(s)
Пример #8
0
    def plot( self, xMin = None, xMax = None, yMin = None, yMax = None, zMin = None, zMax = None, xyzlog = 0, \
        tLabel = None, xLabel = None, yLabel = None, zLabel = None, title = None, tScaleLabel = None, \
        xrot = None, zrot = None, style = None ) :                        # class endl4dmath
        """
        Plots the data.

        xyzlog values and meaning are ::

            xyzlog   plot-type for x-y-z axis
           -----------------------------------
              0     linear-linear-linear
              1     log-linear-linear
              2     linear-log-linear
              3     log-log-linear
              4     linear-linear-log
              5     log-linear-log
              6     linear-log-log
              7     log-log-log
        """

        if (tLabel is None) and (self.tLabel is not None): tLabel = self.tLabel
        if (xLabel is None) and (self.xLabel is not None): xLabel = self.xLabel
        if (yLabel is None) and (self.yLabel is not None): yLabel = self.yLabel
        if (zLabel is None) and (self.zLabel is not None): zLabel = self.zLabel

        dt = plotbase.parsePlotOptions( xMin, xMax, yMin, yMax, xLabel, yLabel, title, zMin = zMin, zMax = zMax, \
            zLabel = zLabel, tLabel = tLabel, tScaleLabel = tScaleLabel, xrot = xrot, zrot = zrot, style = style )
        f = fudgeFileMisc.fudgeTempFile()
        format = fudgemisc.getFormat(self)
        f.write(endl4dmath.toString(self, format=format))
        f.close()
        p = os.path.join(
            __file__.split('/fudge/legacy/')[0], "fudge", "vis", "gnuplot",
            "endl4dplot.py")
        s = ['python', p, 'xyzlog', str(xyzlog)] + dt + [f.getName()]
        subprocessing.spawn(s)