Exemplo n.º 1
0
    def write_absid_file(self, outfil=None):

        from astropy.table import Column
        from astropy.table.table import Table

        wrest = self.lines.keys()
        wrest.sort()

        if outfil is None:
            outfil = self.absid_file

        # Columns
        cols = [Column(np.array(wrest), name='WREST')] 
        clm_nms = self.lines[wrest[0]].analy.keys()
        for clm_nm in clm_nms:
            clist = [self.lines[iwrest].analy[clm_nm] for iwrest in wrest]
            cols.append( Column(np.array(clist), name=clm_nm) )
        cols.append( Column(np.ones(len(cols[0]))*self.zabs, name='ZABS') ) 
        
        table = Table(cols)

        prihdr = fits.Header()
        prihdr['COMMENT'] = "Above are the data sources"
        prihdu = fits.PrimaryHDU(header=prihdr)
        table_hdu = fits.BinTableHDU.from_columns(np.array(table.filled()))

        thdulist = fits.HDUList([prihdu, table_hdu])
        thdulist.writeto(outfil,clobber=True)
        print('Wrote AbsID file: {:s}'.format(outfil))
Exemplo n.º 2
0
    def write_absid_file(self, outfil=None):

        from astropy.table import Column
        from astropy.table.table import Table

        wrest = self.lines.keys()
        wrest.sort()

        if outfil is None:
            outfil = self.absid_file

        # Columns
        cols = [Column(np.array(wrest), name='WREST')] 
        clm_nms = self.lines[wrest[0]].analy.keys()
        for clm_nm in clm_nms:
            clist = [self.lines[iwrest].analy[clm_nm] for iwrest in wrest]
            cols.append( Column(np.array(clist), name=clm_nm) )
        cols.append( Column(np.ones(len(cols[0]))*self.zabs, name='ZABS') ) 
        
        table = Table(cols)

        prihdr = fits.Header()
        prihdr['COMMENT'] = "Above are the data sources"
        prihdu = fits.PrimaryHDU(header=prihdr)
        table_hdu = fits.BinTableHDU.from_columns(np.array(table.filled()))

        thdulist = fits.HDUList([prihdu, table_hdu])
        thdulist.writeto(outfil,clobber=True)
        print('Wrote AbsID file: {:s}'.format(outfil))
Exemplo n.º 3
0
    def write_absid_file(self, outfil=None):
        '''TO BE DEPRECATED (probably)
        Writes portions of the LLS lines to a FITS table.
        '''
        from astropy.table import Column
        from astropy.table.table import Table
        #
        #wrest = self.lines.keys()
        #wrest.sort()
        wrest = [line.wrest.value for line in self.lines]
        if outfil is None:
            outfil = self.absid_file
        # Columns
        cols = [Column(np.array(wrest), name='WREST')] 
        clm_nms = self.lines[0].analy.keys()
        for clm_nm in clm_nms:
            if clm_nm == 'spec':
                continue
            clist = [line.analy[clm_nm] for line in self.lines]
            cols.append( Column(np.array(clist), name=clm_nm) )
        cols.append( Column(np.ones(len(cols[0]))*self.zabs, name='ZABS') ) 
        
        #from PyQt4 import QtCore
        #QtCore.pyqtRemoveInputHook()
        #xdb.set_trace()
        #QtCore.pyqtRestoreInputHook()
        table = Table(cols)

        prihdr = fits.Header()
        prihdr['COMMENT'] = "Above are the data sources"
        prihdu = fits.PrimaryHDU(header=prihdr)
        table_hdu = fits.BinTableHDU.from_columns(np.array(table.filled()))

        thdulist = fits.HDUList([prihdu, table_hdu])
        thdulist.writeto(outfil,clobber=True)
        print('Wrote AbsID file: {:s}'.format(outfil))
Exemplo n.º 4
0
    def write_absid_file(self, outfil=None):
        '''TO BE DEPRECATED (probably)
        Writes portions of the LLS lines to a FITS table.
        '''
        from astropy.table import Column
        from astropy.table.table import Table
        #
        #wrest = self.lines.keys()
        #wrest.sort()
        wrest = [line.wrest.value for line in self.lines]
        if outfil is None:
            outfil = self.absid_file
        # Columns
        cols = [Column(np.array(wrest), name='WREST')]
        clm_nms = self.lines[0].analy.keys()
        for clm_nm in clm_nms:
            if clm_nm == 'spec':
                continue
            clist = [line.analy[clm_nm] for line in self.lines]
            cols.append(Column(np.array(clist), name=clm_nm))
        cols.append(Column(np.ones(len(cols[0])) * self.zabs, name='ZABS'))

        #from PyQt4 import QtCore
        #QtCore.pyqtRemoveInputHook()
        #xdb.set_trace()
        #QtCore.pyqtRestoreInputHook()
        table = Table(cols)

        prihdr = fits.Header()
        prihdr['COMMENT'] = "Above are the data sources"
        prihdu = fits.PrimaryHDU(header=prihdr)
        table_hdu = fits.BinTableHDU.from_columns(np.array(table.filled()))

        thdulist = fits.HDUList([prihdu, table_hdu])
        thdulist.writeto(outfil, clobber=True)
        print('Wrote AbsID file: {:s}'.format(outfil))