Load grid and calculate alpha values from the coverage/2.5.
1093
def load_grid(self, alpha):
        '''
        '''
        grid = CRGrid.crt_grid(self.dirs[0] + '/grid/elem.dat',
                               self.dirs[0] + '/grid/elec.dat')
        self.plotman = CRPlot.plotManager(grid=grid)

        name = self.dirs[0] + '/inv/coverage.mag'
        content = np.genfromtxt(name, skip_header=1,
                                skip_footer=1, usecols=([2]))
        abscov = np.abs(content)
        if alpha:
            normcov = np.divide(abscov, 2.5)
            normcov[np.where(normcov > 1)] = 1
            mask = np.subtract(1, normcov)
            self.alpha = self.plotman.parman.add_data(mask)
        else:
            self.alpha = self.plotman.parman.add_data(np.ones(len(abscov)))
899246
def run(self, coords=None, debug=False):
        
        #self.grid.precompute()
        self.grid.search(coords=coords)
        return self.grid
219976
def calculate_grid(self):
        
        if self.grid is None:
            self.grid = self.get_wellseries(self.get_grid())

        if self.grid_transposed is None:
            self.grid_transposed = self.get_wellseries(
                self.transpose(
                    self.get_grid()))
1042784
void alphaFunction(double alpha[], List<Double> x, int dim, int type) {
    if (dim == 2) {
      if (type == 21) {
        alpha[0] = x.get(0);
        alpha[1] = 1 - Math.sqrt(x.get(0));
      }

      if (type == 22) {
        alpha[0] = x.get(0);
        alpha[1] = 1 - x.get(0) * x.get(0);
      }

      if (type == 23) {
        alpha[0] = x.get(0);
        alpha[1] = 1 - Math.sqrt(alpha[0]) - alpha[0]
          * Math.sin(10 * alpha[0] * alpha[0] * Math.PI);
      }

      if (type == 24) {
        alpha[0] = x.get(0);
        alpha[1] = 1 - x.get(0) - 0.05 * Math.sin(4 * Math.PI * x.get(0));
      }
    } else {
      if (type == 31) {
        alpha[0] = Math.cos(x.get(0) * Math.PI / 2) * Math.cos(x.get(1) * Math.PI / 2);
        alpha[1] = Math.cos(x.get(0) * Math.PI / 2) * Math.sin(x.get(1) * Math.PI / 2);
        alpha[2] = Math.sin(x.get(0) * Math.PI / 2);
      }

      if (type == 32) {
        alpha[0] = 1 - Math.cos(x.get(0) * Math.PI / 2)
          * Math.cos(x.get(1) * Math.PI / 2);
        alpha[1] = 1 - Math.cos(x.get(0) * Math.PI / 2)
          * Math.sin(x.get(1) * Math.PI / 2);
        alpha[2] = 1 - Math.sin(x.get(0) * Math.PI / 2);
      }

      if (type == 33) {
        alpha[0] = x.get(0);
        alpha[1] = x.get(1);
        alpha[2] = 3
          - (Math.sin(3 * Math.PI * x.get(0)) + Math.sin(3 * Math.PI * x.get(1))) - 2
          * (x.get(0) + x.get(1));
      }

      if (type == 34) {
        alpha[0] = x.get(0) * x.get(1);
        alpha[1] = x.get(0) * (1 - x.get(1));
        alpha[2] = (1 - x.get(0));
      }
    }
  }
1247735
def _update_alpha(self, event=None):
        """"""
        a = self.alpha.get()
        hexa = self.hexa.get()
        hexa = hexa[:7] + ("%2.2x" % a).upper()
        self.hexa.delete(0, 'end')
        self.hexa.insert(0, hexa)
        self.alphabar.set(a)
        self._update_preview()
1318775
def display_grid(self):
        """"""
        window_start = self.parent.value('window_start')
        window_length = self.parent.value('window_length')
        window_end = window_start + window_length

        if self.parent.value('grid_x'):
            x_tick = self.parent.value('grid_xtick')
            x_ticks = arange(window_start, window_end + x_tick, x_tick)
            for x in x_ticks:
                x_pos = [x, x]
                y_pos = [0,
                         self.parent.value('y_distance') * len(self.idx_label)]
                path = self.scene.addPath(Path(x_pos, y_pos))
                path.setPen(QPen(QColor(LINE_COLOR), LINE_WIDTH,
                                 Qt.DotLine))

        if self.parent.value('grid_y'):
            y_tick = (self.parent.value('grid_ytick') *
                      self.parent.value('y_scale'))
            for one_label_item in self.idx_label:
                x_pos = [window_start, window_end]
                y = one_label_item.y()

                y_pos_0 = [y, y]
                path_0 = self.scene.addPath(Path(x_pos, y_pos_0))
                path_0.setPen(QPen(QColor(LINE_COLOR), LINE_WIDTH,
                                   Qt.DotLine))

                y_up = one_label_item.y() + y_tick
                y_pos_up = [y_up, y_up]
                path_up = self.scene.addPath(Path(x_pos, y_pos_up))
                path_up.setPen(QPen(QColor(LINE_COLOR), LINE_WIDTH,
                                    Qt.DotLine))

                y_down = one_label_item.y() - y_tick
                y_pos_down = [y_down, y_down]
                path_down = self.scene.addPath(Path(x_pos, y_pos_down))
                path_down.setPen(QPen(QColor(LINE_COLOR), LINE_WIDTH,
                                      Qt.DotLine))
340464
def add_coverage(self, qname, sname, qcover, scover=None):
        """"""
        self.alignment_coverage.loc[qname, sname] = qcover
        if scover:
            self.alignment_coverage.loc[sname, qname] = scover
653388
function() {
        var buffer = this.buffer + 1;
        while(true) {
            var tlTile = this.grid[0][0];
            var tlViewPort = {
                x: tlTile.position.x +
                    this.map.layerContainerOriginPx.x,
                y: tlTile.position.y +
                    this.map.layerContainerOriginPx.y
            };
            var ratio = this.getServerResolution() / this.map.getResolution();
            var tileSize = {
                w: Math.round(this.tileSize.w * ratio),
                h: Math.round(this.tileSize.h * ratio)
            };
            if (tlViewPort.x > -tileSize.w * (buffer - 1)) {
                this.shiftColumn(true, tileSize);
            } else if (tlViewPort.x < -tileSize.w * buffer) {
                this.shiftColumn(false, tileSize);
            } else if (tlViewPort.y > -tileSize.h * (buffer - 1)) {
                this.shiftRow(true, tileSize);
            } else if (tlViewPort.y < -tileSize.h * buffer) {
                this.shiftRow(false, tileSize);
            } else {
                break;
            }
        }
    }
153090
def to_coverage(ctx):
    
    sm = Smother.load(ctx.obj['report'])
    sm.coverage = coverage.coverage()
    sm.write_coverage()
687387
function(){
    // If the data grid has already been built, nothing to do here
    if (this.spreadsheet.datagrid) return this.spreadsheet.datagrid;
    
    var s = this.series,
        datagrid = this.spreadsheet.loadDataGrid(),
        colgroup = ['<colgroup><col />'],
        buttonDownload, buttonSelect, t;
    
    // First row : series' labels
    var html = ['<table class="flotr-datagrid"><tr class="first-row">'];
    html.push('<th>&nbsp;</th>');
    _.each(s, function(serie,i){
      html.push('<th scope="col">'+(serie.label || String.fromCharCode(65+i))+'</th>');
      colgroup.push('<col />');
    });
    html.push('</tr>');
    // Data rows
    _.each(datagrid, function(row){
      html.push('<tr>');
      _.times(s.length+1, function(i){
        var tag = 'td',
            value = row[i],
            // TODO: do we really want to handle problems with floating point
            // precision here?
            content = (!_.isUndefined(value) ? Math.round(value*100000)/100000 : '');
        if (i === 0) {
          tag = 'th';
          var label = getRowLabel.call(this, content);
          if (label) content = label;
        }

        html.push('<'+tag+(tag=='th'?' scope="row"':'')+'>'+content+'</'+tag+'>');
      }, this);
      html.push('</tr>');
    }, this);
    colgroup.push('</colgroup>');
    t = D.node(html.join(''));

    /**
     * @TODO disabled this
    if (!Flotr.isIE || Flotr.isIE == 9) {
      function handleMouseout(){
        t.select('colgroup col.hover, th.hover').invoke('removeClassName', 'hover');
      }
      function handleMouseover(e){
        var td = e.element(),
          siblings = td.previousSiblings();
        t.select('th[scope=col]')[siblings.length-1].addClassName('hover');
        t.select('colgroup col')[siblings.length].addClassName('hover');
      }
      _.each(t.select('td'), function(td) {
        Flotr.EventAdapter.
          observe(td, 'mouseover', handleMouseover).
          observe(td, 'mouseout', handleMouseout);
      });
    }
    */

    buttonDownload = D.node(
      '<button type="button" class="flotr-datagrid-toolbar-button">' +
      this.options.spreadsheet.toolbarDownload +
      '</button>');

    buttonSelect = D.node(
      '<button type="button" class="flotr-datagrid-toolbar-button">' +
      this.options.spreadsheet.toolbarSelectAll+
      '</button>');

    this.
      observe(buttonDownload, 'click', _.bind(this.spreadsheet.downloadCSV, this)).
      observe(buttonSelect, 'click', _.bind(this.spreadsheet.selectAllData, this));

    var toolbar = D.node('<div class="flotr-datagrid-toolbar"></div>');
    D.insert(toolbar, buttonDownload);
    D.insert(toolbar, buttonSelect);

    var containerHeight =this.canvasHeight - D.size(this.spreadsheet.tabsContainer).height-2,
        container = D.node('<div class="flotr-datagrid-container" style="position:absolute;left:0px;top:0px;width:'+
          this.canvasWidth+'px;height:'+containerHeight+'px;overflow:auto;z-index:10"></div>');

    D.insert(container, toolbar);
    D.insert(container, t);
    D.insert(this.el, container);
    this.spreadsheet.datagrid = t;
    this.spreadsheet.container = container;

    return t;
  }
1110039
def get_axis_grid(self, ind):
        
        ng = self.dim
        num_pts = ng[ind]
        lengths = self.structure.lattice.abc
        return [i / num_pts * lengths[ind] for i in range(num_pts)]
265031
public static void printCoverageData(GridCoverage2D coverage) {
        RenderedImage renderedImage = coverage.getRenderedImage();
        RandomIter renderedImageIterator = RandomIterFactory.create(renderedImage, null);
        int[] colsRows = CoverageUtilities.getRegionColsRows(coverage);
        for (int r = 0; r < colsRows[1]; r++) {
            for (int c = 0; c < colsRows[0]; c++) {
                printer.print(renderedImageIterator.getSampleDouble(c, r, 0));
                printer.print(separator);
            }
            printer.println();
        }
    }
22807
public static void printCoverageDataAsMatrix(GridCoverage2D coverage) {
        printer.println("double[][] matrix = new double[][]{//");
        RenderedImage renderedImage = coverage.getRenderedImage();
        RandomIter renderedImageIterator = RandomIterFactory.create(renderedImage, null);
        int[] colsRows = CoverageUtilities.getRegionColsRows(coverage);
        for (int r = 0; r < colsRows[1]; r++) {
            if (r == 0) {
                printer.print("/*    */{");
            } else {
                printer.print("{");
            }
            for (int c = 0; c < colsRows[0]; c++) {
                printer.print(renderedImageIterator.getSampleDouble(c, r, 0));
                if (c < colsRows[0] - 1) {
                    printer.print(", ");
                }
            }
            if (r < colsRows[1] - 1) {
                printer.println("}, //");
            } else {
                printer.println("} //");
            }
        }
        printer.println("};");
        renderedImageIterator.done();
    }
190481
def grid(self, z_x_y):
        
        # sources.py -> MapnikRenderer -> grid
        (z, x, y) = z_x_y
        content = self.reader.grid(z, x, y, self.grid_fields, self.grid_layer)
        return content
70047
public static void scaleRow( double alpha , DMatrixRMaj A , int row ) {
        int idx = row*A.numCols;
        for (int col = 0; col < A.numCols; col++) {
            A.data[idx++] *= alpha;
        }
    }
320704
def _setup_grid(self, cutoff, unit_cell, grid):
        """"""
        if grid is None:
            # automatically choose a decent grid
            if unit_cell is None:
                grid = cutoff/2.9
            else:
                # The following would be faster, but it is not reliable
                # enough yet.
                #grid = unit_cell.get_optimal_subcell(cutoff/2.0)
                divisions = np.ceil(unit_cell.spacings/cutoff)
                divisions[divisions<1] = 1
                grid = unit_cell/divisions

        if isinstance(grid, float):
            grid_cell = UnitCell(np.array([
                [grid, 0, 0],
                [0, grid, 0],
                [0, 0, grid]
            ]))
        elif isinstance(grid, UnitCell):
            grid_cell = grid
        else:
            raise TypeError("Grid must be None, a float or a UnitCell instance.")

        if unit_cell is not None:
            # The columns of integer_matrix are the unit cell vectors in
            # fractional coordinates of the grid cell.
            integer_matrix = grid_cell.to_fractional(unit_cell.matrix.transpose()).transpose()
            if abs((integer_matrix - np.round(integer_matrix))*self.unit_cell.active).max() > 1e-6:
                raise ValueError("The unit cell vectors are not an integer linear combination of grid cell vectors.")
            integer_matrix = integer_matrix.round()
            integer_cell = UnitCell(integer_matrix, unit_cell.active)
        else:
            integer_cell = None

        return grid_cell, integer_cell
628655
function updateGrid(gx, gy, gw, gh, info, item) {
      var occupied = info.occupied;
      var drawMask = settings.drawMask;
      var ctx;
      if (drawMask) {
        ctx = elements[0].getContext('2d');
        ctx.save();
        ctx.fillStyle = settings.maskColor;
      }

      var dimension;
      if (interactive) {
        var bounds = info.bounds;
        dimension = {
          x: (gx + bounds[3]) * g,
          y: (gy + bounds[0]) * g,
          w: (bounds[1] - bounds[3] + 1) * g,
          h: (bounds[2] - bounds[0] + 1) * g
        };
      }

      var i = occupied.length;
      while (i--) {
        var px = gx + occupied[i][0];
        var py = gy + occupied[i][1];

        if (px >= ngx || py >= ngy || px < 0 || py < 0) {
          continue;
        }

        fillGridAt(px, py, drawMask, dimension, item);
      }

      if (drawMask) {
        ctx.restore();
      }
    }