Skip to content

Commit

Permalink
remove utils.hfov_from_table
Browse files Browse the repository at this point in the history
  • Loading branch information
Iburelli committed Jan 6, 2024
1 parent 4b4a4ee commit 47c2bd8
Showing 1 changed file with 0 additions and 54 deletions.
54 changes: 0 additions & 54 deletions divtel/utils.py
Original file line number Diff line number Diff line change
@@ -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):
Expand Down Expand Up @@ -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

0 comments on commit 47c2bd8

Please sign in to comment.