def angle_in_circle(image_filename, position_of_star, rht_data, radius): """ Gets a star, draws a circle around it and returns the average rht angle and standard deviation in this circle. """ ipoints, jpoints, hthets, naxis1, naxis2, wlen, smr, thresh, thets_deg = rht_data c = CirclePixelRegion(PixCoord( np.round(position_of_star)[0], np.round(position_of_star)[1]), radius=radius) # Check which RHT data is in this region, these are the indices: indices = c.contains(PixCoord(ipoints, jpoints)) # hthets[indices] are all the pixel angle distributions found in the circle # Loop through pixels: # We multiply by thets_deg to get angle distribution, then normalise by dividing by the sum of the distribution, and finally take the sum of all values to get the average angle. average_on_pixel = [] for i, v in enumerate(hthets[indices]): average_on_pixel.append( (hthets[indices][i] * thets_deg / hthets[indices][i].sum()).sum()) return np.mean(average_on_pixel), np.std(average_on_pixel)
if(PRINTER.input_text("Automatically find most-intense region? [y/n]") == "y"): PRINTER.info_text("Identifying region") px = np.argwhere(MAPCUBE[0].data == MAPCUBE[0].data.max()) * u.pixel if len(px) > 1: temp = ndimage.measurements.center_of_mass(np.array(px)) px = [px[int(temp[0] + 0.5)]] ######################### center = PixCoord(x = 2048, y = 2048) radius = 1600 region = CirclePixelRegion(center, radius) point = PixCoord(px[0][1], px[0][0]) if not region.contains(point): PRINTER.info_text("Identified region is outside the solar disk") PRINTER.info_text("Defaulting to user selection...") INIT_COORD = cutout_selection(MAPCUBE) else: INIT_COORD = MAPCUBE[0].pixel_to_world(px[0][1], px[0][0]) auto_sel = True else: INIT_COORD = cutout_selection(MAPCUBE) auto_sel = False ######################### PRINTER.line()