Skip to content
This repository has been archived by the owner on Jun 22, 2023. It is now read-only.

Commit

Permalink
Amending key tables (#216)
Browse files Browse the repository at this point in the history
* correct keys updated in tables

* objtype update in tables

* change in warning message for missing keys

* changes in skypeak info
  • Loading branch information
felipeaoli authored Aug 31, 2018
1 parent f53ccde commit 0f7caf3
Show file tree
Hide file tree
Showing 6 changed files with 63 additions and 29 deletions.
17 changes: 16 additions & 1 deletion backend/framework/qlf/dashboard/bokeh/helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -269,10 +269,25 @@ def write_info(qa_name, params):

def write_description(qa_name):
"""Descriptions to be displayed in QA plots."""

info_dic2 ={ 'countbins': ["Count Spectral Bins", "Number of bins above a threshold per spectrum."],
'skycont': ["Sky Continuum", "Mean sky continuum after fiber flattening"],
'countpix': ["Count Pixels", "Fraction of pixels lit after pre processing"],
'skypeak': ["Sky Peaks",
"This QA for QuickLook includes the calculation of the counts and RMS at peak sky wavelengths in a 1D spectrum."],#"Count for Sky Fiber after ApplyFiberFlat QL"],
'getbias': ["Bias From Overscan", "Bias from overscan region after pre processing"],
'skyresid': ["Sky Residual", "Randomly Selected sky substracted, fiber flattened spectra"],
'getrms': ["Get RMS"," NOISE image counts per amplifier"],
'snr': ["Calculate SNR", "Signal-to-Noise ratio after sky substraction"],
'integ': ["Integrate Spectrum", "Integral counts for standard stars"], #Total integrals of STD spectra SkySub QL"
'xwsigma': ["XWSigma", "X & W sigma over sky peaks"],
'checkHDUs': ['',''] }


info_dic ={ 'countbins': ["Count Spectral Bins", "Number of bins above a threshold per spectrum."],
'skycont': ["Sky Continuum", "Mean sky continuum after fiber flattening"],
'countpix': ["Count Pixels", "Fraction of pixels lit after pre processing"],
'skypeak': ["Sky Peaks", "Sky level in regions of peak sky emission lines"],#"Count for Sky Fiber after ApplyFiberFlat QL"],
'skypeak': ["Sky Peaks", "Sky level at peak sky wavelengths in a 1D spectrum"],#"Count for Sky Fiber after ApplyFiberFlat QL"],
'getbias': ["Bias From Overscan", "Bias from overscan region after pre processing"],
'skyresid': ["Sky Residual", "Randomly Selected sky substracted, fiber flattened spectra"],
'getrms': ["Get RMS"," NOISE image counts per amplifier"],
Expand Down
5 changes: 1 addition & 4 deletions backend/framework/qlf/dashboard/bokeh/qagetrms/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,11 +103,8 @@ def load_qa(self):

# Prepare tables
comments='value of RMS for each amplifier read directly from the header of the pre processed image'
metricname='BIAS_AMP'
keyname='getbias'
curexp=mergedqa['TASKS']['CHECK_CCDs']['METRICS']['LITFRAC_AMP']
refexp=mergedqa['TASKS']['CHECK_CCDs']['PARAMS']['BIAS_AMP_REF']
metric_txt=mtable('getbias', mergedqa, comments )
metric_txt=mtable('getrms', mergedqa, comments )
metric_tb=Div(text=metric_txt, width=500)

alert_txt = alert_table(nrg,wrg)
Expand Down
32 changes: 29 additions & 3 deletions backend/framework/qlf/dashboard/bokeh/qainteg/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,12 @@
import logging
from bokeh.resources import CDN
from bokeh.embed import file_html
logger = logging.getLogger(__name__)

from astropy.io import fits
import os
spectro_data = os.environ.get('DESI_SPECTRO_DATA')

logger = logging.getLogger(__name__)

class Integ:
def __init__(self, process_id, arm, spectrograph):
Expand Down Expand Up @@ -95,9 +99,31 @@ def load_qa(self):
, nrng=nrg, wrng=wrg )
tbinfo=Div(text=tb, width=400)

# Prepare tables
# Reading obj_type
try:
from dashboard.models import Job, Process

process_id = self.selected_process_id
process = Process.objects.get(pk=process_id)
joblist = [entry.camera.camera for entry in Job.objects.filter(process_id=process_id)]
exposure = process.exposure
folder = "{}/{}/{:08d}".format(
spectro_data, exposure.night, process.exposure_id)

file = "fibermap-{:08d}.fits".format(process.exposure_id)
fmap = fits.open('{}/{}'.format(folder, file))
otype_tile = fmap['FIBERMAP'].data['OBJTYPE']

objlist = sorted(set(otype_tile))
if 'SKY' in objlist:
objlist.remove('SKY')

except Exception as err:
objlist=None

# Prepare tables
comments='List of the average fiber mag for each of N target types in this camera'
metric_txt=mtable('integ', mergedqa, comments)# objtype=['ELG','STAR'] )
metric_txt=mtable('integ', mergedqa, comments, objtype=objlist) # objtype=['ELG','STAR'] )
metric_tb=Div(text=metric_txt, width=450)
alert_txt = alert_table(nrg,wrg)
alert_tb = Div(text=alert_txt, width=450)
Expand Down
18 changes: 6 additions & 12 deletions backend/framework/qlf/dashboard/bokeh/qaskypeak/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ def load_qa(self):
url = "http://legacysurvey.org/viewer?ra=@ra&dec=@dec&zoom=16&layer=decals-dr5"

c1, c2 = 0,500 # int(selected_spectrograph)*500, (int(selected_spectrograph)+1)*500
qlf_fiberid = np.arange(0, 5000)[c1:c2]
qlf_fiberid = np.arange(0, 500)#[c1:c2]



Expand All @@ -110,8 +110,8 @@ def load_qa(self):
low=0.98*np.min(peakcount_fib),
high=1.02*np.max(peakcount_fib))

radius = 0.013#0.015
radius_hover = 0.015#0.0165
radius = 0.013
radius_hover = 0.015

# axes limit
xmin, xmax = [min(gen_info['RA'][:]), max(gen_info['RA'][:])]
Expand Down Expand Up @@ -149,10 +149,10 @@ def load_qa(self):
p.add_layout(xcolor_bar, 'right')

try:
info, nlines = write_info('skypeak', tests['skypeak'])
txt = PreText(text=info, height=nlines*20, width=int(1.5*p.plot_width))
info_col = Div(text=write_description('skypeak'), width=p.plot_width)
except Exception as err:
f = open('dbg','w')
f.write(str(err))
info_col=Div(text="""""")


Expand All @@ -171,7 +171,6 @@ def load_qa(self):
</div>
"""

Nbins = 40
hist, edges = np.histogram(peakcount_fib, bins="sqrt")

source_hist = ColumnDataSource(data={
Expand Down Expand Up @@ -204,11 +203,6 @@ def load_qa(self):
p_hist.add_layout(spans)


"""for i in par['PEAKCOUNT_WARN_RANGE']:
spans = Span(location= i, dimension='height', line_color='red',
line_dash='dashed', line_width=3)
p_hist.add_layout(spans)
"""

nrg= par['PEAKCOUNT_NORMAL_RANGE']
wrg= par['PEAKCOUNT_WARN_RANGE']
Expand All @@ -217,7 +211,7 @@ def load_qa(self):

# Prepare tables
comments='Sky continuum in all configured continuum areas averaged over all sky fibers'
metric_txt=mtable('skycont', mergedqa, comments )
metric_txt=mtable('skypeak', mergedqa, comments )
metric_tb=Div(text=metric_txt, width=450)
alert_txt = alert_table(nrg,wrg)
alert_tb = Div(text=alert_txt, width=450)
Expand Down
2 changes: 1 addition & 1 deletion backend/framework/qlf/dashboard/bokeh/qasnr/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -546,7 +546,7 @@ def fit_func(xdata, coeff):

# Prepare tables
comments='List of average SNR for the N target type'#, N is number of target types'
metric_txt=mtable('snr', mergedqa, comments)# objtype=['ELG','STAR'] )
metric_txt=mtable('snr', mergedqa, comments, objtype=objlist)
metric_tb=Div(text=metric_txt, width=500)
alert_txt = alert_table(nrg,wrg)
alert_tb = Div(text=alert_txt, width=500)
Expand Down
18 changes: 10 additions & 8 deletions backend/framework/qlf/dashboard/bokeh/qlf_plot.py
Original file line number Diff line number Diff line change
Expand Up @@ -288,14 +288,11 @@ def mtable(qa, data, comments, objtype=['XXELG','XXSTAR']):
try:
curexp=met[key]
except Exception as err:
print('ERR {}'.format(err))

tblines="""<tr>
<td colspan="4">Error in key:{}</td>
</tr>
""".format(err)
if nrows==1:
curexp= 'key N/A'
else:
curexp = ['key N/A']*nrows

return style + title + header +tblines+ end

if nrows > 1:
cur_tb, ref_tb=[],[]
Expand Down Expand Up @@ -327,7 +324,12 @@ def mtable(qa, data, comments, objtype=['XXELG','XXSTAR']):

if qa in ['snr', 'integ']:
# per_TGT
key_tb= [qa_metrics[qa] + ' ( %s)'%objtype[i] for i in list(range(nrows))]
if objtype is not None:
objtype_tb = ['STAR' if i=='STD' else i for i in objtype]
key_tb= [qa_metrics[qa] + ' ( %s)'%objtype_tb[i] for i in list(range(nrows))]
else:
key_tb= [qa_metrics[qa]] *nrows


elif qa in [ 'countpix','getbias','getrms']:
#per AMP
Expand Down

0 comments on commit 0f7caf3

Please sign in to comment.