Beispiel #1
0
    def _redrawColourBar(self, widget):
        oldFill = widget.rootWidget.plotter.lowLevelPlotter.getFill()
        oldColour = widget.rootWidget.plotter.lowLevelPlotter.getColour()

        widget.rootWidget.plotter.lowLevelPlotter.setFill(True)
        yLo = widget.sizes[1].range.lo
        yHi = widget.sizes[1].range.hi
        xHi = widget.sizes[0].range.lo
        for ci in range(self.minAvailCI, self.maxAvailCI + 1):
            xLo = xHi
            xFracHi = (1 + ci - self.minAvailCI) / float(self.maxAvailCI + 1 -
                                                         self.minAvailCI)
            xHi = widget.sizes[0].range.lo * (
                1.0 - xFracHi) + widget.sizes[0].range.hi * xFracHi

            ciFrac = (ci + 0.5 - self.minAvailCI) / (self.maxAvailCI + 1 -
                                                     self.minAvailCI)
            red = self.cm.hueGraphs[0].interpolate(ciFrac)
            grn = self.cm.hueGraphs[1].interpolate(ciFrac)
            blu = self.cm.hueGraphs[2].interpolate(ciFrac)
            pgplot.pgscr(ci, red, grn, blu)

            widget.rootWidget.plotter.lowLevelPlotter.setColour(ci)
            widget.rootWidget.plotter.lowLevelPlotter.drawRectangle(
                xLo, yLo, xHi, yHi)

        widget.rootWidget.plotter.lowLevelPlotter.setFill(oldFill)
        widget.rootWidget.plotter.lowLevelPlotter.setColour(oldColour)
Beispiel #2
0
    def _setColourRepresentations(self):
        if not self.plotDeviceIsOpened:
            raise ValueError(
                'you must open a device before you can set colour representations.'
            )

##### check the number of colours does not exceed max for the device.

        for colour in self.colours.keys():
            ci = self.colours[colour]['ci']
            rgb = self.colours[colour]['rgb']
            if not rgb is None:
                pgplot.pgscr(ci, rgb[0], rgb[1], rgb[2])
Beispiel #3
0
    def startPlotter(self):
        if self.plotDeviceIsOpened:
            raise ValueError("You already started a plot!")

        devId = pgplot.pgopen(self.deviceName)
        self.plotDeviceIsOpened = True

        if not self.widthInches is None:
            pgplot.pgpap(self.widthInches, self.yOnXRatio)

        # For devices /xs, /xw, /png etc, should make the paper white and the ink black. Only for /ps does pgplot default to that.
        #
        deviceWithoutFile = self.deviceName.split('/')[-1]
        if deviceWithoutFile == 'xs' or deviceWithoutFile == 'xw' or deviceWithoutFile == 'png':
            pgplot.pgscr(0, 1.0, 1.0, 1.0)
            pgplot.pgscr(1, 0.0, 0.0, 0.0)

        pgplot.pgsvp(self._vXLo, self._vXHi, self._vYLo, self._vYHi)

        if self.fixAspect:
            pgplot.pgwnad(self.worldXLo, self.worldXHi, self.worldYLo,
                          self.worldYHi)
        else:
            pgplot.pgswin(self.worldXLo, self.worldXHi, self.worldYLo,
                          self.worldYHi)
        pgplot.pgsfs(2)

        pgplot.pgslw(1)
        pgplot.pgsch(self._charHeight)

        self._setColourRepresentations()

        # Set up things so calling pgplot.pggray() won't overwrite the CR of any of the colours in self.colours.
        #
        (minCI, maxCI) = pgplot.pgqcir()
        if minCI <= self.maxCI:
            pgplot.pgscir(self.maxCI + 1, maxCI)

        (xLoPixels, xHiPixels, yLoPixels, yHiPixels) = pgplot.pgqvsz(3)
        (xLoInches, xHiInches, yLoInches, yHiInches) = pgplot.pgqvsz(1)
        self.xPixelWorld = (xHiInches - xLoInches) / (xHiPixels - xLoPixels)
        self.yPixelWorld = (yHiInches - yLoInches) / (yHiPixels - yLoPixels)
Beispiel #4
0
def reset_colors():
    lo_col_ind, hi_col_ind = ppgplot.pgqcol()
    ppgplot.pgscir(lo_col_ind, hi_col_ind)
    #ppgplot.pgscr( 0, 0.00, 0.00, 0.00) # Black (background)     
    #ppgplot.pgscr( 1, 1.00, 1.00, 1.00) # White (default)
    ppgplot.pgscr( 1, 0.00, 0.00, 0.00) # White (background)     
    ppgplot.pgscr( 0, 1.00, 1.00, 1.00) # Black (default)
    ppgplot.pgscr( 2, 1.00, 0.00, 0.00) # Red                    
    ppgplot.pgscr( 3, 0.00, 1.00, 0.00) # Green                  
    ppgplot.pgscr( 4, 0.00, 0.00, 1.00) # Blue                   
    ppgplot.pgscr( 5, 0.00, 1.00, 1.00) # Cyan (Green + Blue)    
    ppgplot.pgscr( 6, 1.00, 0.00, 1.00) # Magenta (Red + Blue)   
    ppgplot.pgscr( 7, 1.00, 1.00, 0.00) # Yellow  (Red + Green)  
    ppgplot.pgscr( 8, 1.00, 0.50, 0.00) # Red + Yellow (Orange)  
    ppgplot.pgscr( 9, 0.50, 1.00, 0.00) # Green + Yellow         
    ppgplot.pgscr(10, 0.00, 1.00, 0.50) # Green + Cyan           
    ppgplot.pgscr(11, 0.00, 0.50, 1.00) # Blue + Cyan            
    ppgplot.pgscr(12, 0.50, 0.00, 1.00) # Blue + Magenta         
    ppgplot.pgscr(13, 1.00, 0.00, 0.50) # Red + Magenta          
    ppgplot.pgscr(14, 0.33, 0.33, 0.33) # Dark Gray              
    ppgplot.pgscr(15, 0.66, 0.66, 0.66) # Light Gray   	  
    for ci in range(16, hi_col_ind+1):
        ppgplot.pgscr(ci, 0.00, 0.00, 0.00) # Black (background)     
Beispiel #5
0
def reset_colors():
    lo_col_ind, hi_col_ind = ppgplot.pgqcol()
    ppgplot.pgscir(lo_col_ind, hi_col_ind)
    ppgplot.pgscr(0, 0.00, 0.00, 0.00)  # Black (background)
    ppgplot.pgscr(1, 1.00, 1.00, 1.00)  # White (default)
    ppgplot.pgscr(2, 1.00, 0.00, 0.00)  # Red
    ppgplot.pgscr(3, 0.00, 1.00, 0.00)  # Green
    ppgplot.pgscr(4, 0.00, 0.00, 1.00)  # Blue
    ppgplot.pgscr(5, 0.00, 1.00, 1.00)  # Cyan (Green + Blue)
    ppgplot.pgscr(6, 1.00, 0.00, 1.00)  # Magenta (Red + Blue)
    ppgplot.pgscr(7, 1.00, 1.00, 0.00)  # Yellow  (Red + Green)
    ppgplot.pgscr(8, 1.00, 0.50, 0.00)  # Red + Yellow (Orange)
    ppgplot.pgscr(9, 0.50, 1.00, 0.00)  # Green + Yellow
    ppgplot.pgscr(10, 0.00, 1.00, 0.50)  # Green + Cyan
    ppgplot.pgscr(11, 0.00, 0.50, 1.00)  # Blue + Cyan
    ppgplot.pgscr(12, 0.50, 0.00, 1.00)  # Blue + Magenta
    ppgplot.pgscr(13, 1.00, 0.00, 0.50)  # Red + Magenta
    ppgplot.pgscr(14, 0.33, 0.33, 0.33)  # Dark Gray
    ppgplot.pgscr(15, 0.66, 0.66, 0.66)  # Light Gray
    for ci in range(16, hi_col_ind + 1):
        ppgplot.pgscr(ci, 0.00, 0.00, 0.00)  # Black (background)
Beispiel #6
0
    # Initialize plot
    ppgplot.pgopen("/xs")
    ppgplot.pgslw(2)
    ppgplot.pgpap(0.0, 0.75)

    # For ever loop
    redraw = True
    while True:
        # Redraw
        if redraw == True:
            # Update
            m.update()

            # Initialize window
            ppgplot.pgscr(0, 0., 0., 0.)
            ppgplot.pgeras()
            ppgplot.pgsvp(0.01, 0.99, 0.01, 0.99)
            ppgplot.pgwnad(-1.5 * m.w, 1.5 * m.w, -m.w, m.w)

            # Set background depending on solar altitude
            if m.sunalt > 0.0:
                ppgplot.pgscr(0, 0.0, 0.0, 0.4)
            elif m.sunalt > -6.0:
                ppgplot.pgscr(0, 0.0, 0.0, 0.3)
            elif m.sunalt > -12.0:
                ppgplot.pgscr(0, 0.0, 0.0, 0.2)
            elif m.sunalt > -18.0:
                ppgplot.pgscr(0, 0.0, 0.0, 0.1)
            else:
                ppgplot.pgscr(0, 0.0, 0.0, 0.0)
Beispiel #7
0
ppgplot.pgbox("BCNST", 0.0, 0, "BCST", 0.0, 0)
ppgplot.pgline(fdotcut, zs)
ppgplot.pgmtxt("B", 2.4, 0.5, 0.5, "Relative Power")

# f-fdot image
ppgplot.pgsvp(margin, margin + imfract, margin, margin + imfract)
ppgplot.pgswin(min(rs), max(rs), min(zs), max(zs))
ppgplot.pgmtxt("B", 2.4, 0.5, 0.5, labx)
ppgplot.pgmtxt("L", 2.0, 0.5, 0.5, laby)
lo_col_ind, hi_col_ind = ppgplot.pgqcol()
lo_col_ind = lo_col_ind + 2
ppgplot.pgscir(lo_col_ind, hi_col_ind)
pgpalette.setpalette(image)
ppgplot.pgctab(pgpalette.l, pgpalette.r, pgpalette.g, pgpalette.b)
ppgplot.pgimag_s(pffdot, 0.0, 0.0, rgx[0], rgy[0], rgx[1], rgy[1])
ppgplot.pgsci(1)
ppgplot.pgcont_s(pffdot, len(contours), contours, rgx[0], rgy[0], rgx[1],
                 rgy[1])
ppgplot.pgbox("BCST", 0.0, 0, "BCST", 0.0, 0)
ppgplot.pgsci(1)
ppgplot.pgbox("N", 0.0, 0, "N", 0.0, 0)

# gray axes
ppgplot.pgscr(1, 0.5, 0.5, 0.5)
ppgplot.pgsci(1)
ppgplot.pgslw(2)
ppgplot.pgline(rgx, num.asarray([0.0, 0.0]))
ppgplot.pgline(num.asarray([0.0, 0.0]), rgy)

ppgplot.pgclos()
Beispiel #8
0
ppgplot.pgline(fdotcut, zs)
ppgplot.pgmtxt("B", 2.4, 0.5, 0.5, "Relative Power");

# f-fdot image
ppgplot.pgsvp(margin, margin+imfract, margin, margin+imfract)
ppgplot.pgswin(min(rs), max(rs), min(zs), max(zs))
ppgplot.pgmtxt("B", 2.4, 0.5, 0.5, labx);
ppgplot.pgmtxt("L", 2.0, 0.5, 0.5, laby);
lo_col_ind, hi_col_ind = ppgplot.pgqcol()
lo_col_ind = lo_col_ind + 2
ppgplot.pgscir(lo_col_ind, hi_col_ind)
pgpalette.setpalette(image)
ppgplot.pgctab(pgpalette.l, pgpalette.r, pgpalette.g, pgpalette.b)
ppgplot.pgimag_s(pffdot, 0.0, 0.0, rgx[0], rgy[0], rgx[1], rgy[1])  
ppgplot.pgsci(1)
ppgplot.pgcont_s(pffdot, len(contours), contours, rgx[0], rgy[0], rgx[1], rgy[1])  
ppgplot.pgbox("BCST", 0.0, 0, "BCST", 0.0, 0)
ppgplot.pgsci(1)
ppgplot.pgbox("N", 0.0, 0, "N", 0.0, 0)

# gray axes
ppgplot.pgscr(1, 0.5, 0.5, 0.5)
ppgplot.pgsci(1)
ppgplot.pgslw(2)
ppgplot.pgline(rgx, num.asarray([0.0, 0.0]))
ppgplot.pgline(num.asarray([0.0, 0.0]), rgy)

ppgplot.pgclos()