def load_fluxes_LSDCatForcedRun(line1='CIV1548',line2='CIII1908',fluxcol='F_3KRON', datadir='/Users/kschmidt/work/MUSE/ciii_candidates/fluxAndEWmeasurements/' 'ForceFluxC3inMUSE_fullrun161031/', redshiftcat='/Users/kschmidt/work/catalogs/MUSE_GTO/candels_1-24_emline_master_v2.1.fits', convert_Flux2Lbol=False,verbose=True): """ Loading the flux output from an LSDcat run and potentially turning it into bolometric luminoisity. Returning data array to be plotted on NEGOAL diagrams --- EXAMPLE OF USE --- import NEOGALmodels as nm lumarray = nm.load_fluxes_LSDCatForcedRun(line1='CIV1548',line2='CIII1908',fluxcol='F_3KRON',convert_Flux2Lbol=True) """ if verbose: print ' - Loading redshift catalog: \n '+redshiftcat z_data = pyfits.open(redshiftcat)[1].data linenamesdic = nm.linenames() if verbose: print ' - Grabbing files with flux measurements in data directory: \n '+datadir fluxfiles = glob.glob(datadir+'*_linelist_fluxes.fits') Nfiles = len(fluxfiles) if Nfiles == 0: sys.exit("Didn't find any *_linelist_fluxes.fits files in datadir="+datadir) outputarray = np.ones([Nfiles,11])*-99 for ff, ffile in enumerate(fluxfiles): f_data = pyfits.open(ffile)[1].data objid = ffile.split('/')[-1][:8] objent = np.where(z_data['UNIQUE_ID'] == objid)[0] if len(objent) != 1: if verbose: print ' - WARNING Found '+str(len(objent))+' matches to '+str(objid)+' in redshift catalog' continue line1name = linenamesdic[line1][0] line2name = linenamesdic[line2][0] line1ent = np.where(f_data['LINENAME'] == line1name)[0] line2ent = np.where(f_data['LINENAME'] == line2name)[0] if (len(line1ent) != 1) or (len(line2ent) != 1): if verbose: print ' - WARNING No match in flux table for '+line1+' and '+line2+' for '+str(objid) continue redshift = z_data['REDSHIFT'][objent] redshifterr = z_data['REDSHIFT_ERR'][objent] lineflux1 = f_data[fluxcol][line1ent] linefluxerr1 = f_data[fluxcol+'_ERR'][line1ent] lineflux2 = f_data[fluxcol][line2ent] linefluxerr2 = f_data[fluxcol+'_ERR'][line2ent] if convert_Flux2Lbol: Lbol1, Lbolerr1 = nm.convert_Fline2Lbol(lineflux1,linefluxerr1,redshift,verbose=False) Lbol2, Lbolerr2 = nm.convert_Fline2Lbol(lineflux2,linefluxerr2,redshift,verbose=False) else: Lbol1, Lbolerr1 = -99, -99 Lbol2, Lbolerr2 = -99, -99 outputarray[ff,:] = int(objid), redshift, redshifterr, \ lineflux1, linefluxerr1, lineflux2, linefluxerr2, \ Lbol1, Lbolerr1, Lbol2, Lbolerr2, return outputarray