def generate_outer_arms(v4a_ss_enu_file, num_clusters_outer, stations_per_outer_cluster, outer_arm_cluster_radius, station_radius_m, num_tries): v4a_ss_enu = numpy.loadtxt(v4a_ss_enu_file) v4a_ss_enu = v4a_ss_enu[:, 1:] v4a_ss_r = (v4a_ss_enu[:, 0]**2 + v4a_ss_enu[:, 1]**2)**0.5 sort_idx = numpy.argsort(v4a_ss_r) v4a_ss_enu = v4a_ss_enu[sort_idx[::-1], :] cluster_x = v4a_ss_enu[:num_clusters_outer, 0] cluster_y = v4a_ss_enu[:num_clusters_outer, 1] # Generate stations at the cluster positions. num_stations = num_clusters_outer * stations_per_outer_cluster arm_x = numpy.zeros(num_stations) arm_y = numpy.zeros(num_stations) for i in range(num_clusters_outer): for t in range(num_tries): x, y, _ = gridgen(stations_per_outer_cluster, outer_arm_cluster_radius * 2.0, station_radius_m * 2.0, 10000) if x.shape[0] == stations_per_outer_cluster: break else: print('.', end='') if not x.shape[0] == stations_per_outer_cluster: raise RuntimeError('Did not generate enough stations in outer arm ' 'cluster. %i / %i' % (x.shape[0], stations_per_outer_cluster)) i0 = i * stations_per_outer_cluster i1 = i0 + stations_per_outer_cluster arm_x[i0:i1] = x + cluster_x[i] arm_y[i0:i1] = y + cluster_y[i] return arm_x, arm_y, cluster_x, cluster_y
def test1(): n = 512 b_max = 100e3 station_d = 35.0 x, y, _ = utils.gridgen(n, b_max * 2.0, station_d, max_trials=1000) # Plotting fig = pyplot.figure(figsize=(8, 8)) ax = fig.add_subplot(111) ax.plot(x, y, ".") circle = pyplot.Circle((0, 0), b_max, color="r", fill=False, alpha=1.0, linewidth=1.0, linestyle="--") ax.add_artist(circle) ax.grid(True) ax.set_xlim(-b_max * 1.1, b_max * 1.1) ax.set_ylim(-b_max * 1.1, b_max * 1.1) pyplot.show()
def generate_core_arms(num_arms, core_arm_count, stations_per_cluster, arm_cluster_radius, station_radius_m, a, b, delta_theta, arm_offsets, num_tries): # Position of station clusters. (generate single arm and rotate to position # with stride 3) num_clusters = num_arms * core_arm_count t = numpy.arange(num_clusters) * delta_theta tmp = a * numpy.exp(b * t) cluster_x = tmp * numpy.cos(t) cluster_y = tmp * numpy.sin(t) for i in range(num_arms): cluster_x[i::3], cluster_y[i::3] = \ rotate_coords(cluster_x[i::3], cluster_y[i::3], math.degrees(arm_offsets[i])) # TODO(BM) shrink arm cluster radius with cluster telescope radius # Generate stations at the cluster positions. num_stations = num_clusters * stations_per_cluster arm_x = numpy.zeros(num_stations) arm_y = numpy.zeros(num_stations) arm_cluster_radius_m_inc = (arm_cluster_radius * 1.0) / (num_clusters - 1) for i in range(num_clusters): cluster_radius_m = arm_cluster_radius_m_inc * (num_clusters - 1 - i) cluster_radius_m += arm_cluster_radius cluster_radius_m = arm_cluster_radius print(i, cluster_radius_m) for t in range(num_tries): # x, y, _ = gridgen(stations_per_cluster, arm_cluster_radius * 2.0, # station_radius_m * 2.0, 30000) x, y, _ = gridgen(stations_per_cluster, cluster_radius_m * 2.0, station_radius_m * 2.0, 30000) if x.shape[0] == stations_per_cluster: break else: print('.', end='') if not x.shape[0] == stations_per_cluster: raise RuntimeError('Did not generate enough stations in arm ' 'cluster. %i / %i' % (x.shape[0], stations_per_cluster)) i0 = i * stations_per_cluster i1 = i0 + stations_per_cluster arm_x[i0:i1] = x + cluster_x[i] arm_y[i0:i1] = y + cluster_y[i] return arm_x, arm_y, cluster_x, cluster_y