This function takes a full multi-extension pupil ghost, derives the azimuthal profile and writes it back to a new file. This azimuthal profile can then be used to remove the pupilghost from science with a range of rotator angles.
Parameters are: - filename of the full 2-d input pupil ghost - name for the output file
This routine takes the input in polar coordinates and fits a straight line to the radial profile inside and outside of the allowed range. This is assumed to be the background level (in analogy to the algorithm used in the IRAF task mkpupil).
Input data: - data (the actual intensity values for all pixels) - radius (the r in the polar coordianates) - angle (the phi in polar coordinates) - radius range (r_inner, r_outer, d_radius) - binfac (the binning used for the data)