diff --git a/backend/framework/qlf/dashboard/bokeh/helper.py b/backend/framework/qlf/dashboard/bokeh/helper.py index 19a13458..e1c59feb 100644 --- a/backend/framework/qlf/dashboard/bokeh/helper.py +++ b/backend/framework/qlf/dashboard/bokeh/helper.py @@ -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"], diff --git a/backend/framework/qlf/dashboard/bokeh/qagetrms/main.py b/backend/framework/qlf/dashboard/bokeh/qagetrms/main.py index 9db3b90b..cd3f3292 100644 --- a/backend/framework/qlf/dashboard/bokeh/qagetrms/main.py +++ b/backend/framework/qlf/dashboard/bokeh/qagetrms/main.py @@ -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) diff --git a/backend/framework/qlf/dashboard/bokeh/qainteg/main.py b/backend/framework/qlf/dashboard/bokeh/qainteg/main.py index a7825c29..58638e1a 100644 --- a/backend/framework/qlf/dashboard/bokeh/qainteg/main.py +++ b/backend/framework/qlf/dashboard/bokeh/qainteg/main.py @@ -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): @@ -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) diff --git a/backend/framework/qlf/dashboard/bokeh/qaskypeak/main.py b/backend/framework/qlf/dashboard/bokeh/qaskypeak/main.py index e2630990..a0f4a8f2 100644 --- a/backend/framework/qlf/dashboard/bokeh/qaskypeak/main.py +++ b/backend/framework/qlf/dashboard/bokeh/qaskypeak/main.py @@ -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] @@ -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'][:])] @@ -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="""""") @@ -171,7 +171,6 @@ def load_qa(self): """ - Nbins = 40 hist, edges = np.histogram(peakcount_fib, bins="sqrt") source_hist = ColumnDataSource(data={ @@ -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'] @@ -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) diff --git a/backend/framework/qlf/dashboard/bokeh/qasnr/main.py b/backend/framework/qlf/dashboard/bokeh/qasnr/main.py index 59847ab5..5b9333cc 100644 --- a/backend/framework/qlf/dashboard/bokeh/qasnr/main.py +++ b/backend/framework/qlf/dashboard/bokeh/qasnr/main.py @@ -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) diff --git a/backend/framework/qlf/dashboard/bokeh/qlf_plot.py b/backend/framework/qlf/dashboard/bokeh/qlf_plot.py index 33b90e14..0b14ca8d 100644 --- a/backend/framework/qlf/dashboard/bokeh/qlf_plot.py +++ b/backend/framework/qlf/dashboard/bokeh/qlf_plot.py @@ -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="""