Visualize water bridges.
330116
def show_wbridges(self):
        """"""
        for bridge in self.plcomplex.waterbridges:
            if bridge.protisdon:
                cmd.select('HBondDonor-P', 'HBondDonor-P or (id %i & %s)' % (bridge.don_id, self.protname))
                cmd.select('HBondAccept-L', 'HBondAccept-L or (id %i & %s)' % (bridge.acc_id, self.ligname))
                cmd.select('tmp_don', 'id %i & %s' % (bridge.don_id, self.protname))
                cmd.select('tmp_acc', 'id %i & %s' % (bridge.acc_id, self.ligname))
            else:
                cmd.select('HBondDonor-L', 'HBondDonor-L or (id %i & %s)' % (bridge.don_id, self.ligname))
                cmd.select('HBondAccept-P', 'HBondAccept-P or (id %i & %s)' % (bridge.acc_id, self.protname))
                cmd.select('tmp_don', 'id %i & %s' % (bridge.don_id, self.ligname))
                cmd.select('tmp_acc', 'id %i & %s' % (bridge.acc_id, self.protname))
            cmd.select('Water', 'Water or (id %i & resn HOH)' % bridge.water_id)
            cmd.select('tmp_water', 'id %i & resn HOH' % bridge.water_id)
            cmd.distance('WaterBridges', 'tmp_acc', 'tmp_water')
            cmd.distance('WaterBridges', 'tmp_don', 'tmp_water')
        if self.object_exists('WaterBridges'):
            cmd.set('dash_color', 'lightblue', 'WaterBridges')
        cmd.delete('tmp_water or tmp_acc or tmp_don')
        cmd.color('lightblue', 'Water')
        cmd.show('spheres', 'Water')
1077238
def add_bridge(self, bridge):
        
        for group in bridge.groups:
            self._groups[group.name] = group
1356575
def render(self, rectangle, data):
        """"""

        size = (1.0 - 2.0*self.margin) * rectangle.h
        offset = self.margin * rectangle.h
        per_mark = 1.0 / float(self.total)
        bottom = offset + size * float(self.index) * per_mark
        top = bottom + per_mark * size

        c = data['output']
        with c:
            c.translate(rectangle.x, rectangle.y)
            c.draw_polygon(
                0, top, -self.width, bottom, self.width, bottom,
                fill=self.color
                )
745622
def rivermap_update(self, river, water_flow, rivermap, precipitations):
        """"""

        isSeed = True
        px, py = (0, 0)
        for x, y in river:
            if isSeed:
                rivermap[y, x] = water_flow[y, x]
                isSeed = False
            else:
                rivermap[y, x] = precipitations[y, x] + rivermap[py, px]
            px, py = x, y
925023
async def async_discovery(session):
    """"""
    bridges = []
    response = await async_request(session.get, URL_DISCOVER)

    if not response:
        _LOGGER.info("No discoverable bridges available.")
        return bridges

    for bridge in response:
        bridges.append({'bridgeid': bridge['id'],
                        'host': bridge['internalipaddress'],
                        'port': bridge['internalport']})

    _LOGGER.info("Discovered the following bridges: %s.", bridges)

    return bridges
269581
def get_bridges(vnic_dir='/sys/devices/virtual/net'):
    """"""
    b_regex = "%s/*/bridge" % vnic_dir
    return [x.replace(vnic_dir, '').split('/')[1] for x in glob.glob(b_regex)]
63618
private Pair<Element, Visualization> value(Element elem, Visualization vis) {
    return new Pair<>(elem, vis);
  }
1108134
def draw_salt_bridges(self,color="blue"):
		
		self.draw_saltbridges=""
		if self.saltbridges!=None:
			for bond in self.saltbridges.saltbridges_for_drawing:
				self.draw_saltbridges ="<g class='SaltBridges' transform='translate("+str((self.molecule.x_dim-self.molecule.molsize1)/2)+","+str((self.molecule.y_dim-self.molecule.molsize2)/2)+")'>'"
				atom = self.topology_data.universe.atoms[bond[0]-1] #zero-based index vs one-based index
				residue = (atom.resname, str(atom.resid), atom.segid)
				self.draw_saltbridges=self.draw_saltbridges+"<line x1='"+str(int(self.molecule.nearest_points_coords[residue][0]))+"' y1='"+str(int(self.molecule.nearest_points_coords[residue][1]))+"' x2='"+str(float(self.molecule.ligand_atom_coords_from_diagr[bond[1]][0]))+"' y2='"+str(float(self.molecule.ligand_atom_coords_from_diagr[bond[1]][1]))+"' style='stroke:white;stroke-width:15' />"
				self.draw_saltbridges=self.draw_saltbridges+"<line x1='"+str(int(self.molecule.nearest_points_coords[residue][0]))+"' y1='"+str(int(self.molecule.nearest_points_coords[residue][1]))+"' x2='"+str(float(self.molecule.ligand_atom_coords_from_diagr[bond[1]][0]))+"' y2='"+str(float(self.molecule.ligand_atom_coords_from_diagr[bond[1]][1]))+"' style='stroke:"+color+";stroke-width:4' />"
				self.draw_saltbridges= self.draw_saltbridges+"</g>"
775060
def iterbridges():
    '''  '''
    net_files = os.listdir(SYSFS_NET_PATH)
    for d in net_files:
        path = os.path.join(SYSFS_NET_PATH, d)
        if not os.path.isdir(path):
            continue
        if os.path.exists(os.path.join(path, b"bridge")):
            yield Bridge(d)
1153292
def draw(molecule, TraversalType=SmilesTraversal):
    """"""
    result = []
    atoms = allAtoms = molecule.atoms

    visitedAtoms = {}
    #
    # Traverse all components of the graph to form
    # the output string
    while atoms:
        atom = _get_lowest_symorder(atoms)
        visitedAtoms[atom] = 1

        visitedBonds = {}
        nextTraverse = TraversalType()
        atomsUsed, bondsUsed = [], []
        _traverse(atom, nextTraverse, None,
                  visitedAtoms, visitedBonds,
                  atomsUsed, bondsUsed, TraversalType)
        atoms = []
        for atom in allAtoms:
            if not visitedAtoms.has_key(atom):
                atoms.append(atom)
        assert nextTraverse.atoms == atomsUsed
        assert nextTraverse.bonds == bondsUsed, "%s %s"%(
            nextTraverse.bonds, bondsUsed)
        

        result.append((str(nextTraverse),
                       atomsUsed, bondsUsed))

    result.sort()
    fragments = []
    for r in result:
        fragments.append(r[0])

    return ".".join(fragments), result
208750
def display(self, data, x=None, y=None, xlabel=None, ylabel=None,
                style=None, nlevels=None, levels=None, contour_labels=None,
                store_data=True, col=0, unzoom=True, auto_contrast=False,
                contrast_level=0, **kws):
        
        if style is not None:
            self.conf.style = style
        self.axes.cla()
        conf = self.conf
        conf.log_scale = False
        conf.rot, conf.flip_ud, conf.flip_lr = False, False, False
        conf.highlight_areas = []
        if 1 in data.shape:
            data = data.squeeze()
        self.data_shape = data.shape
        self.data_range = [0, data.shape[1], 0, data.shape[0]]
        conf.contrast_level = contrast_level
        if auto_contrast:
            conf.contrast_level = 1
        if x is not None:
            self.xdata = np.array(x)
            if self.xdata.shape[0] != data.shape[1]:
                self.xdata = None
        if y is not None:
            self.ydata = np.array(y)
            if self.ydata.shape[0] != data.shape[0]:
                self.ydata = None

        if xlabel is not None:
            self.xlab = xlabel
        if ylabel is not None:
            self.ylab = ylabel
        if store_data:
            self.conf.data = data

        cmap = self.conf.cmap[col]
        if self.conf.style == 'contour':
            if levels is None:
                levels = self.conf.ncontour_levels
            else:
                self.conf.ncontour_levels = levels
            if nlevels is None:
                nlevels = self.conf.ncontour_levels = 9
            nlevels = max(2, nlevels)
            clevels  = np.linspace(data.min(), data.max(), nlevels+1)
            self.conf.contour_levels = clevels
            self.conf.image = self.axes.contourf(data, cmap=self.conf.cmap[col],
                                                 levels=clevels)

            self.conf.contour = self.axes.contour(data, cmap=self.conf.cmap[col],
                                                  levels=clevels)
            cmap_name = self.conf.cmap[col].name
            xname = 'gray'
            try:
                if cmap_name == 'gray_r':
                    xname = 'Reds_r'
                elif cmap_name == 'gray':
                    xname = 'Reds'
                elif cmap_name.endswith('_r'):
                    xname = 'gray_r'
            except:
                pass
            self.conf.contour.set_cmap(getattr(colormap, xname))

            if contour_labels is None:
                contour_labels = self.conf.contour_labels
            if contour_labels:
                self.axes.clabel(self.conf.contour, fontsize=10, inline=1)
            if hasattr(self.contour_callback , '__call__'):
                self.contour_callback(levels=clevels)
        else:
            if data.max() == data.min():
                img = data
            else:
                img = (data - data.min()) /(1.0*data.max() - data.min())
            self.conf.image = self.axes.imshow(img, cmap=self.conf.cmap[col],
                                               interpolation=self.conf.interp)

        self.axes.set_axis_off()
        if unzoom:
            self.unzoom_all()
        if hasattr(self.data_callback, '__call__'):
            self.data_callback(data, x=x, y=y, **kws)

        self.conf.indices = None
        self.indices_thread = Thread(target=self.calc_indices, args=(data.shape, ))
        self.indices_thread.start()
1176724
def draw(self, milliseconds, surface):
        """"""
        super(CollidableObj, self).draw(milliseconds, surface)
1205788
def _writeStructureLink(self, link, fileObject, replaceParamFile):
        
        fileObject.write('%s\n' % link.type)
        fileObject.write('NUMSTRUCTS     %s\n' % link.numElements)

        # Retrieve lists of structures
        weirs = link.weirs
        culverts = link.culverts

        # Write weirs to file
        for weir in weirs:
            fileObject.write('STRUCTTYPE     %s\n' % weir.type)

            # Check for replacement vars
            crestLength = vwp(weir.crestLength, replaceParamFile)
            crestLowElevation = vwp(weir.crestLowElevation, replaceParamFile)
            dischargeCoeffForward = vwp(weir.dischargeCoeffForward, replaceParamFile)
            dischargeCoeffReverse = vwp(weir.dischargeCoeffReverse, replaceParamFile)
            crestLowLocation = vwp(weir.crestLowLocation, replaceParamFile)
            steepSlope = vwp(weir.steepSlope, replaceParamFile)
            shallowSlope = vwp(weir.shallowSlope, replaceParamFile)

            if weir.crestLength != None:
                try:
                    fileObject.write('CREST_LENGTH             %.6f\n' % crestLength)
                except:
                    fileObject.write('CREST_LENGTH             %s\n' % crestLength)

            if weir.crestLowElevation != None:
                try:
                    fileObject.write('CREST_LOW_ELEV           %.6f\n' % crestLowElevation)
                except:
                    fileObject.write('CREST_LOW_ELEV           %s\n' % crestLowElevation)

            if weir.dischargeCoeffForward != None:
                try:
                    fileObject.write('DISCHARGE_COEFF_FORWARD  %.6f\n' % dischargeCoeffForward)
                except:
                    fileObject.write('DISCHARGE_COEFF_FORWARD  %s\n' % dischargeCoeffForward)

            if weir.dischargeCoeffReverse != None:
                try:
                    fileObject.write('DISCHARGE_COEFF_REVERSE  %.6f\n' % dischargeCoeffReverse)
                except:
                    fileObject.write('DISCHARGE_COEFF_REVERSE  %s\n' % dischargeCoeffReverse)

            if weir.crestLowLocation != None:
                    fileObject.write('CREST_LOW_LOC            %s\n' % crestLowLocation)

            if weir.steepSlope != None:
                try:
                    fileObject.write('STEEP_SLOPE              %.6f\n' % steepSlope)
                except:
                    fileObject.write('STEEP_SLOPE              %s\n' % steepSlope)

            if weir.shallowSlope != None:
                try:
                    fileObject.write('SHALLOW_SLOPE            %.6f\n' % shallowSlope)
                except:
                    fileObject.write('SHALLOW_SLOPE            %s\n' % shallowSlope)

        # Write culverts to file
        for culvert in culverts:
            fileObject.write('STRUCTTYPE     %s\n' % culvert.type)

            # Check for replacement vars
            upstreamInvert = vwp(culvert.upstreamInvert, replaceParamFile)
            downstreamInvert = vwp(culvert.downstreamInvert, replaceParamFile)
            inletDischargeCoeff = vwp(culvert.inletDischargeCoeff, replaceParamFile)
            reverseFlowDischargeCoeff = vwp(culvert.reverseFlowDischargeCoeff, replaceParamFile)
            slope = vwp(culvert.slope, replaceParamFile)
            length = vwp(culvert.length, replaceParamFile)
            roughness = vwp(culvert.roughness, replaceParamFile)
            diameter = vwp(culvert.diameter, replaceParamFile)
            width = vwp(culvert.width, replaceParamFile)
            height = vwp(culvert.height, replaceParamFile)

            if culvert.upstreamInvert != None:
                try:
                    fileObject.write('UPINVERT                 %.6f\n' % upstreamInvert)
                except:
                    fileObject.write('UPINVERT                 %s\n' % upstreamInvert)

            if culvert.downstreamInvert != None:
                try:
                    fileObject.write('DOWNINVERT               %.6f\n' % downstreamInvert)
                except:
                    fileObject.write('DOWNINVERT               %s\n' % downstreamInvert)

            if culvert.inletDischargeCoeff != None:
                try:
                    fileObject.write('INLET_DISCH_COEFF        %.6f\n' % inletDischargeCoeff)
                except:
                    fileObject.write('INLET_DISCH_COEFF        %s\n' % inletDischargeCoeff)

            if culvert.reverseFlowDischargeCoeff != None:
                try:
                    fileObject.write('REV_FLOW_DISCH_COEFF     %.6f\n' % reverseFlowDischargeCoeff)
                except:
                    fileObject.write('REV_FLOW_DISCH_COEFF     %s\n' % reverseFlowDischargeCoeff)

            if culvert.slope != None:
                try:
                    fileObject.write('SLOPE                    %.6f\n' % slope)
                except:
                    fileObject.write('SLOPE                    %s\n' % slope)

            if culvert.length != None:
                try:
                    fileObject.write('LENGTH                   %.6f\n' % length)
                except:
                    fileObject.write('LENGTH                   %s\n' % length)

            if culvert.roughness != None:
                try:
                    fileObject.write('ROUGH_COEFF              %.6f\n' % roughness)
                except:
                    fileObject.write('ROUGH_COEFF              %s\n' % roughness)

            if culvert.diameter != None:
                try:
                    fileObject.write('DIAMETER                 %.6f\n' % diameter)
                except:
                    fileObject.write('DIAMETER                 %s\n' % diameter)


            if culvert.width != None:
                try:
                    fileObject.write('WIDTH                    %.6f\n' % width)
                except:
                    fileObject.write('WIDTH                    %s\n' % width)

            if culvert.height != None:
                try:
                    fileObject.write('HEIGHT                   %.6f\n' % height)
                except:
                    fileObject.write('HEIGHT                   %s\n' % height)
355794
def imageMsg2Image(img, bridge):
    '''
    

    '''
    image = Image()

    image.width = img.width
    image.height = img.height
    image.format = "RGB8"
    image.timeStamp = img.header.stamp.secs + (img.header.stamp.nsecs *1e-9)
    cv_image=0
    if (img.encoding == "32FC1"):
        gray_img_buff = bridge.imgmsg_to_cv2(img, "32FC1")
        cv_image  = depthToRGB8(gray_img_buff)
    else:
        cv_image = bridge.imgmsg_to_cv2(img, "rgb8")
    image.data = cv_image
    return image
765258
def show():
    """"""
    env = get_environment()

    for key, val in sorted(env.env.items(), key=lambda item: item[0]):
        click.secho('%s = %s' % (key, val))
403144
def project(vx, vy, occlusion):
    """"""
    p = np.zeros(vx.shape)
    div = -0.5 * (np.roll(vx, -1, axis=1) - np.roll(vx, 1, axis=1)
                + np.roll(vy, -1, axis=0) - np.roll(vy, 1, axis=0))
    div = make_continuous(div, occlusion)

    for k in range(50):
        p = (div + np.roll(p, 1, axis=1) + np.roll(p, -1, axis=1)
                 + np.roll(p, 1, axis=0) + np.roll(p, -1, axis=0))/4.0
        p = make_continuous(p, occlusion)

    vx = vx - 0.5*(np.roll(p, -1, axis=1) - np.roll(p, 1, axis=1))
    vy = vy - 0.5*(np.roll(p, -1, axis=0) - np.roll(p, 1, axis=0))

    vx = occlude(vx, occlusion)
    vy = occlude(vy, occlusion)
    return vx, vy
1372149
def display(self):
        """"""
        if self.data is None:
            return

        if self.scene is not None:
            self.y_scrollbar_value = self.verticalScrollBar().value()
            self.scene.clear()

        self.create_chan_labels()
        self.create_time_labels()

        window_start = self.parent.value('window_start')
        window_length = self.parent.value('window_length')

        time_height = max([x.boundingRect().height() for x in self.idx_time])
        label_width = window_length * self.parent.value('label_ratio')
        scene_height = (len(self.idx_label) * self.parent.value('y_distance') +
                        time_height)

        self.scene = QGraphicsScene(window_start - label_width,
                                    0,
                                    window_length + label_width,
                                    scene_height)
        self.setScene(self.scene)

        self.idx_markers = []
        self.idx_annot = []
        self.idx_annot_labels = []

        self.add_chan_labels()
        self.add_time_labels()
        self.add_traces()
        self.display_grid()
        self.display_markers()
        self.display_annotations()

        self.resizeEvent(None)
        self.verticalScrollBar().setValue(self.y_scrollbar_value)
        self.parent.info.display_view()
        self.parent.overview.display_current()