Saves the direction of the slope to a file
8382
def save_direction(self, rootpath, raw=False, as_int=False):
        
        self.save_array(self.direction, None, 'ang', rootpath, raw, as_int=as_int)
12518
def vertical_gradient(self, x0, y0, x1, y1, start, end):
        """"""
        x0, y0, x1, y1 = self.rect_helper(x0, y0, x1, y1)
        grad = gradient_list(start, end, y1 - y0)
        for x in range(x0, x1 + 1):
            for y in range(y0, y1 + 1):
                self.point(x, y, grad[y - y0])
753254
function(dpad, normalize) {
        var x = 0,
            y = 0;

        // Sum up all active directions
        for (var d in dpad.directions) {
            var dir = dpad.directions[d];
            if (!dir.active) continue;
            x += dir.n.x;
            y += dir.n.y;
        }

        // Mitigate rounding errors when close to zero movement
        x = -1e-10 < x && x < 1e-10 ? 0 : x;
        y = -1e-10 < y && y < 1e-10 ? 0 : y;

        // Normalize
        if (normalize) {
            var m = Math.sqrt(x * x + y * y);
            if (m > 0) {
                x /= m;
                y /= m;
            }
        }

        dpad.x = x;
        dpad.y = y;
    }
227268
def save(self, fn:PathOrStr):
        ""
        x = image2np(self.data*255).astype(np.uint8)
        PIL.Image.fromarray(x).save(fn)
557250
def _tarboton_slopes_directions(self, data, dX, dY):
        

        return _tarboton_slopes_directions(data, dX, dY,
                                           self.facets, self.ang_adj)
419663
def persist(filename):
    
    dem_projected = obtain_to(filename)
    with nc.loader(filename) as root:
        data = nc.getvar(root, 'data')
        dem = nc.getvar(root, 'dem', 'f4', source=data)
        stack = [dim for dim in dem.shape if dim not in dem_projected.shape]
        stack = stack[0] if stack else 1
        dem[:] = np.vstack(map(lambda x: [dem_projected], range(stack)))
1001067
def save(self,
             data,
             chart_type,
             options=None,
             filename='chart',
             w=800,
             h=420,
             overwrite=True):
        """"""
        html = self.render(
            data=data,
            chart_type=chart_type,
            options=options,
            div_id=filename,
            head=self.head,
            w=w,
            h=h)

        if overwrite:
            with open(filename.replace(" ", "_") + '.html', 'w') as f:
                f.write(html)
        else:
            if not os.path.exists(filename.replace(" ", "_") + '.html'):
                with open(filename.replace(" ", "_") + '.html', 'w') as f:
                    f.write(html)
            else:
                raise IOError('File Already Exists!')
922246
function calcDirection(start, end) {
  var direction = new Vec2(end);
  direction.subtract(start);
  direction.normalize();
  return direction;
}
981441
def save_file(self):
        """"""

        l = []
        walk = self.walker
        for edit in walk.lines:
            # collect the text already stored in edit widgets
            if edit.original_text.expandtabs() == edit.edit_text:
                l.append(edit.original_text)
            else:
                l.append(re_tab(edit.edit_text))

        # then the rest
        while walk.file is not None:
            l.append(walk.read_next_line())

        # write back to disk
        outfile = open(self.save_name, "w")

        l_iter = iter(l)

        line = next(l_iter)
        prefix = ""

        while True:
            try:
                outfile.write(prefix + line)
                prefix = "\n"
                line = next(l_iter)
            except StopIteration:
                if line != "\n":
                    outfile.write("\n")
                break
626701
def slope(self, other):
        
        X1, Y1, X2, Y2 = self.X, self.Y, other.X, other.Y
        Y3 = Y1 - Y2
        X3 = X1 - X2
        return (Y3 * self.inverse(X3)) % self.P
896296
private void createStar() {
        Point2D.Float point = start;
        p = new GeneralPath(GeneralPath.WIND_NON_ZERO);
        p.moveTo(point.x, point.y);
        p.lineTo(point.x + 3.0f, point.y - 1.5f);            // Line from start to A
        point = (Point2D.Float) p.getCurrentPoint();
        p.lineTo(point.x + 1.5f, point.y - 3.0f);            // Line from A to B
        point = (Point2D.Float) p.getCurrentPoint();
        p.lineTo(point.x + 1.5f, point.y + 3.0f);            // Line from B to C
        point = (Point2D.Float) p.getCurrentPoint();
        p.lineTo(point.x + 3.0f, point.y + 1.5f);            // Line from C to D
        point = (Point2D.Float) p.getCurrentPoint();
        p.lineTo(point.x - 3.0f, point.y + 1.5f);            // Line from D to E
        point = (Point2D.Float) p.getCurrentPoint();
        p.lineTo(point.x - 1.5f, point.y + 3.0f);            // Line from E to F
        point = (Point2D.Float) p.getCurrentPoint();
        p.lineTo(point.x - 1.5f, point.y - 3.0f);            // Line from F to g
        p.closePath();                                        // Line from G to start
    }
1241231
def _central_slopes_directions(self, data, dX, dY):
        
        shp = np.array(data.shape) - 1

        direction = np.full(data.shape, FLAT_ID_INT, 'float64')
        mag = np.full(direction, FLAT_ID_INT, 'float64')

        ind = 0
        d1, d2, theta = _get_d1_d2(dX, dY, ind, [0, 1], [1, 1], shp)
        s2 = (data[0:-2, 1:-1] - data[2:, 1:-1]) / d2
        s1 = -(data[1:-1, 0:-2] - data[1:-1, 2:]) / d1
        direction[1:-1, 1:-1] = np.arctan2(s2, s1) + np.pi
        mag = np.sqrt(s1**2 + s2**2)

        return mag, direction
59601
def _save_potentials(self, directory):
        
        print('saving potentials')
        digits = int(np.ceil(np.log10(self.configs.configs.shape[0])))
        for i in range(0, self.configs.configs.shape[0]):
            pot_data = self.get_potential(i)
            filename_raw = 'pot{0:0' + '{0}'.format(digits) + '}.dat'
            filename = directory + os.sep + filename_raw.format(i + 1)

            nodes = self.grid.nodes['sorted'][:, 1:3]
            all_data = np.hstack((
                nodes,
                pot_data[0][:, np.newaxis],
                pot_data[1][:, np.newaxis],
            ))
            with open(filename, 'wb') as fid:
                np.savetxt(fid, all_data)
443326
def save_graph(cn_topo, filename, showintfs=False, showaddrs=False):
    '''
     
    '''
    __do_draw(cn_topo, showintfs=showintfs, showaddrs=showaddrs)
    pyp.savefig(filename)
304854
private void applyDirection() {
		String imgUrl = "";
		switch (direction) {
			case NORTH:
				panVector = new Coordinate(0, 1);
				imgUrl = northImage;
				break;
			case EAST:
				panVector = new Coordinate(1, 0);
				imgUrl = eastImage;
				break;
			case SOUTH:
				panVector = new Coordinate(0, -1);
				imgUrl = southImage;
				break;
			case WEST:
				panVector = new Coordinate(-1, 0);
				imgUrl = westImage;
				break;
		}
		controller = new PanArrowController(map, panVector);
		image = new Image(getId());
		image.setHref(imgUrl);
		image.setStyle(style);
		image.setBounds(new Bbox(0, 0, getWidth(), getHeight()));
	}
1240454
def _write_angle_information(gsd_file, structure):
    

    gsd_file.angles.N = len(structure.angles)

    unique_angle_types = set()
    for angle in structure.angles:
        t1, t2, t3 = angle.atom1.type, angle.atom2.type, angle.atom3.type
        t1, t3 = sorted([t1, t3], key=natural_sort)
        angle_type = ('-'.join((t1, t2, t3)))
        unique_angle_types.add(angle_type)
    unique_angle_types = sorted(list(unique_angle_types), key=natural_sort)
    gsd_file.angles.types = unique_angle_types

    angle_typeids = []
    angle_groups = []
    for angle in structure.angles:
        t1, t2, t3 = angle.atom1.type, angle.atom2.type, angle.atom3.type
        t1, t3 = sorted([t1, t3], key=natural_sort)
        angle_type = ('-'.join((t1, t2, t3)))
        angle_typeids.append(unique_angle_types.index(angle_type))
        angle_groups.append((angle.atom1.idx, angle.atom2.idx,
                             angle.atom3.idx))

    gsd_file.angles.typeid = angle_typeids
    gsd_file.angles.group = angle_groups
604687
def dinfFlowDirection(self,
                          flow_dir_grid,
                          slope_grid,
                          pit_filled_elevation_grid=None):
        
        log("PROCESS: DinfFlowDirection")
        if pit_filled_elevation_grid:
            self.pit_filled_elevation_grid = pit_filled_elevation_grid

        # Construct the taudem command line.
        cmd = [os.path.join(self.taudem_exe_path, 'dinfflowdir'),
               '-fel', self.pit_filled_elevation_grid,
               '-ang', flow_dir_grid,
               '-slp', slope_grid,
               ]

        self._run_mpi_cmd(cmd)

        # create projection files
        self._add_prj_file(self.pit_filled_elevation_grid,
                           flow_dir_grid)
        self._add_prj_file(self.pit_filled_elevation_grid,
                           slope_grid)