Skip to content

Commit

Permalink
fix proctable exptable merging in exp dash
Browse files Browse the repository at this point in the history
  • Loading branch information
akremin committed Aug 30, 2024
1 parent f69d5f2 commit 652b05b
Show file tree
Hide file tree
Showing 2 changed files with 57 additions and 100 deletions.
111 changes: 56 additions & 55 deletions py/desispec/scripts/procdashboard.py
Original file line number Diff line number Diff line change
Expand Up @@ -221,18 +221,18 @@ def populate_night_info(night, check_on_disk=False,
new_proc_expids = set(np.concatenate(proctab['EXPID']).astype(int))
expid_processing.update(new_proc_expids)
expjobs_ptab = proctab[np.isin(proctab['JOBDESC'],
['arc', 'flat', 'tilenight',
'prestdstar', 'stdstar', 'poststdstar'])]
[b'arc', b'flat', b'tilenight',
b'prestdstar', b'stdstar', b'poststdstar'])]
for i,erow in enumerate(exptab):
## proctable has an array of expids, so check for them in a loop
for prow in expjobs_ptab:
if erow['EXPID'] in prow['EXPID']:
erow['STATUS'][i] = prow['STATUS']
erow['LATEST_QID'][i] = prow['LATEST_QID']
erow['PTAB_INTID'][i] = prow['INTID']
erow['JOBDESC'][i] = prow['JOBDESC']
exptab['STATUS'][i] = prow['STATUS']
exptab['LATEST_QID'][i] = prow['LATEST_QID']
exptab['PTAB_INTID'][i] = prow['INTID']
exptab['JOBDESC'][i] = prow['JOBDESC']
caljobs_ptab = proctab[np.isin(proctab['JOBDESC'],
['ccdcalib', 'psfnight', 'nightlyflat'])]
[b'ccdcalib', b'psfnight', b'nightlyflat'])]
for prow in caljobs_ptab:
jobdesc = prow['JOBDESC']
expids = prow['EXPID']
Expand All @@ -245,54 +245,55 @@ def populate_night_info(night, check_on_disk=False,
joint_erow['COMMENTS'] = [f"Exposure {expids[0]}"]
else:
joint_erow['COMMENTS'] = [f"Exposures {expids[0]}-{expids[-1]}"]
# ## Derive the appropriate PROCCAMWORD from the exposure table
# pcamwords = []
# for expid in expids:
# if expid in exptab['EXPID']:
# erow = table_row_to_dict(exptab[exptab['EXPID'] == expid][0])
# pcamword = ''
# if 'BADCAMWORD' in erow:
# if 'BADAMPS' in erow:
# pcamword = erow_to_goodcamword(erow,
# suppress_logging=True,
# exclude_badamps=False)
# else:
# pcamword = difference_camwords(erow['CAMWORD'], erow['BADCAMWORD'])
# else:
# pcamword = erow['CAMWORD']
# pcamwords.append(pcamword)
#
# if len(pcamwords) == 0:
# print(f"Couldn't find exposures {expids} for joint job {jobdesc}")
# continue
# ## For flats we want any camera that exists in all 12 exposures
# ## For arcs we want any camera that exists in at least 3 exposures
# if jobdesc == 'nightlyflat':
# joint_erow['CAMWORD'] = camword_intersection(pcamwords,
# full_spectros_only=False)
# elif jobdesc == 'psfnight':
# ## Count number of exposures each camera is present for
# camcheck = {}
# for camword in pcamwords:
# for cam in decode_camword(camword):
# if cam in camcheck:
# camcheck[cam] += 1
# else:
# camcheck[cam] = 1
# ## if exists in 3 or more exposures, then include it
# goodcams = []
# for cam, camcount in camcheck.items():
# if camcount >= 3:
# goodcams.append(cam)
# joint_erow['CAMWORD'] = create_camword(goodcams)

joint_erow['CAMWORD'] = prow['PROCCAMWORD']
joint_erow['BADCAMWORD'] = ''
joint_erow['BADAMPS'] = ''
joint_erow['STATUS'] = prow['STATUS']
joint_erow['LATEST_QID'] = prow['LATEST_QID']
joint_erow['PTAB_INTID'] = prow['INTID']
exptab.add_row(joint_erow)
# ## Derive the appropriate PROCCAMWORD from the exposure table
# pcamwords = []
# for expid in expids:
# if expid in exptab['EXPID']:
# erow = table_row_to_dict(exptab[exptab['EXPID'] == expid][0])
# pcamword = ''
# if 'BADCAMWORD' in erow:
# if 'BADAMPS' in erow:
# pcamword = erow_to_goodcamword(erow,
# suppress_logging=True,
# exclude_badamps=False)
# else:
# pcamword = difference_camwords(erow['CAMWORD'], erow['BADCAMWORD'])
# else:
# pcamword = erow['CAMWORD']
# pcamwords.append(pcamword)
#
# if len(pcamwords) == 0:
# print(f"Couldn't find exposures {expids} for joint job {jobdesc}")
# continue
# ## For flats we want any camera that exists in all 12 exposures
# ## For arcs we want any camera that exists in at least 3 exposures
# if jobdesc == 'nightlyflat':
# joint_erow['CAMWORD'] = camword_intersection(pcamwords,
# full_spectros_only=False)
# elif jobdesc == 'psfnight':
# ## Count number of exposures each camera is present for
# camcheck = {}
# for camword in pcamwords:
# for cam in decode_camword(camword):
# if cam in camcheck:
# camcheck[cam] += 1
# else:
# camcheck[cam] = 1
# ## if exists in 3 or more exposures, then include it
# goodcams = []
# for cam, camcount in camcheck.items():
# if camcount >= 3:
# goodcams.append(cam)
# joint_erow['CAMWORD'] = create_camword(goodcams)

joint_erow['CAMWORD'] = prow['PROCCAMWORD']
joint_erow['BADCAMWORD'] = ''
joint_erow['BADAMPS'] = ''
joint_erow['STATUS'] = prow['STATUS']
joint_erow['LATEST_QID'] = prow['LATEST_QID']
joint_erow['PTAB_INTID'] = prow['INTID']
joint_erow['JOBDESC'] = prow['JOBDESC']
exptab.add_row(joint_erow)

del proctab
exptab.sort(['ORDER'])
Expand Down
46 changes: 1 addition & 45 deletions py/desispec/workflow/proc_dashboard_funcs.py
Original file line number Diff line number Diff line change
Expand Up @@ -536,7 +536,7 @@ def _initialize_page(color_profile, titlefill='Processing'):
background = cdict['background']
html_page += f'\t#{ctype} ' + '{background-color:' + f'{background}' + ';}\n'

html_page + "\n"
html_page += "\n"
## Table rows shouldn't do the default background because of cell coloring
for ctype,cdict in color_profile.items():
font = cdict['font']
Expand Down Expand Up @@ -649,50 +649,6 @@ def _str_frac(numerator,denominator):
frac = f'{numerator}/{denominator}'
return frac

def _js_path(output_dir):
return os.path.join(output_dir,'js','open_nightly_table.js')

def js_import_str(output_dir): # Not used
output_path = _js_path(output_dir)
if not os.path.exists(os.path.join(output_dir,'js')):
os.makedirs(os.path.join(output_dir,'js'))
if not os.path.exists(output_path):
_write_js_script(output_path)
return f'<script type="text/javascript" src="{output_path}"></script>'

def _write_js_script(output_path):
"""
Return the javascript script to be added to the html file
"""
s="""
var coll = document.getElementsByClassName('collapsible');
var i;
for (i = 0; i < coll.length; i++) {
coll[i].nextElementSibling.style.maxHeight='0px';
coll[i].addEventListener('click', function() {
this.classList.toggle('active');
var content = this.nextElementSibling;
if (content.style.maxHeight){
content.style.maxHeight = null;
} else {
content.style.maxHeight = '0px';
}
});
};
var b1 = document.getElementById('b1');
b1.addEventListener('click',function() {
for (i = 0; i < coll.length; i++) {
coll[i].nextElementSibling.style.maxHeight=null;
}});
var b2 = document.getElementById('b2');
b2.addEventListener('click',function() {
for (i = 0; i < coll.length; i++) {
coll[i].nextElementSibling.style.maxHeight='0px'
}});
"""
with open(output_path,'w') as outjs:
outjs.write(s)

def js_str(): # Used
"""
Return the javascript script to be added to the html file
Expand Down

0 comments on commit 652b05b

Please sign in to comment.