Skip to content

Commit

Permalink
Merge d52ae8e into 0c46945
Browse files Browse the repository at this point in the history
  • Loading branch information
CoreySpohn committed Sep 14, 2020
2 parents 0c46945 + d52ae8e commit fc1d876
Show file tree
Hide file tree
Showing 160 changed files with 8,148 additions and 137 deletions.
14 changes: 7 additions & 7 deletions EXOSIMS/Completeness/BrownCompleteness.py
Original file line number Diff line number Diff line change
Expand Up @@ -452,7 +452,7 @@ def genplans(self, nplan):

return s, dMag

def comp_per_intTime(self, intTimes, TL, sInds, fZ, fEZ, WA, mode, C_b=None, C_sp=None):
def comp_per_intTime(self, intTimes, TL, sInds, fZ, fEZ, WA, mode, C_b=None, C_sp=None, TK=None):
"""Calculates completeness for integration time
Args:
Expand Down Expand Up @@ -481,7 +481,7 @@ def comp_per_intTime(self, intTimes, TL, sInds, fZ, fEZ, WA, mode, C_b=None, C_s
Completeness values
"""
intTimes, sInds, fZ, fEZ, WA, smin, smax, dMag = self.comps_input_reshape(intTimes, TL, sInds, fZ, fEZ, WA, mode, C_b=C_b, C_sp=C_sp)
intTimes, sInds, fZ, fEZ, WA, smin, smax, dMag = self.comps_input_reshape(intTimes, TL, sInds, fZ, fEZ, WA, mode, C_b=C_b, C_sp=C_sp, TK=TK)

comp = self.comp_calc(smin, smax, dMag)
mask = smin>self.PlanetPopulation.rrange[1].to('AU').value
Expand Down Expand Up @@ -518,7 +518,7 @@ def comp_calc(self, smin, smax, dMag):

return comp

def dcomp_dt(self, intTimes, TL, sInds, fZ, fEZ, WA, mode, C_b=None, C_sp=None):
def dcomp_dt(self, intTimes, TL, sInds, fZ, fEZ, WA, mode, C_b=None, C_sp=None, TK=None):
"""Calculates derivative of completeness with respect to integration time
Args:
Expand Down Expand Up @@ -547,16 +547,16 @@ def dcomp_dt(self, intTimes, TL, sInds, fZ, fEZ, WA, mode, C_b=None, C_sp=None):
Derivative of completeness with respect to integration time (units 1/time)
"""
intTimes, sInds, fZ, fEZ, WA, smin, smax, dMag = self.comps_input_reshape(intTimes, TL, sInds, fZ, fEZ, WA, mode, C_b=C_b, C_sp=C_sp)
intTimes, sInds, fZ, fEZ, WA, smin, smax, dMag = self.comps_input_reshape(intTimes, TL, sInds, fZ, fEZ, WA, mode, C_b=C_b, C_sp=C_sp, TK=TK)

ddMag = TL.OpticalSystem.ddMag_dt(intTimes, TL, sInds, fZ, fEZ, WA, mode).reshape((len(intTimes),))
ddMag = TL.OpticalSystem.ddMag_dt(intTimes, TL, sInds, fZ, fEZ, WA, mode, TK=TK).reshape((len(intTimes),))
dcomp = self.calc_fdmag(dMag, smin, smax)
mask = smin>self.PlanetPopulation.rrange[1].to('AU').value
dcomp[mask] = 0.

return dcomp*ddMag

def comps_input_reshape(self, intTimes, TL, sInds, fZ, fEZ, WA, mode, C_b=None, C_sp=None):
def comps_input_reshape(self, intTimes, TL, sInds, fZ, fEZ, WA, mode, C_b=None, C_sp=None, TK=None):
"""
Reshapes inputs for comp_per_intTime and dcomp_dt as necessary
Expand Down Expand Up @@ -621,7 +621,7 @@ def comps_input_reshape(self, intTimes, TL, sInds, fZ, fEZ, WA, mode, C_b=None,
if len(WA) == 1:
WA = np.repeat(WA.value, len(sInds))*WA.unit

dMag = TL.OpticalSystem.calc_dMag_per_intTime(intTimes, TL, sInds, fZ, fEZ, WA, mode, C_b=C_b, C_sp=C_sp).reshape((len(intTimes),))
dMag = TL.OpticalSystem.calc_dMag_per_intTime(intTimes, TL, sInds, fZ, fEZ, WA, mode, C_b=C_b, C_sp=C_sp, TK=TK).reshape((len(intTimes),))
# calculate separations based on IWA and OWA
IWA = mode['IWA']
OWA = mode['OWA']
Expand Down
4 changes: 2 additions & 2 deletions EXOSIMS/OpticalSystem/KasdinBraems.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ def __init__(self, **specs):
OpticalSystem.__init__(self, **specs)


def calc_intTime(self, TL, sInds, fZ, fEZ, dMag, WA, mode):
def calc_intTime(self, TL, sInds, fZ, fEZ, dMag, WA, mode, TK=None):
"""Finds integration times of target systems for a specific observing
mode (imaging or characterization), based on Kasdin and Braems 2006.
Expand All @@ -50,7 +50,7 @@ def calc_intTime(self, TL, sInds, fZ, fEZ, dMag, WA, mode):
"""

# electron counts
C_p, C_b, C_sp = self.Cp_Cb_Csp(TL, sInds, fZ, fEZ, dMag, WA, mode)
C_p, C_b, C_sp = self.Cp_Cb_Csp(TL, sInds, fZ, fEZ, dMag, WA, mode, TK=TK)

# Kasdin06+ method
inst = mode['inst'] # scienceInstrument
Expand Down
26 changes: 19 additions & 7 deletions EXOSIMS/OpticalSystem/Nemati.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ def __init__(self, **specs):

OpticalSystem.__init__(self, **specs)

def calc_intTime(self, TL, sInds, fZ, fEZ, dMag, WA, mode):
def calc_intTime(self, TL, sInds, fZ, fEZ, dMag, WA, mode, TK=None):
"""Finds integration times of target systems for a specific observing
mode (imaging or characterization), based on Nemati 2014 (SPIE).
Expand All @@ -42,6 +42,9 @@ def calc_intTime(self, TL, sInds, fZ, fEZ, dMag, WA, mode):
Working angles of the planets of interest in units of arcsec
mode (dict):
Selected observing mode
TK (TimeKeeping object):
Optional TimeKeeping object (default None), used to model detector
degradation effects where applicable.
Returns:
intTime (astropy Quantity array):
Expand All @@ -50,7 +53,7 @@ def calc_intTime(self, TL, sInds, fZ, fEZ, dMag, WA, mode):
"""

# electron counts
C_p, C_b, C_sp = self.Cp_Cb_Csp(TL, sInds, fZ, fEZ, dMag, WA, mode)
C_p, C_b, C_sp = self.Cp_Cb_Csp(TL, sInds, fZ, fEZ, dMag, WA, mode, TK=TK)

# get SNR threshold
SNR = mode['SNR']
Expand All @@ -67,7 +70,7 @@ def calc_intTime(self, TL, sInds, fZ, fEZ, dMag, WA, mode):

return intTime.to('day')

def calc_dMag_per_intTime(self, intTimes, TL, sInds, fZ, fEZ, WA, mode, C_b=None, C_sp=None):
def calc_dMag_per_intTime(self, intTimes, TL, sInds, fZ, fEZ, WA, mode, C_b=None, C_sp=None, TK=None):
"""Finds achievable dMag for one integration time per star in the input
list at one working angle.
Expand All @@ -93,6 +96,9 @@ def calc_dMag_per_intTime(self, intTimes, TL, sInds, fZ, fEZ, WA, mode, C_b=None
C_sp (astropy Quantity array):
Residual speckle spatial structure (systematic error) in units of 1/s
(optional)
TK (TimeKeeping object):
Optional TimeKeeping object (default None), used to model detector
degradation effects where applicable.
Returns:
dMag (ndarray):
Expand All @@ -117,6 +123,8 @@ def calc_dMag_per_intTime(self, intTimes, TL, sInds, fZ, fEZ, WA, mode, C_b=None

# get mode wavelength
lam = mode['lam']
# get mode fractional bandwidth
BW = mode['BW']
# get mode bandwidth (including any IFS spectral resolving power)
deltaLam = lam/inst['Rs'] if 'spec' in inst['name'].lower() else mode['deltaLam']

Expand All @@ -128,15 +136,16 @@ def calc_dMag_per_intTime(self, intTimes, TL, sInds, fZ, fEZ, WA, mode, C_b=None

# spectral flux density = F0 * A * Dlam * QE * T (attenuation due to optics)
attenuation = inst['optics']*syst['optics']
C_F0 = self.F0(lam)*self.pupilArea*deltaLam*inst['QE'](lam)*attenuation
F_0 = TL.starF0(sInds,mode)
C_F0 = F_0*self.pupilArea*deltaLam*inst['QE'](lam)*attenuation

# get core_thruput
core_thruput = syst['core_thruput'](lam, WA)

# calculate planet delta magnitude
dMagLim = np.zeros(len(sInds)) + TL.Completeness.dMagLim
if (C_b is None) or (C_sp is None):
_, C_b, C_sp = self.Cp_Cb_Csp(TL, sInds, fZ, fEZ, dMagLim, WA, mode)
_, C_b, C_sp = self.Cp_Cb_Csp(TL, sInds, fZ, fEZ, dMagLim, WA, mode, TK=TK)
intTimes[intTimes.value < 0.] = 0.
tmp = np.nan_to_num(C_b/intTimes)
assert all(tmp + C_sp**2. >= 0.) , 'Invalid value in Nemati sqrt, '
Expand All @@ -145,7 +154,7 @@ def calc_dMag_per_intTime(self, intTimes, TL, sInds, fZ, fEZ, WA, mode, C_b=None

return dMag

def ddMag_dt(self, intTimes, TL, sInds, fZ, fEZ, WA, mode, C_b=None, C_sp=None):
def ddMag_dt(self, intTimes, TL, sInds, fZ, fEZ, WA, mode, C_b=None, C_sp=None, TK=None):
"""Finds derivative of achievable dMag with respect to integration time
Args:
Expand All @@ -170,6 +179,9 @@ def ddMag_dt(self, intTimes, TL, sInds, fZ, fEZ, WA, mode, C_b=None, C_sp=None):
C_sp (astropy Quantity array):
Residual speckle spatial structure (systematic error) in units of 1/s
(optional)
TK (TimeKeeping object):
Optional TimeKeeping object (default None), used to model detector
degradation effects where applicable.
Returns:
ddMagdt (ndarray):
Expand All @@ -190,7 +202,7 @@ def ddMag_dt(self, intTimes, TL, sInds, fZ, fEZ, WA, mode, C_b=None, C_sp=None):

dMagLim = np.zeros(len(sInds)) + 25.
if (C_b is None) or (C_sp is None):
_, C_b, C_sp = self.Cp_Cb_Csp(TL, sInds, fZ, fEZ, dMagLim, WA, mode)
_, C_b, C_sp = self.Cp_Cb_Csp(TL, sInds, fZ, fEZ, dMagLim, WA, mode, TK=TK)
ddMagdt = 2.5/(2.0*np.log(10.0))*(C_b/(C_b*intTimes + (C_sp*intTimes)**2.)).to('1/s').value

return ddMagdt/u.s

0 comments on commit fc1d876

Please sign in to comment.