Пример #1
0
    def main(args):
        t = time.perf_counter()

        if args.bgagg:
            pyplot.switch_backend('agg')

        redux_path = manga.drp_redux_path(drpver=args.drpver) \
                            if args.redux_path is None else Path(args.redux_path).resolve()
        analysis_path = manga.dap_analysis_path(drpver=args.drpver, dapver=args.dapver) \
                            if args.analysis_path is None else Path(args.analysis_path).resolve()

        plan = manga.MaNGAAnalysisPlan.default(analysis_path=analysis_path) \
                    if args.plan_file is None \
                    else manga.MaNGAAnalysisPlan.from_toml(args.plan_file,
                                                           analysis_path=analysis_path)

        drpall_file = manga.drpall_file(drpver=args.drpver,
                                        redux_path=redux_path)
        dapall_file = manga.dapall_file(drpver=args.drpver,
                                        dapver=args.dapver,
                                        analysis_path=analysis_path)

        drpall_hdu = fits.open(str(drpall_file))
        dapall_hdu = fits.open(str(dapall_file))

        eml = channel_dictionary(dapall_hdu, 0, prefix='ELG')
        spi = channel_dictionary(dapall_hdu, 0, prefix='SPI')

        for i, key in enumerate(plan.keys()):
            dapall_qa(drpall_hdu['MANGA'].data,
                      dapall_hdu[plan[key]['key']].data, analysis_path,
                      plan[key]['key'], eml, spi)

        print('Elapsed time: {0} seconds'.format(time.perf_counter() - t))
Пример #2
0
def get_obsinput(plt, ifu, drpall_file=None):
    """
    Grab the input parameters the DAP requires for each observation to
    fit a cube.  If the drpall file is None, use the default path.
    """
    if drpall_file is None:
        drpall_file = manga.drpall_file()
    hdu = fits.open(drpall_file)
    indx = hdu[1].data['PLATEIFU'] == '{0}-{1}'.format(plt, ifu)

    return ObsInputPar(plate=plt, ifudesign=ifu, mode='CUBE',
                       vel=astropy.constants.c.to('km/s').value*hdu[1].data['NSA_Z'][indx][0],
                       vdisp=100.,
                       ell=1-hdu[1].data['NSA_ELPETRO_BA'][indx][0],
                       pa=hdu[1].data['NSA_ELPETRO_PHI'][indx][0],
                       reff=hdu[1].data['NSA_ELPETRO_TH50_R'][indx][0])
Пример #3
0
def get_config(plt, ifu, config_file, drpall_file=None):
    if drpall_file is None:
        drpall_file = manga.drpall_file()

    # Use the DRPall file
    with fits.open(drpall_file) as hdu:
        indx = numpy.where(
            hdu['MANGA'].data['PLATEIFU'] == '{0}-{1}'.format(plt, ifu))[0]
        if len(indx) != 1:
            raise ValueError(
                '{0}-{1} either does not exist or has more than one match!'.
                format(plt, ifu))

        MaNGADataCube.write_config(
            config_file,
            plt,
            ifu,
            z=hdu[1].data['z'][indx[0]],
            ell=1 - hdu[1].data['nsa_elpetro_ba'][indx[0]],
            pa=hdu[1].data['nsa_elpetro_phi'][indx[0]],
            reff=hdu[1].data['nsa_elpetro_th50_r'][indx[0]],
            overwrite=True)
Пример #4
0
def get_redshift(plt, ifu, drpall_file=None):
    """
    Get the redshift of a galaxy from the DRPall file.

    Args:
        plt (:obj:`int`):
            Plate number
        ifu (:obj:`int`):
            IFU identifier
        drapall_file (:obj:`str`, optional):
            DRPall file. If None, attempts to use the default path to
            the file using environmental variables.
    
    Returns:
        :obj:`float`: The redshift to the galaxy observed by the
        provided PLATEIFU.
    """
    if drpall_file is None:
        drpall_file = manga.drpall_file()
    if not drpall_file.exists():
        raise FileNotFoundError(f'Could not find DRPall file: {drpall_file}')
    hdu = fits.open(str(drpall_file))
    indx = hdu[1].data['PLATEIFU'] == '{0}-{1}'.format(plt, ifu)
    return hdu[1].data['NSA_Z'][indx][0]