text:
import numpy as np
from PySide import QtGui, QtCore
import sharppy.sharptab as tab
from sharppy.sharptab.profile import Profile, create_profile
from sharppy.sharptab.constants import *
from PySide.QtGui import *
from PySide.QtCore import *

__all__ = ['backgroundHodo', 'plotHodo']

class backgroundHodo(QtGui.QFrame):
    '''
    Handles the plotting of the backgroun frame onto
    a QPixmap. Inherits from the QtGui.QFrame object.
    Unlike most plotting classes in SHARPPy, this class
    will not call the function to draw the background.
    This is so that the background can be redrawn when
    the hodograph gets centered on a vector.
    '''
    def __init__(self):
        super(backgroundHodo, self).__init__()
        self.first = True
        self.initUI()

    def initUI(self):
        '''
        Initialize the User Interface

        '''
        ## set the interface variables for width, height, padding, etc.
        self.lpad = 0; self.rpad = 0
        self.tpad = 0; self.bpad = 0
        self.wid = self.size().width()
        self.hgt = self.size().height()
        self.tlx = self.rpad; self.tly = self.tpad
        self.brx = self.wid; self.bry = self.hgt
        ## set default center to the origin
        self.point = (0,0)
        self.hodomag = 160.
        self.centerx = self.wid / 2; self.centery = self.hgt / 2
        self.scale = (self.brx - self.tlx) / self.hodomag
        ## ring increment
        self.ring_increment = 10
        self.rings = xrange(self.ring_increment, 100+self.ring_increment,
            self.ring_increment)
        if self.physicalDpiX() > 75:
            fsize = 7
        else:
            fsize = 9
        self.label_font = QtGui.QFont('Helvetica', fsize)
        self.critical_font = QtGui.QFont('Helvetica', fsize + 2)
        self.label_metrics = QtGui.QFontMetrics( self.label_font )
        self.critical_metrics = QtGui.QFontMetrics( self.critical_font )
        self.label_height = self.label_metrics.xHeight() + 5
        self.critical_height = self.critical_metrics.xHeight() + 5

        self.plotBitMap = QtGui.QPixmap(self.width(), self.height())
        self.saveBitMap = None
        self.plotBitMap.fill(QtCore.Qt.black)
        self.plotBackground()
        self.backgroundBitMap = self.plotBitMap.copy()

    def center_hodo(self, point):
        '''
        Center the hodograph in the window. It will either center it about
        the origin, about the mean wind vector, or the storm motion vector.

        Parameters
        ----------
        point: A (u,v) vector that the hodograph is to be centered on.

        '''
        ## modify the center based on an offset from the origin
        centerx = self.wid / 2; centery = self.hgt / 2
        point = self.uv_to_pix(point[0], point[1])
        ## if the function was called but the center hasn't changed in pixel space,
        ## just leave the center as is
        if self.point == point:
            self.centerx = self.centerx
            self.centery = self.centery
        ## otherwise, offset the hodograph center
        else:
            self.point = point
            diffx = centerx - point[0]; diffy = centery - point[1]
            self.centerx += diffx; self.centery += diffy
        self.plotBitMap.fill(QtCore.Qt.black)
        self.plotBackground()
        self.backgroundBitMap = self.plotBitMap.copy()

    def wheelEvent(self, e):
        '''
        Handeles the zooming of the hodograph window.

        Parameters
        ----------
        e: an Event object

        '''
        ## get the new scaling magnitude
        new_mag = self.hodomag + e.delta() / 5
        ## make sure the user doesn't zoom out of
        ## bounds to prevent drawing issues
        if new_mag >= 40. and new_mag <= 200.:
            self.hodomag = new_mag
        ## if it is out of bounds, do nothing
        else:
            self.hodomag = self.hodomag
        ## get the maximum speed value in the frame for the ring increment.
        ## this is to help reduce drawing resources
        max_uv = int(self.pix_to_uv(self.brx, 0)[0])
        self.rings = xrange(self.ring_increment, max_uv+self.ring_increment,
                           self.ring_increment)
        ## reassign the new scale
        self.scale = (self.brx - self.tlx) / self.hodomag

        self.plotBitMap.fill(QtCore.Qt.black)
        self.plotBackground()
        self.backgroundBitMap = self.plotBitMap.copy()
        self.plotData()

        ## update
        self.update()

    def resizeEvent(self, e):
        '''
        Resize the plot based on adjusting the main window.

        Parameters
        ----------
        e: an Event object

        '''
        self.initUI()

    def plotBackground(self):
        '''
        Handles painting the frame background onto the
        QPixmap.
        '''
        ## initialize a QPainter object.
        qp = QtGui.QPainter()
        qp.begin(self.plotBitMap)
        qp.setRenderHint(qp.Antialiasing)
        qp.setRenderHint(qp.TextAntialiasing)
        ## draw the wind speed rings
        for spd in self.rings: self.draw_ring(spd, qp)
        ## draw the frame axes
        self.draw_axes(qp)
        self.draw_frame(qp)
        qp.end()

    def draw_frame(self, qp):
        '''
        Draw frame around object.

        Parameters
        ----------
        qp: QtGui.QPainter object

        '''
        ## initialize a white pen to draw the frame
        pen = QtGui.QPen(QtGui.QColor(WHITE), 2)
        pen.setStyle(QtCore.Qt.SolidLine)
        qp.setPen(pen)
        ## draw the frame borders
        qp.drawLine(self.tlx, self.tly, self.brx, self.tly)
        qp.drawLine(self.brx, self.tly, self.brx, self.bry)
        qp.drawLine(self.brx, self.bry, self.tlx, self.bry)
        qp.drawLine(self.tlx, self.bry, self.tlx, self.tly)

    def draw_axes(self, qp):
        '''
        Draw the X, Y Axes.

        Parameters
        ----------
        qp: QtGui.QPainter object

        '''
        ## initialize a white pen to draw the frame axes
        pen = QtGui.QPen(QtGui.QColor(WHITE), 2)
        pen.setStyle(QtCore.Qt.SolidLine)
        qp.setPen(pen)
        ## draw the frame axes
        qp.drawLine(self.centerx, self.tly, self.centerx, self.bry)
        qp.drawLine(self.tlx, self.centery, self.brx, self.centery)

    def draw_ring(self, spd, qp):
        '''
        Draw a range ring.

        Parameters
        ----------
        spd: wind speed
        qp: QtGui.QPainter object

        '''
        ## set the ring color and get the u and v components of a
        ## 0 direction vector with speed spd.
        color = "#555555"
        uu, vv = tab.utils.vec2comp(0, spd)
        vv *= self.scale
        ## create a center point
        center = QtCore.QPointF(self.centerx, self.centery)
        ## initialize a pen to draw with
        pen = QtGui.QPen(QtGui.QColor(color), 1)
        pen.setStyle(QtCore.Qt.DashLine)
        qp.setPen(pen)
        ## draw the range ring
        qp.drawEllipse(center, vv, vv)
        qp.setFont(self.label_font)
        ## reset the pen to draw with. Color is set to black and width zero
        ## because we actually don't want to draw and lines yet.
        pen = QtGui.QPen(QtGui.QColor('#000000'), 0, QtCore.Qt.SolidLine)
        qp.setPen(pen)
        offset = 5; width = 15; hght = 15;
        ## crete some rectangles
        top_rect = QtCore.QRectF(self.centerx+offset,
                    self.centery+vv-offset, width, hght)
        bottom_rect = QtCore.QRectF(self.centerx+offset,
                    self.centery-vv-offset, width, hght)

        right_rect = QtCore.QRectF(self.centerx+vv-offset,
                    self.centery+offset, width, hght)
        left_rect = QtCore.QRectF(self.centerx-vv-offset,
                    self.centery+offset, width, hght)
        ## draw some invisible rectangles
        qp.drawRect(top_rect); qp.drawRect(right_rect)
        qp.drawRect(bottom_rect); qp.drawRect(left_rect)
        ## now make the pen white and draw text using
        ## the invisible rectangles
        pen = QtGui.QPen(QtGui.QColor("#FFFFFF"))
        qp.setPen(pen)
        qp.setFont(self.label_font)
        qp.drawText(top_rect, QtCore.Qt.AlignCenter, tab.utils.INT2STR(spd))
        qp.drawText(right_rect, QtCore.Qt.AlignCenter, tab.utils.INT2STR(spd))
        qp.drawText(bottom_rect, QtCore.Qt.AlignCenter, tab.utils.INT2STR(spd))
        qp.drawText(left_rect, QtCore.Qt.AlignCenter, tab.utils.INT2STR(spd))

    def hodo_to_pix(self, ang, spd):
        '''
        Function to convert a (direction, speed) to (x, y) coordinates.

        Parameters
        ----------
        ang: wind direction
        spd: wind speed

        '''
        uu, vv = tab.utils.vec2comp(ang, spd)
        xx = self.centerx + (uu * self.scale)
        yy = self.centery + (vv * self.scale)
        return xx, yy

    def uv_to_pix(self, u, v):
        '''
        Function to convert (u, v) to (x, y) coordinates.

        Parameters
        ----------
        u: the u wind component
        v: the v wind component

        '''
        xx = self.centerx + (u * self.scale)
        yy = self.centery - (v * self.scale)
        return xx, yy

    def pix_to_uv(self, xx, yy):
        '''
        Function to convert (x,y) to (u,v) coordinates.

        Parameters
        ----------
        xx: the x pixel value
        yy: the y pixel value

        '''
        u = (xx - self.centerx) / self.scale
        v = (self.centery - yy) / self.scale
        return u, v

class plotHodo(backgroundHodo):
    '''
    Plots the data on the hodograph. Inherits from the backgroundHodo
    class that plots the background frame onto a QPixmap.
    '''

    modified = Signal(int, dict)
    reset = Signal(list)

    def __init__(self, **kwargs):
        '''
        Initialize the data used in the class.
        '''
        super(plotHodo, self).__init__()
        self.prof = None
        self.pc_idx = 0
        self.prof_collections = []

        self.all_observed = False

        self.colors = [
            QtGui.QColor("#FF0000"),
            QtGui.QColor("#00FF00"),
            QtGui.QColor("#FFFF00"),
            QtGui.QColor("#00FFFF")
        ]

        self.ens_colors = [
            QtGui.QColor("#880000"),
            QtGui.QColor("#008800"),
            QtGui.QColor("#888800"),
            QtGui.QColor("#008888")
        ]

        ## if you want the storm motion vector, you need to
        ## provide the profile.
        self.cursor_type = kwargs.get('cursor', 'none')
        self.bndy_spd = kwargs.get('bndy_spd', 0)
        self.bndy_dir = kwargs.get('bndy_dir', 0)
        self.bndy_u, self.bndy_v = tab.utils.vec2comp(self.bndy_dir, self.bndy_spd)

        self.track_cursor = False
        self.was_right_click = False
        self.initdrag = False
        self.dragging = False
        self.drag_idx = None
        self.drag_buffer = 5
        self.clickradius = 6

        self.centered = kwargs.get('centered', (0,0))
        self.center_loc = 'centered'

        ## the following is used for the dynamic readout
        self.setMouseTracking(True)
        self.wndReadout = QLabel(parent=self)
        self.srh1kmReadout = QLabel(parent=self)
        self.srh3kmReadout = QLabel(parent=self)
        self.esrhReadout = QLabel(parent=self)

        self.wndReadout.setFixedWidth(0)
        self.srh1kmReadout.setFixedWidth(0)
        self.srh3kmReadout.setFixedWidth(0)
        self.esrhReadout.setFixedWidth(0)
        ## these stylesheets have to be set for
        ## each readout
        self.wndReadout.setStyleSheet("QLabel {"
            "  background-color: rgb(0, 0, 0);"
            "  border-width: 0px;"
            "  font-size: 11px;"
            "  color: #FFFFFF;}")
        self.srh1kmReadout.setStyleSheet("QLabel {"
            "  background-color: rgb(0, 0, 0);"
            "  border-width: 0px;"
            "  font-size: 11px;"
            "  color: #FF0000;}")
        self.srh3kmReadout.setStyleSheet("QLabel {"
            "  background-color: rgb(0, 0, 0);"
            "  border-width: 0px;"
            "  font-size: 11px;"
            "  color: #00FF00;}")
        self.esrhReadout.setStyleSheet("QLabel {"
            "  background-color: rgb(0, 0, 0);"
            "  border-width: 0px;"
            "  font-size: 11px;"
            "  color: #00FFFF;}")
        self.hband = QRubberBand(QRubberBand.Line, self)
        self.vband = QRubberBand(QRubberBand.Line, self)

        self.setContextMenuPolicy(Qt.CustomContextMenu)
        self.customContextMenuRequested.connect(self.showCursorMenu)
        self.popupmenu=QMenu("Cursor Type:")
        ag = QtGui.QActionGroup(self, exclusive=True)

        nocurs = QAction(self)
        nocurs.setText("No Cursor")
        nocurs.setCheckable(True)
        nocurs.setChecked(True)
        nocurs.triggered.connect(self.setNoCursor)
        a = ag.addAction(nocurs)
        self.popupmenu.addAction(a)

        storm_motion = QAction(self)
        storm_motion.setText("Strm Motion Cursor")
        storm_motion.setCheckable(True)
        storm_motion.triggered.connect(self.setStormMotionCursor)
        a = ag.addAction(storm_motion)
        self.popupmenu.addAction(a)

        bnd = QAction(self)
        bnd.setText("Bndy Cursor")
        bnd.setCheckable(True)
        bnd.triggered.connect(self.setBndyCursor)
        a = ag.addAction(bnd)
        self.popupmenu.addAction(a)

        self.popupmenu.addSeparator()
        ag2 = QtGui.QActionGroup(self, exclusive=True)

        norm = QAction(self)
        norm.setText("Normal")
        norm.setCheckable(True)
        norm.setChecked(True)
        norm.triggered.connect(self.setNormalCenter)
        a = ag2.addAction(norm)
        self.popupmenu.addAction(a)

        sr = QAction(self)
        sr.setText("Storm Relative")
        sr.setCheckable(True)
        sr.triggered.connect(self.setSRCenter)
        a = ag2.addAction(sr)
        self.popupmenu.addAction(a)

        mw = QAction(self)
        mw.setText("Mean Wind")
        mw.setCheckable(True)
        mw.triggered.connect(self.setMWCenter)
        a = ag2.addAction(mw)
        self.popupmenu.addAction(a)

        self.popupmenu.addSeparator()

        reset = QAction(self)
        reset.setText("Reset Hodograph")
        reset.triggered.connect(lambda: self.reset.emit(['u', 'v']))
        self.popupmenu.addAction(reset)

    def addProfileCollection(self, prof_coll):
        self.prof_collections.append(prof_coll)

    def rmProfileCollection(self, prof_coll):
        self.prof_collections.remove(prof_coll)

    def setActiveCollection(self, pc_idx, **kwargs):
        self.pc_idx = pc_idx
        prof = self.prof_collections[pc_idx].getHighlightedProf()

        self.prof = prof
        self.hght = prof.hght
        self.u = prof.u; self.v = prof.v
        ## if you want the storm motion vector, you need to
        ## provide the profile.
        self.srwind = self.prof.srwind
        self.ptop = self.prof.etop
        self.pbottom = self.prof.ebottom

        mean_lcl_el = self.prof.mean_lcl_el
        if tab.utils.QC(mean_lcl_el[0]):
            self.mean_lcl_el = tab.utils.vec2comp(*self.prof.mean_lcl_el)
        else:
            self.mean_lcl_el = (np.ma.masked, np.ma.masked)

        self.corfidi_up_u = self.prof.upshear_downshear[0]
        self.corfidi_up_v = self.prof.upshear_downshear[1]
        self.corfidi_dn_u = self.prof.upshear_downshear[2]
        self.corfidi_dn_v = self.prof.upshear_downshear[3]
        self.bunkers_right_vec = tab.utils.comp2vec(self.prof.srwind[0], self.prof.srwind[1])
        self.bunkers_left_vec = tab.utils.comp2vec(self.prof.srwind[2], self.prof.srwind[3])
        self.upshear = tab.utils.comp2vec(self.prof.upshear_downshear[0],self.prof.upshear_downshear[1])
        self.downshear = tab.utils.comp2vec(self.prof.upshear_downshear[2],self.prof.upshear_downshear[3])
        self.mean_lcl_el_vec = self.prof.mean_lcl_el #tab.utils.comp2vec(self.prof.mean_lcl_el[0], self.prof.mean_lcl_el[1])

        self.clearData()
        self.plotData()
        self.update()

    def setBndyCursor(self):
        self.track_cursor = True
        self.cursor_type = 'boundary'
        self.plotBndy(self.bndy_dir)
        self.wndReadout.hide()
        self.srh1kmReadout.hide()
        self.srh3kmReadout.show()
        self.esrhReadout.hide()
        self.clearData()
        self.plotData()
        self.update()
        self.parentWidget().setFocus()

    def setNoCursor(self):
        self.track_cursor = False
        self.cursor_type = 'none'
        self.unsetCursor()
        self.hband.hide()
        self.vband.hide()
        self.clearData()
        self.plotData()
        self.update()
        self.wndReadout.hide()
        self.srh1kmReadout.hide()
        self.srh3kmReadout.hide()
        self.esrhReadout.hide()
        self.parentWidget().setFocus()

    def setStormMotionCursor(self):
        self.unsetCursor()
        self.track_cursor = True
        self.cursor_type = 'stormmotion'
        self.wndReadout.show()
        self.srh1kmReadout.show()
        self.srh3kmReadout.show()
        self.esrhReadout.show()
        self.clearData()
        self.plotData()
        self.update()
        self.parentWidget().setFocus()

    def showCursorMenu(self, pos):
        self.popupmenu.popup(self.mapToGlobal(pos))

    def setNormalCenter(self):
        self.centered = (0, 0)
        self.center_loc = 'centered'
        self.clearData()
        self.center_hodo(self.centered)
        self.plotData()
        self.update()
        self.parentWidget().setFocus()

    def setMWCenter(self):
        if not tab.utils.QC(self.mean_lcl_el[0]):
            return

        self.centered = (self.mean_lcl_el[0],self.mean_lcl_el[1])
        self.center_loc = 'meanwind'
        self.clearData()
        self.center_hodo(self.centered)
        self.plotData()
        self.update()
        self.parentWidget().setFocus()

    def setSRCenter(self):
        rstu,rstv,lstu,lstv = self.srwind
        self.centered = (rstu, rstv)
        self.center_loc = 'stormrelative'
        self.clearData()
        self.center_hodo(self.centered)
        self.plotData()
        self.update()
        self.parentWidget().setFocus()

    def setAllObserved(self, all_observed, update_gui=True):
        self.all_observed = all_observed

        if update_gui:
            self.clearData()
            self.plotData()
            self.update()
            self.parentWidget().setFocus()

    def wheelEvent(self, e):
        '''
        Handles the zooming of the hodograph.

        Parameters
        ----------
        e: an Event object

        '''
        super(plotHodo, self).wheelEvent(e)
#       self.clearData()
#       self.plotData()

    def mousePressEvent(self, e):
        '''
        Handles when the mouse is pressed.
        Used to set the storm motion vector.

        Parameters
        ----------
        e: an Event object

        '''
        if self.prof is None:
            return

        self.was_right_click = e.button() & QtCore.Qt.RightButton

        if self.cursor_type == 'none' and not self.was_right_click:
            visible = np.where(self.hght <= 12000)

            xs, ys = self.uv_to_pix(self.u[visible], self.v[visible])
            dists = np.hypot(xs - e.x(), ys - e.y())

            if dists.min() < self.clickradius:
                self.initdrag = True
                self.drag_idx = np.argmin(dists)

    def mouseReleaseEvent(self, e):
        if self.cursor_type == 'stormmotion' and not self.was_right_click:
            self.track_cursor = not self.track_cursor
        elif self.cursor_type == 'boundary' and not self.was_right_click:
            if self.track_cursor:
                qp = QtGui.QPainter()
                self.bndy_u, self.bndy_v = self.pix_to_uv(e.x(), e.y())
                self.bndy_dir, self.bndy_spd = tab.utils.comp2vec(self.bndy_u, self.bndy_v)
                y1 = 400*np.sin(np.radians(self.bndy_dir)) + e.y()
                x1 = 400*np.cos(np.radians(self.bndy_dir)) + e.x()
                y2 = e.y() - 400*np.sin(np.radians(self.bndy_dir))
                x2 = e.x() - 400*np.cos(np.radians(self.bndy_dir))
                penwidth = 2
                width = 300
                hght = 14
                # Plot the actual boundary
                boundary_color = QtGui.QColor("#CC9900")
                pen = QtGui.QPen(boundary_color, penwidth)
                qp.begin(self.plotBitMap)
                qp.setRenderHint(qp.Antialiasing)
                qp.setRenderHint(qp.TextAntialiasing)
                qp.setPen(pen)
                qp.drawLine(x1, y1, x2, y2)
                center_rm = QtCore.QPointF(e.x(),e.y())
                qp.setPen(pen)
                pen = QtGui.QPen(boundary_color, 50)
                pen.setStyle(QtCore.Qt.SolidLine)
                qp.drawEllipse(center_rm, 3, 3)

                # Plot the shear vector
                width = 150
                qp = self.setBlackPen(qp)
                rect = QtCore.QRectF(3, self.bry-35, width, hght)
                qp.drawRect(rect)
                shear_color = QtGui.QColor("#0099CC")
                pen = QtGui.QPen(shear_color, penwidth)
                qp.setFont(self.critical_font)
                qp.setPen(pen)
                to_add = self.pix_to_uv(e.x(), e.y())
                x2, y2 = self.uv_to_pix(self.prof.sfc_6km_shear[0] + to_add[0], self.prof.sfc_6km_shear[1]+ to_add[1])
                qp.drawLine(e.x(), e.y(), x2, y2)
                dir, spd = tab.utils.comp2vec(self.prof.sfc_6km_shear[0], self.prof.sfc_6km_shear[1])
                qp.drawText(rect, QtCore.Qt.TextDontClip | QtCore.Qt.AlignLeft, "0 - 6 km Shear: " + tab.utils.INT2STR(dir) + '/' + tab.utils.INT2STR(spd) + ' kts')

                # Plot the 9-11 km Storm Relative Winds
                width = 200
                qp = self.setBlackPen(qp)
                rect = QtCore.QRectF(3, self.bry-20, width, hght)
                qp.drawRect(rect)
                srw_color = QtGui.QColor("#FF00FF")
                pen = QtGui.QPen(srw_color, penwidth)
                qp.setPen(pen)
                x2, y2 = self.uv_to_pix(self.prof.srw_9_11km[0] + to_add[0], self.prof.srw_9_11km[1] + to_add[1])
                qp.drawLine(e.x(), e.y(), x2, y2)
                dir, spd = tab.utils.comp2vec(self.prof.srw_9_11km[0], self.prof.srw_9_11km[1])
                if spd >= 70:
                    supercell_type = "LP"
                elif spd < 70 and spd > 40:
                    supercell_type = "Classic"
                else:
                    supercell_type = "HP"
                qp.drawText(rect, QtCore.Qt.TextDontClip | QtCore.Qt.AlignLeft, "9 - 11 km SR-Wind: " + tab.utils.INT2STR(dir) + '/' + tab.utils.INT2STR(spd) + ' kts - (' + supercell_type + ')')
                # Removing this function until @wblumberg can finish fixing this function.
                """
                # Draw the descrete vs mixed/linear mode output only if there is an LCL-EL layer.
                norm_Shear, mode_Shear, norm_Wind, norm_Mode = self.calculateStormMode()

                if tab.utils.QC(norm_Wind) and self.prof.mupcl.bplus != 0:
                    width = 80
                    qp = self.setBlackPen(qp)
                    rect = QtCore.QRectF(3, self.bry-80, width, hght)
                    qp.drawRect(rect)
                    color = QtGui.QColor(YELLOW)
                    pen = QtGui.QPen(color, penwidth)
                    qp.setPen(pen)
                    qp.drawText(rect, QtCore.Qt.TextDontClip | QtCore.Qt.AlignLeft, "...Storm Mode...")

                    width = 270
                    qp = self.setBlackPen(qp)
                    rect = QtCore.QRectF(3, self.bry-50, width, hght)
                    qp.drawRect(rect)
                    if norm_Wind < 6:
                        color = QtGui.QColor(RED)
                    else:
                        color = QtGui.QColor(MAGENTA)
                    pen = QtGui.QPen(color, penwidth)
                    qp.setPen(pen)
                    qp.drawText(rect, QtCore.Qt.TextDontClip | QtCore.Qt.AlignLeft, "From Cloud Layer Wind - Bndy Diff (" + tab.utils.INT2STR(norm_Wind) + " m/s): " + norm_Mode)
                    width = 200

                    qp = self.setBlackPen(qp)
                    rect = QtCore.QRectF(3, self.bry-65, width, hght)
                    qp.drawRect(rect)
                    if norm_Shear < 15:
                        color = QtGui.QColor(RED)
                    else:
                        color = QtGui.QColor(MAGENTA)
                    pen = QtGui.QPen(color, penwidth)
                    qp.setPen(pen)
                    qp.drawText(rect, QtCore.Qt.TextDontClip | QtCore.Qt.AlignLeft, "From Bndy 0-6 km Shr Diff (" + tab.utils.INT2STR(norm_Shear) + " m/s): " + mode_Shear)
                """
                qp.end()

                self.update()
                self.track_cursor = False
            else:
                self.plotBndy(self.bndy_dir)
                self.clearData()
                self.plotData()
                self.update()
                self.track_cursor = True
        elif self.cursor_type == 'none' and (self.dragging or self.initdrag):
            u, v = self.pix_to_uv(e.x(), e.y())

#           new_u = self.u.copy()
#           new_v = self.v.copy()
#           new_u[self.drag_idx] = u
#           new_v[self.drag_idx] = v

#           new_prof = type(self.prof).copy(self.prof, u=new_u, v=new_v)

            self.modified.emit(self.drag_idx, {'u':u, 'v':v})

            self.drag_idx = None
            self.dragging = False
            self.saveBitMap = None

        self.initdrag = False

    def setBlackPen(self, qp):
        color = QtGui.QColor('#000000')
        color.setAlphaF(.5)
        pen = QtGui.QPen(color, 0, QtCore.Qt.SolidLine)
        brush = QtGui.QBrush(QtCore.Qt.SolidPattern)
        qp.setPen(pen)
        qp.setBrush(brush)
        return qp

    def calculateStormMode(self):
        """
            Logic based off of some of the key findings in Dial et al. (2010)
        """
        dir_06shear, mag_06shear = tab.utils.comp2vec(self.prof.sfc_6km_shear[0], self.prof.sfc_6km_shear[1])
        norm_shear = mag_06shear * np.sin( np.radians( dir_06shear - (self.bndy_dir + 90)) )
        norm_shear = np.abs(tab.utils.KTS2MS(norm_shear))
        if norm_shear < 15: # M/S
            shear_mode = "Linear/Mixed"
        else:
            shear_mode = "Discrete"

        if not tab.utils.QC(self.mean_lcl_el[0]) or (self.mean_lcl_el[0] == 0 and self.mean_lcl_el[1] == 0):
            wind_mode = np.ma.masked
            wind_diff = np.ma.masked
        else:
            dir_cloud, mag_cloud = tab.utils.comp2vec(self.prof.mean_lcl_el[0], self.prof.mean_lcl_el[1])
            norm_cloudmotion = mag_cloud * np.sin( np.radians( dir_cloud - (self.bndy_dir + 90) ) )
            wind_diff = tab.utils.KTS2MS(np.abs(norm_cloudmotion) - self.bndy_spd)
            if wind_diff > 6: # M/S
                wind_mode = "Discrete"
            else:
                wind_mode = "Linear/Mixed"

        return norm_shear, shear_mode, wind_diff, wind_mode

    def plotBndy(self, direction):
        length = 40
        y1 = length*np.sin(np.radians(direction))
        x1 = length*np.cos(np.radians(direction))
        penwidth = 2

        top_x_pix = x1 + length/2
        top_y_pix = y1 + length/2
        bot_x_pix = length/2 - x1
        bot_y_pix = length/2 - y1

        pixmap = QPixmap(length,length)
        pixmap.fill(Qt.transparent)
        painter = QPainter(pixmap)
        boundary_color = QtGui.QColor("#CC9900")
        pen = QtGui.QPen(boundary_color, penwidth)
        painter.setPen(pen)
        painter.drawLine(top_x_pix, top_y_pix, bot_x_pix, bot_y_pix)
        center_rm = QtCore.QPointF(length/2, length/2)
        pen = QtGui.QPen(boundary_color, 2)
        painter.setPen(pen)
        painter.drawEllipse(center_rm, 3, 3)
        painter.end()
        self.setCursor(pixmap)

    def mouseMoveEvent(self, e):
        '''
        Handles the tracking of the mouse to
        provide the dynamic readouts.

        Parameters
        ----------
        e: an Event object

        '''
        if self.cursor_type == 'stormmotion' and self.track_cursor:
            ## convert the location of the mouse to u,v space
            u, v = self.pix_to_uv(e.x(), e.y())
            ## get the direction and speed from u,v
            dir, spd = tab.utils.comp2vec(u,v)
            ## calculate the storm relative helicity for a storm motion
            ## vector with a u,v at the mouse pointer
            srh1km = tab.winds.helicity(self.prof, 0, 1000., stu=u, stv=v)[0]
            srh3km = tab.winds.helicity(self.prof, 0, 3000., stu=u, stv=v)[0]
            ## do some sanity checks to prevent crashing if there is no
            ## effective inflow layer
            etop, ebot = self.prof.etopm, self.prof.ebotm
            if tab.utils.QC(etop) and tab.utils.QC(ebot):
                esrh = tab.winds.helicity(self.prof, ebot, etop, stu=u, stv=v)[0]
                self.esrhReadout.setText('effective: ' + tab.utils.INT2STR(esrh) + ' m2/s2')
            else:
                esrh = np.ma.masked
                self.esrhReadout.setText('effective: ' + str(esrh) + ' m2/s2')
            ## set the crosshair in the window
            self.hband.setGeometry(QRect(QPoint(self.lpad,e.y()), QPoint(self.brx,e.y())).normalized())
            self.vband.setGeometry(QRect(QPoint(e.x(), self.tpad), QPoint(e.x(),self.bry)).normalized())
            ## set the readout texts
            self.wndReadout.setText(tab.utils.INT2STR(dir) + '/' + tab.utils.FLOAT2STR(spd, 1))
            self.srh1kmReadout.setText('sfc-1km: ' + tab.utils.INT2STR(srh1km) + ' m2/s2')
            self.srh3kmReadout.setText('sfc-3km: ' + tab.utils.INT2STR(srh3km) + ' m2/s2')
            ## set the readout width
            self.wndReadout.setFixedWidth(50)
            self.srh1kmReadout.setFixedWidth(120)
            self.srh3kmReadout.setFixedWidth(120)
            self.esrhReadout.setFixedWidth(120)
            ## place the readout
            self.wndReadout.move(1, self.bry-15)
            self.srh1kmReadout.move(self.brx-130, self.bry-45)
            self.srh3kmReadout.move(self.brx-130, self.bry-30)
            self.esrhReadout.move(self.brx-130, self.bry-15)
            ## show the crosshair
            self.hband.show()
            self.vband.show()
        elif self.cursor_type == 'boundary':
            self.hband.hide()
            self.vband.hide()
            u, v = self.pix_to_uv(e.x(), e.y())

            ## get the direction and speed from u,v
            dir, spd = tab.utils.comp2vec(u,v)
            self.plotBndy(dir)
            self.srh3kmReadout.setText('Bndy Motion: ' + tab.utils.INT2STR(dir) + '/' + tab.utils.INT2STR(spd))
            self.srh3kmReadout.setFixedWidth(120)
            self.srh3kmReadout.move(self.brx-130, self.bry-30)
        elif self.cursor_type == 'none' and (self.initdrag or self.dragging):
            self.initdrag = False
            self.dragging = True
            self.dragHodo(e)

    def dragHodo(self, e):
        idx = self.drag_idx
        u, v = self.pix_to_uv(e.x(), e.y())

        u_pts = [ u ]
        v_pts = [ v ]

        lb_idx, ub_idx = max(idx - 1, 0), min(idx + 1, self.u.shape[0] - 1)

        while lb_idx >= 0 and (self.u.mask[lb_idx] or self.v.mask[lb_idx]):
            lb_idx -= 1

        while ub_idx < self.u.shape[0] and (self.u.mask[ub_idx] or self.v.mask[ub_idx]):
            ub_idx += 1

        if lb_idx != -1:
            u_pts.append(self.u[lb_idx])
            v_pts.append(self.v[lb_idx])
        if ub_idx != self.u.shape[0]:
            u_pts.append(self.u[ub_idx])
            v_pts.append(self.v[ub_idx])

        lb_u, ub_u = min(u_pts), max(u_pts)
        lb_v, ub_v = min(v_pts), max(v_pts)

        lb_x, lb_y = self.uv_to_pix(lb_u, ub_v)
        ub_x, ub_y = self.uv_to_pix(ub_u, lb_v)

        qp = QtGui.QPainter()
        qp.begin(self.plotBitMap)

        if self.saveBitMap is not None:
            (origin, size, bmap) = self.saveBitMap
            qp.drawPixmap(origin, bmap, QRect(QPoint(0, 0), size))

        # Capture the new portion of the image to save
        origin = QPoint(max(lb_x - self.drag_buffer, 0), max(lb_y - self.drag_buffer, 0))
        size = QSize(ub_x - lb_x + 2 * self.drag_buffer, ub_y - lb_y + 2 * self.drag_buffer)
        bmap = self.plotBitMap.copy(QRect(origin, size))
        self.saveBitMap = (origin, size, bmap)

        pen = QtGui.QPen(QtGui.QColor('#FFFFFF'), 1, QtCore.Qt.SolidLine)
        qp.setPen(pen)
        if lb_idx != -1:
            prof_x, prof_y = self.uv_to_pix(self.u[lb_idx], self.v[lb_idx])
            qp.drawLine(prof_x, prof_y, e.x(), e.y())
        if ub_idx != self.u.shape[0]:
            prof_x, prof_y = self.uv_to_pix(self.u[ub_idx], self.v[ub_idx])
            qp.drawLine(e.x(), e.y(), prof_x, prof_y)

        qp.end()
        self.update()

    def resizeEvent(self, e):
        '''
        Resize the plot based on adjusting the main window.

        Parameters
        ----------
        e: an Event object

        '''
        super(plotHodo, self).resizeEvent(e)
        self.plotData()

    def paintEvent(self, e):
        '''
        Handles painting the QPixmap onto the QWidget frame.

        Parameters
        ----------
        e: an Event object

        '''
        super(plotHodo, self).paintEvent(e)
        qp = QtGui.QPainter()
        qp.begin(self)
        qp.drawPixmap(0, 0, self.plotBitMap)
        qp.end()

    def clearData(self):
        '''
        Clears/resets the base QPixmap.
        '''
        self.plotBitMap = self.backgroundBitMap.copy()

    def plotData(self):
        '''
        Handles the plotting of the data in the QPixmap.
        '''
        ## initialize a QPainter object
        if self.prof is None:
            return

        qp = QtGui.QPainter()
        qp.begin(self.plotBitMap)
        qp.setRenderHint(qp.Antialiasing)
        qp.setRenderHint(qp.TextAntialiasing)

        cur_dt = self.prof_collections[self.pc_idx].getCurrentDate()
        for idx, prof_coll in enumerate(self.prof_collections):
            # Draw all unhighlighed members
            if prof_coll.getCurrentDate() == cur_dt:
                proflist = prof_coll.getCurrentProfs().values()

                if idx == self.pc_idx:
                    for prof in proflist:
                        self.draw_hodo(qp, prof, self.ens_colors, width=1)
                else:
                    for prof in proflist:
                        self.draw_profile(qp, prof, width=1)

        for idx, prof_coll in enumerate(self.prof_collections):
            # Draw all highlighted members that aren't the active one.
            if idx != self.pc_idx and (prof_coll.getCurrentDate() == cur_dt or self.all_observed):
                prof = prof_coll.getHighlightedProf()
                self.draw_profile(qp, prof)

        ## draw the hodograph
        self.draw_hodo(qp, self.prof, self.colors)
        ## draw the storm motion vector
        self.drawSMV(qp)
        self.drawCorfidi(qp)
        self.drawLCLtoEL_MW(qp)
        if self.cursor_type in [ 'none', 'stormmotion' ]:
            self.drawCriticalAngle(qp)

        qp.end()

    def drawLCLtoEL_MW(self, qp):
        '''
        Draws the LCL to EL mean wind onto the hodo.

        Parameters
        ----------
        qp: a QPainter object

        '''
        penwidth = 2
        pen = QtGui.QPen(QtGui.QColor("#B8860B"), penwidth)
        pen.setStyle(QtCore.Qt.SolidLine)
        qp.setPen(pen)

        try:
            mean_u, mean_v = self.uv_to_pix(self.mean_lcl_el[0],self.mean_lcl_el[1])
            half_length = (8./2.)
            qp.drawRect(mean_u-half_length, mean_v+half_length ,8,8)
        except:
            return
        # This probably needs to be checked.

        color = QtGui.QColor('#000000')
        color.setAlpha(0)
        pen = QtGui.QPen(color, 0, QtCore.Qt.SolidLine)
        qp.setPen(pen)
        v_offset=5; h_offset = 1; width = 40; hght = 12;

        mw_rect = QtCore.QRectF(mean_u+h_offset, mean_v+v_offset, width, hght)
        qp.drawRect(mw_rect)

        pen = QtGui.QPen(QtGui.QColor("#B8860B"))
        qp.setPen(pen)
        qp.setFont(self.label_font)
        mw_str = tab.utils.INT2STR(self.mean_lcl_el_vec[0]) + '/' + tab.utils.INT2STR(self.mean_lcl_el_vec[1])
        qp.drawText(mw_rect, QtCore.Qt.AlignCenter, mw_str)

    def drawCorfidi(self, qp):
        '''
        Draw the Corfidi upshear/downshear vectors

        Parameters
        ----------
        qp: a QPainter object

        '''
        penwidth = 1
        pen = QtGui.QPen(QtGui.QColor("#00BFFF"), penwidth)
        pen.setStyle(QtCore.Qt.SolidLine)
        qp.setPen(pen)

        if not np.isfinite(self.corfidi_up_u) or not np.isfinite(self.corfidi_up_v) or \
            not np.isfinite(self.corfidi_dn_u) or not np.isfinite(self.corfidi_dn_v):
            return

        try:
            up_u, up_v = self.uv_to_pix(self.corfidi_up_u, self.corfidi_up_v)
            dn_u, dn_v = self.uv_to_pix(self.corfidi_dn_u, self.corfidi_dn_v)
            center_up = QtCore.QPointF(up_u, up_v)
            center_dn = QtCore.QPointF(dn_u, dn_v)
            ## draw circles around the center point of the Corfidi vectors
            qp.drawEllipse(center_up, 3, 3)
            qp.drawEllipse(center_dn, 3, 3)
        except:
            return

        up_u, up_v = self.uv_to_pix(self.corfidi_up_u, self.corfidi_up_v)
        dn_u, dn_v = self.uv_to_pix(self.corfidi_dn_u, self.corfidi_dn_v)
        center_up = QtCore.QPointF(up_u, up_v)
        center_dn = QtCore.QPointF(dn_u, dn_v)
        ## draw circles around the center point of the Corfidi vectors
        qp.drawEllipse(center_up, 3, 3)
        qp.drawEllipse(center_dn, 3, 3)

        color = QtGui.QColor('#000000')
        color.setAlpha(0)
        pen = QtGui.QPen(color, 0, QtCore.Qt.SolidLine)
        qp.setPen(pen)
        v_offset=3; h_offset = 1; width = 60; hght = 10;

        up_rect = QtCore.QRectF(up_u+h_offset, up_v+v_offset, width, hght)
        dn_rect = QtCore.QRectF(dn_u+h_offset, dn_v+v_offset, width, hght)
        qp.drawRect(up_rect)
        qp.drawRect(dn_rect)
        ## now make the pen white and draw text using
        ## the invisible rectangles
        pen = QtGui.QPen(QtGui.QColor("#00BFFF"))
        qp.setPen(pen)
        qp.setFont(self.label_font)
        up_stuff = tab.utils.INT2STR(self.upshear[0]) + '/' + tab.utils.INT2STR(self.upshear[1])
        dn_stuff = tab.utils.INT2STR(self.downshear[0]) + '/' + tab.utils.INT2STR(self.downshear[1])
        qp.drawText(up_rect, QtCore.Qt.AlignCenter, "UP=" + up_stuff)
        qp.drawText(dn_rect, QtCore.Qt.AlignCenter, "DN=" + dn_stuff)

    def drawSMV(self, qp):
        '''
        Draws the storm motion vector.

        Parameters
        ----------
        qp: QtGui.QPainter object

        '''
        ## set a pen with white color, width 1, solid line.
        penwidth = 1
        pen = QtGui.QPen(QtGui.QColor(WHITE), penwidth)
        pen.setStyle(QtCore.Qt.SolidLine)
        qp.setPen(pen)
        ## check and make sure there is no missing data
        try:
            mask = np.maximum( self.u, self.v )
            hght = self.hght[~mask]
            u = self.u[~mask]; v = self.v[~mask]
            ## calculate the left and right storm motion vectors
            rstu,rstv,lstu,lstv = self.srwind
            rstu = rstu[~mask]; rstv = rstv[~mask]
            lstu = lstu[~mask]; lstv = lstv[~mask]
        ## otherwise the data is fine
        except:
            hght = self.hght
            u = self.u; v = self.v
            rstu,rstv,lstu,lstv = self.srwind

        # make sure the storm motion exists
        if not tab.utils.QC(rstu) or not tab.utils.QC(lstu):
            return

        ## convert the left and right mover vector components to pixel values
        ruu, rvv = self.uv_to_pix(rstu,rstv)
        luu, lvv = self.uv_to_pix(lstu, lstv)
        ## calculate the center points of the storm motion vectors
        center_rm = QtCore.QPointF(ruu,rvv)
        center_lm = QtCore.QPointF(luu,lvv)
        ## draw circles around the sorm motion vectors
        qp.drawEllipse(center_rm, 5, 5)
        qp.drawEllipse(center_lm, 5, 5)

        ## get the effective inflow layer
        ptop, pbottom = self.ptop, self.pbottom
        ## make sure the effective inflow layer and storm motion vectors exist
        if tab.utils.QC(ptop) and tab.utils.QC(pbottom):
            ## get the interpolated wind at the bottom and top
            ## of the effective inflow layer
            utop,vtop = tab.interp.components(self.prof, ptop)
            ubot,vbot = tab.interp.components(self.prof, pbottom)
            ## convert these values to pixels
            uutop, vvtop = self.uv_to_pix(utop, vtop)
            uubot, vvbot = self.uv_to_pix(ubot, vbot)
            ## set a pen
            pen = QtGui.QPen(QtGui.QColor("#00FFFF"), penwidth)
            pen.setStyle(QtCore.Qt.SolidLine)
            qp.setPen(pen)
            ## draw lines showing the effective inflow layer
            qp.drawLine(center_rm.x(), center_rm.y(), uubot, vvbot)
            qp.drawLine(center_rm.x(), center_rm.y(), uutop, vvtop)

        color = QtGui.QColor('#000000')
        color.setAlpha(0)
        pen = QtGui.QPen(color, 0, QtCore.Qt.SolidLine)
        qp.setPen(pen)
        h_offset = 2; v_offset=5; width = 55; hght = 12;
        rm_rect = QtCore.QRectF(ruu+h_offset, rvv+v_offset, width, hght)
        lm_rect = QtCore.QRectF(luu+h_offset, lvv+v_offset, width, hght)
        qp.drawRect(rm_rect)
        qp.drawRect(lm_rect)
        ## now make the pen white and draw text using
        ## the invisible rectangles
        pen = QtGui.QPen(QtGui.QColor("#FFFFFF"))
        qp.setPen(pen)
        qp.setFont(self.label_font)
        rm_stuff = tab.utils.INT2STR(self.bunkers_right_vec[0]) + '/' + tab.utils.INT2STR(self.bunkers_right_vec[1])
        lm_stuff = tab.utils.INT2STR(self.bunkers_left_vec[0]) + '/' + tab.utils.INT2STR(self.bunkers_left_vec[1])
        qp.drawText(rm_rect, QtCore.Qt.AlignCenter, rm_stuff + " RM")
        qp.drawText(lm_rect, QtCore.Qt.AlignCenter, lm_stuff + " LM")

    def drawCriticalAngle(self, qp):
        '''
        Plot the critical angle on the hodograph and show the value in the hodograph.

        Parameters
        ----------
        qp : QtGui.QPainter object
        '''

        if tab.utils.QC(self.ptop) and tab.utils.QC(self.pbottom):
            # There is an effective inflow layer at the surface so draw the critical angle line
            ca_color = QtGui.QColor("#FF00FF")
            pres_500m = tab.interp.pres(self.prof, tab.interp.to_msl(self.prof, 500))
            u500, v500 = tab.interp.components(self.prof, pres_500m)
            sfc_u, sfc_v = tab.interp.components(self.prof, self.prof.pres[self.prof.get_sfc()])
            sfc_u_pix, sfc_v_pix = self.uv_to_pix(sfc_u,sfc_v)
            u500_pix, v500_pix = self.uv_to_pix(u500, v500)
            pen = QtGui.QPen(ca_color, 1.0, QtCore.Qt.SolidLine)
            qp.setPen(pen)
            qp.drawLine(sfc_u_pix, sfc_v_pix, u500_pix, v500_pix)
            vec1_u, vec1_v = u500 - sfc_u, v500 - sfc_v
            try:
                mask = np.maximum( self.u, self.v )
                rstu,rstv,lstu,lstv = self.srwind
                rstu = rstu[~mask]; rstv = rstv[~mask]
            except:
                rstu,rstv,lstu,lstv = self.srwind

            if tab.utils.QC(rstu) and tab.utils.QC(lstu):
                qp = self.setBlackPen(qp)
                rect = QtCore.QRectF(15, self.bry-36, 140, self.critical_height + 5)
                qp.drawRect(rect)
                ca_text_color = QtGui.QColor("#00FFFF")
                pen = QtGui.QPen(ca_text_color, 1.0, QtCore.Qt.SolidLine)
                qp.setPen(pen)
                qp.setFont(self.critical_font)
                offset = 10
                qp.drawText(rect, QtCore.Qt.AlignLeft, 'Critical Angle = ' + tab.utils.INT2STR(self.prof.critical_angle))

    def draw_hodo(self, qp, prof, colors, width=2):
        '''
        Plot the Hodograph.

        Parameters
        ----------
        qp: QtGui.QPainter object

        '''
        ## check for masked daata
        try:
            mask = np.maximum(prof.u.mask, prof.v.mask)
            z = tab.interp.to_agl(prof, prof.hght[~mask])
            u = prof.u[~mask]
            v = prof.v[~mask]
        ## otherwise the data is fine
        except:
            z = tab.interp.to_agl(prof, prof.hght )
            u = prof.u
            v = prof.v
        ## convert the u and v values to x and y pixels
        xx, yy = self.uv_to_pix(u, v)
        ## define the colors for the different hodograph heights
        penwidth = width
        seg_bnds = [0., 3000., 6000., 9000., 12000.]
        seg_x = [ tab.interp.generic_interp_hght(bnd, z, xx) for bnd in seg_bnds ]
        seg_y = [ tab.interp.generic_interp_hght(bnd, z, yy) for bnd in seg_bnds ]

        seg_idxs = np.searchsorted(z, seg_bnds)
        for idx in xrange(len(seg_bnds) - 1):
            ## define a pen to draw with
            pen = QtGui.QPen(colors[idx], penwidth)
            pen.setStyle(QtCore.Qt.SolidLine)
            qp.setPen(pen)

            path = QPainterPath()
            path.moveTo(seg_x[idx], seg_y[idx])
            for z_idx in xrange(seg_idxs[idx] + 1, seg_idxs[idx + 1]):
                path.lineTo(xx[z_idx], yy[z_idx])
            path.lineTo(seg_x[idx + 1], seg_y[idx + 1])

            qp.drawPath(path)

    def draw_profile(self, qp, prof, color="#6666CC", width=2):
        '''
        Plot the Hodograph.

        Parameters
        ----------
        qp: QtGui.QPainter object

        '''
        ## check for masked daata
        try:
            mask = np.maximum(prof.u.mask, prof.v.mask)
            z = tab.interp.to_agl(prof.prof, prof.hght[~mask])
            u = prof.u[~mask]
            v = prof.v[~mask]
        ## otherwise the data is fine
        except:
            z = tab.interp.to_agl(prof, prof.hght )
            u = prof.u
            v = prof.v
        ## convert the u and v values to x and y pixels
        xx, yy = self.uv_to_pix(u, v)

        penwidth = width
        pen = QtGui.QPen(QtGui.QColor(color), penwidth)
        pen.setStyle(QtCore.Qt.SolidLine)
        qp.setPen(pen)
        qp.setBrush(Qt.NoBrush)

        seg_bnds = [0., 3000., 6000., 9000., 12000.]
        seg_x = [ tab.interp.generic_interp_hght(bnd, z, xx) for bnd in seg_bnds ]
        seg_y = [ tab.interp.generic_interp_hght(bnd, z, yy) for bnd in seg_bnds ]

        seg_idxs = np.searchsorted(z, seg_bnds)
        for idx in xrange(len(seg_bnds) - 1):
            ## define a pen to draw with
            pen = QtGui.QPen(QtGui.QColor(color), penwidth)
            pen.setStyle(QtCore.Qt.SolidLine)
            qp.setPen(pen)

            path = QPainterPath()
            path.moveTo(seg_x[idx], seg_y[idx])
            for z_idx in xrange(seg_idxs[idx] + 1, seg_idxs[idx + 1]):
                path.lineTo(xx[z_idx], yy[z_idx])
            path.lineTo(seg_x[idx + 1], seg_y[idx + 1])

            qp.drawPath(path)

redpajama_set_name: RedPajamaGithub


Criterion's May 2011 Assault on Your Wallet | Birth.Movies.Death.
In May, Criterion is bringing us three more new titles paired with four Blu-ray upgrades, and one of the more eclectic mixes they've done in a while.
Which ones are must-buys for you, in this rare month of seven releases?


Safety and security at GC2018 has been raised higher with innovative sensing solutions being provided by GOLDOC's newest sponsor.
As the official Video Security Provider of GC2018, FLIR Systems Inc. (FLIR) will provide surveillance equipment, including security cameras and video management software to help national and local law enforcement provide safety and security at the Games this April.
Founded in 1978, FLIR is a world-leading maker of sensor systems that enhance perception and heighten awareness.
With a vision to be 'The World's Sixth Sense', FLIR look to leverage thermal imaging and adjacent technologies to provide innovative, intelligent solutions for security and surveillance, environmental and condition monitoring, outdoor recreation, machine vision, navigation and advanced threat detection.
"FLIR is honoured to be selected as the official supplier of video security for Gold Coast 2018 Commonwealth Games," said Travis Merrill, President of FLIR Commercial Business Unit.
"FLIR products will provide wide area, 24/7 surveillance to ensure the protection of the Gold Coast community, guests, and athletes.
FLIR infrared cameras show temperature differences over entire surfaces.
To protect the high-profile international event, FLIR will provide a mix of thermal imaging cameras that operate day and night, through light fog or smoke, ensuring continual observation and accurate detection capabilities.
In many cases, cameras will also be equipped with embedded video analytics and will detect threats and stream live information to allow rapid response to security events at Games' venues.
"Public safety is our number one priority and we are determined to make sure all athletes and spectators are able to enjoy GC2018," said GOLDOC Chairman, Peter Beattie AC.
"The Games are a major sporting event - not a security event – and importantly for fans, we are using a number of products, like those being delivered by FLIR, to provide a safe and secure environment while still allowing for efficient access to venues for patrons, athletes and officials in an unobtrusive manner."
To learn more about FLIR security products and solutions, visit flir.com/security.


text:
Home News Stocks Infosys to consider share buyback on Saturday
Infosys to consider share buyback on Saturday
Author: IANS/Thursday, August 17, 2017/Categories: Stocks
Bengaluru - The Infosys Board of Directors will meet on August 19 to consider a proposal for buyback of its equity shares of Rs 5 face value, said the global software major.
"The Board of Directors will consider a proposal for buyback of equity shares of the company at its meeting to be held on August 19," said the IT major in a regulatory filing on the BSE.
The outcome of the Board will be notified to the stock exchanges (BSE and NSE) on the same day.
In view of the Board meeting on the share buyback, the company closed the trading window with immediate effect and will re-open on August 22, said Company Secretary A.G.S. Manikantha in the filing.
The company on April 13 hinted at the buyback during this fiscal (2017-18) up to Rs 13,000 crore.
The company's blue chip scrip opened at the BSE at Rs 1,010 per share on Thursday, gaining Rs 33.40 (3.40%) during the early hours of trading session from August 16's closing price of Rs 976.80 per share.
The Infosys buyback comes nearly a month after rival Wipro announced on July 20 to buyback 343.75 equity shares of Rs 2 each for Rs 11,000 crore at Rs 320 per share.
Indian IT bellwether Tata Consulting Services (TCS) completed buyback of its 5.6 crore equity shares of Re 1 each on May 31 at Rs 2,850 per share, with the attractive offer oversubscribed by 221% or 12.4 crore shares.
The country's fourth largest software services firm HCL Technologies completed buyback of 3.5 crore equity shares of Rs 2 face value at Rs 1,000 per share on June 23.
Small stocks fail to impress; fall up to 13% so far in 2018
TCS first company to close over Rs 7 lakh crore m-cap
Kingfisher Airlines among 18 firms to be delisted from NSE
Seven of top 10 cos add Rs 69,918 cr in m-cap
Axis Bank shares surge over 5%; mcap increases by Rs 7,212 cr
Tags: BSEInfosysNSETCSbuybackTata Consulting Services
S Vijaykrishnan

redpajama_set_name: RedPajamaCommonCrawl


text:
Liberty Hamilton
Assistant Professor, Assistant Professor of Neurology
Department of Speech, Language, and Hearing Sciences, Department of Neurology
liberty.hamilton@austin.utexas.edu
CMA 4.116B
2504 A WHITIS AVE
Liberty Hamilton joins the CSD faculty in the Fall of 2017 as an Assistant Professor. Her research interests include how speech sounds are represented in the auditory cortex and how these representations change during learning, development, and as a result of plasticity. To investigate this, she applies computational methods to intracranial electrophysiological recordings from patients undergoing surgical treatment for epilepsy. This work involves collaborations with clinicians and epileptologists at Austin's Dell Children's Hospital and through the UT Dell Medical School. Dr. Hamilton also teaches Anatomy and Physiology of the Auditory System (CSD 391P/Q). She has co-authored research that has been published in journals including Science, Neuron, The Journal of Neuroscience, and the Journal of the Acoustical Society of America. She has also presented her research at conferences both nationally and internationally.
Dr. Hamilton earned her Ph.D. in neuroscience from the University of California, Berkeley in 2013 in the laboratory of Dr. Shaowen Bao, where she studied sound representation and plasticity in the auditory cortex using multi-unit electrophysiological recordings. This work was funded by an NSF Graduate Research Fellowship. She completed her postdoctoral training with Dr. Edward Chang at the University of California, San Francisco, where she investigated how the human auditory cortex represents speech sounds using intracranial recordings in adult patients with intractable epilepsy. This work was funded by an NIH Ruth Kirschstein National Research Service Award (NRSA). She also has previous research experience in non-invasive methods for measuring brain structure and function, including structural magnetic resonance imaging (MRI), functional MRI (fMRI), and diffusion tensor imaging (DTI).
Tang C, Hamilton LS, Chang EF. Intonational speech prosody encoding in the human auditory cortex. Science. 2017 Aug 25;357(6353):797-801. doi: 10.1126/science.aam8577.
Hamilton LS, Sohl-Dickstein J, Huth AG, Carels VM, Deisseroth K, Bao S. Optogenetic activation of an inhibitory network enhances feedforward functional connectivity in auditory cortex. Neuron. 2013 Nov 20;80(4):1066-76. doi: 10.1016/j.neuron.2013.08.017.
Institute for Neuroscience


The curated shopping experience is an antidote to big-box blues.
Using unconventional thinking and smart design processes, Arik Levy transforms everyday household objects into beautiful works of art.
Developer Solidere has succeeded in restoring downtown as a meaningful public realm.
With a new block-size park by Herbert Dreiseitl, Portland restores a piece of its natural environment.
Philip Freelon built his practice from the ground up—and now he's the go-to architect for African-American cultural commissions.
A Russian fashion boutique is reimagined using an off-the-shelf material.
In a new maritime-inspired branch library, a Seattle neighborhood has gotten a design that perfectly fits its values.
If you judge the greatness of a city solely by the swiftness and ease of the ride in from the airport, New York is a cow town compared to Hong Kong.
Some of the architect's original furniture designs are now being put into production.
Targeting Asian tourists, Louis Vuitton's new Paris flagship defies French expectations of luxury.
MVRDV converts a pair of soybean silos in Copenhagen into an exclusive apartment building.
Designed by Michael Van Valkenburgh Associates, Brooklyn Bridge Park seems destined to become New York's third great urban landscape.
CATIA gets its due in an intricate installation at the Storefront for Art and Architecture.
Expertise as an architect or planner may not qualify you as an astute political analyst.


A report of findings from a Municipal Management Priorities Survey prepared for the Chrostwaite Institute, an organization focused on research and government efficiency, illustrates that capital infrastructure maintenance and improvement is a top-rated priority for more than 21 percent of municipal governments. Infrastructure also ranked as the highest-rated priority on average across the 15 broad initiatives included in the survey.
The management priorities' survey was distributed in 2017 to 1,058 municipalities with 2,500 or more residents. The survey sample included 322 boroughs; 53 third class cities; 83 first class townships; 599 second class townships; and one town. Of these, 633 surveys were completed representing a 60 percent rate of return.
The survey and its findings, prepared by Beverly A. Cigler, Ph.D., distinguished professor emerita at Penn State University, were supported by the Pennsylvania State Association of Boroughs and PA Borough Councils Association.
The purpose of the survey was to determine what issues were the most important for municipalities across the state and to explore any significant differences in municipal priority rankings. The findings indicate that priorities often vary among cities, boroughs, and townships.
For example, blight prevention and remediation had the fifth most top-priority ratings of all the initiatives. Fifty-eight percent of city respondents rated blight prevention and remediation as a top priority. By comparison, 26 percent of borough respondents rated blight a top priority, while only 10 percent of first class township and 5 percent of second class township respondents rated blight at the highest priority level.
Following infrastructure, obtaining grants and intergovernmental revenues, stormwater management, and community development were the second through fourth highest ranked priorities, respectively. Community development ratings provide another example of divergence in priority by municipal form. Forty-five percent of city respondents rated the initiative at the top-priority level compared to 25 percent of first class townships, 21 percent of boroughs, and 11 percent of second class townships.
City respondents were also more likely to list pension costs as a top priority – at 37.5 percent of respondents —relative to 16 percent of first class townships respondents, 8.4 percent of second class townships, and 8 percent of borough respondents.
Initiatives having the lowest number of top priority ratings were infill development/redevelopment; provision of services via the internet; and human resources management.
Over the past 10 years, 39 percent of respondents said their municipality's population size increased; 18 percent said it decreased; and 40 percent said it remained the same.
Just under 40 percent of municipal comprehensive plans have been reported to have been updated within the past five years, and nearly 25 percent have not been updated in over a decade.
Nearly 50 percent of respondents reported having general fund revenues between $1 and $5 million; 27.2 percent reported having revenues less than or equal to $1 million; and 23.2 percent reported having revenues over $5 million.
Approximately 60 percent of survey respondents have their own police department; 28 percent use State Police; 8 percent are members of a regional police force; and 3 percent contract with a neighboring department.
Respondents from cities perceive their communities to have numerous issues and initiatives that they rate as highest priority, while respondents from boroughs and townships were less likely to rate as many initiatives at the highest priority level.
To view the full report of findings, visit www.chrostwaite.com.
The Chrostwaite Institute is an independent, non-partisan, non-profit organization dedicated to research and analysis. It focuses on such key areas as government efficiency, community investment, transportation, water infrastructure, economic development, and the promotion of civic engagement in local communities. Visit www.chrostwaite.com for more information.
The Pennsylvania State Association of Boroughs (PSAB) is a statewide non-partisan, non-profit organization dedicated to serving 956 borough governments. Since 1911, PSAB has represented the interests of boroughs and helped to shape the laws that laid their foundation. The Association improves and assists local governments through legislative advocacy, research, education, and other services. With more than 2.6 million Pennsylvanians residing in borough communities, our members strive to deliver quality leadership and service to citizens across the Commonwealth.
The Borough Councils Association (BCA) represents more than 6,000 borough council members across PA. The BCA provides educational programming to its members. For more information, visit https://boroughs.org/bca.


text:
Bullet Symphony: Horns and Halos #3 — четвертий спільний альбом американських реперів Андре Нікатіни й Equipto, виданий 12 грудня 2006 р. лейблом Fillmoe Coleman Records. Є третім, останнім релізом із серії Horns and Halos. Виконавчі продюсери: Fillmoe Coleman, Equipto. Оформлення: Боб Гопкінс. Мастеринг, зведення: Джастін Вейс. Зведення, звукорежисер, координатор проекту: Нік Піс. Зведення «Comb My Hair Like»: Алафі Фінні, One Drop Scott.

Список пісень

Посилання

Альбоми Андре Нікатіни
Англомовні музичні альбоми

redpajama_set_name: RedPajamaWikipedia


SALT LAKE CITY (ABC 4 Utah) – As part of National Safety Month, Smiths Food and Drug is stepping up their safety measures when it comes to shopping carts their customers put their kids in.
According to a recent study, each day 66 kids are sent to the emergency room for shopping cart related injuries. "That's a scary number for sure," said Carlee Johnson who was out shopping with her 11 month old at Smiths in Salt Lake.
Johnson says she is shocked to learn so many children are injured from shopping carts and says it's too bad her 11 month old is too old to use the new "Safe-Dock's" Smith's Food and Drug is offering its customers. However, she's happy to see the grocery store is helping parents keep kids secure. "When my baby was really little I would just put him in a stroller because I didn't think the cart was a safe option," said Johnson.
Smith's recognized that concern and started making changes. "We invested a quarter of a million dollars to buy these and put them in all of our stores throughout our area, because we think it's going to be a great security and convenience for our families," said Marsha Gilford, Smith's Food and Drug spokesperson.
According to the recent study conducted by the Center for Injury Research and Policy of the Research Institute at Nationwide Children's Hospital, 530,494 children were treated to shopping cart related injuries in the emergency room between 1990 and 2011. Those numbers translate to 24,000 per year and 66 per day.
Now, with the new "Safe-Dock" Smiths Food and Drug hopes to reduce those numbers, but they need parents to make sure they are using them correctly. "It's strictly for car seat usage. If the child is able to sit up they should be in a normal cart with the seat," said Gilford.
So, although the safe dock isn't for Johnson's baby boy she thinks it's a great solution for other parents trying to get their shopping in. "I think it's great they have different options for parents so they can bring their kids to the grocery store," said Johnson.
All Smith Food and Drug locations in Utah should have directions in both English and Spanish posted near the shopping carts on how to safely use the Safe-dock. If a location does not have Safe-Docks available ask for the store director, who can assist you.


text:
Service dogs funded in young showjumper's memory
Lucy Elder 7 February, 2017 12:34
Four dogs who will be trained to help people with special needs have been secured through a memorial fund for a young showjumper.
British citizen Billie Kinder was 12 years old when she died in an accident at home in Sydney last May.
A talented rider, her wins included titles at the New South Wales Interschools Championships in 2015.
She was also a member of Sydney Showjumping Club and volunteered with the Riding for the Disabled Association.
Following her death, Billie's family released a collection of her poems and other writings — titled Hope — in honour of her wish to write a book.
Money raised through its sales is given to charities through the Billie Kinder Foundation to help young people in palliative care or who need assistance dogs.
Funds from the book have already gone towards three dogs in Australia, and now the trust has secured a puppy in the UK through charity Dogs for Good.
The Labrador cross golden retriever, named Hope, is 14 months old and is being prepared to become a fully-trained assistance dog.
"Hope is now learning all about the world around her, looked after by her volunteer puppy socialiser," a Dogs for Good spokesman told H&H.
She is attending puppy classes and is also learning to cope with busy places, such as shopping centres, trains, and buses, that she will encounter as a working dog.
"At around 16 to 17 months old, Hope will start work with Dogs for Good trainers and instructors," added the spokesman.
"She will spend around six to eight months learning the vital skills she needs such as picking up dropped items, fetching the phone, loading and unloading the washing machine, calling lifts and helping someone dress and undress.
"[She will also learn] how to distract or comfort a child with autism when they're angry, anxious or distressed and to keep them safe when they are out and about."
Young showjumper's family publish book in her memory
Tributes paid to Billie Kinder
Billie's book is published independently by her parents, Danny and David Kinder, and is being sold in more than 12 countries.
"When we first thought of publishing Billie's writing we couldn't imagine just how the book would take off, but it has created its own momentum with families, libraries and we are now also hearing from orphanages," said Danny.
"To be able to support the provision of Response Dogs to help young people in need is a wonderful legacy and we know that Billie would have been proud to be helping other children."
The first proceeds from the book went to Bear Cottage, a palliative care home in Sydney for children and their families, to pay for their resident dog named Frankie.
A seizure response dog has also been secured for a six-year-old with epilepsy, and the third donation went to assistance dogs Australia to help fund a autism service dog for a child.


Hemp is cannabis that contains less than 0.3% THC, and four years ago it was completely illegal.
The Hemp Farming Act of 2018, cosponsored by Sen. Rand Paul (R-KY), Sen. Ron Wyden (D-OR), and Rep.
open the way for researchers to apply for grants from the US Department of Agriculture, and allow for state regulation of the plant.
beneficial cannabinoid that can be extracted from all forms of the cannabis plant, including hemp.
Hemp is legally defined as cannabis that contains less than 0.3% THC, the intoxicating cannabinoid in marijuana.
There are no limits on the amount of CBD that may be contained in hemp.
cannabis as a Schedule I substance.
the same as its distant cousin?
I think we've moved past that. I think most members of the Senate now understand it's two very different plans.
production to 12,000 acres in less than four years.
seeds in their 40-foot by 40-foot plot.
were to be legalized nationwide.
full-time jobs in the West Kentucky farming community.
said at the groundbreaking ceremony.


We are committed to give our member-owners the most reliable, cost-effective services possible.
life for our members, our employees, and our communities.
Western Illinois Electrical Coop. is a member-owned electrical cooperative based in Carthage, Illinois. Organized in 1938, WIEC was established to bring the convenience of electricity to the rural areas of Hancock and Henderson Counties. Since that time, we have been committed to give our 3,600 (and growing) members the best customer service possible and along with reliable electric service.
One of the founding principles of WIEC is that we are owned by those we serve. The members have a voice in who represents them. WIEC is governed by a seven member board of directors, who are elected to a three-year term.
The directors are elected by the members at our Annual Meeting, which is usually held on the third Thursday in June.


text:
10/01/2017 4:35 PM IST | Updated 10/01/2017 4:46 PM IST
Delhi Traffic Policeman Returns Wallet With Cash To Owner, Goes Viral On Facebook
By Anahita Khanna
Jagpreet Singh/Facebook
In a heartwarming incident, a sub-inspector with the Delhi Police trended on Facebook on Monday, after an east Delhi businessman took to social media to share the story of how the cop returned his missing wallet. Madan Singh, a 54-year-old policeman, not only returned the wallet but also refused to accept a reward of ₹5,000.
On 7 January, at around 9.30 a.m., Jagpreet Singh lost his wallet near the Nizamuddin bridge. He was returning home from Defence Colony to Preet Vihar when his car broke down. "I had to push my car to start it. The wallet must have slipped then," Singh said.
Fortunately, Madan Singh noticed a cyclist picking up a wallet from the road. He immediately chased the cyclist and asked him to hand over the wallet. "There was a lot of money, foreign currency, ATM cards, driving licence and visiting cards. It did not belong to that cyclist. I spotted the visiting card and called the man," said Singh.
Jagpreet had lost all hope of finding his wallet and that's when he received a call from the traffic cop. "Sub-inspector Singh told me to come to Nizamuddin and collect the wallet. I thought he must have found an empty wallet with only my identity card. It had around ₹35,000 and $300. But to my surprise, everything was there in my wallet, untouched and safe," he wrote in his Facebook post.
"It is rare to find an honest man such as Singh. I even offered him ₹5,000 for his honesty but he refused saying he was only doing his duty. This was a story I had to share to the world. I did not know it would go viral. Singh was even shy to pose for a photograph but I convinced him," he added.
"We appreciate Singh's honest efforts. He has made us proud. We will recommend a suitable reward for him so that others get inspiration from his story," said DK Gupta, Madan Singh's boss.
The Facebook post lauding Madan Singh's honesty has been shared over 2,000 times.
Also on HuffPost India
Photo gallery 'Indica: A Deep Natural History Of The Indian Subcontinent' Is More Compelling Than Sci-Fi See Gallery
'Indica: A Deep Natural History Of The Indian Subcontinent' Is More Compelling Than Sci-Fi
Anahita Khanna Editorial Fellow
MORE: delhi delhi police facebook honest traffic cop news traffic police


text:
Q: European wattmeter symbol I am very new at circuitikz.  I have most of the european symbols I need, but now I need to make this simple wattmeter symbol and I do not know how.
One could start with the european voltage source symbol.  The horizontal line inside the circle should also be thicker than the example to clearly show the current coil.
Any help would be very nice.

A: There is no such a symbol; the only wattmeter in circuitikz is this:

But you can use the rmeter (or even rmeterwa if you fancy the metering arrow):

For example like this:
\documentclass[border=10pt]{standalone}
\usepackage[siunitx, RPvoltages]{circuitikz}
\begin{document}
\begin{circuitikz}[
    ]
    \draw (0,0) |- ++(1,1) to[rmeter, name=W] ++(2,0);
    % add the lines to the rmeter
    \draw [very thick] (W.west) -- (W.east);
    \draw (W.north) -- (W.south);
    % leads
    \draw (0,0) to[short, *-] (W.south|- 0,0) -- (W.south);
    \draw (W.north) |- ++(1,1);
\end{circuitikz}
\end{document}

A: This is a long comment to the accepted answer above.
Please vote if you agree that the symbols below would be useful!

I propose a uniform set of symbols for active- reactive- and apparent power meters as below as well as restricting ammeters and voltmeters in the same circuits to those above.  Sample code (bad sample code) follows:
\documentclass[border=3mm]{standalone}
\usepackage{comment}

\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{lmodern}

% Overall font to Times New Roman
%\usepackage{fontspec}
%\setmainfont{Times New Roman}

% Add a period (.) after the clause numbering (in the actual document, NOT toc)
\makeatletter
\def\@seccntformat#1{\csname the#1\endcsname.\quad}
\makeatother

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Source: http://en.wikibooks.org/wiki/LaTeX/Hyperlinks %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\usepackage{hyperref}
\usepackage{graphicx}
\usepackage{amsmath,amsfonts,amssymb}
\usepackage{booktabs}
\usepackage{IEEEtrantools}

\usepackage{tikz,pgfplots}   %TikZ is required for this to work.  Make sure this exists before the next line
%\usepackage{tikz-3dplot} %requires 3dplot.sty to be in same directory, or in your LaTeX installation

\usetikzlibrary{arrows,pgfplots.groupplots}
\pgfplotsset{compat = 1.10}
\usepgfplotslibrary{fillbetween}
\usetikzlibrary{calc}
\usepackage[siunitx,european,oldvoltagedirection]{circuitikz}
\tikzset{voltage dir = RP}
%\usetikzlibrary{external}
%\tikzexternalize[prefix=tikz/]
%\tikzexternalize[prefix=tikz/,optimize command away=\includepdf]

\usepackage{pgf,siunitx}
\sisetup{output-decimal-marker = {,}}
\SendSettingsToPgf

\usepackage{steinmetz} %for phase angles
\usepackage{xpatch}
\xpatchcmd{\phase}{#2}{\vphantom{,}#2}{}{}

\usepackage[iso,english]{isodate}
\renewcommand*\date[1]{{\isodate{#1}}}

\usepackage[backend=biber,style=iso-authoryear]{biblatex}
\addbibresource{Biblio.bib}
% omit page numbers from citations
\DeclareFieldFormat{postnote}{#1}
\DeclareFieldFormat{multipostnote}{#1}

\usepackage{csquotes}
\usepackage[acronym,nonumberlist]{glossaries}
\input{terms}
\input{abbrv}
\makeglossaries

\usepackage[UKenglish]{babel}

\usepackage{bm}
\DeclareSIUnit\kVA{kVA}
% \mbf bold upright math
% \mbs bold italic math
\makeatletter
  \AtBeginDocument{%
  % For mtpro2 users, switch \mathbold to \mbs
  \@ifpackageloaded{mtpro2}{\let\mbs\mathbold}{\let\mbs\bm}
  % For non-mtpro2 users, switch \mbf to \mathbf
  \@ifpackageloaded{mtpro2}{}{\let\mbf\mathbf} }
\makeatother
\renewcommand\vec{\bm}
\def\j{\ensuremath{\mbf{j}}}
\def\Z{\ensuremath{\vec{Z}}}
\def\u{\ensuremath{\vec{u}}}
\def\i{\ensuremath{\vec{i}}}
\def\S{\ensuremath{\vec{S}}}
\def\aa{\ensuremath{\mbf{a}}}
\def\a{\ensuremath{\vec{a}}}
\def\b{\ensuremath{\vec{b}}}
\def\c{\ensuremath{\vec{c}}}
\def\cc{\ensuremath{\boldsymbol{^*}}}
\def\A{\ensuremath{\vec{A}}}
\def\B{\ensuremath{\vec{B}}}
\def\C{\ensuremath{\vec{C}}}
\def\U{\ensuremath{\vec{U}}}
\def\I{\ensuremath{\vec{I}}}
\def\Re{\ensuremath{\mathrm{Re}}}
\def\Im{\ensuremath{\mathrm{Im}}}
\def\d{\ensuremath{\mathrm{d}}}
\def\rms{\ensuremath{\mathrm{RMS}}} % see IEC 60050 effective value
\def\eff{\ensuremath{\mathrm{eff}}}
\def\pf{\ensuremath{\mathrm{pf}}}
\def\E{\ensuremath{\mathrm{E}}}
\def\e{\ensuremath{\mathrm{e}}}
\def\ohm{\ensuremath{\mathrm{\Omega}}}
\def\ac{a.c.\,}
\def\dc{d.c.\,}
\begin{document}
\begin{circuitikz}
    { % power meter, active -  P [W], reactive - Q [var] and apparent - \S [VA]
      % proposed unified symbol for use - also Q1-Q4 implied in symbol
      % the diagonal link symbol might also be angular or omitted.
    \draw (0.5,5) to [open] (1,5) to [rmeter, name=W,i_=$I_a$] ++(1.8,0);
    \draw [very thick] (W.west) -- (W.east);
    \draw (W.north) to [open] (W.south) node[anchor=south]{\scriptsize[\si{VA}]};
    \draw (W.west) ++(-0.5,0)  to [short, o-] (W.east) to [short, -o] ++(0.5,0);
    \draw (W.west) to[short,l={$\S_a$}] (W.east);
    \draw (W.south) ++(0,-0.5)  to [short, o-] (W.south) (W.north) to [short, -o] ++(0,+0.5);
    \draw ($(W.north)+(0,+0.25)$) to [short, *-*] ($(W.west)-(0.25,0)$) ;
    \draw ($(W.south)-(0,0.5)$) to [open, v>=~, voltage shift=1.0] ($(W.north)+(0,0.5)$);
    \draw ($(W.north)+(0.25,0.25)$) node[anchor=west]{$U_a$};
    }
    { % voltmeter All voltmeters are vertically connected
    \draw (3,5) to [open] (3.15,5) to [rmeter, name=U,] ++(0.85,0);
%    \draw [very thick] (W.west) -- (W.east);
    \draw (U.north) to [open] (U.south) node[anchor=south]{\scriptsize[\si{V}]};
%    \draw (U.west) ++(-0.5,0)  to [short, o-] (W.east) to [short, -o] ++(0.5,0);
    \draw ($(U.west)+(0.2,0)$) to [short,l={$U_a$}] ($(U.east)-(0.2,0)$);% package error when open!!!!
    \draw (U.south) ++(0,-0.5)  to [short, o-] (U.south) (U.north) to [short, -o] ++(0,+0.5);
%    \draw ($(U.north)+(0,+0.25)$) to [short, *-*] ($(U.west)-(0.25,0)$) ;
    \draw ($(U.south)-(0,0.5)$) to [open, v>=~, voltage shift=1.0] ($(U.north)+(0,0.5)$);
    \draw ($(U.north)+(0.25,0.25)$) node[anchor=west]{$U_a$};
    }
    { % ammeter All ammeters are vertically connected
    \draw (4.0,5) to [open] (4.5,5) to [rmeter, name=A,i_=$I_a$] ++(1.8,0);
    \draw [very thick] (A.west) -- (A.east);
    \draw (A.north) to [open] (A.south) node[anchor=south]{\scriptsize[\si{A}]};
    \draw (A.west) ++(-0.5,0)  to [short, o-] (A.east) to [short, -o] ++(0.5,0);
    \draw (A.west) to[short,l={$I_a$}] (A.east);
%    \draw (A.south) ++(0,-0.5)  to [short, o-] (A.south) (A.north) to [short, -o] ++(0,+0.5);
%    \draw ($(A.north)+(0,+0.25)$) to [short, *-*] ($(A.west)-(0.25,0)$) ;
%    \draw ($(A.south)-(0,0.5)$) to [open, v>=~, voltage shift=1.0] ($(A.north)+(0,0.5)$);
%    \draw ($(A.north)+(0.25,0.25)$) node[anchor=west]{$\U_a$};
    }
    { circuitikz ammeter - not IEC
%    \draw (0.5,0) to [open] (1,0) to [ammeter, name=A, i_=$I_a$] ++(2,0);
    }
\end{circuitikz}
\end{document}

redpajama_set_name: RedPajamaStackExchange


Note: This is the third of a four-part series on what I call the "attention garden." The goal of this series is to help you become aware of, hone, and harness the power of your attention. I previously explained the metaphor and the scientific background (part one), then talked about how to choose what to plant in your attention garden (part two). In this post I will discuss tools for tending your garden (part three) and next I will discuss the importance of harvest time (part four).
If you've read the first two posts in this series, you already understand something about the science of your attention garden and you have an idea about what you might want to plant there. It sounds pretty easy, but there are a few tricks to nurturing the seeds you have planted in your attention garden so they grow into what you were hoping to harvest (and sometimes more).
Attention can be thought of as consisting of two major systems: the internally-driven, or inner system and the externally-driven, or outer system (also called "endogenous" and "exogenous"; see part 1 of this series). The inner system is the one that keeps you focused because you know you have to finish your report by noon; the outer one is the one that tells you that the baby is crying and your goal has to be briefly interrupted.
As you might have guessed, these systems both influence your ability to focus. You need to remain focused on a task in order to complete it, and at the same time, you also need to take care of external events that require you to change what you're doing. These systems can seem to be in competition with one another (Berger, Henik, & Rafal, 2005), and in other situations they can also seem to be independent (Peelen, Heslenfeld, & Theeuwes). Regardless, both systems are important.
If your outer attentional system is overactive, you will get distracted by many events in your environment that don't matter at all; these are like weeds popping up in your attention garden. And if your inner attentional system is overactive, you may work so hard on focusing on a goal that you don't give yourself any breaks and become exhausted; or you might have too many goals and not achieve any of them. Both of these situations will end up producing more weeds – things that do not serve you – in your attention garden.
The key is to keep both systems active at a healthy level. This balance can often be achieved by being in an environment that is safe and pleasant for your work. It doesn't have to be perfect; it just needs to be basically safe and basically pleasant. Otherwise, your attentional systems will be working on something other than your goal: Trying to make the environment better.
Many of us need help in getting our attention balanced, because we have internal processes that put one or the other system into overdrive. That's where Focus@Will audio comes in. Basically any tool designed to help you balance between your inner and outer attentional systems can help, but even before I became Focus@Will's Science Director, I had seen the effects of its attention-balancing firsthand, so I don't think I'm totally biased in pointing out that it can be very useful in balancing you between your external and internal attentional systems.
Practice in attending to your garden is likely to make your garden flourish. As in real gardening, with practice you will learn how to spot weeds before they grow larger, you will find out what each object of your attention needs in order to thrive, and you will learn how to balance your two attention systems.
What does focus practice mean? It means that you need to keep track of what's in your attention garden – what you want to spend your life, right now, paying attention to – and then practice attending to it. This practice should not be simply thinking about the things in your attention garden, though it's important to get a visual check on your garden every so often, by imagining and naming everything you want growing there (see weeding, tool 5).
You also need to actively put your attention on each object in your attention garden, each "seed" that you have planted there. This means, for instance, if one of your seeds is "getting a job," you need to not only contact your network and edit your resume, but you need to put your full attention on contacting your network and editing your resume. With active practice, your attention is likely to cause your intentions to bloom into reality (Mossbridge, 2009).
The seeds you plant in your attention garden are essentially intentions or goals that are activated by attention. Setting these goals by planting them in your attention garden is the first step, but in general, when we set smaller goals along the way, we are more likely to achieve what we set out to do (for review, see Locke & Latham, 2002).
So let's say that in your attention garden, you've planted the seed called, "stand up for myself." To help this seed flourish, give it the fertilizer of shorter-term goals such as, "at the next work meeting, speak up if I don't like the direction management is headed." Once you meet that sub-goal, your "stand up for myself" seed will start to sprout.
One risk of the habit of goal setting is that it can produce paralysis if you have too many goals (Welsh, Ordóñez, 2014). But with your attention garden, you'll know when that happens. When you imagine your garden, you'll see too many plants, causing an overgrowth that needs to be thinned. Then you'll know it's time for weeding (tool 5, below).
Ah, kindness! Thank you! What a gift.
I list kindness as tool number 4, because I like to remind people about kindness right before I talk about weeding. But I consider kindness the most important tool in the garden – kindness to yourself, that is. There are at least three common pitfalls related to unkindness that are known to reduce your ability to focus your attention on what you want to nourish: rude environments, self-criticism, and dwelling on negativity. Perhaps unsurprisingly, they all work by putting the wrong things (weeds) into your attention garden.
Let's talk about rude environments first. In a series of three experiments, researchers asked participants to complete a cognitive task after they had experienced someone being rude to them. In each experiment, performance on the task declined as compared to the performance of participants who did not experience this rudeness. This performance decrease was interpreted as an attentional effect, in that the attention of the participants was now distracted from the task at hand as their attention went toward trying to deal with their emotional response to the rudeness (Porath & Erez, 2007).
So what does this mean for us? What it means is that to care for your attention garden, be kind to yourself and remove yourself from rudeness, however you can – by addressing it head on or by leaving the situation to do your work elsewhere.
Next, let's talk about self-criticism and negative thoughts. Self-criticism is being critical of yourself in a way that is not helpful; dwelling on negative thoughts (dysphoric rumination) is obsessively focusing on the negative aspects of what you've done in the past. Both problems are very common, and there is evidence that both distract from your ability to pay attention (Lyubomirsky, Kasri, & Zehm, 2003; Mulkens, Bögels, de Jong, & Louwers, 2001). It can be difficult for people who are too critical of themselves and who dwell on the negative to stop, even when they know it is damaging.
What has worked is to focus attention on something other than oneself (Hertel & Rude, 1991; Lyubomirsky, Kasri, & Zehm, 2003; Mulkens, Bögels, de Jong, & Louwers, 2001). Having an attention garden on which to focus attention is one way of solving the problem – each time a self-critical or ruminating thought appears, you can imagine it as a weed, and toss it out. Then you can immediately switch your focus to one of the plants you do want growing in your garden. It may not be easy at first, but with kind practice, the plants you want in your garden will bloom beautifully.
I've alluded to the importance of weeding throughout this post, and I would say that after kindness, weeding is the most important tool. Luckily, it's easy to use.
Why should you weed your garden? So that what grows in your garden is exactly what will help you in your life. Maybe you planted a seed that you thought you wanted, but now that it has grown into a full-fledged plant, it turns out it's not what you want at all. Or, as happens to most of us, maybe weeds sprouted up because you had too many goals, didn't pay attention to the plants you wanted there, or did not cut the weeds down before they grew large.
Weeds are clutter, and they don't help us. As experienced clutter expert Brooks Palmer says, you don't have to know why the clutter is there. You just have to recognize that it doesn't serve you, then let it go. Cutting down weeds can seem harsh, but it is really an outgrowth of the tool of kindness – it is placing the quality of your life as your top priority.
focus your attention on what you want to nourish in your garden.
Once a week, take a few minutes and imagine or even sketch out your attention garden. Name the plants and seeds that you want in there. The rest of them? They are all weeds. You can name them, but naming them tends to give them attention, so I would suggest simply plucking them out of the ground (in your imagination) or erasing them from the page (in your sketch) and throwing them outside of the walls of your garden. Finally, focus on the plants still growing in your garden and shower them with your attention.
Here's a note to those concerned they will get rid of something important during the weeding process – don't worry. If it's important, it'll eventually grow back as a plant that you will want to nourish. For instance, last time I gave the example of what we feel when a close friend dies – grief and agony. If you see those feelings as weeds and throw them out of your garden, they will come back later, as plants that you want to keep – such as "memories of my friend." Then as you attend to those memories, they will grow, and you will connect again with your grief and agony. But this time, they will grow in a context that serves the best interest of your own blooming.
If this all seems like a lot of work, you should know it is only difficult to imagine. It gets easier when you do it; I think that's because the whole process follows along the lines of how humans are already designed to work. But it may help to look forward to the payoff, so tune in next week when I discuss the importance of harvesting the fruits of your attention garden!
NOTE: This blog post was powered by Focus@Will's Ambient channel.
Focus@Will – scientifically designed music to focus your attention and improve your productivity.
Berger, A., Henik, A., & Rafal, R. (2005). Competition between endogenous and exogenous orienting of visual attention. Journal of Experimental Psychology: General, 134(2), 207.
Hertel, P. T., & Rude, S. S. (1991). Depressive deficits in memory: Focusing attention improves subsequent recall. Journal of Experimental Psychology: General, 120(3), 301.
Locke, E. A., & Latham, G. P. (2002). Building a practically useful theory of goal setting and task motivation: A 35-year odyssey. American psychologist, 57(9), 705.
Lyubomirsky, S., Kasri, F., & Zehm, K. (2003). Dysphoric rumination impairs concentration on academic tasks. Cognitive Therapy and Research, 27(3), 309-330.
Mossbridge JA. 2009. Brain Shaping at Work: Wiring Our Brains for Integrity, Leadership, Creativity and [Insert Your Favorite Trait or Skill Here]. In "The Workplace and Spirituality: New Perspectives in Research and Practice," Dr. Joan Marques, Ed. Skylight Paths Publishing.
Mulkens, S., Bögels, S. M., de Jong, P. J., & Louwers, J. (2001). Fear of blushing: effects of task concentration training versus exposure in vivo on fear and physiology. Journal of Anxiety Disorders, 15(5), 413-432.
Peelen, M. V., Heslenfeld, D. J., & Theeuwes, J. (2004). Endogenous and exogenous attention shifts are mediated by the same large-scale neural network. Neuroimage, 22(2), 822-830.
Porath, C. L., & Erez, A. (2007). Does rudeness really matter? The effects of rudeness on task performance and helpfulness. Academy of Management Journal, 50(5), 1181-1197.
Welsh, D. T., & Ordóñez, L. D. (2014). The dark side of consecutive high performance goals: Linking goal setting, depletion, and unethical behavior. Organizational Behavior and Human Decision Processes, 123(2), 79-89.


For individual cable solutions in industrial and utility buildings.
Ha-VIS preLink®– the HARTING program for individual cable solutions in industrial and utility buildings – now includes a new 19" format distributor field. It has been specially developed for fitting into 19" distributors and switch cabinets and provides 24 RJ45 ports for transmitting up to 10 gigabits to 1 HE. Ha-VIS preLink® modules are produced in the keystone format and can be wired using Ha-VIS preLink® assembly technology using all types of commercially available 4- and 8-wire data cables.
Also new to the program: robust industry outlets with two RJ45 ports in AIDA compliant HARTING PushPull V.14 interfaces. Machine and plant manufacturers like these, particularly for automobile manufacturing. The metal outlets are tough and designed to IP 65/67. Installation uses time-saving and secure Ha-VIS preLink® assembly technology.


haha, I just saw a Microsoft store for the first time in Scottsdale, AZ's Scottsdale Fashion Square Mall. The first thing I thought of was... where did the creative thinking go? A company that deals with technology is supposed to be innovative right? Innovation is one part discovery and one part creativity. There was no creativity what so ever, they even use the colored boxes instead of a name, kind of like an apple.. It looked exactly like an apple store, plain white walls, lightly accented wood flooring, and a middle isle to the checkout with products symmetrically laid out on either side. It is such a good way for a company to display technological products. OH YEA! thats why Apple did it. OH YEA! they already did it... Ill just use this as another reason I wont ever buy from Microsoft again. Lame.
Totally agree. I haven't been to the MSFT Store, and I wouldn't take the time out of my day to go see it, i'd have to happen upon it by accident or something.
Where there a lot of people in the store?


text:
Q: Multiple Information Management Policies on Content Type - but just at Site-Level I am working with SharePoint 2016 On Prem.  My goal is to add an Information Management Policy to a document library at the site level that deletes all files older than 30 days.
When I create the Document Library, there already exists a Site Collection wide policy that is set for the parent content type.  This policy defines only auditing, and helps ensure site collection wide auditing is performed for documents for management purposes.  It does not have retention specified.
One of the side effects of this policy, is when I go to my local site and try to add a Information Management Policy with retention, I get the message:

You cannot change the policy settings for this content type because it inherited the settings from its parent content type or a site level content type.  To change these policy settings, change the settings for the parent of this content type.

My fear is if I change the settings to the parent, and add retention to the parent policy, that this will be applied to all document libraries of the site collection.  I don't want this applied site collection wide, just at the one document library at the site.
Is there a way to get a local retention policy applied to a document library that already has a site collection wide policy that specifies auditing?

A: Yes, if you change the setting to the parent, it will inherit across the site collection. Because of this you need to create a new content type which will not inherit any policies from its parent content types. Only then you can apply the local policy (plus the policy you have site collection wide, if you wish that to apply as well).
If you have defined the policy at a very parent level of content types (e.g. to content type "Document"), I'm afraid that's a mistake. A somewhat good practice is to not apply any information management policies into built-in content types due to their nature of being unique - thus not something you could create by yourself. This can be only fixed by creating an immediate child-level custom content type, apply the desirable policy, and change your content into this content type. The "change"-part isn't trivial.

A: I'd just add some extra guidance to Moe's good answer.  It's possible to apply information management policy settings in different ways.  Doing via Content Types might be the best way, but has limitations unless you create a new content type to apply the policy to (as Moe describes).
I'd recommend reading this guide by SP Maven; he details the different ways you can apply a policy - to a site collection, content type, list/library or to a folder.  Personally, since our Sharepoint is probably not ideally configured (I wouldn't use a content type policy), we're gone down the route described in the SP Maven's link in section 3. How to set Retention Policy for the Document Library.  As you'll see in section 3.5, you can apply the policy on a Library or Folder - so the policy is specifically targeted to the Library, not a content type.
Further Reading
I know your question was just to delete a document after x days, but I thought I'd mention that you can hook up your information management policy to an OOTB Disposition workflow, as Kim Frehe described in her excellent post.
The Disposition workflow, initiated once the date criteria are satisfied, will generate a 'review task' - this could be useful for more important HR / Finance documents where you might want a person to review prior to deletion.


Our approach is rooted in an understanding of client goals and the applicable law for specific situations. We're focused on successful outcomes for every client. Our cannabis attorneys share a dedication to the evolving area of Michigan marijuana and hemp law and its intersection with business.


text:
September 25, 2019 Middle East, World, Europe, Iran
Iran's Rouhani says he is open to discussing small changes to nuclear deal
French President Emmanuel Macron (L) and Iranian President Hassan Rouhani shake hands after a meeting at the UN headquarters on September 23, 2019, in New York.
:: Iranian President Hassan Rouhani said on Tuesday he was open to discussing small changes, additions or amendments to a 2015 nuclear deal between Iran and six major powers if the United States lifted sanctions imposed on the Islamic republic.
The Iranian president told media in New York that he will be open to discuss with major powers "small changes, additions or amendments" to nuclear deal if sanctions were taken away.
US President Donald Trump, who has adopted an "economic pressure" policy towards Iran to force its leadership to renegotiate the accord, said on Tuesday that he had no intention of lifting sanctions on Iran.
"All nations have a duty to act. No responsible government should subsidies Iran's blood lust," Trump said in a speech to the United Nations General Assembly annual gathering of world leaders. "As long as Iran's menacing behavior continues sanctions will not be lifted, they will be tightened."
Tensions have spiked between longtime foes, Tehran and Washington, since last year when Trump exited the nuclear pact and imposed sanctions on the Islamic republic that were lifted under the agreement.
In retaliation for the US "maximum pressure" policy, Iran has gradually reduced its commitments to the pact and plans to further breach it if the European parties fail to keep their promises to shield Iran's economy from US penalties.
Iran's top authority Supreme Leader Ayatollah Ali Khamenei said last week that Iran could engage in multilateral discussions if the United States returned to the deal and lifted sanctions.
The confrontation has intensified between Tehran and Washington following an attack on major oil sites in Saudi Arabia on Sept. 14 that sent oil prices soaring and raised fears of a new Middle East conflict.
The United States, European powers and Saudi Arabia have blamed Tehran for the attacks, which was claimed by Iran-aligned Houthi group in Yemen. Iran has denied any involvement.
Rouhani said those who doubt Yemen has the military capability for such attack, "aren't saying who the culprit is."
Trump responds positively to idea of new Iran deal floated by UK's Johnson
Iran threatens to 'vigorously' resume enrichment if US quits nuclear deal
UN urged to act against Iran over Houthi missiles
Tillerson, Russia's Lavrov to meet on Sunday: US State Dept.
Khamenei: Iran will reduce nuclear commitments until 'desired result' reached
Syria's Foreign Minister says Turkey continues to support terrorists
If US lifts sanctions, Iran to accept 'small changes' to nuclear deal: Official
UK minister discusses regional tensions, nuclear deal in Iran
Iran will not wage war against any nation, says Iranian president
Saudi authorities free citizen held for four years by Houthi militia
Six Muslim Brotherhood members killed in firefight in Egypt: Ministry
NUCLEAR DEAL, New York, UNITED NATIONS GENERAL ASSEMBLY