Return 3-D weights map for this component as a Map object.

        Returns
        -------
        map : `~fermipy.skymap.MapBase`
767710
def weight_map(self):
        
        # EAC we need the try blocks b/c older versions of the ST don't have some of these functions
        if isinstance(self.like, gtutils.SummedLikelihood):
            cmap = self.like.components[0].logLike.countsMap()
            try:
                p_method = cmap.projection().method()
            except AttributeError:
                p_method = 0
            try:
                if self.like.components[0].logLike.has_weights():
                    wmap = self.like.components[0].logLike.weightMap()
                else:
                    wmap = None
            except Exception:
                wmap = None
        else:
            cmap = self.like.logLike.countsMap()
            try:
                p_method = cmap.projection().method()
            except AttributeError:
                p_method = 0
            try:
                if self.like.logLike.has_weights():
                    wmap = self.like.logLike.weightMap()
                else:
                    wmap = None
            except Exception:
                wmap = None

        if p_method == 0:  # WCS
            if wmap is None:
                z = np.ones((self.enumbins, self.npix, self.npix))
            else:
                z = wmap.model()
                z = np.array(z).reshape(self.enumbins, self.npix, self.npix)
            return WcsNDMap(copy.deepcopy(self._geom), z)
        elif p_method == 1:  # HPX
            nhpix = np.max(self.geom.npix)
            if wmap is None:
                z = np.ones((self.enumbins, nhpix))
            else:
                z = wmap.model()
                z = np.array(z).reshape(self.enumbins, nhpix)
            return HpxNDMap(self.geom, z)
        else:
            self.logger.error('Did not recognize CountsMap type %i' % p_method,
                              exc_info=True)
        return None
1137763
function() {
        return {
            center: this.map.getCenter(),
            resolution: this.map.getResolution(),
            projection: this.map.getProjectionObject(),
            units: this.map.getProjectionObject().getUnits() || 
                this.map.units || this.map.baseLayer.units
        };
    }
1085631
def _get_base_model(self):
        
        if self.model_name == 'inception_v3':
            return InceptionV3(weights='imagenet', include_top=False)
        elif self.model_name == 'xception':
            return Xception(weights='imagenet', include_top=False)
        elif self.model_name == 'vgg16':
            return VGG16(weights='imagenet', include_top=False)
        elif self.model_name == 'vgg19':
            return VGG19(weights='imagenet', include_top=False)
        elif self.model_name == 'resnet50':
            return ResNet50(weights='imagenet', include_top=False)
        else:
            raise ValueError('Cannot find base model %s' % self.model_name)
741404
def _plot_weights_heatmap(self, index=None, figsize=None, **kwargs):
        
        W = self.get_weights()[0]
        if index is None:
            index = np.arange(W.shape[2])

        fig = heatmap(np.swapaxes(W[:, :, index], 0, 1), plot_name="filter: ",
                      vocab=self.VOCAB, figsize=figsize, **kwargs)
        # plt.show()
        return fig
76543
@JsonIgnore
    public Map<String, long[]> getParamShapes() {
        Map<String, long[]> map = new LinkedHashMap<>();
        map.putAll(weightParams);
        map.putAll(biasParams);
        return map;
    }
1078447
def projection(self, **kwargs):
        
        viewpoint = kwargs.pop('viewpoint', None)
        if viewpoint is None:
            ndim = self.shape[0]-1
            viewpoint = N.zeros(ndim)
        plane = self.polar_plane(viewpoint)
        return self.slice(plane, **kwargs)
503555
def keys(self):
        ""
        return (list(self._pb.IntMap.keys()) + list(self._pb.StringMap.keys()) +
                list(self._pb.FloatMap.keys()) + list(self._pb.BoolMap.keys()))
477417
def get_color_map(name):
    
    redmap = [0]
    greenmap = [0]
    bluemap = [0]
    if name == 'white':
        # essentially a noop
        redmap = [0, 1]
        greenmap = [0, 1]
        bluemap = [0, 1]
    elif name == 'simple':
        redmap = [0, 1, 1, 1]
        greenmap = [0, 0, 1, 1]
        bluemap = [0, 0, 0, 1]
    elif name == 'hot':
        redmap = [0, 0.03968253968253968, 0.07936507936507936, 0.119047619047619, 0.1587301587301587, 0.1984126984126984, 0.2380952380952381, 0.2777777777777778, 0.3174603174603174, 0.3571428571428571, 0.3968253968253968, 0.4365079365079365, 0.4761904761904762, 0.5158730158730158, 0.5555555555555556, 0.5952380952380952,
                  0.6349206349206349, 0.6746031746031745, 0.7142857142857142, 0.753968253968254, 0.7936507936507936, 0.8333333333333333, 0.873015873015873, 0.9126984126984127, 0.9523809523809523, 0.992063492063492, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]
        greenmap = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0.03174603174603163, 0.0714285714285714, 0.1111111111111112, 0.1507936507936507, 0.1904761904761905, 0.23015873015873, 0.2698412698412698, 0.3095238095238093, 0.3492063492063491, 0.3888888888888888, 0.4285714285714284,
                    0.4682539682539679, 0.5079365079365079, 0.5476190476190477, 0.5873015873015872, 0.6269841269841268, 0.6666666666666665, 0.7063492063492065, 0.746031746031746, 0.7857142857142856, 0.8253968253968254, 0.8650793650793651, 0.9047619047619047, 0.9444444444444442, 0.984126984126984, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]
        bluemap = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0.04761904761904745, 0.1269841269841265,
                   0.2063492063492056, 0.2857142857142856, 0.3650793650793656, 0.4444444444444446, 0.5238095238095237, 0.6031746031746028, 0.6825396825396828, 0.7619047619047619, 0.8412698412698409, 0.92063492063492, 1]
    elif name == 'rainbow':
        redmap = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0.9365079365079367, 0.8571428571428572, 0.7777777777777777, 0.6984126984126986, 0.6190476190476191, 0.53968253968254, 0.4603174603174605, 0.3809523809523814, 0.3015873015873018, 0.2222222222222223, 0.1428571428571432,
                  0.06349206349206415, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0.03174603174603208, 0.08465608465608465, 0.1375661375661377, 0.1904761904761907, 0.2433862433862437, 0.2962962962962963, 0.3492063492063493, 0.4021164021164023, 0.4550264550264553, 0.5079365079365079, 0.5608465608465609, 0.6137566137566139, 0.666666666666667]
        greenmap = [0, 0.03968253968253968, 0.07936507936507936, 0.119047619047619, 0.1587301587301587, 0.1984126984126984, 0.2380952380952381, 0.2777777777777778, 0.3174603174603174, 0.3571428571428571, 0.3968253968253968, 0.4365079365079365, 0.4761904761904762, 0.5158730158730158, 0.5555555555555556, 0.5952380952380952, 0.6349206349206349, 0.6746031746031745, 0.7142857142857142, 0.753968253968254, 0.7936507936507936,
                    0.8333333333333333, 0.873015873015873, 0.9126984126984127, 0.9523809523809523, 0.992063492063492, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0.9841269841269842, 0.9047619047619047, 0.8253968253968256, 0.7460317460317465, 0.666666666666667, 0.587301587301587, 0.5079365079365079, 0.4285714285714288, 0.3492063492063493, 0.2698412698412698, 0.1904761904761907, 0.1111111111111116, 0.03174603174603208, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
        bluemap = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0.01587301587301582, 0.09523809523809534, 0.1746031746031744, 0.2539682539682535,
                   0.333333333333333, 0.412698412698413, 0.4920634920634921, 0.5714285714285712, 0.6507936507936507, 0.7301587301587302, 0.8095238095238093, 0.8888888888888884, 0.9682539682539679, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]
    elif name == 'winter':
        greenmap = [0, 1]
        bluemap = [1, 0.5]
    else:
        if name != 'jet':
            print('Warning: colormap "%s" not supported. Using jet instead.' % name)
        redmap = [0, 0, 0, 0, 0.5, 1, 1, 1, 0.5]
        greenmap = [0, 0, 0.5, 1, 1, 1, 0.5, 0, 0]
        bluemap = [0.5, 1, 1, 1, 0.5, 0, 0, 0, 0]
    return 255.0 * np.array(redmap), 255.0 * np.array(greenmap), 255.0 * np.array(bluemap)
1167319
def rtree_create_weight_table(lsm_grid_lat, lsm_grid_lon,
                              in_catchment_shapefile, river_id,
                              in_rapid_connect, out_weight_table,
                              file_geodatabase=None, area_id=None):
    
    time_start_all = datetime.utcnow()

    if lsm_grid_lat.ndim == 3 and lsm_grid_lon.ndim == 3:
        # assume first dimension is time
        lsm_grid_lat = lsm_grid_lat[0]
        lsm_grid_lon = lsm_grid_lon[0]

    log("Generating LSM Grid Thiessen Array ...")
    if file_geodatabase:
        gdb_driver = ogr.GetDriverByName("OpenFileGDB")
        ogr_file_geodatabase = gdb_driver.Open(file_geodatabase, 0)
        ogr_catchment_shapefile_lyr = \
            ogr_file_geodatabase.GetLayer(in_catchment_shapefile)
    else:
        ogr_catchment_shapefile = ogr.Open(in_catchment_shapefile)
        ogr_catchment_shapefile_lyr = ogr_catchment_shapefile.GetLayer()

    ogr_catchment_shapefile_lyr_proj = \
        ogr_catchment_shapefile_lyr.GetSpatialRef()
    original_catchment_proj = \
        Proj(ogr_catchment_shapefile_lyr_proj.ExportToProj4())
    geographic_proj = Proj(init='EPSG:4326')
    extent = ogr_catchment_shapefile_lyr.GetExtent()
    if original_catchment_proj != geographic_proj:
        x, y = transform(original_catchment_proj,
                         geographic_proj,
                         [extent[0], extent[1]],
                         [extent[2], extent[3]])
        extent = [min(x), max(x), min(y), max(y)]

    lsm_grid_feature_list = \
        pointsToVoronoiGridArray(lsm_grid_lat, lsm_grid_lon, extent)

#    ##COMMENTED LINES FOR TESTING
#    import os
#    from .voronoi import pointsToVoronoiGridShapefile
#    vor_shp_path = \
#        os.path.join(os.path.dirname(in_catchment_shapefile), "test_grid.shp")
#    pointsToVoronoiGridShapefile(lsm_grid_lat, lsm_grid_lon,
#                                 vor_shp_path, extent)

    time_end_lsm_grid_thiessen = datetime.utcnow()
    log(time_end_lsm_grid_thiessen - time_start_all)

    log("Generating LSM Grid Rtree ...")
    rtree_idx = rtree.index.Index()
    # Populate R-tree index with bounds of ECMWF grid cells
    for lsm_grid_pos, lsm_grid_feature in enumerate(lsm_grid_feature_list):
        rtree_idx.insert(lsm_grid_pos, lsm_grid_feature['polygon'].bounds)

    time_end_lsm_grid_rtree = datetime.utcnow()
    log(time_end_lsm_grid_rtree - time_end_lsm_grid_thiessen)

    log("Retrieving catchment river id list ...")
    number_of_catchment_features = \
        ogr_catchment_shapefile_lyr.GetFeatureCount()
    catchment_rivid_list = \
        np.zeros(number_of_catchment_features, dtype=np.int32)
    for feature_idx, catchment_feature in \
            enumerate(ogr_catchment_shapefile_lyr):
        catchment_rivid_list[feature_idx] = \
            catchment_feature.GetField(river_id)

    log("Reading in RAPID connect file ...")
    rapid_connect_rivid_list = np.loadtxt(in_rapid_connect,
                                          delimiter=",",
                                          usecols=(0,),
                                          ndmin=1,
                                          dtype=int)
    log("Find LSM grid cells that intersect with each catchment")
    log("and write out weight table ...")

    dummy_lat_index, dummy_lon_index = \
        _get_lat_lon_indices(lsm_grid_lat,
                             lsm_grid_lon,
                             lsm_grid_feature_list[0]['lat'],
                             lsm_grid_feature_list[0]['lon'])
    dummy_row_end = [
        0,
        dummy_lon_index,
        dummy_lat_index,
        1,
        lsm_grid_feature_list[0]['lon'],
        lsm_grid_feature_list[0]['lat']
    ]

    with open_csv(out_weight_table, 'w') as csvfile:
        connectwriter = csv.writer(csvfile)
        connectwriter.writerow(['rivid', 'area_sqm', 'lon_index', 'lat_index',
                                'npoints', 'lsm_grid_lon', 'lsm_grid_lat'])
        geographic_proj = Proj(init='EPSG:4326')
        osr_geographic_proj = osr.SpatialReference()
        osr_geographic_proj.ImportFromEPSG(4326)
        proj_transform = None
        if original_catchment_proj != geographic_proj:
            proj_transform = \
                osr.CoordinateTransformation(ogr_catchment_shapefile_lyr_proj,
                                             osr_geographic_proj)

        for rapid_connect_rivid in rapid_connect_rivid_list:
            intersect_grid_info_list = []
            try:
                catchment_pos = \
                    np.where(catchment_rivid_list == rapid_connect_rivid)[0][0]
            except IndexError:
                # if it is not in the catchment, add dummy row in its place
                connectwriter.writerow([rapid_connect_rivid] + dummy_row_end)
                continue

            get_catchment_feature = \
                ogr_catchment_shapefile_lyr.GetFeature(catchment_pos)
            feat_geom = get_catchment_feature.GetGeometryRef()
            # make sure coordinates are geographic
            if proj_transform:
                feat_geom.Transform(proj_transform)
            catchment_polygon = shapely_loads(feat_geom.ExportToWkb())

            for sub_lsm_grid_pos in \
                    rtree_idx.intersection(catchment_polygon.bounds):
                lsm_grid_polygon = \
                    lsm_grid_feature_list[sub_lsm_grid_pos]['polygon']
                if catchment_polygon.intersects(lsm_grid_polygon):
                    try:
                        intersect_poly = \
                            catchment_polygon.intersection(lsm_grid_polygon)
                    except TopologicalError:
                        log('The catchment polygon with id {0} was '
                            'invalid. Attempting to self clean...'
                            .format(rapid_connect_rivid))
                        original_area = catchment_polygon.area
                        catchment_polygon = catchment_polygon.buffer(0)
                        area_ratio = original_area/catchment_polygon.area
                        log('AREA_RATIO: {0}'.format(area_ratio))
                        msg_level = "INFO"
                        if round(area_ratio, 5) != 1:
                            msg_level = "WARNING"
                        log('The cleaned catchment polygon area '
                            'differs from the original area by {1}%.'
                            .format(abs(area_ratio - 1)), severity=msg_level)
                        intersect_poly = \
                            catchment_polygon.intersection(lsm_grid_polygon)
                    if not area_id:
                        # attempt to calculate AREA
                        poly_area = get_poly_area_geo(intersect_poly)
                    else:
                        poly_area = \
                            float(get_catchment_feature.GetField(area_id)) * \
                            intersect_poly.area/catchment_polygon.area

                    index_lsm_grid_lat, index_lsm_grid_lon = \
                        _get_lat_lon_indices(
                            lsm_grid_lat,
                            lsm_grid_lon,
                            lsm_grid_feature_list[sub_lsm_grid_pos]['lat'],
                            lsm_grid_feature_list[sub_lsm_grid_pos]['lon'])
                    intersect_grid_info_list.append({
                        'rivid': rapid_connect_rivid,
                        'area': poly_area,
                        'lsm_grid_lat':
                            lsm_grid_feature_list[sub_lsm_grid_pos]['lat'],
                        'lsm_grid_lon':
                            lsm_grid_feature_list[sub_lsm_grid_pos]['lon'],
                        'index_lsm_grid_lon': index_lsm_grid_lon,
                        'index_lsm_grid_lat': index_lsm_grid_lat
                    })

            npoints = len(intersect_grid_info_list)
            # If no intersection found, add dummy row
            if npoints <= 0:
                connectwriter.writerow([rapid_connect_rivid] + dummy_row_end)

            for intersect_grid_info in intersect_grid_info_list:
                connectwriter.writerow([
                    intersect_grid_info['rivid'],
                    intersect_grid_info['area'],
                    intersect_grid_info['index_lsm_grid_lon'],
                    intersect_grid_info['index_lsm_grid_lat'],
                    npoints,
                    intersect_grid_info['lsm_grid_lon'],
                    intersect_grid_info['lsm_grid_lat']
                ])

    time_end_all = datetime.utcnow()
    log(time_end_all - time_end_lsm_grid_rtree)
    log("TOTAL TIME: {0}".format(time_end_all - time_start_all))
190507
def get_value_map(self):
        
        value_map = {}
        tree_clone = self.tree_mapping_widget.invisibleRootItem().clone()
        for tree_branch in tree_clone.takeChildren():
            value_list = []
            for tree_leaf in tree_branch.takeChildren():
                value_list += [tree_leaf.data(0, Qt.UserRole)]
            if value_list:
                value_map[tree_branch.data(0, Qt.UserRole)] = value_list
        return value_map
742126
def remapScipy(im, coords):
    
    height, width = im.shape[0], im.shape[1]
    
    # switch to y,x order
    coords = coords[:,:,::-1]

    # make it (h, w, 3, 3)
    coords_channels = np.empty((height, width, 3, 3))
    coords_channel = np.zeros((height, width, 3))
    coords_channel[:,:,:2] = coords
    coords_channels[:,:,0] = coords_channel
    coords_channels[:,:,1] = coords_channel
    coords_channels[:,:,1,2] = 1
    coords_channels[:,:,2] = coords_channel
    coords_channels[:,:,2,2] = 2
    coords = coords_channels
    
    # (3, h, w, 3)
    coords = np.rollaxis(coords, 3)
        
    return map_coordinates(im, coords, order=1)
16019
public java.util.Map<java.lang.String, org.tensorflow.framework.TensorInfo> getInputsMap() {
    return internalGetInputs().getMap();
  }
1142190
def _make_map(self, limit):
        
        ny = 2000
        y = numpy.random.uniform(0., 1., (ny,1))
        limit = numpy.arctan(limit)
        m = AdaptiveMap([[-limit, limit]], ninc=100)
        theta = numpy.empty(y.shape, float)
        jac = numpy.empty(y.shape[0], float)
        for itn in range(10):
            m.map(y, theta, jac)
            tan_theta = numpy.tan(theta[:, 0])
            x = self.scale * tan_theta
            fx = (tan_theta ** 2 + 1) * numpy.exp(-(x ** 2) / 2.)
            m.add_training_data(y, (jac * fx) ** 2)
            m.adapt(alpha=1.5)
        return numpy.array(m.grid[0])
887474
public double[][] to2D(double[] weights) {
    double[][] newWeights = new double[map.length][];
    int index = 0;
    for (int i = 0; i < map.length; i++) {
      newWeights[i] = new double[labelIndices[map[i]].size()];
      System.arraycopy(weights, index, newWeights[i], 0, labelIndices[map[i]].size());
      index += labelIndices[map[i]].size();
    }
    return newWeights;
  }
1370211
def _raw_weights(self):
        
        if self._debug:
            return np.array([[],[],[],[]])

        if not self._running:
            raise ValueError('Weight sensor is not running!')
        if len(self._weight_buffers) == 0:
            time.sleep(0.3)
            if len(self._weight_buffers) == 0:
                raise ValueError('Weight sensor is not retrieving data!')
        weights = np.array(self._weight_buffers)
        return weights
155373
def full_scope(self):
        
        maps = [self.temps] + self.resolvers.maps + self.scope.maps
        return DeepChainMap(*maps)
490416
def as_dict(self):
        
        return {"@module": self.__class__.__module__,
                "@class": self.__class__.__name__,
                "additional_condition": self._additional_condition,
                "symmetry_measure_type": self.symmetry_measure_type,
                "nb_set_weights": [nb_set_weight.as_dict() for nb_set_weight in self.nb_set_weights],
                "ce_estimator": self.ce_estimator,
                }