-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
75 additions
and
71 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
master-v2.1 | ||
master-v2.1.1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -472,13 +472,15 @@ def validate(self): | |
logger.info('--------------------------------------------------------') | ||
|
||
#---------------------------------------------------------------------------------------------- | ||
def basic(self, warn_errors_ratio=0.05): | ||
def basic(self, errors_ratio_warn=0.05, errors_ratio_err=0.10): | ||
""" | ||
Perform basic checks of the TODO-file and the lightcurve files. | ||
Parameters: | ||
warn_errors_ratio (float, optional): Fraction of photometry ERRORs to OK and WARNINGs | ||
errors_ratio_warn (float, optional): Fraction of ERRORs to OK and WARNINGs | ||
to warn about. Default=5%. | ||
errors_ratio_err (float, optional): Fraction of ERRORs to OK and WARNINGs | ||
to throw error about. Default=10%. | ||
.. codeauthor:: Rasmus Handberg <[email protected]> | ||
""" | ||
|
@@ -528,8 +530,9 @@ def basic(self, warn_errors_ratio=0.05): | |
)) | ||
count_errors = self.cursor.fetchone()[0] | ||
ratio = count_errors/(count_good + count_errors) if count_good + count_errors > 0 else 0 | ||
if ratio > warn_errors_ratio: | ||
logger.warning(" CAMERA=%d, CCD=%d: High number of errors detected: %.2f%% (%d errors, %d good)", | ||
if ratio > errors_ratio_warn or ratio > errors_ratio_err: | ||
loglevel = logging.ERROR if ratio > errors_ratio_err else logging.WARNING | ||
logger.log(loglevel, " CAMERA=%d, CCD=%d: High number of errors detected: %.2f%% (%d errors, %d good)", | ||
camera, ccd, 100*ratio, count_errors, count_good) | ||
else: | ||
logger.info(" CAMERA=%d, CCD=%d: %.2f%% (%d errors, %d good)", | ||
|
@@ -585,8 +588,9 @@ def basic(self, warn_errors_ratio=0.05): | |
)) | ||
count_errors = self.cursor.fetchone()[0] | ||
ratio = count_errors/(count_good + count_errors) if count_good + count_errors > 0 else 0 | ||
if ratio > warn_errors_ratio: | ||
logger.warning(" CAMERA=%d, CCD=%d: High number of errors detected: %.2f%% (%d errors, %d good)", | ||
if ratio > errors_ratio_warn or ratio > errors_ratio_err: | ||
loglevel = logging.ERROR if ratio > errors_ratio_err else logging.WARNING | ||
logger.log(loglevel, " CAMERA=%d, CCD=%d: High number of errors detected: %.2f%% (%d errors, %d good)", | ||
camera, ccd, 100*ratio, count_errors, count_good) | ||
else: | ||
logger.info(" CAMERA=%d, CCD=%d: %.2f%% (%d errors, %d good)", | ||
|
@@ -606,7 +610,8 @@ def basic(self, warn_errors_ratio=0.05): | |
'FileNotFoundError', | ||
'sqlite3.%', | ||
'TargetNotFoundError', # custom "error" set in photometry.TaskManager.save_result | ||
'TypeError' | ||
'TypeError', | ||
'Could not save lightcurve file' | ||
] | ||
|
||
logger.info("Checking for specific errors...") | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,6 +10,7 @@ | |
from astropy import units as u | ||
from astropy.coordinates import SkyCoord | ||
import scipy.interpolate as INT | ||
from .utilities import mag2flux | ||
|
||
#-------------------------------------------------------------------------------------------------- | ||
def ZLnoise(gal_lat): | ||
|
@@ -55,28 +56,6 @@ def Pixinaperture(Tmag, cad=1800): | |
|
||
return np.asarray(np.maximum(pixels, 3), dtype='int32') | ||
|
||
#-------------------------------------------------------------------------------------------------- | ||
def mean_flux_level(Tmag): | ||
""" | ||
Mean flux from TESS magnitude | ||
.. codeauthor:: Mikkel N. Lund <[email protected]> | ||
""" | ||
# Magnitude system based on Sullivan et al. | ||
#collecting_area = np.pi*(10.5/2)**2 # square cm | ||
#Teff_list = np.array([2450, 3000, 3200, 3400, 3700, 4100, 4500, 5000, 5777, 6500, 7200, 9700]) # Based on Sullivan | ||
#Flux_list = np.array([2.38, 1.43, 1.40, 1.38, 1.39, 1.41, 1.43, 1.45, 1.45, 1.48, 1.48, 1.56])*1e6 # photons per sec; Based on Sullivan | ||
#Magn_list = np.array([306, -191, -202, -201, -174, -132, -101, -80, -69.5, -40, -34.1, 35])*1e-3 #Ic-Tmag (mmag) | ||
|
||
#Flux_int = INT.UnivariateSpline(Teff_list, Flux_list, k=1, s=0) | ||
#Magn_int = INT.UnivariateSpline(Teff_list, Magn_list, k=1, s=0) | ||
|
||
#Imag = Magn_int(Teff)+Tmag | ||
#Flux = 10**(-0.4*Imag) * Flux_int(Teff) * collecting_area | ||
|
||
Flux = 10**(-0.4*(Tmag - 20.54)) | ||
return Flux | ||
|
||
#-------------------------------------------------------------------------------------------------- | ||
def phot_noise(Tmag, timescale=3600, coord=None, sysnoise=60, Teff=5775, cadpix=1800): | ||
""" | ||
|
@@ -136,7 +115,7 @@ def phot_noise(Tmag, timescale=3600, coord=None, sysnoise=60, Teff=5775, cadpix= | |
Flux_factor = np.sqrt(integrations * pixels) | ||
|
||
# Mean flux level in electrons per cadence | ||
mean_level_ppm = mean_flux_level(Tmag) * timescale # electrons (based on measurement) #, Teff | ||
mean_level_ppm = mag2flux(Tmag) * timescale # electrons (based on measurement) #, Teff | ||
|
||
# Shot noise | ||
shot_noise = 1e6/np.sqrt(mean_level_ppm) | ||
|
@@ -152,8 +131,10 @@ def phot_noise(Tmag, timescale=3600, coord=None, sysnoise=60, Teff=5775, cadpix= | |
|
||
# Put individual components together in single table: | ||
noise_vals = np.column_stack((shot_noise, zodiacal_noise, read_noise, systematic_noise)) | ||
noise_vals = np.clip(noise_vals, 0, None) | ||
|
||
# Calculate the total noise model by adding up the individual contributions: | ||
total_noise = np.sqrt(np.sum(noise_vals**2, axis=1)) | ||
total_noise = np.clip(total_noise, 0, None) | ||
|
||
return total_noise, noise_vals # ppm per cadence |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters