Skip to content

Commit

Permalink
compute bias option for file listing NIGHT EXPID to use
Browse files Browse the repository at this point in the history
  • Loading branch information
Stephen Bailey authored and Stephen Bailey committed Jan 31, 2021
1 parent 38851e1 commit db50416
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 4 deletions.
13 changes: 10 additions & 3 deletions bin/desi_compute_bias
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,20 @@ parser = argparse.ArgumentParser(formatter_class=argparse.ArgumentDefaultsHelpFo
description="Compute a master bias from a set of raw data bias images",
epilog='''This is simply a median of the input raw images.'''
)
parser.add_argument('-i','--image', type = str, default = None, required = True, nargs="*",
parser.add_argument('-i','--image', type = str, default = None, nargs="*",
help = 'path of image fits files')
parser.add_argument('-o','--outfile', type = str, default = None, required = True,
parser.add_argument('-o','--outfile', type=str, default = None, required = True,
help = 'output median image filename')
parser.add_argument('--camera',type = str, required = True,
help = 'camera name BX,RX,ZX with X from 0 to 9')
parser.add_argument('--explistfile', type=str, default=None, required=False,
help = 'Read NIGHT EXPID from file (one per line)')

args = parser.parse_args()

compute_bias_file(args.image, args.outfile, args.camera)
if (args.image is not None) and (args.explistfile is not None):
print('ERROR: specify --image or --explistfile but not both')
sys.exit(1)

compute_bias_file(args.image, args.outfile, args.camera,
explistfile=args.explistfile)
29 changes: 28 additions & 1 deletion py/desispec/ccdcalib.py
Original file line number Diff line number Diff line change
Expand Up @@ -187,17 +187,44 @@ def compute_dark_file(rawfiles, outfile, camera, bias=None, nocosmic=False,
log.info(f"done")


def compute_bias_file(rawfiles, outfile, camera):
def compute_bias_file(rawfiles, outfile, camera, explistfile=None):
"""
Compute a bias file from input ZERO rawfiles
Args:
rawfiles: list of input raw file names
outfile (str): output filename
camera (str): camera, e.g. b0, r1, z9
Options:
explistfile: filename with text list of NIGHT EXPID to use
Notes: explistfile is only used if rawfiles=None; it should have
one NIGHT EXPID entry per line.
"""
log = get_logger()

if explistfile is not None:
if rawfiles is not None:
msg = "specify rawfiles or explistfile, but not both"
log.error(msg)
raise ValueError(msg)

rawfiles = list()
with open(explistfile, 'r') as fx:
for line in fx:
line = line.strip()
if line.startswith('#') or len(line)<2:
continue
night, expid = map(int, line.split())
filename = io.findfile('raw', night, expid)
if not os.path.exists(filename):
msg = f'Missing {filename}'
log.critical(msg)
raise RuntimeError(msg)

rawfiles.append(filename)

log.info("read images ...")
images=[]
shape=None
Expand Down

0 comments on commit db50416

Please sign in to comment.