Skip to content

Commit

Permalink
add keyword to choose length, default to 1d
Browse files Browse the repository at this point in the history
  • Loading branch information
Waelthus committed Jan 4, 2024
1 parent a2b2816 commit f4bc026
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 6 deletions.
7 changes: 5 additions & 2 deletions bin/desi_compute_dark_nonlinear
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,9 @@ parser.add_argument('--nskip-zeros', type=int, default=30, required=False,
help='Skip N ZEROs per day while flushing charge')
parser.add_argument('--mindarks', type=int, default=5, required=False,
help='Minimum number of DARKs per EXPTIME to use that EXPTIME')
parser.add_argument('--min-vccdsec', type=float, default=86400., required=False,
help='Minimum number of DARKs per EXPTIME to use that EXPTIME')


args = parser.parse_args()

Expand Down Expand Up @@ -215,7 +218,7 @@ for night in nights:
with pyfits.open(rawfile) as hdulist :
if args.camera in hdulist :
if 'VCCDSEC' in hdulist[args.camera].header:
if hdulist[args.camera].header['VCCDSEC']<10000:
if hdulist[args.camera].header['VCCDSEC']<args.min_vccdsec:
log.info(f"{args.camera} in {rawfile} had low VCCDSEC, skipping")
continue
else:
Expand Down Expand Up @@ -256,7 +259,7 @@ for exptime in darktimes:
with pyfits.open(filename) as hdulist :
if args.camera in hdulist :
if 'VCCDSEC' in hdulist[args.camera].header:
if hdulist[args.camera].header['VCCDSEC']<10000:
if hdulist[args.camera].header['VCCDSEC']<args.min_vccdsec:
log.info(f"{args.camera} in {filename} had low VCCDSEC, skipping")
continue
else:
Expand Down
2 changes: 2 additions & 0 deletions bin/desi_make_regular_darks
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ parser.add_argument('--system-name', type=str, default=None, required=False,
help='Name of system to make scripts for (default: current system)')
parser.add_argument('--no-obslist', action='store_true',
help='Do not use list of observations for the computation, instead parse from all frames observed in the timespan')
parser.add_argument('--min-vccdsec', type=float, default=86400., required=False,
help='Minimum number of DARKs per EXPTIME to use that EXPTIME')
args = parser.parse_args()

make_regular_darks(**vars(args))
14 changes: 10 additions & 4 deletions py/desispec/ccdcalib.py
Original file line number Diff line number Diff line change
Expand Up @@ -973,7 +973,8 @@ def model_y1d(image, smooth=0):
def make_dark_scripts(outdir, days=None, nights=None, cameras=None,
linexptime=None, nskip_zeros=None, tempdir=None, nosubmit=False,
first_expid=None,night_for_name=None, use_exptable=True,queue='realtime',
copy_outputs_to_split_dirs=False, prepared_exptable=None, system_name=None):
copy_outputs_to_split_dirs=False, prepared_exptable=None, system_name=None,
min_vccdsec=None):
"""
Generate batch script to run desi_compute_dark_nonlinear
Expand All @@ -993,6 +994,8 @@ def make_dark_scripts(outdir, days=None, nights=None, cameras=None,
copy_outputs_to_split_dirs (bool): whether to copy outputs to bias_frames/dark_frames subdirs
prepared_exptable (exptable): if a table is submitted here, no further spectra will be searched and this will be used instead
system_name (str): the system for which batch files should be created, defaults to guessing current system
min_vccdsec(str): minimum time a ccd needs to be turned on to be allowed in the model
Args/Options are passed to the desi_compute_dark_nonlinear script
"""
Expand Down Expand Up @@ -1164,6 +1167,8 @@ def make_dark_scripts(outdir, days=None, nights=None, cameras=None,
cmd += f" \\\n --nskip-zeros {nskip_zeros}"
if first_expid is not None:
cmd += f" \\\n --first-expid {first_expid}"
if min_vccdsec is not None:
cmd += f" \\\n --min-vccdsec {min_vccdsec}"

with open(batchfile, 'a') as fx:
fx.write(f"time {cmd} > {logfile2} 2> {logfile2} &\n")
Expand Down Expand Up @@ -1191,7 +1196,7 @@ def make_regular_darks(outdir=None, lastnight=None, cameras=None, window=30,
linexptime=None, nskip_zeros=None, tempdir=None, nosubmit=False,
first_expid=None,night_for_name=None, use_exptable=True,queue='realtime',
copy_outputs_to_split_dirs=None, transmit_obslist = True, system_name=None,
no_obslist=False):
no_obslist=False,min_vccdsec=None):
"""
Generate batch script to run desi_compute_dark_nonlinear
Expand All @@ -1211,7 +1216,7 @@ def make_regular_darks(outdir=None, lastnight=None, cameras=None, window=30,
transmit_obslist(bool): if True will give use the obslist from here downstream
system_name(str): allows to overwrite the system for which slurm scripts are created, will default to guessing the current system
no_obslist(str): just use exactly the specified night-range, but assume we do not have exposure tables for this (useful when there is no exposure_table yet)
min_vccdsec(str): minimum time a ccd needs to be turned on to be allowed in the model
Args/Options are passed to the desi_compute_dark_nonlinear script
"""
Expand Down Expand Up @@ -1311,4 +1316,5 @@ def make_regular_darks(outdir=None, lastnight=None, cameras=None, window=30,
make_dark_scripts(outdir, nights=nights, cameras=cameras,
linexptime=linexptime, nskip_zeros=nskip_zeros, tempdir=tempdir, nosubmit=nosubmit,
first_expid=first_expid,night_for_name=night_for_name, use_exptable=use_exptable,queue=queue,
copy_outputs_to_split_dirs=copy_outputs_to_split_dirs,prepared_exptable=obslist, system_name=system_name)
copy_outputs_to_split_dirs=copy_outputs_to_split_dirs,prepared_exptable=obslist, system_name=system_name,
min_vccdsec=min_vccdsec)

0 comments on commit f4bc026

Please sign in to comment.