Skip to content

Commit

Permalink
Merge pull request #76 from lsst-camera-dh/u/jchiang/enable_use_of_da…
Browse files Browse the repository at this point in the history
…rk_current_files_for_raft_mosaic

enable use of dark current files for raft mosaic
  • Loading branch information
jchiang87 authored Aug 30, 2020
2 parents e130742 + 532e07d commit 24547b0
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 11 deletions.
13 changes: 9 additions & 4 deletions harnessed_jobs/raft_results_summary_BOT/v0/raft_results_task.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,11 +112,16 @@ def plt_savefig(filename):
del median_bias

# Dark mosaic
dark_files = None
try:
dark_files = get_raft_files_by_slot(raft_name, 'median_dark_bp.fits')
except FileNotFoundError as eobj:
print(eobj)
else:
except FileNotFoundError:
try:
dark_files = get_raft_files_by_slot(raft_name,
'median_dark_current.fits')
except FileNotFoundError as eobj:
print(eobj)
if dark_files is not None:
dark_mosaic = raftTest.make_raft_mosaic(dark_files, gains=gains,
bias_frames=bias_frames)
dark_mosaic.plot(title='{}, medianed dark frames'.format(title),
Expand Down Expand Up @@ -272,7 +277,7 @@ def plt_savefig(filename):
file_prefix = make_file_prefix(run, raft_name)
df_raft = pd.read_pickle(stats_file)
if raft_name in 'R00 R04 R40 R44':
slots = 'SG0 SW2 SW0 SG1'.split()
slots = 'SG0 SW1 SW0 SG1'.split()
else:
slots = 'S20 S21 S22 S10 S11 S12 S00 S01 S02'.split()
t0 = int(np.min(df_raft['MJD']))
Expand Down
20 changes: 13 additions & 7 deletions python/bot_eo_analyses.py
Original file line number Diff line number Diff line change
Expand Up @@ -385,7 +385,8 @@ class GetAmplifierGains:
configuration.
"""
def __init__(self, bot_eo_config_file=None,
et_results_file='et_results.pkl', run=None):
et_results_file='et_results.pkl', run=None, verbose=True):
self.verbose = verbose
if run is None:
self.run = siteUtils\
.get_analysis_run('gain', bot_eo_config_file=bot_eo_config_file)
Expand All @@ -405,7 +406,8 @@ def _get_curated_gains(self):
# Read the curated gains from the json file.
with open(gain_file, 'r') as fd:
self.curated_gains = json.load(fd)
print("GetAmplifierGains: Using gains from", gain_file)
if self.verbose:
print("GetAmplifierGains: Using gains from", gain_file)

def _get_gains_from_run(self, et_results_file):
if not os.path.isfile(et_results_file):
Expand All @@ -415,7 +417,8 @@ def _get_gains_from_run(self, et_results_file):
else:
with open(et_results_file, 'rb') as fd:
self.et_results = pickle.load(fd)
print("GetAmplifierGains: Using gains from run", self.run)
if self.verbose:
print("GetAmplifierGains: Using gains from run", self.run)

def __call__(self, file_pattern):
if self.run is None:
Expand All @@ -428,19 +431,22 @@ def __call__(self, file_pattern):
det_name = file_pattern[match.start(): match.end()]

if self.curated_gains is not None:
print('GetAmplifierGains.__call__: retrieving curated gains.')
if self.verbose:
print('GetAmplifierGains.__call__: retrieving curated gains.')
my_gains = self.curated_gains[det_name]
if len(my_gains) == 8:
channels = siteUtils.ETResults.wf_amp_names
else:
channels = siteUtils.ETResults.amp_names
return {amp: my_gains[_] for amp, _ in enumerate(channels, 1)}

print("GetAmplifierGains.__call__: retrieving gains from eT.")
if self.verbose:
print("GetAmplifierGains.__call__: retrieving gains from eT.")
gains = self.et_results.get_amp_gains(det_name)
if not gains:
print("GetAmplifierGains.__call__: "
"gains from eT not found, using unit gains.")
if self.verbose:
print("GetAmplifierGains.__call__: "
"gains from eT not found, using unit gains.")
return {amp: 1 for amp in range(1, 17)}
return gains

Expand Down

0 comments on commit 24547b0

Please sign in to comment.