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
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)
In [38]:
from desistudy_qa import print_file_locations
print_file_locations(simdir,sims)
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)
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)
In [12]:
current_sim_name = 'sim13'
In [13]:
print_sim_params(current_sim_name, sim_names, sims, conditions)
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")
In [15]:
current_sim_name = 'sim14'
In [16]:
print_sim_params(current_sim_name, sim_names, sims, conditions)
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")
In [18]:
current_sim_name = 'sim16'
In [19]:
print_sim_params(current_sim_name, sim_names, sims, conditions)
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)
In [21]:
current_sim_name = 'sim17'
In [22]:
print_sim_params(current_sim_name, sim_names, sims, conditions)
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")