예제 #1
0
 def show_possible_nodes(self):
     """
     Once the subsets by aspect and slope have been set, call this function
     to see both the whole elevation map, and the subset of nodes that
     will be searched.
     """
     possible_core_nodes = np.logical_and(self.steep_nodes, self.aspect_close_nodes)
     figure(1)
     gridshow.imshow_node_grid(self.grid, self.elevs)
     figure(2)
     gridshow.imshow_core_node_grid(self.grid, self.slopes)
     figure(3)
     gridshow.imshow_core_node_grid(self.grid, self.aspect)
     figure(4)
     gridshow.imshow_core_node_grid(self.grid, possible_core_nodes)
     show()
예제 #2
0
 def show_possible_nodes(self):
     """
     Once the subsets by aspect and slope have been set, call this function
     to see both the whole elevation map, and the subset of nodes that
     will be searched.
     """
     possible_core_nodes = np.logical_and(self.steep_nodes, self.aspect_close_nodes)
     figure(1)
     gridshow.imshow_node_grid(self.grid, self.elevs)
     figure(2)
     gridshow.imshow_core_node_grid(self.grid, self.slopes)
     figure(3)
     gridshow.imshow_core_node_grid(self.grid, self.aspect)
     figure(4)
     gridshow.imshow_core_node_grid(self.grid, possible_core_nodes)
     show()
예제 #3
0
 def define_aspect_node_subset_local(self, dist_tolerance=4., angle_tolerance=15., dip_dir='E'):
     """
     """
     grid = self.grid
     try:
         print('using subset')
         # remember, steep_nodes is already core_nodes.size long
         subset = np.where(self.steep_nodes)[0]
     except NameError:
         print('using all nodes')
         subset = np.arange(grid.core_nodes.size)
     closest_ft_node = np.empty(subset.size, dtype=int)
     angle_to_ft = np.empty_like(closest_ft_node, dtype=float)
     new_angle_to_ft = np.empty_like(closest_ft_node, dtype=float)
     distance_to_ft = np.empty_like(closest_ft_node, dtype=float)
     distance_to_ft.fill(sys.float_info.max)
     new_distance_to_ft = np.empty_like(closest_ft_node, dtype=float)
     for i in self.ft_trace_node_ids:
         grid.get_distances_of_nodes_to_point((grid.node_x[i], grid.node_y[i]),
                                              node_subset=grid.core_nodes[
                                                  subset], get_az='angles',
                                              out_distance=new_distance_to_ft, out_azimuth=new_angle_to_ft)
         closer_nodes = new_distance_to_ft < distance_to_ft
         distance_to_ft[closer_nodes] = new_distance_to_ft[closer_nodes]
         angle_to_ft[closer_nodes] = new_angle_to_ft[closer_nodes]
         closest_ft_node[closer_nodes] = i
     self.closest_ft_node = -np.ones(grid.core_nodes.size)
     self.distance_to_ft = -np.ones(grid.core_nodes.size)
     self.angle_to_ft = -np.ones(grid.core_nodes.size)
     self.closest_ft_node[subset] = closest_ft_node
     self.distance_to_ft[subset] = distance_to_ft
     # angle_to_ft is actually the angle_from_ft! So we need to adjust.
     # a second problem is that pts downslope (opposite az) can also be on the line.
     # solution - take a dip_dir input...
     angle_to_ft = (angle_to_ft + np.pi) % (2. * np.pi)
     self.angle_to_ft[subset] = angle_to_ft
     #gridshow.imshow_core_node_grid(self.grid, self.distance_to_ft)
     # show()
     #gridshow.imshow_core_node_grid(self.grid, self.angle_to_ft)
     # show()
     # the relevant condition is now that the local aspect and angle to fault
     # are the same...
     # We need to bias the five degrees against distant points, as it's easier
     # to have similar angles in the far field. Rule should be in px - the
     # two angles should be within *angle_tol* px of each other at the ft
     # trace.
     divergence_at_ft = distance_to_ft * \
         np.tan((angle_to_ft - self.aspect[subset]) % np.pi)
     # might be *too* forgiving for close-in nodes
     condition = np.less(np.fabs(divergence_at_ft),
                         grid.node_spacing * dist_tolerance)
     #...so add another tester; must be w/i 15 degrees of each other:
     diff_angles = np.min([np.fabs(angle_to_ft - self.aspect[subset]), np.fabs(
         np.fabs(angle_to_ft - self.aspect[subset]) - 2. * np.pi)], axis=0)
     self.diff_angles = np.empty(grid.core_nodes.size, dtype=float)
     self.diff_angles.fill(sys.float_info.max)
     self.diff_angles[subset] = diff_angles
     #gridshow.imshow_core_node_grid(self.grid, self.angle_to_ft)
     # show()
     figure(6)
     gridshow.imshow_core_node_grid(self.grid, np.where(
         self.diff_angles < 100000., self.diff_angles, -1.))
     condition2 = np.less(diff_angles, angle_tolerance * np.pi / 180.)
     condition = np.logical_and(condition, condition2)
     core_nodes_size_condition = np.zeros(grid.core_nodes.size, dtype=bool)
     core_nodes_size_condition[subset] = condition
     #gridshow.imshow_core_node_grid(self.grid, core_nodes_size_condition)
     # show()
     #core_nodes_size_condition = np.zeros(grid.core_nodes.size, dtype=bool)
     #core_nodes_size_condition[subset] = condition2
     #gridshow.imshow_core_node_grid(self.grid, core_nodes_size_condition)
     # show()
     self.aspect_close_nodes = core_nodes_size_condition
     print('Calculated and stored nodes with aspects compatible with fault trace...')
     return self.aspect_close_nodes
예제 #4
0
 def define_aspect_node_subset_local(self,
                                     dist_tolerance=4.,
                                     angle_tolerance=15.,
                                     dip_dir='E'):
     """
     """
     grid = self.grid
     try:
         print 'using subset'
         subset = np.where(self.steep_nodes)[
             0]  #remember, steep_nodes is already core_nodes.size long
     except NameError:
         print 'using all nodes'
         subset = np.arange(grid.core_nodes.size)
     closest_ft_node = np.empty(subset.size, dtype=int)
     angle_to_ft = np.empty_like(closest_ft_node, dtype=float)
     new_angle_to_ft = np.empty_like(closest_ft_node, dtype=float)
     distance_to_ft = np.empty_like(closest_ft_node, dtype=float)
     distance_to_ft.fill(sys.float_info.max)
     new_distance_to_ft = np.empty_like(closest_ft_node, dtype=float)
     for i in self.ft_trace_node_ids:
         grid.get_distances_of_nodes_to_point(
             (grid.node_x[i], grid.node_y[i]),
             node_subset=grid.core_nodes[subset],
             get_az='angles',
             out_distance=new_distance_to_ft,
             out_azimuth=new_angle_to_ft)
         closer_nodes = new_distance_to_ft < distance_to_ft
         distance_to_ft[closer_nodes] = new_distance_to_ft[closer_nodes]
         angle_to_ft[closer_nodes] = new_angle_to_ft[closer_nodes]
         closest_ft_node[closer_nodes] = i
     self.closest_ft_node = -np.ones(grid.core_nodes.size)
     self.distance_to_ft = -np.ones(grid.core_nodes.size)
     self.angle_to_ft = -np.ones(grid.core_nodes.size)
     self.closest_ft_node[subset] = closest_ft_node
     self.distance_to_ft[subset] = distance_to_ft
     #angle_to_ft is actually the angle_from_ft! So we need to adjust.
     #a second problem is that pts downslope (opposite az) can also be on the line.
     #solution - take a dip_dir input...
     angle_to_ft = (angle_to_ft + np.pi) % (2. * np.pi)
     self.angle_to_ft[subset] = angle_to_ft
     #gridshow.imshow_core_node_grid(self.grid, self.distance_to_ft)
     #show()
     #gridshow.imshow_core_node_grid(self.grid, self.angle_to_ft)
     #show()
     #the relevant condition is now that the local aspect and angle to fault
     #are the same...
     #We need to bias the five degrees against distant points, as it's easier
     #to have similar angles in the far field. Rule should be in px - the
     #two angles should be within *angle_tol* px of each other at the ft
     #trace.
     divergence_at_ft = distance_to_ft * np.tan(
         (angle_to_ft - self.aspect[subset]) % np.pi)
     condition = np.less(
         np.fabs(divergence_at_ft), grid.node_spacing *
         dist_tolerance)  #might be *too* forgiving for close-in nodes
     #...so add another tester; must be w/i 15 degrees of each other:
     diff_angles = np.min([
         np.fabs(angle_to_ft - self.aspect[subset]),
         np.fabs(np.fabs(angle_to_ft - self.aspect[subset]) - 2. * np.pi)
     ],
                          axis=0)
     self.diff_angles = np.empty(grid.core_nodes.size, dtype=float)
     self.diff_angles.fill(sys.float_info.max)
     self.diff_angles[subset] = diff_angles
     #gridshow.imshow_core_node_grid(self.grid, self.angle_to_ft)
     #show()
     figure(6)
     gridshow.imshow_core_node_grid(
         self.grid,
         np.where(self.diff_angles < 100000., self.diff_angles, -1.))
     condition2 = np.less(diff_angles, angle_tolerance * np.pi / 180.)
     condition = np.logical_and(condition, condition2)
     core_nodes_size_condition = np.zeros(grid.core_nodes.size, dtype=bool)
     core_nodes_size_condition[subset] = condition
     #gridshow.imshow_core_node_grid(self.grid, core_nodes_size_condition)
     #show()
     #core_nodes_size_condition = np.zeros(grid.core_nodes.size, dtype=bool)
     #core_nodes_size_condition[subset] = condition2
     #gridshow.imshow_core_node_grid(self.grid, core_nodes_size_condition)
     #show()
     self.aspect_close_nodes = core_nodes_size_condition
     print 'Calculated and stored nodes with aspects compatible with fault trace...'
     return self.aspect_close_nodes