Skip to content

Commit

Permalink
search previous phase
Browse files Browse the repository at this point in the history
  • Loading branch information
weaverba137 committed May 16, 2024
1 parent b6a43f4 commit 696c391
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 14 deletions.
43 changes: 32 additions & 11 deletions py/gfa_reduce/scripts/concat_ccds.py
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ def _concat_many_nights(night_min='20201214', night_max='99999999',


def _write_many_nights(night_min='20201214', night_max='99999999',
basedir=None, acq=False, phase='SV1',
basedir=None, acq=False, phase='main',
outdir='.', user_basedir=None, workers=1):
log = get_logger()
if not os.path.exists(outdir):
Expand Down Expand Up @@ -273,19 +273,40 @@ def _write_many_nights(night_min='20201214', night_max='99999999',
log.info('Done')


def _latest_summary_file(outdir='.', phase='SV3'):
def _latest_summary_file(outdir='.', phase='main'):
"""Find the most recent summary file.
files = glob.glob(outdir + f'/offline_matched_coadd_ccds_{phase}-thru_????????.fits')
Parameters
----------
outdir : :class:`str`, optional
Directory to search.
phase : :class:`str`, optional
Survey phase.
Returns
-------
:class:`tuple`
A tuple of the filename and most recent night.
"""
files = glob.glob(os.path.join(outdir, f'/offline_matched_coadd_ccds_{phase}-thru_????????.fits'))
if len(files) == 0:
old_phases = ('main', 'SV3', 'SV2', 'SV1')
for ph in old_phases:
files = glob.glob(os.path.join(outdir, f'/offline_matched_coadd_ccds_{ph}-thru_????????.fits'))
if len(files) > 0:
break

files = np.array([os.path.splitext(f)[0] for f in files])
basenames = [os.path.splitext(f)[0] for f in files]

nights = np.array([int(f.split("_")[-1]) for f in files])
nights = np.array([int(f.split("_")[-1]) for f in basenames])

latest_summary_file = files[np.argmax(nights)]+'.fits'
last_night = np.argmax(nights)

latest_night = str(nights[np.argmax(nights)])
latest_summary_file = files[last_night]+'.fits'

return latest_summary_file, latest_night
latest_night = str(nights[last_night])

return (latest_summary_file, latest_night)


def _next_obsnight(night='00000000'):
Expand Down Expand Up @@ -315,8 +336,8 @@ def _load_concas_ccds_file(file):


def _append_many_nights(night_min='20201214', night_max='99999999',
basedir=None, acq=False, phase='SV1',
outdir='.', user_basedir=None, workers=1):
basedir=None, acq=False, phase='main',
outdir='.', user_basedir=None, workers=1):
log = get_logger()
if not os.path.exists(outdir):
log.error('Output directory does not exist ... quitting!')
Expand Down Expand Up @@ -406,7 +427,7 @@ def _append_many_nights(night_min='20201214', night_max='99999999',
parser.add_argument('--night_max', default='99999999', type=str,
help='last observing night')

parser.add_argument('--phase', default='SV1', type=str,
parser.add_argument('--phase', default='main', type=str,
help='survey phase (SV1, SV2, ...)')

parser.add_argument('--outdir', default='.', type=str,
Expand Down
5 changes: 2 additions & 3 deletions py/gfa_reduce/scripts/daily_summary.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,9 +87,8 @@ def gfa_daily_summary(workers=8):
outdir = os.environ['GFA_SUMMRY_FILE_DIR']
log.debug('basedir = %s', basedir)
log.debug('outdir = %s', outdir)
_append_many_nights(night_min='20210405', night_max='21000101', basedir=basedir,
acq=False, phase='main', outdir=outdir, user_basedir=None,
workers=workers)
_append_many_nights(night_min='20210405', basedir=basedir,
outdir=outdir, workers=workers)
return


Expand Down

0 comments on commit 696c391

Please sign in to comment.