From 47c2bd81b9f0cdf9f48dd02fb705f0c86aef9298 Mon Sep 17 00:00:00 2001 From: Iburelli Date: Sat, 6 Jan 2024 18:28:30 +0100 Subject: [PATCH] remove utils.hfov_from_table --- divtel/utils.py | 54 ------------------------------------------------- 1 file changed, 54 deletions(-) diff --git a/divtel/utils.py b/divtel/utils.py index 59837c1..50a4550 100644 --- a/divtel/utils.py +++ b/divtel/utils.py @@ -1,9 +1,6 @@ import numpy as np import matplotlib.pyplot as plt -from shapely.ops import unary_union, polygonize -from shapely.geometry import LineString, Point - import astropy.units as u def calc_mean(table, columns): @@ -95,54 +92,3 @@ def convert_radius(radius, focal, toDeg=False): temp = radius.to(u.rad) radius= np.tan(temp.value)*focal return radius - -def hfov_from_table(table, m_cut=0, return_multiplicity=False, full_output=False): - - if table['alt'].unit == 'rad': - table['alt']=table['alt']*180/np.pi - table['az']=table['az']*180/np.pi - - - - if max(table["az"])-min(table["az"]) > 180: - polygons = [] - - for az, alt, r in zip(table['az'], table['alt'], table["radius"]): - if az < 180: - polygons.append(Point(az, alt).buffer(r)) - else: - polygons.append(Point(az-360, alt).buffer(r)) - else: - polygons = [Point(az, alt).buffer(r) for az, alt, r in zip(table['az'], table['alt'], table["radius"])] - - union = unary_union([LineString(list(pol.exterior.coords)) for pol in polygons]) - geoms = [geom for geom in polygonize(union)] - hfov = [geom.area for geom in geoms] - - count_overlaps = np.zeros(len(geoms)) - for i, geom in enumerate(geoms): - count_overlaps[i] = sum([1 for pol in polygons if abs(geom.difference(pol).area)<1e-5]) - - hfov = np.array(hfov) - - # multiplicity associated with each patch - overlaps = np.array(count_overlaps) - multiplicity = np.array([[i, hfov[overlaps==i].sum()] for i in set(overlaps)]) - eff_overlaps=[] - eff_geoms=[] - for i in range(len(overlaps)): - if overlaps[i]>m_cut: - eff_overlaps.append(overlaps[i]) - eff_geoms.append(geoms[i]) - - fov = sum(multiplicity[:,1][multiplicity[:,0]>=m_cut])*u.deg**2 - - if full_output: - return multiplicity, eff_overlaps, eff_geoms - elif return_multiplicity: - m_ave = np.average(multiplicity[:,0], weights=multiplicity[:,1]) - m_var = np.average((multiplicity[:,0]-m_ave)**2, weights=multiplicity[:,1]) - return fov, m_ave, m_var - else: - return fov -