Esempio n. 1
0
 def from_sfits(self):
     '''Generate the Survey from a summary FITS file
     '''
     # Read
     systems = QTable.read(self.summ_fits)
     self.nsys = len(systems)
     # Dict
     kdict = dict(NHI=['NHI', 'logNHI'],
                  sigNHI=['sig(logNHI)'],
                  name=['Name'],
                  vlim=['vlim'],
                  zabs=['Z_LLS'],
                  zem=['Z_QSO'],
                  RA=['RA'],
                  Dec=['DEC', 'Dec'])
     # Parse the Table
     inputs = {}
     for key in kdict.keys():
         vals, tag = lsio.get_table_column(kdict[key], [systems], idx=0)
         if vals is not None:
             inputs[key] = vals
     # Generate
     for kk, row in enumerate(systems):
         # Generate keywords
         kwargs = {}
         for key in inputs.keys():
             kwargs[key] = inputs[key][kk]
         # Instantiate
         self._abs_sys.append(set_absclass(self.abs_type)(**kwargs))
Esempio n. 2
0
 def from_sfits(self):
     '''Generate the Survey from a summary FITS file
     '''
     # Read
     systems = QTable.read(self.summ_fits)
     self.nsys = len(systems)
     # Dict
     kdict = dict(NHI=['NHI','logNHI'],
         sigNHI=['sig(logNHI)'],
         name=['Name'], 
         vlim=['vlim'],
         zabs=['Z_LLS'],
         zem=['Z_QSO'],
         RA=['RA'],
         Dec=['DEC','Dec'])
     # Parse the Table
     inputs = {}
     for key in kdict.keys():
         vals, tag = lsio.get_table_column(kdict[key],[systems],idx=0)
         if vals is not None:
             inputs[key] = vals
     # Generate
     for kk,row in enumerate(systems):
         # Generate keywords
         kwargs = {}
         for key in inputs.keys():
             kwargs[key] = inputs[key][kk]
         # Instantiate
         self._abs_sys.append(set_absclass(self.abs_type)(**kwargs))
Esempio n. 3
0
    def from_sfits(cls, summ_fits, **kwargs):
        """Generate the Survey from a summary FITS file

        Handles SPEC_FILES too.

        Parameters
        ----------
        summ_fits : str or Table or QTable
          Summary FITS file
        **kwargs : dict
          passed to __init__
        """
        # Init
        slf = cls(**kwargs)
        # Read
        if isinstance(summ_fits, Table):
            systems = summ_fits
        else:
            systems = QTable.read(summ_fits)
        nsys = len(systems)
        # Dict
        kdict = dict(NHI=['NHI', 'logNHI'],
                     sig_NHI=['sig(logNHI)', 'SIGNHI'],
                     name=['Name'], vlim=['vlim'],
                     zabs=['Z_LLS', 'ZABS', 'zabs'],
                     zem=['Z_QSO', 'QSO_ZEM'],
                     RA=['RA'], Dec=['DEC', 'Dec'])
        # Parse the Table
        inputs = {}
        for key in kdict.keys():
            vals, tag = lsio.get_table_column(kdict[key], [systems],idx=0)
            if vals is not None:
                inputs[key] = vals
        # vlim
        if 'vlim' not in inputs.keys():
            default_vlim = [-1000, 1000.]* u.km / u.s
            inputs['vlim'] = [default_vlim]*nsys
        # Generate
        for kk in range(nsys):
            # Generate keywords
            kwargs = {}
            args = {}
            for key in inputs.keys():
                if key in ['vlim', 'zabs', 'RA', 'Dec']:
                    args[key] = inputs[key][kk]
                else:
                    kwargs[key] = inputs[key][kk]
            # Instantiate
            abssys = class_by_type(slf.abs_type)((args['RA'], args['Dec']), args['zabs'], args['vlim'], **kwargs)
            # spec_files
            try:
                abssys.spec_files += systems[kk]['SPEC_FILES'].tolist()
            except (KeyError, AttributeError):
                pass
            slf._abs_sys.append(abssys)
        # Mask
        slf.init_mask()
        # Return
        return slf
Esempio n. 4
0
def check_dup_table(table,
                    tol=1 * u.arcsec,
                    ra_tags=['TARG_RA', 'ra', 'RA'],
                    dec_tags=['TARG_DEC', 'dec', 'DEC']):
    """
    Checks for duplicates in a Table based on their
    sky coordinates given by RA and DEC.

    Parameters
    ----------
    table : Table
        Table to check duplicates for
    tol : Angle, optional
        Tolerance for the duplicates search
    ra_tags : str, list; optional
        Name(s) of the column corresponding to RA.
        If not given, it guesses it.
    dec_tags : str, list; optional
        Name(s) of the column corresponding to DEC.
        If not given, it guesses it.

    Returns
    -------
    isdup : boolean array, shape(len(table),)
        Whether the row in `table` is duplicate
    idx : array, shape(len(table),)
        Indices of the first nearest neighbour as
        given by astropy.coord.match_coordinates_sky()
    coords : SkyCoord array for the table

    """

    ra, _ = get_table_column(ra_tags, [table], idx=0)
    dec, _ = get_table_column(dec_tags, [table], idx=0)

    coords = SkyCoord(ra, dec, unit='deg')

    isdup, idx = check_dup_coord(coords, tol=tol)

    return isdup, idx, coords
Esempio n. 5
0
File: utils.py Progetto: ninoc/pyigm
def check_dup_table(table, tol=1*u.arcsec, ra_tags=['TARG_RA','ra','RA'], dec_tags=['TARG_DEC','dec','DEC']):
    """
    Checks for duplicates in a Table based on their
    sky coordinates given by RA and DEC.

    Parameters
    ----------
    table : Table
        Table to check duplicates for
    tol : Angle, optional
        Tolerance for the duplicates search
    ra_tags : str, list; optional
        Name(s) of the column corresponding to RA.
        If not given, it guesses it.
    dec_tags : str, list; optional
        Name(s) of the column corresponding to DEC.
        If not given, it guesses it.

    Returns
    -------
    isdup : boolean array, shape(len(table),)
        Whether the row in `table` is duplicate
    idx : array, shape(len(table),)
        Indices of the first nearest neighbour as
        given by astropy.coord.match_coordinates_sky()
    coords : SkyCoord array for the table

    """

    ra, _ = get_table_column(ra_tags, [table], idx=0)
    dec, _ = get_table_column(dec_tags, [table], idx=0)

    coords = SkyCoord(ra, dec, unit='deg')

    isdup, idx = check_dup_coord(coords, tol=tol)

    return isdup, idx, coords
Esempio n. 6
0
    def from_sfits(cls, summ_fits, **kwargs):
        """Generate the Survey from a summary FITS file or Table

        Handles SPEC_FILES too.

        Parameters
        ----------
        summ_fits : str or Table or QTable
          Summary FITS file
        **kwargs : dict
          passed to __init__
        """
        # Init
        slf = cls(**kwargs)
        # Read
        if isinstance(summ_fits, Table):
            systems = summ_fits
        else:
            systems = QTable.read(summ_fits)
        nsys = len(systems)
        # Dict
        kdict = dict(NHI=['NHI', 'logNHI'],
                     sig_NHI=['sig(logNHI)', 'SIGNHI', 'NHI_ERR'],
                     name=['Name'],
                     vlim=['vlim'],
                     zabs=['Z_LLS', 'ZABS', 'zabs'],
                     zem=['Z_QSO', 'QSO_ZEM', 'ZEM'],
                     RA=['RA'],
                     Dec=['DEC', 'Dec'])
        # Parse the Table
        inputs = {}
        for key in kdict.keys():
            vals, tag = lsio.get_table_column(kdict[key], [systems], idx=0)
            if vals is not None:
                inputs[key] = vals
        # vlim
        if 'vlim' not in inputs.keys():
            default_vlim = [-1000, 1000.] * u.km / u.s
            inputs['vlim'] = [default_vlim] * nsys
        # Generate
        for kk in range(nsys):
            # Generate keywords
            kwargs = {}
            args = {}
            for key in inputs.keys():
                if key in ['vlim', 'zabs', 'RA', 'Dec']:
                    args[key] = inputs[key][kk]
                else:
                    kwargs[key] = inputs[key][kk]
            # Instantiate
            abssys = class_by_type(slf.abs_type)((args['RA'], args['Dec']),
                                                 args['zabs'], args['vlim'],
                                                 **kwargs)
            # spec_files
            try:
                abssys.spec_files += systems[kk]['SPEC_FILES'].tolist()
            except (KeyError, AttributeError):
                pass
            slf._abs_sys.append(abssys)
        # Mask
        slf.init_mask()
        # Return
        return slf