コード例 #1
0
    def __init__(self, mesh_name, directory, **kwargs):
        self.dec = decaminfo()
        y_keys = ['z{0}'.format(i) for i in range(4, 12)]
        x_keys = ['x', 'y']

        # ingest the data here
        data = self.digest_mesh(directory=directory, mesh_name=mesh_name)

        super(Mesh_Interpolator, self).__init__(data=data, y_keys=y_keys, x_keys=x_keys, **kwargs)
コード例 #2
0
    def digest_fits(self, file_name, columns=None, exclude=['VIGNET', 'FLUX_APER', 'FLUXERR_APER', 'MAG_APER', 'MAGERR_APER'], ext=2, do_exclude=False, **kwargs):
        try:
            #from astropy.table import Table
            from astropy.io import fits
        except Exception:
            print('No Astropy installation. Trying pyfits!')
            try:
                import pyfits as fits
            except Exception:
                raise ImportError('Astropy and Pyfits both missing!')

        data = fits.getdata(file_name, ext=ext)
        df = DataFrame.from_records(data, exclude=exclude, columns=columns)
        if 'MAG_APER' in exclude:
            for i in xrange(data['MAG_APER'].shape[1]):
                df['MAG_APER_{0}'.format(i)] = data['MAG_APER'][:, i]
        if 'x' not in df.keys() and 'XWIN_IMAGE' in df.keys() and 'ext' in df.keys():
            decaminf = decaminfo()
            # get focal plane coordinates
            xPos = df['XWIN_IMAGE']
            yPos = df['YWIN_IMAGE']
            extnums = df['ext'].values
            x, y = decaminf.getPosition_extnum(extnums, xPos, yPos)
            df['x'] = x
            df['y'] = y

        # TODO: This is a really annoying hackaround the endianness problem:
        # turn everything into floats. This should be fixed in the next major
        # astropy release 1.1
        df = df.astype('<f8')

        if do_exclude:
            # return the df and the excluded
            return df, data[exclude]
        else:
            return df
コード例 #3
0
def generate_random_coordinates(number):
    x = np.random.random(number) * 2048
    y = np.random.random(number) * 4096
    extnum = np.random.randint(1, 62, number)
    x, y = decaminfo().getPosition_extnum(extnum, x, y)
    return x, y, extnum