In [1]:
# Makes print and division act like Python 3
from __future__ import print_function, division
# Import the usual libraries
import numpy as np
import matplotlib
import matplotlib.pyplot as plt
import matplotlib.patches as mpatches
# Enable inline plotting
%matplotlib inline
from IPython.display import display, Latex, clear_output
from matplotlib.backends.backend_pdf import PdfPages
In [2]:
import pynrc
from pynrc import nrc_utils
from pynrc.nrc_utils import S, source_spectrum
pynrc.setup_logging('WARNING', verbose=False)
In [3]:
# Observation Definitions
from pynrc.nb_funcs import make_key, obs_wfe, obs_optimize, model_info
# Functions to run a series of operations
from pynrc.nb_funcs import do_opt, do_contrast, do_gen_hdus, do_sat_levels
# Plotting routines
from pynrc.nb_funcs import plot_contrasts, plot_contrasts_mjup, planet_mags, plot_planet_patches
from pynrc.nb_funcs import update_yscale, do_plot_contrasts, do_plot_contrasts2
from pynrc.nb_funcs import plot_hdulist, plot_images, plot_images_swlw
In [4]:
from pynrc.nb_funcs import update_yscale
In [5]:
from astropy.table import Table
def make_contrast_tbl(curves):
data = []
names =[]
rr = curves[0][0]
igood = rr>1.5
data.append(rr[igood])
names.append('Arcsec')
for j, vals in enumerate(curves):
rr, contrast, sen = vals
data.append(contrast[igood])
data.append(sen[igood])
wfe = wfe_list[j]
names.append('Contr_{:.0f}nm'.format(wfe))
names.append('Sen_{:.0f}nm'.format(wfe))
# Modify number formats
tbl = Table(data, names=names)
tbl[names[0]].format = '.4f'
for name in names:
if 'Cont' in name: fmt = '.3E'
elif 'Sen' in name: fmt ='.4f'
else: fmt = tbl[name].format
tbl[name].format = fmt
return tbl
In [6]:
def update_yscale2(ax, scale_type, ylim=None):
# Some fancy log+linear plotting
from matplotlib.ticker import FixedLocator, ScalarFormatter, LogFormatterSciNotation
if scale_type=='symlog':
ylim = [0,100] if ylim is None else ylim
ax.set_ylim(ylim)
yr = ax.get_ylim()
ax.set_yscale('symlog', linthreshy=10, linscaley=2)
ax.set_yticks(list(range(0,10)) + [10,100,1000])
#ax.get_yaxis().set_major_formatter(ScalarFormatter())
ax.yaxis.set_major_formatter(ScalarFormatter())
minor_log = list(np.arange(20,100,10)) + list(np.arange(200,1000,100))
minorLocator = FixedLocator(minor_log)
ax.yaxis.set_minor_locator(minorLocator)
ax.set_ylim([0,yr[1]])
elif scale_type=='log':
ax.set_yscale('log')
ylim = [0.1,100] if ylim is None else ylim
ax.set_ylim(ylim)
ax.yaxis.set_major_formatter(LogFormatterSciNotation())
In [7]:
# Various Bandpasses
bp_v = S.ObsBandpass('v')
bp_k = pynrc.bp_2mass('k')
bp_w1 = pynrc.bp_wise('w1')
bp_w2 = pynrc.bp_wise('w2')
In [8]:
# Argument list:(Name, dist, age, sptype, mag)
args_sources = [('AUMic', 9.72, 24, 'M1V', 4.53, bp_k),
('HIP17695', 16.80, 150, 'M3V', 6.93, bp_k),
('G7-34', 14.59, 150, 'M4V', 8.18, bp_k),
('TYC5899', 15.83, 130, 'M3V', 6.89, bp_k),
('2MJ0944-1220', 13.13, 50, 'M5V', 7.60, bp_k),
('APCol', 8.67, 50, 'M5V', 6.87, bp_k),
('FomalhautC', 7.67, 440, 'M4V', 7.21, bp_k),
('LP944-20', 6.42, 200, 'M9V', 9.55, bp_k),
('2MJ0443+0002', 21.09, 24, 'M9V', 11.22, bp_k)]
ref_sources = [('TYC5899', 'M3V', 6.9, bp_k),
('TYC5899', 'M3V', 6.9, bp_k),
('TYC5899', 'M3V', 6.9, bp_k),
('HIP17695', 'M3V', 6.9, bp_k),
('APCol', 'M5V', 6.9, bp_k),
('2MJ0944-1220', 'M5V', 7.6, bp_k),
('APCol', 'M5V', 6.9, bp_k),
('2MJ0443+0002', 'M9V', 11.2, bp_k),
('LP944-20', 'M9V', 9.6, bp_k)]
In [9]:
# Directory housing VOTables
# http://vizier.u-strasbg.fr/vizier/sed/
votdir = 'votables/'
# Directory to save plots and figures
outdir = 'MDwarfs/'
In [10]:
# List of filters
args_filter = [('F480M', None, None),
# ('F444W', None, None),
('F444W', 'MASK430R', 'CIRCLYOT')]
subsize = 320
filt_keys = []
for filt,mask,pupil in args_filter:
filt_keys.append(make_key(filt, mask=mask, pupil=pupil))
In [11]:
# Fit spectrum to SED photometry
i=0
name_sci, dist_sci, age_sci, spt_sci, mag_sci, bp_sci = args_sources[i]
vot = votdir + name_sci.replace(' ' ,'') + '.vot'
args = (name_sci, spt_sci, mag_sci, bp_sci, vot)
kwargs = {}
src = source_spectrum(*args, **kwargs)
src.fit_SED(use_err=False, robust=True, wlim=[1,4])
# Final source spectrum
sp_sci = src.sp_model
In [12]:
# Do the same for the reference source
name_ref, spt_ref, mag_ref, bp_ref = ref_sources[i]
vot = votdir + name_ref.replace(' ' ,'') + '.vot'
args = (name_ref, spt_ref, mag_ref, bp_ref, vot)
kwargs = {}
ref = nrc_utils.source_spectrum(*args, **kwargs)
ref.fit_SED(use_err=True, robust=True)
# Final reference spectrum
sp_ref = ref.sp_model
In [13]:
# Create a dictionary that holds the obs_coronagraphy class for each filter
wfe_drift = 0
obs_dict = obs_wfe(wfe_drift, args_filter, sp_sci, dist_sci, sp_ref=sp_ref,
wind_mode='WINDOW', subsize=subsize, verbose=False)
In [14]:
# Update detector readout
for key in filt_keys:
obs = obs_dict[key]
if 'none' in key:
pattern, ng, nint_sci, nint_ref = ('RAPID',10,600,600)
obs.update_detectors(xpix=160, ypix=160)
obs.nrc_ref.update_detectors(xpix=160, ypix=160)
elif ('MASK210R' in key) or ('MASKSWB' in key):
pattern, ng, nint_sci, nint_ref = ('BRIGHT2',10,20,20)
else:
pattern, ng, nint_sci, nint_ref = ('MEDIUM8',10,17,17)
obs.update_detectors(read_mode=pattern, ngroup=ng, nint=nint_sci)
obs.nrc_ref.update_detectors(read_mode=pattern, ngroup=ng, nint=nint_ref)
print(key)
print(obs.multiaccum_times)
_ = obs.sensitivity(nsig=5, units='vegamag', verbose=True)
print('')
In [15]:
sat_dict = {}
for k in filt_keys:
print('\n{}'.format(k))
obs = obs_dict[k]
dsat_asec = do_sat_levels(obs, satval=0.9, plot=False)
sat_dict[k] = dsat_asec
In [16]:
# Determine contrast curves for various WFE drift values
wfe_list = [0,2,5,10]
nsig = 5
roll = 10
# (Roll1 - Ref) + (Roll2 - Ref)
curves_ref = do_contrast(obs_dict, wfe_list, filt_keys, nsig=nsig, roll_angle=roll, opt_diff=False)
# (Roll1 - Roll2) + (Roll2 - Roll1)
curves_roll = do_contrast(obs_dict, wfe_list, filt_keys, nsig=nsig, roll_angle=roll, no_ref=True,
opt_diff=False)
In [17]:
# key1, key2 = ('F444W_MASK430R_CIRCLYOT', 'F444W_MASK430R_CIRCLYOT') #filt_keys[-2:][::-1]
key1, key2 = ('F480M_none_none', 'F444W_MASK430R_CIRCLYOT')
for curves in [curves_ref, curves_roll]:
#key1 = filt_keys[0]
#key2 = filt_keys[1]
lab1 = 'Direct (F480M)'
lab2 = 'Coron (F444W)'
fig, axes_all = do_plot_contrasts2(key1, key2, curves, nsig, obs_dict, wfe_list, age_sci,
sat_dict=sat_dict, label1=lab1, label2=lab2, yr=[24,10],
yscale2='log', yr2=[3e-2, 30], linder_models=True)
fname = "{}_compare.pdf".format(name_sci.replace(" ", ""))
fig.savefig(outdir+fname)
In [18]:
# Fit spectrum to SED photometry
i=1
name_sci, dist_sci, age_sci, spt_sci, mag_sci, bp_sci = args_sources[i]
vot = votdir + name_sci.replace(' ' ,'') + '.vot'
args = (name_sci, spt_sci, mag_sci, bp_sci, vot)
kwargs = {}
src = source_spectrum(*args, **kwargs)
src.fit_SED(use_err=False, robust=True, wlim=[1,4])
# Final source spectrum
sp_sci = src.sp_model
In [19]:
# Do the same for the reference source
name_ref, spt_ref, mag_ref, bp_ref = ref_sources[i]
vot = votdir + name_ref.replace(' ' ,'') + '.vot'
args = (name_ref, spt_ref, mag_ref, bp_ref, vot)
kwargs = {}
ref = nrc_utils.source_spectrum(*args, **kwargs)
ref.fit_SED(use_err=True, robust=True)
# Final reference spectrum
sp_ref = ref.sp_model
In [20]:
# Create a dictionary that holds the obs_coronagraphy class for each filter
wfe_drift = 0
obs_dict = obs_wfe(wfe_drift, args_filter, sp_sci, dist_sci, sp_ref=sp_ref,
wind_mode='WINDOW', subsize=subsize, verbose=False)
In [21]:
# Update detector readout
for key in filt_keys:
obs = obs_dict[key]
if 'none' in key:
pattern, ng, nint_sci, nint_ref = ('RAPID',10,600,600)
obs.update_detectors(xpix=160, ypix=160)
obs.nrc_ref.update_detectors(xpix=160, ypix=160)
elif ('MASK210R' in key) or ('MASKSWB' in key):
pattern, ng, nint_sci, nint_ref = ('BRIGHT2',10,20,20)
else:
pattern, ng, nint_sci, nint_ref = ('MEDIUM8',10,17,17)
obs.update_detectors(read_mode=pattern, ngroup=ng, nint=nint_sci)
obs.nrc_ref.update_detectors(read_mode=pattern, ngroup=ng, nint=nint_ref)
# print(key)
# print(obs.multiaccum_times)
# _ = obs.sensitivity(nsig=5, units='vegamag', verbose=True)
# print('')
In [22]:
sat_dict = {}
for k in filt_keys:
print('\n{}'.format(k))
obs = obs_dict[k]
dsat_asec = do_sat_levels(obs, satval=0.9, plot=False)
sat_dict[k] = dsat_asec
In [23]:
# Determine contrast curves for various WFE drift values
wfe_list = [0,2,5,10]
nsig = 5
roll = 10
# (Roll1 - Ref) + (Roll2 - Ref)
curves_ref = do_contrast(obs_dict, wfe_list, filt_keys, nsig=nsig, roll_angle=roll, opt_diff=False)
# (Roll1 - Roll2) + (Roll2 - Roll1)
curves_roll = do_contrast(obs_dict, wfe_list, filt_keys, nsig=nsig, roll_angle=roll, no_ref=True,
opt_diff=False)
In [24]:
# key1, key2 = ('F444W_MASK430R_CIRCLYOT', 'F444W_MASK430R_CIRCLYOT') #filt_keys[-2:][::-1]
key1, key2 = ('F480M_none_none', 'F444W_MASK430R_CIRCLYOT')
for curves in [curves_ref, curves_roll]:
#key1 = filt_keys[0]
#key2 = filt_keys[1]
lab1 = 'Direct (F480M)'
lab2 = 'Coron (F444W)'
fig, axes_all = do_plot_contrasts2(key1, key2, curves, nsig, obs_dict, wfe_list, age_sci,
sat_dict=sat_dict, label1=lab1, label2=lab2, yr=[24,10],
yscale2='log', yr2=[3e-2, 30], linder_models=True)
fname = "{}_compare.pdf".format(name_sci.replace(" ", ""))
fig.savefig(outdir+fname)
In [25]:
# Fit spectrum to SED photometry
i=2
name_sci, dist_sci, age_sci, spt_sci, mag_sci, bp_sci = args_sources[i]
vot = votdir + name_sci.replace(' ' ,'') + '.vot'
args = (name_sci, spt_sci, mag_sci, bp_sci, vot)
kwargs = {}
src = source_spectrum(*args, **kwargs)
src.fit_SED(use_err=False, robust=True, wlim=[1,4])
# Final source spectrum
sp_sci = src.sp_model
In [26]:
# Do the same for the reference source
name_ref, spt_ref, mag_ref, bp_ref = ref_sources[i]
vot = votdir + name_ref.replace(' ' ,'') + '.vot'
args = (name_ref, spt_ref, mag_ref, bp_ref, vot)
kwargs = {}
ref = nrc_utils.source_spectrum(*args, **kwargs)
ref.fit_SED(use_err=True, robust=True)
# Final reference spectrum
sp_ref = ref.sp_model
In [27]:
# Create a dictionary that holds the obs_coronagraphy class for each filter
wfe_drift = 0
obs_dict = obs_wfe(wfe_drift, args_filter, sp_sci, dist_sci, sp_ref=sp_ref,
wind_mode='WINDOW', subsize=subsize, verbose=False)
In [28]:
# Update detector readout
for key in filt_keys:
obs = obs_dict[key]
if 'none' in key:
pattern, ng, nint_sci, nint_ref = ('RAPID',10,600,600)
obs.update_detectors(xpix=160, ypix=160)
obs.nrc_ref.update_detectors(xpix=160, ypix=160)
elif ('MASK210R' in key) or ('MASKSWB' in key):
pattern, ng, nint_sci, nint_ref = ('BRIGHT2',10,20,20)
else:
pattern, ng, nint_sci, nint_ref = ('MEDIUM8',10,17,17)
obs.update_detectors(read_mode=pattern, ngroup=ng, nint=nint_sci)
obs.nrc_ref.update_detectors(read_mode=pattern, ngroup=ng, nint=nint_ref)
# print(key)
# print(obs.multiaccum_times)
# _ = obs.sensitivity(nsig=5, units='vegamag', verbose=True)
# print('')
In [29]:
sat_dict = {}
for k in filt_keys:
print('\n{}'.format(k))
obs = obs_dict[k]
dsat_asec = do_sat_levels(obs, satval=0.9, plot=False)
sat_dict[k] = dsat_asec
In [30]:
# Determine contrast curves for various WFE drift values
wfe_list = [0,2,5,10]
nsig = 5
roll = 10
# (Roll1 - Ref) + (Roll2 - Ref)
curves_ref = do_contrast(obs_dict, wfe_list, filt_keys, nsig=nsig, roll_angle=roll, opt_diff=False)
# (Roll1 - Roll2) + (Roll2 - Roll1)
curves_roll = do_contrast(obs_dict, wfe_list, filt_keys, nsig=nsig, roll_angle=roll, no_ref=True,
opt_diff=False)
In [31]:
# key1, key2 = ('F444W_MASK430R_CIRCLYOT', 'F444W_MASK430R_CIRCLYOT') #filt_keys[-2:][::-1]
key1, key2 = ('F480M_none_none', 'F444W_MASK430R_CIRCLYOT')
for curves in [curves_ref, curves_roll]:
#key1 = filt_keys[0]
#key2 = filt_keys[1]
lab1 = 'Direct (F480M)'
lab2 = 'Coron (F444W)'
fig, axes_all = do_plot_contrasts2(key1, key2, curves, nsig, obs_dict, wfe_list, age_sci,
sat_dict=sat_dict, label1=lab1, label2=lab2, yr=[24,10],
yscale2='log', yr2=[3e-2, 30], linder_models=True)
fname = "{}_compare.pdf".format(name_sci.replace(" ", ""))
fig.savefig(outdir+fname)
In [32]:
# Fit spectrum to SED photometry
i=3
name_sci, dist_sci, age_sci, spt_sci, mag_sci, bp_sci = args_sources[i]
vot = votdir + name_sci.replace(' ' ,'') + '.vot'
args = (name_sci, spt_sci, mag_sci, bp_sci, vot)
kwargs = {}
src = source_spectrum(*args, **kwargs)
src.fit_SED(use_err=False, robust=True, wlim=[1,4])
# Final source spectrum
sp_sci = src.sp_model
In [33]:
# Do the same for the reference source
name_ref, spt_ref, mag_ref, bp_ref = ref_sources[i]
vot = votdir + name_ref.replace(' ' ,'') + '.vot'
args = (name_ref, spt_ref, mag_ref, bp_ref, vot)
kwargs = {}
ref = nrc_utils.source_spectrum(*args, **kwargs)
ref.fit_SED(use_err=True, robust=True, wlim=[1,5])
# Final reference spectrum
sp_ref = ref.sp_model
In [34]:
# Create a dictionary that holds the obs_coronagraphy class for each filter
wfe_drift = 0
obs_dict = obs_wfe(wfe_drift, args_filter, sp_sci, dist_sci, sp_ref=sp_ref,
wind_mode='WINDOW', subsize=subsize, verbose=False)
In [35]:
# Update detector readout
for key in filt_keys:
obs = obs_dict[key]
if 'none' in key:
pattern, ng, nint_sci, nint_ref = ('RAPID',10,600,600)
obs.update_detectors(xpix=160, ypix=160)
obs.nrc_ref.update_detectors(xpix=160, ypix=160)
elif ('MASK210R' in key) or ('MASKSWB' in key):
pattern, ng, nint_sci, nint_ref = ('BRIGHT2',10,20,20)
else:
pattern, ng, nint_sci, nint_ref = ('MEDIUM8',10,17,17)
obs.update_detectors(read_mode=pattern, ngroup=ng, nint=nint_sci)
obs.nrc_ref.update_detectors(read_mode=pattern, ngroup=ng, nint=nint_ref)
# print(key)
# print(obs.multiaccum_times)
# _ = obs.sensitivity(nsig=5, units='vegamag', verbose=True)
# print('')
In [36]:
sat_dict = {}
for k in filt_keys:
print('\n{}'.format(k))
obs = obs_dict[k]
dsat_asec = do_sat_levels(obs, satval=0.9, plot=False)
sat_dict[k] = dsat_asec
In [37]:
# Determine contrast curves for various WFE drift values
wfe_list = [0,2,5,10]
nsig = 5
roll = 10
# (Roll1 - Ref) + (Roll2 - Ref)
curves_ref = do_contrast(obs_dict, wfe_list, filt_keys, nsig=nsig, roll_angle=roll, opt_diff=False)
# (Roll1 - Roll2) + (Roll2 - Roll1)
curves_roll = do_contrast(obs_dict, wfe_list, filt_keys, nsig=nsig, roll_angle=roll, no_ref=True,
opt_diff=False)
In [38]:
# key1, key2 = ('F444W_MASK430R_CIRCLYOT', 'F444W_MASK430R_CIRCLYOT') #filt_keys[-2:][::-1]
key1, key2 = ('F480M_none_none', 'F444W_MASK430R_CIRCLYOT')
for curves in [curves_ref, curves_roll]:
#key1 = filt_keys[0]
#key2 = filt_keys[1]
lab1 = 'Direct (F480M)'
lab2 = 'Coron (F444W)'
fig, axes_all = do_plot_contrasts2(key1, key2, curves, nsig, obs_dict, wfe_list, age_sci,
sat_dict=sat_dict, label1=lab1, label2=lab2, yr=[24,10],
yscale2='log', yr2=[3e-2, 30], linder_models=True)
fname = "{}_compare.pdf".format(name_sci.replace(" ", ""))
fig.savefig(outdir+fname)
In [39]:
# Fit spectrum to SED photometry
i=4
name_sci, dist_sci, age_sci, spt_sci, mag_sci, bp_sci = args_sources[i]
vot = votdir + name_sci.replace(' ' ,'') + '.vot'
args = (name_sci, spt_sci, mag_sci, bp_sci, vot)
kwargs = {}
src = source_spectrum(*args, **kwargs)
src.fit_SED(use_err=False, robust=True, wlim=[2,5])
# Final source spectrum
sp_sci = src.sp_model
In [40]:
# Do the same for the reference source
name_ref, spt_ref, mag_ref, bp_ref = ref_sources[i]
vot = votdir + name_ref.replace(' ' ,'') + '.vot'
args = (name_ref, spt_ref, mag_ref, bp_ref, vot)
kwargs = {}
ref = nrc_utils.source_spectrum(*args, **kwargs)
ref.fit_SED(use_err=True, robust=True, wlim=[2,5])
# Final reference spectrum
sp_ref = ref.sp_model
In [41]:
# Create a dictionary that holds the obs_coronagraphy class for each filter
wfe_drift = 0
obs_dict = obs_wfe(wfe_drift, args_filter, sp_sci, dist_sci, sp_ref=sp_ref,
wind_mode='WINDOW', subsize=subsize, verbose=False)
In [42]:
# Update detector readout
for key in filt_keys:
obs = obs_dict[key]
if 'none' in key:
pattern, ng, nint_sci, nint_ref = ('RAPID',10,600,600)
obs.update_detectors(xpix=160, ypix=160)
obs.nrc_ref.update_detectors(xpix=160, ypix=160)
elif ('MASK210R' in key) or ('MASKSWB' in key):
pattern, ng, nint_sci, nint_ref = ('BRIGHT2',10,20,20)
else:
pattern, ng, nint_sci, nint_ref = ('MEDIUM8',10,17,17)
obs.update_detectors(read_mode=pattern, ngroup=ng, nint=nint_sci)
obs.nrc_ref.update_detectors(read_mode=pattern, ngroup=ng, nint=nint_ref)
# print(key)
# print(obs.multiaccum_times)
# _ = obs.sensitivity(nsig=5, units='vegamag', verbose=True)
# print('')
In [43]:
sat_dict = {}
for k in filt_keys:
print('\n{}'.format(k))
obs = obs_dict[k]
dsat_asec = do_sat_levels(obs, satval=0.9, plot=False)
sat_dict[k] = dsat_asec
In [44]:
# Determine contrast curves for various WFE drift values
wfe_list = [0,2,5,10]
nsig = 5
roll = 10
# (Roll1 - Ref) + (Roll2 - Ref)
curves_ref = do_contrast(obs_dict, wfe_list, filt_keys, nsig=nsig, roll_angle=roll, opt_diff=False)
# (Roll1 - Roll2) + (Roll2 - Roll1)
curves_roll = do_contrast(obs_dict, wfe_list, filt_keys, nsig=nsig, roll_angle=roll, no_ref=True,
opt_diff=False)
In [45]:
# key1, key2 = ('F444W_MASK430R_CIRCLYOT', 'F444W_MASK430R_CIRCLYOT') #filt_keys[-2:][::-1]
key1, key2 = ('F480M_none_none', 'F444W_MASK430R_CIRCLYOT')
for curves in [curves_ref, curves_roll]:
#key1 = filt_keys[0]
#key2 = filt_keys[1]
lab1 = 'Direct (F480M)'
lab2 = 'Coron (F444W)'
fig, axes_all = do_plot_contrasts2(key1, key2, curves, nsig, obs_dict, wfe_list, age_sci,
sat_dict=sat_dict, label1=lab1, label2=lab2, yr=[24,10],
yscale2='log', yr2=[3e-2, 30], linder_models=True)
fname = "{}_compare.pdf".format(name_sci.replace(" ", ""))
fig.savefig(outdir+fname)
In [46]:
# Fit spectrum to SED photometry
i=5
name_sci, dist_sci, age_sci, spt_sci, mag_sci, bp_sci = args_sources[i]
vot = votdir + name_sci.replace(' ' ,'') + '.vot'
args = (name_sci, spt_sci, mag_sci, bp_sci, vot)
kwargs = {}
src = source_spectrum(*args, **kwargs)
src.fit_SED(use_err=False, robust=True, wlim=[2,5])
# Final source spectrum
sp_sci = src.sp_model
In [47]:
# Do the same for the reference source
name_ref, spt_ref, mag_ref, bp_ref = ref_sources[i]
vot = votdir + name_ref.replace(' ' ,'') + '.vot'
args = (name_ref, spt_ref, mag_ref, bp_ref, vot)
kwargs = {}
ref = nrc_utils.source_spectrum(*args, **kwargs)
ref.fit_SED(use_err=True, robust=True, wlim=[2,5])
# Final reference spectrum
sp_ref = ref.sp_model
In [48]:
# Create a dictionary that holds the obs_coronagraphy class for each filter
wfe_drift = 0
obs_dict = obs_wfe(wfe_drift, args_filter, sp_sci, dist_sci, sp_ref=sp_ref,
wind_mode='WINDOW', subsize=subsize, verbose=False)
In [49]:
# Update detector readout
for key in filt_keys:
obs = obs_dict[key]
if 'none' in key:
pattern, ng, nint_sci, nint_ref = ('RAPID',10,600,600)
obs.update_detectors(xpix=160, ypix=160)
obs.nrc_ref.update_detectors(xpix=160, ypix=160)
elif ('MASK210R' in key) or ('MASKSWB' in key):
pattern, ng, nint_sci, nint_ref = ('BRIGHT2',10,20,20)
else:
pattern, ng, nint_sci, nint_ref = ('MEDIUM8',10,17,17)
obs.update_detectors(read_mode=pattern, ngroup=ng, nint=nint_sci)
obs.nrc_ref.update_detectors(read_mode=pattern, ngroup=ng, nint=nint_ref)
# print(key)
# print(obs.multiaccum_times)
# _ = obs.sensitivity(nsig=5, units='vegamag', verbose=True)
# print('')
In [50]:
sat_dict = {}
for k in filt_keys:
print('\n{}'.format(k))
obs = obs_dict[k]
dsat_asec = do_sat_levels(obs, satval=0.9, plot=False)
sat_dict[k] = dsat_asec
In [51]:
# Determine contrast curves for various WFE drift values
wfe_list = [0,2,5,10]
nsig = 5
roll = 10
# (Roll1 - Ref) + (Roll2 - Ref)
curves_ref = do_contrast(obs_dict, wfe_list, filt_keys, nsig=nsig, roll_angle=roll, opt_diff=False)
# (Roll1 - Roll2) + (Roll2 - Roll1)
curves_roll = do_contrast(obs_dict, wfe_list, filt_keys, nsig=nsig, roll_angle=roll, no_ref=True,
opt_diff=False)
In [52]:
# key1, key2 = ('F444W_MASK430R_CIRCLYOT', 'F444W_MASK430R_CIRCLYOT') #filt_keys[-2:][::-1]
key1, key2 = ('F480M_none_none', 'F444W_MASK430R_CIRCLYOT')
for curves in [curves_ref, curves_roll]:
#key1 = filt_keys[0]
#key2 = filt_keys[1]
lab1 = 'Direct (F480M)'
lab2 = 'Coron (F444W)'
fig, axes_all = do_plot_contrasts2(key1, key2, curves, nsig, obs_dict, wfe_list, age_sci,
sat_dict=sat_dict, label1=lab1, label2=lab2, yr=[24,10],
yscale2='log', yr2=[3e-2, 30], linder_models=True)
fname = "{}_compare.pdf".format(name_sci.replace(" ", ""))
fig.savefig(outdir+fname)
In [53]:
# Fit spectrum to SED photometry
i=6
name_sci, dist_sci, age_sci, spt_sci, mag_sci, bp_sci = args_sources[i]
vot = votdir + name_sci.replace(' ' ,'') + '.vot'
args = (name_sci, spt_sci, mag_sci, bp_sci, vot)
kwargs = {}
src = source_spectrum(*args, **kwargs)
src.fit_SED(use_err=False, robust=True, wlim=[2,5])
# Final source spectrum
sp_sci = src.sp_model
In [54]:
# Do the same for the reference source
name_ref, spt_ref, mag_ref, bp_ref = ref_sources[i]
vot = votdir + name_ref.replace(' ' ,'') + '.vot'
args = (name_ref, spt_ref, mag_ref, bp_ref, vot)
kwargs = {}
ref = nrc_utils.source_spectrum(*args, **kwargs)
ref.fit_SED(use_err=False, robust=True, wlim=[2,5])
# Final reference spectrum
sp_ref = ref.sp_model
In [55]:
# Create a dictionary that holds the obs_coronagraphy class for each filter
wfe_drift = 0
obs_dict = obs_wfe(wfe_drift, args_filter, sp_sci, dist_sci, sp_ref=sp_ref,
wind_mode='WINDOW', subsize=subsize, verbose=False)
In [56]:
# Update detector readout
for key in filt_keys:
obs = obs_dict[key]
if 'none' in key:
pattern, ng, nint_sci, nint_ref = ('RAPID',10,600,600)
obs.update_detectors(xpix=160, ypix=160)
obs.nrc_ref.update_detectors(xpix=160, ypix=160)
elif ('MASK210R' in key) or ('MASKSWB' in key):
pattern, ng, nint_sci, nint_ref = ('BRIGHT2',10,20,20)
else:
pattern, ng, nint_sci, nint_ref = ('MEDIUM8',10,17,17)
obs.update_detectors(read_mode=pattern, ngroup=ng, nint=nint_sci)
obs.nrc_ref.update_detectors(read_mode=pattern, ngroup=ng, nint=nint_ref)
# print(key)
# print(obs.multiaccum_times)
# _ = obs.sensitivity(nsig=5, units='vegamag', verbose=True)
# print('')
In [57]:
sat_dict = {}
for k in filt_keys:
print('\n{}'.format(k))
obs = obs_dict[k]
dsat_asec = do_sat_levels(obs, satval=0.9, plot=False)
sat_dict[k] = dsat_asec
In [58]:
# Determine contrast curves for various WFE drift values
wfe_list = [0,2,5,10]
nsig = 5
roll = 10
# (Roll1 - Ref) + (Roll2 - Ref)
curves_ref = do_contrast(obs_dict, wfe_list, filt_keys, nsig=nsig, roll_angle=roll, opt_diff=False)
# (Roll1 - Roll2) + (Roll2 - Roll1)
curves_roll = do_contrast(obs_dict, wfe_list, filt_keys, nsig=nsig, roll_angle=roll, no_ref=True,
opt_diff=False)
In [59]:
# key1, key2 = ('F444W_MASK430R_CIRCLYOT', 'F444W_MASK430R_CIRCLYOT') #filt_keys[-2:][::-1]
key1, key2 = ('F480M_none_none', 'F444W_MASK430R_CIRCLYOT')
for curves in [curves_ref, curves_roll]:
#key1 = filt_keys[0]
#key2 = filt_keys[1]
lab1 = 'Direct (F480M)'
lab2 = 'Coron (F444W)'
fig, axes_all = do_plot_contrasts2(key1, key2, curves, nsig, obs_dict, wfe_list, age_sci,
sat_dict=sat_dict, label1=lab1, label2=lab2, yr=[24,10],
yscale2='log', yr2=[3e-2, 30], linder_models=True)
fname = "{}_compare.pdf".format(name_sci.replace(" ", ""))
fig.savefig(outdir+fname)
In [60]:
# Fit spectrum to SED photometry
i=7
name_sci, dist_sci, age_sci, spt_sci, mag_sci, bp_sci = args_sources[i]
vot = votdir + name_sci.replace(' ' ,'') + '.vot'
args = (name_sci, spt_sci, mag_sci, bp_sci, vot)
kwargs = {}
src = source_spectrum(*args, **kwargs)
src.fit_SED(use_err=False, robust=True, wlim=[2,5])
# Final source spectrum
sp_sci = src.sp_model
In [61]:
# Do the same for the reference source
name_ref, spt_ref, mag_ref, bp_ref = ref_sources[i]
vot = votdir + name_ref.replace(' ' ,'') + '.vot'
args = (name_ref, spt_ref, mag_ref, bp_ref, vot)
kwargs = {}
ref = nrc_utils.source_spectrum(*args, **kwargs)
ref.fit_SED(use_err=False, robust=True, wlim=[2,5])
# Final reference spectrum
sp_ref = ref.sp_model
In [62]:
# Create a dictionary that holds the obs_coronagraphy class for each filter
wfe_drift = 0
obs_dict = obs_wfe(wfe_drift, args_filter, sp_sci, dist_sci, sp_ref=sp_ref,
wind_mode='WINDOW', subsize=subsize, verbose=False)
In [63]:
# Update detector readout
for key in filt_keys:
obs = obs_dict[key]
if 'none' in key:
pattern, ng, nint_sci, nint_ref = ('RAPID',10,600,600)
obs.update_detectors(xpix=160, ypix=160)
obs.nrc_ref.update_detectors(xpix=160, ypix=160)
elif ('MASK210R' in key) or ('MASKSWB' in key):
pattern, ng, nint_sci, nint_ref = ('BRIGHT2',10,20,20)
else:
pattern, ng, nint_sci, nint_ref = ('MEDIUM8',10,17,17)
obs.update_detectors(read_mode=pattern, ngroup=ng, nint=nint_sci)
obs.nrc_ref.update_detectors(read_mode=pattern, ngroup=ng, nint=nint_ref)
# print(key)
# print(obs.multiaccum_times)
# _ = obs.sensitivity(nsig=5, units='vegamag', verbose=True)
# print('')
In [64]:
sat_dict = {}
for k in filt_keys:
print('\n{}'.format(k))
obs = obs_dict[k]
dsat_asec = do_sat_levels(obs, satval=0.9, plot=False)
sat_dict[k] = dsat_asec
In [65]:
# Determine contrast curves for various WFE drift values
wfe_list = [0,2,5,10]
nsig = 5
roll = 10
# (Roll1 - Ref) + (Roll2 - Ref)
curves_ref = do_contrast(obs_dict, wfe_list, filt_keys, nsig=nsig, roll_angle=roll, opt_diff=False)
# (Roll1 - Roll2) + (Roll2 - Roll1)
curves_roll = do_contrast(obs_dict, wfe_list, filt_keys, nsig=nsig, roll_angle=roll, no_ref=True,
opt_diff=False)
In [66]:
# key1, key2 = ('F444W_MASK430R_CIRCLYOT', 'F444W_MASK430R_CIRCLYOT') #filt_keys[-2:][::-1]
key1, key2 = ('F480M_none_none', 'F444W_MASK430R_CIRCLYOT')
for curves in [curves_ref, curves_roll]:
#key1 = filt_keys[0]
#key2 = filt_keys[1]
lab1 = 'Direct (F480M)'
lab2 = 'Coron (F444W)'
fig, axes_all = do_plot_contrasts2(key1, key2, curves, nsig, obs_dict, wfe_list, age_sci,
sat_dict=sat_dict, label1=lab1, label2=lab2, yr=[24,10],
yscale2='log', yr2=[3e-2, 30], linder_models=True)
fname = "{}_compare.pdf".format(name_sci.replace(" ", ""))
fig.savefig(outdir+fname)
In [67]:
# Fit spectrum to SED photometry
i=8
name_sci, dist_sci, age_sci, spt_sci, mag_sci, bp_sci = args_sources[i]
vot = votdir + name_sci.replace(' ' ,'') + '.vot'
args = (name_sci, spt_sci, mag_sci, bp_sci, vot)
kwargs = {}
src = source_spectrum(*args, **kwargs)
src.fit_SED(use_err=False, robust=True, wlim=[2,5])
# Final source spectrum
sp_sci = src.sp_model
In [68]:
# Do the same for the reference source
name_ref, spt_ref, mag_ref, bp_ref = ref_sources[i]
vot = votdir + name_ref.replace(' ' ,'') + '.vot'
args = (name_ref, spt_ref, mag_ref, bp_ref, vot)
kwargs = {}
ref = nrc_utils.source_spectrum(*args, **kwargs)
ref.fit_SED(use_err=False, robust=True, wlim=[2,5])
# Final reference spectrum
sp_ref = ref.sp_model
In [69]:
# Create a dictionary that holds the obs_coronagraphy class for each filter
wfe_drift = 0
obs_dict = obs_wfe(wfe_drift, args_filter, sp_sci, dist_sci, sp_ref=sp_ref,
wind_mode='WINDOW', subsize=subsize, verbose=False)
In [70]:
# Update detector readout
for key in filt_keys:
obs = obs_dict[key]
if 'none' in key:
pattern, ng, nint_sci, nint_ref = ('RAPID',10,600,600)
obs.update_detectors(xpix=160, ypix=160)
obs.nrc_ref.update_detectors(xpix=160, ypix=160)
elif ('MASK210R' in key) or ('MASKSWB' in key):
pattern, ng, nint_sci, nint_ref = ('BRIGHT2',10,20,20)
else:
pattern, ng, nint_sci, nint_ref = ('MEDIUM8',10,17,17)
obs.update_detectors(read_mode=pattern, ngroup=ng, nint=nint_sci)
obs.nrc_ref.update_detectors(read_mode=pattern, ngroup=ng, nint=nint_ref)
# print(key)
# print(obs.multiaccum_times)
# _ = obs.sensitivity(nsig=5, units='vegamag', verbose=True)
# print('')
In [71]:
sat_dict = {}
for k in filt_keys:
print('\n{}'.format(k))
obs = obs_dict[k]
dsat_asec = do_sat_levels(obs, satval=0.9, plot=False)
sat_dict[k] = dsat_asec
In [72]:
# Determine contrast curves for various WFE drift values
wfe_list = [0,2,5,10]
nsig = 5
roll = 10
# (Roll1 - Ref) + (Roll2 - Ref)
curves_ref = do_contrast(obs_dict, wfe_list, filt_keys, nsig=nsig, roll_angle=roll, opt_diff=False)
# (Roll1 - Roll2) + (Roll2 - Roll1)
curves_roll = do_contrast(obs_dict, wfe_list, filt_keys, nsig=nsig, roll_angle=roll, no_ref=True,
opt_diff=False)
In [73]:
# key1, key2 = ('F444W_MASK430R_CIRCLYOT', 'F444W_MASK430R_CIRCLYOT') #filt_keys[-2:][::-1]
key1, key2 = ('F480M_none_none', 'F444W_MASK430R_CIRCLYOT')
for curves in [curves_ref, curves_roll]:
#key1 = filt_keys[0]
#key2 = filt_keys[1]
lab1 = 'Direct (F480M)'
lab2 = 'Coron (F444W)'
fig, axes_all = do_plot_contrasts2(key1, key2, curves, nsig, obs_dict, wfe_list, age_sci,
sat_dict=sat_dict, label1=lab1, label2=lab2, yr=[24,10],
yscale2='log', yr2=[3e-2, 30], linder_models=True)
fname = "{}_compare.pdf".format(name_sci.replace(" ", ""))
fig.savefig(outdir+fname)
In [ ]:
In [ ]:
In [ ]: