Skip to content

Commit

Permalink
add logger to unpickled psfs
Browse files Browse the repository at this point in the history
  • Loading branch information
jchiang87 committed Aug 16, 2018
1 parent 4146648 commit 5ba15e6
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
2 changes: 1 addition & 1 deletion bin.src/imsim.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@
if args.psf_file is not None:
desc.imsim.save_psf(psf, args.psf_file)
else:
psf = desc.imsim.load_psf(args.psf_file)
psf = desc.imsim.load_psf(args.psf_file, log_level=args.log_level)

sensor_list = args.sensors.split('^') if args.sensors is not None \
else args.sensors
Expand Down
8 changes: 7 additions & 1 deletion python/desc/imsim/imSim.py
Original file line number Diff line number Diff line change
Expand Up @@ -917,10 +917,16 @@ def save_psf(psf, outfile):
with open(outfile, 'wb') as output:
pickle.dump(psf, output)

def load_psf(psf_file):
def load_psf(psf_file, log_level='INFO'):
"""
Load a psf from a pickle file.
"""
with open(psf_file, 'rb') as fd:
psf = pickle.load(fd)

# Since save_psf sets any logger attribute to None, restore
# it here.
if hasattr(psf, 'logger'):
psf.logger = get_logger(log_level, 'psf')

return psf

0 comments on commit 5ba15e6

Please sign in to comment.