def main(args): t = time.perf_counter() if args.bgagg: pyplot.switch_backend('agg') # Set the paths redux_path = defaults.drp_redux_path(drpver=args.drpver) \ if args.redux_path is None else args.redux_path analysis_path = defaults.dap_analysis_path(drpver=args.drpver, dapver=args.dapver) \ if args.analysis_path is None else args.analysis_path daptypes = [] if args.daptype is None: analysisplan = AnalysisPlanSet.default() if args.plan_file is None \ else AnalysisPlanSet.from_par_file(args.plan_file) for p in analysisplan: bin_method = SpatiallyBinnedSpectra.define_method(p['bin_key']) sc_method = StellarContinuumModel.define_method(p['continuum_key']) el_method = EmissionLineModel.define_method(p['elfit_key']) daptypes += [ defaults.dap_method( bin_method['key'], sc_method['fitpar']['template_library_key'], el_method['continuum_tpl_key']) ] else: daptypes = [args.daptype] for daptype in daptypes: plate_fit_qa(args.dapver, analysis_path, daptype, args.plate) print('Elapsed time: {0} seconds'.format(time.perf_counter() - t))
def main(args): import time from mangadap.config import defaults from mangadap.par.analysisplan import AnalysisPlanSet from mangadap.proc.spatiallybinnedspectra import SpatiallyBinnedSpectra from mangadap.proc.stellarcontinuummodel import StellarContinuumModel from mangadap.proc.emissionlinemodel import EmissionLineModel t = time.perf_counter() # Set the the analysis path and make sure it exists analysis_path = defaults.dap_analysis_path(drpver=args.drpver, dapver=args.dapver) \ if args.analysis_path is None else args.analysis_path analysisplan = AnalysisPlanSet.from_par_file(args.plan_file) daptypes = [] for p in analysisplan: bin_method = SpatiallyBinnedSpectra.define_method(p['bin_key']) sc_method = StellarContinuumModel.define_method(p['continuum_key']) el_method = EmissionLineModel.define_method(p['elfit_key']) daptypes += [defaults.dap_method(bin_method['key'], sc_method['fitpar']['template_library_key'], el_method['continuum_tpl_key'])] dap_status(analysis_path, daptypes, logdir=args.logdir) print('Elapsed time: {0} seconds'.format(time.perf_counter() - t))
def main(args): t = time.perf_counter() if args.bgagg: pyplot.switch_backend('agg') # Set the the analysis path and make sure it exists analysis_path = defaults.dap_analysis_path(drpver=args.drpver, dapver=args.dapver) \ if args.analysis_path is None else args.analysis_path daptypes = [] if args.daptype is None: analysisplan = AnalysisPlanSet.default() if args.plan_file is None \ else AnalysisPlanSet.from_par_file(args.plan_file) for p in analysisplan: bin_method = SpatiallyBinnedSpectra.define_method(p['bin_key']) sc_method = StellarContinuumModel.define_method(p['continuum_key']) el_method = EmissionLineModel.define_method(p['elfit_key']) daptypes += [ defaults.dap_method( bin_method['key'], sc_method['fitpar']['template_library_key'], el_method['continuum_tpl_key']) ] else: daptypes = [args.daptype] for daptype in daptypes: plan_qa_dir = defaults.dap_method_path(daptype, plate=args.plate, ifudesign=args.ifudesign, qa=True, drpver=args.drpver, dapver=args.dapver, analysis_path=analysis_path) ofile = os.path.join( plan_qa_dir, 'manga-{0}-{1}-MAPS-{2}-spotcheck.png'.format( args.plate, args.ifudesign, daptype)) if not os.path.isdir(plan_qa_dir): os.makedirs(plan_qa_dir) spotcheck_images(analysis_path, daptype, args.plate, args.ifudesign, ofile=ofile) print('Elapsed time: {0} seconds'.format(time.perf_counter() - t))
def main(args): t = time.perf_counter() if args.bgagg: pyplot.switch_backend('agg') # Set the paths redux_path = defaults.drp_redux_path(drpver=args.drpver) \ if args.redux_path is None else args.redux_path analysis_path = defaults.dap_analysis_path(drpver=args.drpver, dapver=args.dapver) \ if args.analysis_path is None else args.analysis_path daptypes = [] if args.daptype is None: analysisplan = AnalysisPlanSet.default() if args.plan_file is None \ else AnalysisPlanSet.from_par_file(args.plan_file) for p in analysisplan: bin_method = SpatiallyBinnedSpectra.define_method(p['bin_key']) sc_method = StellarContinuumModel.define_method(p['continuum_key']) el_method = EmissionLineModel.define_method(p['elfit_key']) daptypes += [ defaults.dap_method( bin_method['key'], sc_method['fitpar']['template_library_key'], el_method['continuum_tpl_key']) ] else: daptypes = [args.daptype] drpall_file = defaults.drpall_file(drpver=args.drpver, redux_path=redux_path) dapall_file = defaults.dapall_file(drpver=args.drpver, dapver=args.dapver, analysis_path=analysis_path) drpall_hdu = fits.open(drpall_file) dapall_hdu = fits.open(dapall_file) eml = channel_dictionary(dapall_hdu, 0, prefix='ELG') spi = channel_dictionary(dapall_hdu, 0, prefix='SPI') for daptype in daptypes: dapall_qa(drpall_hdu['MANGA'].data, dapall_hdu[daptype].data, analysis_path, daptype, eml, spi) print('Elapsed time: {0} seconds'.format(time.perf_counter() - t))
def get_maps_files(daptype='HYB10-MILESHC-MASTARHC2'): # return ['/uufs/chpc.utah.edu/common/home/sdss/mangawork/manga/spectro/analysis/v3_0_1/3.0.1/HYB10-MILESHC-MASTARHC2/7443/12704/manga-7443-12704-MAPS-HYB10-MILESHC-MASTARHC2.fits.gz', '/uufs/chpc.utah.edu/common/home/sdss/mangawork/manga/spectro/analysis/v3_0_1/3.0.1/HYB10-MILESHC-MASTARHC2/7443/12701/manga-7443-12701-MAPS-HYB10-MILESHC-MASTARHC2.fits.gz', '/uufs/chpc.utah.edu/common/home/sdss/mangawork/manga/spectro/analysis/v3_0_1/3.0.1/HYB10-MILESHC-MASTARHC2/7443/12703/manga-7443-12703-MAPS-HYB10-MILESHC-MASTARHC2.fits.gz', '/uufs/chpc.utah.edu/common/home/sdss/mangawork/manga/spectro/analysis/v3_0_1/3.0.1/HYB10-MILESHC-MASTARHC2/7443/12705/manga-7443-12705-MAPS-HYB10-MILESHC-MASTARHC2.fits.gz', '/uufs/chpc.utah.edu/common/home/sdss/mangawork/manga/spectro/analysis/v3_0_1/3.0.1/HYB10-MILESHC-MASTARHC2/7443/1901/manga-7443-1901-MAPS-HYB10-MILESHC-MASTARHC2.fits.gz', '/uufs/chpc.utah.edu/common/home/sdss/mangawork/manga/spectro/analysis/v3_0_1/3.0.1/HYB10-MILESHC-MASTARHC2/7443/1902/manga-7443-1902-MAPS-HYB10-MILESHC-MASTARHC2.fits.gz', '/uufs/chpc.utah.edu/common/home/sdss/mangawork/manga/spectro/analysis/v3_0_1/3.0.1/HYB10-MILESHC-MASTARHC2/7443/12702/manga-7443-12702-MAPS-HYB10-MILESHC-MASTARHC2.fits.gz'] root = os.path.join(defaults.dap_analysis_path(dapver='3.0.1'), daptype) return glob.glob(os.path.join(root, '*', '*', '*MAPS*fits.gz'))
def ppxffit_qa_plot(plt, ifu, plan, drpver=None, redux_path=None, dapver=None, analysis_path=None, tpl_flux_renorm=None): # Set the redux and DRP directory paths _drpver = defaults.drp_version() if drpver is None else drpver _redux_path = defaults.drp_redux_path( drpver=_drpver) if redux_path is None else redux_path if not os.path.isdir(_redux_path): raise NotADirectoryError('{0} is not a directory.'.format(_redux_path)) # Set the analysis path _dapver = defaults.dap_version() if dapver is None else dapver _analysis_path = defaults.dap_analysis_path(drpver=_drpver, dapver=_dapver) \ if analysis_path is None else analysis_path if not os.path.isdir(_analysis_path): raise NotADirectoryError( '{0} is not a directory.'.format(_analysis_path)) # Get the method, it's root directory, and the qa directories bin_method = SpatiallyBinnedSpectra.define_method(plan['bin_key']) sc_method = StellarContinuumModel.define_method(plan['continuum_key']) el_method = EmissionLineModel.define_method(plan['elfit_key']) method = defaults.dap_method(bin_method['key'], sc_method['fitpar']['template_library_key'], el_method['continuum_tpl_key']) method_dir = defaults.dap_method_path(method, plate=plt, ifudesign=ifu, drpver=_drpver, dapver=_dapver, analysis_path=_analysis_path) method_qa_dir = defaults.dap_method_path(method, plate=plt, ifudesign=ifu, qa=True, drpver=_drpver, dapver=_dapver, analysis_path=_analysis_path) # Check that the paths exists if not os.path.isdir(method_dir): raise NotADirectoryError( '{0} is not a directory; run the DAP first!'.format(method_dir)) if not os.path.isdir(method_qa_dir): os.makedirs(method_qa_dir) # Get the name of the output file ofile = os.path.join( method_qa_dir, 'manga-{0}-{1}-MAPS-{2}-ppxffit.png'.format(plt, ifu, method)) # Get the g-r map gmr_map = gmr_data(plt, ifu, _drpver, _redux_path) # Get the reduction assessment data signal_map, snr_map = rdxqa_data(plt, ifu, plan, _drpver, _dapver, _analysis_path) # Get the template weights and additive-polynomial coefficients binid_map, t, dt, tn, dtn, a, da, an, dan \ = continuum_component_data(plt, ifu, plan, _drpver, _dapver, _analysis_path, signal_map=signal_map, tpl_flux_renorm=tpl_flux_renorm) # print('t:', numpy.sum(t > 0), numpy.prod(t.shape)) # print('dt:', numpy.sum(dt > 0), numpy.prod(dt.shape)) # print('tn:', numpy.sum(tn > 0), numpy.prod(tn.shape)) # print('dtn:', numpy.sum(dtn > 0), numpy.prod(dtn.shape)) # print('a:', numpy.sum(a > 0), numpy.prod(a.shape)) # print('da:', numpy.sum(da > 0), numpy.prod(da.shape)) # print('an:', numpy.sum(an > 0), numpy.prod(an.shape)) # print('dan:', numpy.sum(dan > 0), numpy.prod(dan.shape)) # Map the continuum component data t_map = DAPFitsUtil.reconstruct_map(binid_map.shape, binid_map.ravel(), t, quiet=True) t_map = numpy.ma.MaskedArray(t_map, mask=numpy.invert(t_map > 0)) dt_map = DAPFitsUtil.reconstruct_map(binid_map.shape, binid_map.ravel(), dt, quiet=True) dt_map = numpy.ma.MaskedArray(dt_map, mask=numpy.invert(dt_map > 0)) #/t_map tn_map = DAPFitsUtil.reconstruct_map(binid_map.shape, binid_map.ravel(), tn, quiet=True) tn_map = numpy.ma.MaskedArray(tn_map, mask=numpy.invert(tn_map > 0)) dtn_map = DAPFitsUtil.reconstruct_map(binid_map.shape, binid_map.ravel(), dtn, quiet=True) dtn_map = numpy.ma.MaskedArray(dtn_map, mask=numpy.invert(dtn_map > 0)) #/tn_map a_map = DAPFitsUtil.reconstruct_map(binid_map.shape, binid_map.ravel(), a, quiet=True) a_map = numpy.ma.MaskedArray(a_map, mask=numpy.invert(a_map > 0)) da_map = DAPFitsUtil.reconstruct_map(binid_map.shape, binid_map.ravel(), da, quiet=True) da_map = numpy.ma.MaskedArray(da_map, mask=numpy.invert(da_map > 0)) #/a_map an_map = DAPFitsUtil.reconstruct_map(binid_map.shape, binid_map.ravel(), an, quiet=True) an_map = numpy.ma.MaskedArray(an_map, mask=numpy.invert(an_map > 0)) dan_map = DAPFitsUtil.reconstruct_map(binid_map.shape, binid_map.ravel(), dan, quiet=True) dan_map = numpy.ma.MaskedArray(dan_map, mask=numpy.invert(dan_map > 0)) #/an_map # Get the remaining output maps from the MAPS file r68_map, r99_map, rchi2_map, svel_map, ssigo_map, ssigcor_map, ssigc_map, extent \ = maps_data(plt, ifu, plan, _drpver, _dapver, _analysis_path) # if not os.path.isfile(ofile): stellar_continuum_maps(plt, ifu, method, snr_map, r68_map, r99_map, rchi2_map, signal_map, a_map, da_map, an_map, dan_map, gmr_map, t_map, dt_map, tn_map, dtn_map, svel_map, ssigo_map, ssigcor_map, ssigc_map, extent=extent, ofile=ofile)