コード例 #1
0
    def next_impactor(self):
        cr = craters.impactor()

        (impact_x, impact_y) = self.next_impact_position()
        cr._radius = self.next_impactor_radius()
        cr.set_depth_from_size()
        cr.set_crater_volume()
        cr._xcoord, cr._ycoord = (impact_x, impact_y)

        return cr
コード例 #2
0
ファイル: component.py プロジェクト: JianweiHan/landlab
    def next_impactor(self):
        cr = craters.impactor()

        (impact_x, impact_y) = self.next_impact_position()
        cr._radius = self.next_impactor_radius()
        cr.set_depth_from_size()
        cr.set_crater_volume()
        cr._xcoord, cr._ycoord = (impact_x, impact_y)

        return cr
コード例 #3
0
ファイル: craters_timetests.py プロジェクト: Fooway/landlab
def dig_one_crater_timetest(reps, nr, nc, dx, rel_x, rel_y, radius, switch):
    '''
        This script digs a single crater, either using the crawler method (switch=0), or by sweeping the whole grid (switch=1). It is designed to time the the crater digging scripts in crater.py, with an eye to determining 1. if solving over the whole grid can be faster than the conditional crawler, and 2. if there's a crossover point for small (i.e., typical!) craters.
    '''
    mg = RasterModelGrid()
    mg.initialize(nr, nc, dx)
    vectors = data(mg)
    vectors.elev[:] = 100.
    cr = craters.impactor()

    start_time = time.time()
    for i in range(reps):
        cr._radius = radius
        #print 'Radius: ', cr._radius
        cr.set_depth_from_size()
        #print 'Depth: ', cr._depth
        cr.set_crater_volume()
        cr._xcoord = rel_x * mg.get_grid_xdimension()
        cr._ycoord = rel_y * mg.get_grid_ydimension()
        vertices_array = mg.get_nodes_around_point(cr._xcoord, cr._ycoord)
        distances_to_vertices = []
        #print vertices_array
        #print len(mg.node_x)
        for x in vertices_array:
            distances_to_vertices.append(
                numpy.sqrt((cr._xcoord - mg.node_x[x])**2. +
                           (cr._ycoord - mg.node_y[x])**2.))
        cr.closest_node_index = vertices_array[numpy.argmin(
            distances_to_vertices)]
        cr.closest_node_elev = vectors.elev[cr.closest_node_index]

        cr._angle_to_horizontal = numpy.pi * 0.5 * 3. / 3.
        cr._azimuth_of_travel = numpy.pi * 1.5
        cr.set_crater_mean_slope_v2(mg, vectors)
        print('Azimuth of travel: ', cr._azimuth_of_travel)
        print('Angle of ground: ', cr._surface_slope)
        print('Dip direction of ground: ', cr._surface_dip_direction)
        if switch:
            cr.set_elev_change_across_grid(mg, vectors)
        else:
            cr.set_elev_change_at_pts(mg, vectors)
        print('Impact angle to ground normal: ',
              cr.impactor_angle_to_surface_normal)

    end_time = time.time()
    print(('Elapsed time was %g seconds' % (end_time - start_time)))

    elev_raster = mg.node_vector_to_raster(vectors.elev, flip_vertically=True)
    vectors.viewing_raster = elev_raster
    return cr, mg, vectors
コード例 #4
0
def dig_one_crater_timetest(reps, nr, nc, dx, rel_x, rel_y, radius, switch):
    '''
        This script digs a single crater, either using the crawler method (switch=0), or by sweeping the whole grid (switch=1). It is designed to time the the crater digging scripts in crater.py, with an eye to determining 1. if solving over the whole grid can be faster than the conditional crawler, and 2. if there's a crossover point for small (i.e., typical!) craters.
    '''
    mg = RasterModelGrid()
    mg.initialize(nr, nc, dx)
    vectors = data(mg)
    vectors.elev[:] = 100.
    cr = craters.impactor()

    start_time = time.time()
    for i in range(reps):
        cr._radius = radius
        #print 'Radius: ', cr._radius
        cr.set_depth_from_size()
        #print 'Depth: ', cr._depth
        cr.set_crater_volume()
        cr._xcoord = rel_x*mg.get_grid_xdimension()
        cr._ycoord = rel_y*mg.get_grid_ydimension()
        vertices_array = mg.get_nodes_around_point(cr._xcoord, cr._ycoord)
        distances_to_vertices = []
        #print vertices_array
        #print len(mg.node_x)
        for x in vertices_array:
            distances_to_vertices.append(numpy.sqrt((cr._xcoord-mg.node_x[x])**2. + (cr._ycoord-mg.node_y[x])**2.))
        cr.closest_node_index = vertices_array[numpy.argmin(distances_to_vertices)]
        cr.closest_node_elev = vectors.elev[cr.closest_node_index]
        
        cr._angle_to_horizontal = numpy.pi*0.5*3./3.
        cr._azimuth_of_travel = numpy.pi*1.5
        cr.set_crater_mean_slope_v2(mg, vectors)
        print 'Azimuth of travel: ', cr._azimuth_of_travel
        print 'Angle of ground: ', cr._surface_slope
        print 'Dip direction of ground: ', cr._surface_dip_direction
        if switch:
            cr.set_elev_change_across_grid(mg, vectors)
        else:
            cr.set_elev_change_at_pts(mg, vectors)
        print 'Impact angle to ground normal: ', cr.impactor_angle_to_surface_normal
    
    end_time = time.time()
    print('Elapsed time was %g seconds' % (end_time - start_time))
    
    elev_raster = mg.node_vector_to_raster(vectors.elev, flip_vertically=True)
    vectors.viewing_raster = elev_raster
    return cr, mg, vectors
コード例 #5
0
    def dig_one_crater(self, impact_loc, radius):
        """
        Dig a crater that impacts the surface at *impact_loc*, which is a
        tuple of an x, y position (in km) on the planet surface. *radius* is
        the size of the impactor in km.
        """
        cr = craters.impactor()

        cr._radius = radius
        cr.set_depth_from_size()
        cr.set_crater_volume()
        cr._xcoord, cr._ycoord = (impact_loc[1], impact_loc[0])

        z0 = self._grid.at_node['planet_surface__elevation'].copy()

        vertices_array = self.grid.get_nodes_around_point(
            impact_loc[1], impact_loc[0])

        distances_to_vertices = []
        for node_id in vertices_array:
            try:
                distances_to_vertices.append(
                    np.sqrt((impact_loc[1] - self.grid.node_x[node_id])**2. +
                            (impact_loc[0] - self.grid.node_y[node_id])**2.))
            except IndexError:
                return

        cr.closest_node_index = vertices_array[np.argmin(
            distances_to_vertices)]
        cr.closest_node_elev = self._vectors.elev[cr.closest_node_index]
        cr._angle_to_horizontal = np.pi * 0.5 * 3. / 3.
        cr._azimuth_of_travel = np.pi * 1.5

        cr.set_crater_mean_slope_v2(self.grid, self._vectors)
        cr.set_elev_change_across_grid(self.grid, self._vectors)

        self._grid.at_node['planet_surface__elevation_increment'][:].flat = (
            self._grid.at_node['planet_surface__elevation'].flat - z0)
コード例 #6
0
ファイル: component.py プロジェクト: JianweiHan/landlab
    def dig_one_crater(self, impact_loc, radius):
        """
        Dig a crater that impacts the surface at *impact_loc*, which is a
        tuple of an x, y position (in km) on the planet surface. *radius* is
        the size of the impactor in km.
        """
        cr = craters.impactor()

        cr._radius = radius
        cr.set_depth_from_size()
        cr.set_crater_volume()
        cr._xcoord, cr._ycoord = (impact_loc[1], impact_loc[0])

        z0 = self._grid.at_node['planet_surface__elevation'].copy()

        vertices_array = self.grid.get_nodes_around_point(impact_loc[1],
                                                          impact_loc[0])

        distances_to_vertices = []
        for node_id in vertices_array:
            try:
                distances_to_vertices.append(
                    np.sqrt((impact_loc[1] - self.grid.node_x[node_id]) ** 2. +
                            (impact_loc[0] - self.grid.node_y[node_id]) ** 2.))
            except IndexError:
                return

        cr.closest_node_index = vertices_array[np.argmin(distances_to_vertices)]
        cr.closest_node_elev = self._vectors.elev[cr.closest_node_index]
        cr._angle_to_horizontal = np.pi * 0.5 * 3. / 3.
        cr._azimuth_of_travel = np.pi * 1.5

        cr.set_crater_mean_slope_v2(self.grid, self._vectors)
        cr.set_elev_change_across_grid(self.grid, self._vectors)

        self._grid.at_node['planet_surface__elevation_increment'][:].flat = (
            self._grid.at_node['planet_surface__elevation'].flat - z0)
コード例 #7
0
nt = inputs.read_int('number_of_craters_per_loop')
loops = inputs.read_int('number_of_loops')

mg = RasterModelGrid(nrows, ncols, dx)
mg.set_inactive_boundaries(False, False, False, False)

#create the fields in the grid
mg.add_zeros('topographic__elevation', at='node')
mg['node']['topographic__elevation'] = np.load('init.npy')

# Display a message
print('Running ...')
start_time = time.time()

#instantiate the component:
craters_component = impactor(mg, input_file)
craters_component.radius_auto_flag = 0
craters_component.position_auto_flag = 0
craters_component.angle_auto_flag = 0

#perform the loops:
slope = np.empty(nt)
mass_balance = np.empty(nt)
redug_crater = np.empty(nt)
for i in range(loops):
    x = np.load('x_' + str((i + 1) * nt) + '.npy')
    y = np.load('y_' + str((i + 1) * nt) + '.npy')
    r = np.load('r_' + str((i + 1) * nt) + '.npy')
    angle = np.load('angle_' + str((i + 1) * nt) + '.npy')
    az = np.load('az_' + str((i + 1) * nt) + '.npy')
    for j in range(nt):
コード例 #8
0
nt = inputs.read_int('number_of_craters_per_loop')
loops = inputs.read_int('number_of_loops')

mg = RasterModelGrid(nrows, ncols, dx)
mg.set_inactive_boundaries(False, False, False, False)

#create the fields in the grid
mg.add_zeros('topographic__elevation', at='node')
mg['node'][ 'topographic__elevation'] = np.load('init.npy')

# Display a message
print( 'Running ...' )
start_time = time.time()

#instantiate the component:
craters_component = impactor(mg, input_file)
craters_component.radius_auto_flag = 0
craters_component.position_auto_flag = 0
craters_component.angle_auto_flag = 0

#perform the loops:
slope = np.empty(nt)
mass_balance = np.empty(nt)
for i in range(loops):
    x = np.load('x_'+str((i+1)*nt)+'.npy')
    y = np.load('y_'+str((i+1)*nt)+'.npy')
    r = np.load('r_'+str((i+1)*nt)+'.npy')
    angle = np.load('angle_'+str((i+1)*nt)+'.npy')
    az = np.load('az_'+str((i+1)*nt)+'.npy')
    for j in range(nt):
        craters_component._xcoord = x[j]
コード例 #9
0
ファイル: angles_test.py プロジェクト: Fooway/landlab
mg = RasterModelGrid(nrows, ncols, dx)
mg.set_looped_boundaries(True, True)

#create the fields in the grid
mg.add_zeros('topographic__elevation', at='node')
z = mg.zeros(at='node') + leftmost_elev
z += initial_slope*np.amax(mg.node_y) - initial_slope*mg.node_y
mg['node'][ 'topographic__elevation'] = z #+ np.random.rand(len(z))/10000.

# Display a message
print( 'Running ...' )
start_time = time.time()

#instantiate the component:
craters_component = impactor(mg, input_file)

offset=0

#perform the loops:
x = np.empty(nt)
y = np.empty(nt)
r = np.empty(nt)
slope = np.empty(nt)
angle = np.empty(nt)
az = np.empty(nt)
mass_balance = np.empty(nt)
for i in range(loops):
    for j in range(nt):
        mg = craters_component.excavate_a_crater_furbish(mg)
        x[j] = craters_component.impact_xy_location[0]