BGS Signal-to-Noise Ratio and Redshift Efficiency: QA


In [1]:
import os
import numpy as np
import matplotlib.pyplot as plt
from astropy.table import Table, vstack
from astropy.io import fits
import seaborn as sns
sns.set(style='white', font_scale=1.1, palette='deep')

In [2]:
from desiutil.log import get_logger, DEBUG
log = get_logger()

In [3]:
from desistudy_qa import qa_zmag, qa_efficiency, qa_zwarn4, qa_radec

In [4]:
%matplotlib inline
%load_ext autoreload
%autoreload 2

Just a few things we need to define to set things up


In [35]:
sim_names = ['sim12','sim13','sim14','sim16','sim17','sim18','sim26','sim36']

In [36]:
simdir = os.path.join(os.getenv('DESI_ROOT'), 'spectro', 'sim', 'bgs', 'kremin', 'flat_priors')

In [37]:
from desistudy_qa import get_all_sims_obs

sim_names = np.asarray(sim_names)
sims, conditions = get_all_sims_obs(sim_names)

Analyze the outputs.

Sims 12-14 have magnitude range 17.0-19.5 and z-range 0.1-0.6

Sims 16-18 have magnitude range 19.5-20 and z-range 0.1-0.8


In [38]:
from desistudy_qa import print_file_locations
print_file_locations(simdir,sims)


In /global/project/projectdirs/desi/spectro/sim/bgs/kremin/flat_priors/ :
	In sim12/:
		   bgs-sim12-results.fits
	In sim13/:
		   bgs-sim13-results.fits
	In sim14/:
		   bgs-sim14-results.fits
	In sim16/:
		   bgs-sim16-results.fits
	In sim17/:
		   bgs-sim17-results.fits
	In sim18/:
		   bgs-sim18-results.fits
	In sim26/:
		   bgs-sim26-results.fits
	In sim36/:

Sim 12


In [9]:
current_sim_name = 'sim12'

In [10]:
from desistudy_qa import print_sim_params
print_sim_params(current_sim_name, sim_names, sims, conditions)


Sim: sim12
	Sim Parameters: 
		suffix: sim12
		use_mock: False
		nsim: 2
		nspec: 4000
		zmin: 0.1
		zmax: 0.6
		rmagmin: 17.0
		rmagmax: 19.5
		seed: 1968
	Obs Parameters: 
		AIRMASS: 1.0
		SEEING: 1.1
		MOONALT: 30
		MOONSEP: 60
		EXPTIME: 480
		MOONFRAC: 0.8

In [11]:
# sim 12
if current_sim_name in sim_names:
    ind = np.where(sim_names==current_sim_name)[0][0]
    sim,obs = sims[ind],conditions[ind]
    
    resultfile = os.path.join(simdir, sim['suffix'], 'bgs-{}-results.fits'.format(sim['suffix']))
    if os.path.exists(resultfile):
        print('Sim: {} with nspec: {} and nsim: {}'.format(sim['suffix'],sim['nspec'],sim['nsim']))

        if 'EXPTIME' in obs.keys(): exptime = "{}".format(obs['EXPTIME'])
        else:                       exptime = "{}-{}".format(obs['exptimemin'],obs['exptimemax'])

        if 'MOONFRAC' in obs.keys(): moonfrac = "{}".format(obs['MOONFRAC'])
        else:                        moonfrac = "{}-{}".format(obs['moonfracmin'],obs['moonfracmax'])

        print('ObsConds ExpTime: {}, MoonFrac: {}, MoonAlt: {}, MoonSep: {}'.format(exptime,moonfrac,obs['MOONALT'],obs['MOONSEP']))
        result = Table.read(resultfile)
        #result.pprint()
        qa_zmag(result['ZTRUE'], result['RMAG'], maglabel=r'$r_{\rm DECaLS}$ (AB mag)', faintmag=19.5)
        qa_efficiency(result)
        qa_zwarn4(result)


Sim: sim12 with nspec: 4000 and nsim: 2
ObsConds ExpTime: 480, MoonFrac: 0.8, MoonAlt: 30, MoonSep: 60

Sim 13


In [12]:
current_sim_name = 'sim13'

In [13]:
print_sim_params(current_sim_name, sim_names, sims, conditions)


Sim: sim13
	Sim Parameters: 
		suffix: sim13
		use_mock: False
		nsim: 10
		nspec: 1000
		zmin: 0.1
		zmax: 0.6
		rmagmin: 17.0
		rmagmax: 19.5
		seed: 2132
	Obs Parameters: 
		AIRMASS: 1.0
		SEEING: 1.1
		MOONALT: 30
		MOONSEP: 60
		exptimemin: 300
		exptimemax: 720
		MOONFRAC: 0.8

In [14]:
# sim 13
from desistudy_qa import qa_exptime

if current_sim_name in sim_names:
    ind = np.where(sim_names==current_sim_name)[0][0]
    sim,obs = sims[ind],conditions[ind]
    
    resultfile = os.path.join(simdir, sim['suffix'], 'bgs-{}-results.fits'.format(sim['suffix']))
    if os.path.exists(resultfile):
        print('Sim: {} with nspec: {} and nsim: {}'.format(sim['suffix'],sim['nspec'],sim['nsim']))

        if 'EXPTIME' in obs.keys(): exptime = "{}".format(obs['EXPTIME'])
        else:                       exptime = "{}-{}".format(obs['exptimemin'],obs['exptimemax'])

        if 'MOONFRAC' in obs.keys(): moonfrac = "{}".format(obs['MOONFRAC'])
        else:                        moonfrac = "{}-{}".format(obs['moonfracmin'],obs['moonfracmax'])

        print('ObsConds ExpTime: {}, MoonFrac: {}, MoonAlt: {}, MoonSep: {}'.format(exptime,moonfrac,obs['MOONALT'],obs['MOONSEP']))
        result = Table.read(resultfile)
        qa_zmag(result['ZTRUE'], result['RMAG'], maglabel=r'$r_{\rm DECaLS}$ (AB mag)', faintmag=19.5)
        qa_efficiency(result)
        qa_zwarn4(result)
        qa_exptime(result,"zeff_vs_exptime.png")


Sim: sim13 with nspec: 1000 and nsim: 10
ObsConds ExpTime: 300-720, MoonFrac: 0.8, MoonAlt: 30, MoonSep: 60

Sim 14


In [15]:
current_sim_name = 'sim14'

In [16]:
print_sim_params(current_sim_name, sim_names, sims, conditions)


Sim: sim14
	Sim Parameters: 
		suffix: sim14
		use_mock: False
		nsim: 10
		nspec: 1000
		zmin: 0.1
		zmax: 0.6
		rmagmin: 17.0
		rmagmax: 19.5
		seed: 2296
	Obs Parameters: 
		AIRMASS: 1.0
		SEEING: 1.1
		MOONALT: 30
		MOONSEP: 60
		EXPTIME: 600
		moonfracmin: 0.6
		moonfracmax: 0.98

In [17]:
# sim 14
from desistudy_qa import qa_moonfrac

if current_sim_name in sim_names:
    ind = np.where(sim_names==current_sim_name)[0][0]
    sim,obs = sims[ind],conditions[ind]
    
    resultfile = os.path.join(simdir, sim['suffix'], 'bgs-{}-results.fits'.format(sim['suffix']))
    if os.path.exists(resultfile):
        print('Sim: {} with nspec: {} and nsim: {}'.format(sim['suffix'],sim['nspec'],sim['nsim']))

        if 'EXPTIME' in obs.keys(): exptime = "{}".format(obs['EXPTIME'])
        else:                       exptime = "{}-{}".format(obs['exptimemin'],obs['exptimemax'])

        if 'MOONFRAC' in obs.keys(): moonfrac = "{}".format(obs['MOONFRAC'])
        else:                        moonfrac = "{}-{}".format(obs['moonfracmin'],obs['moonfracmax'])

        print('ObsConds ExpTime: {}, MoonFrac: {}, MoonAlt: {}, MoonSep: {}'.format(exptime,moonfrac,obs['MOONALT'],obs['MOONSEP']))
        result = Table.read(resultfile)
        qa_zmag(result['ZTRUE'], result['RMAG'], maglabel=r'$r_{\rm DECaLS}$ (AB mag)', faintmag=19.5)
        qa_efficiency(result)
        qa_zwarn4(result)
        qa_moonfrac(result,"zeff_vs_moonfrac.png")


Sim: sim14 with nspec: 1000 and nsim: 10
ObsConds ExpTime: 600, MoonFrac: 0.6-0.98, MoonAlt: 30, MoonSep: 60

Sim 16


In [18]:
current_sim_name = 'sim16'

In [19]:
print_sim_params(current_sim_name, sim_names, sims, conditions)


Sim: sim16
	Sim Parameters: 
		suffix: sim16
		use_mock: False
		nsim: 2
		nspec: 800
		zmin: 0.1
		zmax: 0.8
		rmagmin: 19.5
		rmagmax: 20.0
		seed: 2624
	Obs Parameters: 
		AIRMASS: 1.0
		SEEING: 1.1
		MOONALT: 30
		MOONSEP: 60
		EXPTIME: 480
		MOONFRAC: 0.8

In [20]:
# sim 16
if current_sim_name in sim_names:
    ind = np.where(sim_names==current_sim_name)[0][0]
    sim,obs = sims[ind],conditions[ind]
    
    resultfile = os.path.join(simdir, sim['suffix'], 'bgs-{}-results.fits'.format(sim['suffix']))
    if os.path.exists(resultfile):
        print('Sim: {} with nspec: {} and nsim: {}'.format(sim['suffix'],sim['nspec'],sim['nsim']))

        if 'EXPTIME' in obs.keys(): exptime = "{}".format(obs['EXPTIME'])
        else:                       exptime = "{}-{}".format(obs['exptimemin'],obs['exptimemax'])

        if 'MOONFRAC' in obs.keys(): moonfrac = "{}".format(obs['MOONFRAC'])
        else:                        moonfrac = "{}-{}".format(obs['moonfracmin'],obs['moonfracmax'])

        print('ObsConds ExpTime: {}, MoonFrac: {}, MoonAlt: {}, MoonSep: {}'.format(exptime,moonfrac,obs['MOONALT'],obs['MOONSEP']))
        result = Table.read(resultfile)
        #result.pprint()
        qa_zmag(result['ZTRUE'], result['RMAG'], maglabel=r'$r_{\rm DECaLS}$ (AB mag)', faintmag=20.)
        qa_efficiency(result)
        qa_zwarn4(result)


Sim: sim16 with nspec: 800 and nsim: 2
ObsConds ExpTime: 480, MoonFrac: 0.8, MoonAlt: 30, MoonSep: 60

Sim 17


In [21]:
current_sim_name = 'sim17'

In [22]:
print_sim_params(current_sim_name, sim_names, sims, conditions)


Sim: sim17
	Sim Parameters: 
		suffix: sim17
		use_mock: False
		nsim: 10
		nspec: 200
		zmin: 0.1
		zmax: 0.8
		rmagmin: 19.5
		rmagmax: 20.0
		seed: 2788
	Obs Parameters: 
		AIRMASS: 1.0
		SEEING: 1.1
		MOONALT: 30
		MOONSEP: 60
		exptimemin: 300
		exptimemax: 720
		MOONFRAC: 0.8

In [23]:
# sim 17
if current_sim_name in sim_names:
    ind = np.where(sim_names==current_sim_name)[0][0]
    sim,obs = sims[ind],conditions[ind]
    
    resultfile = os.path.join(simdir, sim['suffix'], 'bgs-{}-results.fits'.format(sim['suffix']))
    if os.path.exists(resultfile):
        print('Sim: {} with nspec: {} and nsim: {}'.format(sim['suffix'],sim['nspec'],sim['nsim']))

        if 'EXPTIME' in obs.keys(): exptime = "{}".format(obs['EXPTIME'])
        else:                       exptime = "{}-{}".format(obs['exptimemin'],obs['exptimemax'])

        if 'MOONFRAC' in obs.keys(): moonfrac = "{}".format(obs['MOONFRAC'])
        else:                        moonfrac = "{}-{}".format(obs['moonfracmin'],obs['moonfracmax'])

        print('ObsConds ExpTime: {}, MoonFrac: {}, MoonAlt: {}, MoonSep: {}'.format(exptime,moonfrac,obs['MOONALT'],obs['MOONSEP']))
        result = Table.read(resultfile)
        qa_zmag(result['ZTRUE'], result['RMAG'], maglabel=r'$r_{\rm DECaLS}$ (AB mag)', faintmag=20.)
        qa_efficiency(result)
        qa_zwarn4(result)
        qa_exptime(result,"zeff_vs_exptime.png")


Sim: sim17 with nspec: 200 and nsim: 10
ObsConds ExpTime: 300-720, MoonFrac: 0.8, MoonAlt: 30, MoonSep: 60