Ejemplo n.º 1
0
    def createpupilarray(self, puplscal=None, fitsfile=None):

        pupil = np.zeros((int(np.ceil(self.OD / puplscal)),
                          int(np.ceil(self.OD / puplscal))))

        pupil = pupil + \
                makedisk(s=pupil.shape, c=(pupil.shape[0]/2.0 - 0.5, pupil.shape[1]/2.0 - 0.5),
                                   r=0.5*self.OD/puplscal, t=np.float64, grey=0) - \
                makedisk(s=pupil.shape,  c=(pupil.shape[0]/2.0 - 0.5, pupil.shape[1]/2.0 - 0.5),
                                   r=0.5*self.ID/puplscal, t=np.float64, grey=0)

        hdu = fits.PrimaryHDU()
        hdu.data = pupil.astype(np.uint8)
        hdu.header.update("PUPLSCAL", puplscal,
                          "Pupil pixel scale in m/pixels DL")
        hdu.header.update("PIXSCALE", puplscal,
                          "Pupil pixel scale in m/pixels MDP")
        hdu.header.update("PUPLDIAM", self.OD,
                          "Full pupil file size, incl padding in m")
        hdu.header.update(
            "DIAM", self.activeD,
            "Active pupil diameter in m")  # changed from OD - AS Feb 13
        hdu.header.update("ROTATE", self.rotdeg,
                          "Mask counterclockwise rotation (deg)")
        if fitsfile is not None:
            hdu.writeto(fitsfile, clobber=True)
        self.fullpupil = pupil.copy()
        self.fullpuplscale = puplscal
        hdulist = fits.HDUList([hdu])
        return hdulist
Ejemplo n.º 2
0
    def createnrmarray(self,
                       puplscal=None,
                       fitsfile=None,
                       holeid=None,
                       fullpupil=False):
        """ fullpupil is a possibly oversized array, in meters using puplscal """
        if fullpupil:
            D = self.OD  # array side size, m
        else:
            D = self.activeD  # light-transmitting diameter, m

        pupil = np.zeros(
            (int(np.ceil(D / puplscal)), int(np.ceil(D / puplscal))))
        print("creating pupil array with shape ", pupil.shape)

        factor = 1
        #modify to add hex holes later
        for ctrn, ctr in enumerate(self.ctrs):
            if holeid:
                factor = ctrn + 1
            # convert to zero-at-corner, meters
            center = (0.5 * pupil.shape[0] + ctr[0] / puplscal - 0.5,
                      0.5 * pupil.shape[1] + ctr[1] / puplscal - 0.5)
            pupil = pupil + \
            makedisk(s=pupil.shape, c=center,
                       r=0.5*self.hdia/puplscal, t=np.float64, grey=0)* factor
        self.nrmpupil = pupil.copy()
        self.puplscale = puplscal

        hdu = fits.PrimaryHDU()
        hdu.data = pupil.astype(np.uint8)
        hdu.header.update("PUPLSCAL", puplscal,
                          "Pupil pixel scale in m/pixels MDP")
        hdu.header.update("PIXSCALE", puplscal,
                          "Pupil pixel scale in m/pixels DL")
        hdu.header.update("PUPLDIAM", D,
                          "Full pupil file size, incl padding in m")
        hdu.header.update("DIAM", self.activeD, "Active pupil diameter in m")
        if hasattr(self, 'rotate'):
            hdu.header.update("ROTATE", self.rotdeg,
                              "Mask counterclockwise rotation (deg)")
        (year, month, day, hour, minute, second, weekday, DOY,
         DST) = time.gmtime()
        hdu.header.update("CODESRC", "NRM_mask_definitions.py",
                          "Anand S. and Alex G.")
        hdu.header.update("DATE", "%4d-%02d-%02dT%02d:%02d:%02d" % \
                         (year, month, day, hour, minute, second), "Date of calculation")
        if fitsfile is not None:
            hdu.writeto(fitsfile, clobber=True)
        hdulist = fits.HDUList([hdu])
        return hdulist