def get_cities(lat, lon, radius, minpop=0): region = od.radius_to_region(lat, lon, radius) cities = get_cities_region(region, minpop=minpop) clats = num.array([c.lat for c in cities]) clons = num.array([c.lon for c in cities]) dists = od.distance_accurate50m_numpy(lat, lon, clats, clons) order = num.argsort(dists) cities_sorted = [cities[i] for i in order if dists[i] < radius] return cities_sorted
def grid_points_in_error_ellipses(lat_ev, lon_ev, depth_ev, error_h, error_z, path_models=None, gf_store_id=None): pathlist = Path(path_models).glob('model_%s_*' % gf_store_id) region = orthodrome.radius_to_region(lat_ev, lon_ev, error_h) grid_points = [] for path in sorted(pathlist): path = str(path) model_coordinates = path.split("_") lat = float(model_coordinates[3]) lon = float(model_coordinates[4]) depth = float(model_coordinates[5]) dists = orthodrome.distance_accurate50m_numpy(lat_ev, lon_ev, lat, lon) if dists < error_h: if depth_ev-error_z < depth and depth_ev+error_z > depth: grid_points.append(path) return grid_points