def disk_hidden_area(disk_radius, disk_inclination, x_star, y_star, star_disk_intersections, tol): """ Calculating the area hidden by the planet. Models using DoubleHiddenAreaAlgorithm for consistency and lack of errors. Parameters ---------- disk_radius : ``1-D array`` Disk's radius relative to star's radius disk_inclination : ``float`` Disk's inclination (in radians) x_star : ``1-D array`` x coordinate of the star's center y_star : ``1-D array`` y coordinate of the star's center star_disk_intersections : ``2-D array`` the array of star-disk intersections as returned by get_star_disk_intersection tol : ``float``, optional Error tolerance parameter Returns ------- disk_area : ``1-D array`` Area hidden by the disk """ #The commented-out code is a case-specific implememtnation of Step 1.1.1 of the algorithm. # disk_area = np.zeros_like(x_star) # scalc = np.all(np.isnan(star_disk_intersections),(1,2)) # simplei = scalc.copy() # sx = x_star[scalc] # sy = y_star[scalc] # sr = disk_radius[scalc] # sinc = M.sin(disk_inclination) # instar = sx**2+sy**2<=(1+tol)**2 # indisk = np.sqrt((sx-sr*sinc)**2+sy**2)+np.sqrt((sx+sr*sinc)**2+sy**2)<=2*sr+tol # incalc = np.logical_or(instar,indisk) # sr = sr[incalc]**2*M.cos(disk_inclination) # sr[sr>1] = 1 # scalc[np.nonzero(scalc)[0][np.logical_not(incalc)]] = False # disk_area[scalc] = M.pi*sr # scalc = simplei # remcalc = np.logical_not(scalc) # border = border_sort(star_disk_intersections[remcalc]) # dangle = border[:,3,:] # this_disk = Disk(disk_radius[remcalc], disk_inclination, dangle, np.ones_like(dangle, dtype=bool)) # this_star = Star(np.concatenate((x_star[remcalc].reshape((1,-1)),y_star[remcalc].reshape((1,-1)))), border[:,2,:], np.ones_like(dangle, dtype=bool)) # disk_area[remcalc] = double_hidden_area((this_star,this_disk),border,tol) #Prepare the objects for the algorithm border = border_sort(star_disk_intersections) dangle = border[:, 3, :] this_disk = Disk(disk_radius, disk_inclination, dangle, np.ones_like(dangle, dtype=bool)) this_star = Star( np.concatenate((x_star.reshape((1, -1)), y_star.reshape((1, -1)))), border[:, 2, :], np.ones_like(dangle, dtype=bool)) #Calculate the area disk_area = double_hidden_area((this_star, this_disk), border, tol) return disk_area
def planet_hidden_area(radius_planet, x_star, y_star, star_planet_intersections, tol): """ Calculating the area hidden by the planet. Models using DoubleHiddenAreaAlgorithm for consistency and lack of errors. Parameters ---------- radius_planet : ``1-D array`` Planet's radius relative to star's radius x_star : ``1-D array`` x coordinate of the star's center y_star : ``1-D array`` y coordinate of the star's center star_planet_intersections : ``2-D array`` the array of star-planet intersections as returned by get_star_planet_intersection tol : ``float``, optional Error tolerance parameter Returns ------- planet_area : ``1-D array`` Area hidden by the planet """ #The commented-out code is a case-specific implememtnation of Step 1.1.1 of the algorithm. # #Initilize with zeros to avoid special handling of another special case # planet_area = np.zeros_like(x_star) # calcr = radius_planet.copy() # calcr[calcr<1] = 1 # #If there are <2 intersections and the planet is hiding part of the star # scalc = np.logical_and(np.any(np.isnan(star_planet_intersections),(1,2)),np.sqrt(x_star**2+y_star**2)<=calcr) # calcr = radius_planet[scalc].copy() # calcr[calcr>1] = 1 # planet_area[scalc] = M.pi*calcr**2 # #If there are 2 intersections, call the hidden area calculator. # scalc = np.any(np.isnan(star_planet_intersections),(1,2)) # remcalc = np.logical_not(scalc) # border = border_sort(star_planet_intersections[remcalc]) # pangles = border[:,3,:] # this_planet = Planet(radius_planet[remcalc], pangles, np.ones_like(pangles, dtype=bool)) # this_star = Star(np.concatenate((x_star[remcalc].reshape((1,-1)),y_star[remcalc].reshape((1,-1)))), border[:,2,:], np.ones_like(pangles, dtype=bool)) # planet_area[remcalc] = double_hidden_area((this_star,this_planet),border,tol) #Prepare the objects for the algorithm border = border_sort(star_planet_intersections) pangles = border[:, 3, :] this_planet = Planet(radius_planet, pangles, np.ones_like(pangles, dtype=bool)) this_star = Star( np.concatenate((x_star.reshape((1, -1)), y_star.reshape((1, -1)))), border[:, 2, :], np.ones_like(pangles, dtype=bool)) #Calculate the area planet_area = double_hidden_area((this_star, this_planet), border, tol) return planet_area
def tot_hidden_area(radius_planet, radius_in, radius_out, x_star, y_star, ring_inclination, star_planet_intersections, star_disk_intersections_in, star_disk_intersections_out, disk_planet_intersections_in, disk_planet_intersections_out, opacity, tol=10**-10): """ Calculation of the total hidden area of the planet and ring together Parameters ---------- radius_planet : ``1-D array`` Planet's radius radius_in : ``1-D array`` Ring's inner radius radius_out : ``1-D array`` Ring's outer radius x_star : ``1-D array`` x coordinate of the star's center y_star : ``1-D array`` y coordinate of the star's center ring_inclination : ``float`` Ring's inclination (in radians) star_planet_intersections : ``2-D array`` the array of star-planet intersections as returned by get_star_planet_intersection star_disk_intersections_in : ``2-D array`` the array of star-inner disk intersections as returned by get_star_disk_intersection star_disk_intersections_out : ``2-D array`` the array of star-outer disk intersections as returned by get_star_disk_intersection disk_planet_intersections_in : ``2-D array`` the array of inner disk-planet intersections as returned by get_disk_planet_intersection disk_planet_intersections_out : ``2-D array`` the array of outer disk-planet intersections as returned by get_disk_planet_intersection opacity : ``float`` Ring's opacity tol : ``float``, optional Error tolerance parameter Returns ------- hidden_area : ``1-D array`` Total hidden area by the planet and ring. """ #Planet hidden area planet_area = planet_hidden_area(radius_planet, x_star, y_star, star_planet_intersections, tol) #Disks hidden area disk_in_area = disk_hidden_area(radius_in, ring_inclination, x_star, y_star, star_disk_intersections_in, tol) disk_out_area = disk_hidden_area(radius_out, ring_inclination, x_star, y_star, star_disk_intersections_out, tol) #Double hidden area #Initial values assuming no intersections double_area_in = np.minimum(planet_area, disk_in_area) double_area_out = np.minimum(planet_area, disk_out_area) #When there are intersections, call the algorithm to find the double hidden area. calcin = np.logical_and( np.logical_and(planet_area > 0, disk_in_area > 0), np.any(np.logical_not(np.isnan(disk_planet_intersections_in)), (1, 2))) star, planet, disk, dha_border_in = handler( radius_planet[calcin], radius_in[calcin], ring_inclination, x_star[calcin], y_star[calcin], star_planet_intersections[calcin], star_disk_intersections_in[calcin], disk_planet_intersections_in[calcin], tol) double_area_in[calcin] = double_hidden_area((star, planet, disk), dha_border_in, tol) calcout = np.logical_and( np.logical_and(planet_area > 0, disk_out_area > 0), np.any(np.logical_not(np.isnan(disk_planet_intersections_out)), (1, 2))) star, planet, disk, dha_border_out = handler( radius_planet[calcout], radius_out[calcout], ring_inclination, x_star[calcout], y_star[calcout], star_planet_intersections[calcout], star_disk_intersections_out[calcout], disk_planet_intersections_out[calcout], tol) double_area_out[calcout] = double_hidden_area((star, planet, disk), dha_border_out, tol) #Conclusions ring_area = (disk_out_area - double_area_out) - (disk_in_area - double_area_in) hidden_area = opacity * ring_area + planet_area return hidden_area