# PURPOSE:	Configuration file for trendPlotter
# REPORT_NAME:  KPI_SPECRES
# AUTHOR:	Reinhard Hanuschik, ESO-DMD
# MAINTAINER:	qc_flames
# VERSIONS:	1.0 - KPI plot (2017-08)
# 		2.0 - section 4.7 added, standard KPI configuration (2018-02-15)
# 		2.1 - migrated to HighChart (2019-02-20)

# ==================================================================================
# 0. General
# ==================================================================================
RELATED_URL     /qc/GIRAFFE/qc/wave_qc1.html  # optional URL to refer to
REPORT_GROUP    KPI.grp   	# mark if report belongs to a group (requires <report_group>.grp file)
START_DATE      2003-01         # START_DATE for HISTORY plots
VNAVBAR		YES		# YES|NO: use group name to construct name of vertical navigation bar
                                # (to be provided in $QC_DIR/common !)

# ==================================================================================
# 1. Report definition
# REPORT_NAME:	displays on report header
# REPORT_TYPE:  standard format (REPORT2/4/6/8/10), or CUSTOM
# RANGE:	standard range in days (60/90/180/365) or FULL or MON<n> or KPI
# MARK_DATES: 	mark civil dates by vertical lines (YES/NO)
# MARK_ALIENS:	mark data points outside of the box y-limits (YES/NO)
# ADD_TEXT:	NONE, or tag to be defined under ADD_TEXT; 
#		this is a label written into the second line of the caption
# DESCR_FILE:	optional text file to be included in html output page (or NONE)
# MARK_LAST:	mark the last entry (YES/NO); evaluated only for type CURRENT
# ==================================================================================

#REPORT_NAME	REPORT_NAME	REPORT_	RANGE	MARK_	MARK_	ADD_TEXT	DESCR_FILE	MARK_LAST
#				 TYPE		 DATES	 ALIENS
REPORT_NAME	KPI_SPECRES	REPORT10 KPI	YES	NO	ARCRESOL_TEXT	KPI_SPECRES.txt	YES

# ==================================================================================
# 2. Plots definition
# 2.1 Plot parameters
# Define here the plots for the report
# PLOT_NAME:	unique name of plot
# P_INDEX:	plot index, used for numbering and reference
# XFORMAT:	AUTO (write tick labels) or NONE (no labels) or
#		<format description for tick labels>, e.g. 5.3f
# XLABEL:	label for X axis; use SPACE to indicate spaces within your label; or NONE
# XAXIS:	if XPARAM = mjd_obs, 2 parameters: xlabels,xticks;
#		if XPARAM != mjd_obs, 4 parameters: xmin,xmax,xlabels,xticks
# YFORMAT:	as XFORMAT
# YLABEL:	as XLABEL
# YAXIS:	ymin,ymax; you can also specify: ymin,ymax,ylabels,yticks
# PLABEL:       optional label for plot (single word, restricted to 20 chars)
# SCORE_ENABLED: YES by default; if NO, scoreHC flags the report as "not implemented"
# NO_MARK_LAST: YES: turn MARK_LAST off for this report; NO: take MARK_LAST
# SFORMAT:	format string for AUTO (.3g, default) or NONE (g) or valid format string (e.g. 8.3f)
# INTERACTIVE:	INTER by default, STATIC if interactivity should be switched off 
# ==================================================================================

#PLOT_NAME	P_INDEX	PLOT_NAME	XFORMAT	XLABEL	YFORMAT	YLABEL		XAXIS	YAXIS		PLABEL		SCORE_ENABLED	NO_MARK_LAST    SFORMAT INTERACTIVE
PLOT_NAME	1	MED1_H		AUTO	MJD_OBS	AUTO	resolving_power_R 2000,1000 0,70000	Medusa1_HR	NO
PLOT_NAME	2	MED2_H		AUTO	MJD_OBS	NONE	NONE 		2000,1000 0,70000	Medusa2_HR	NO
PLOT_NAME	3	IFU1_H		AUTO	MJD_OBS	NONE	NONE		2000,1000 0,70000	IFU1_HR		NO
PLOT_NAME	4	IFU2_H		AUTO	MJD_OBS	NONE	NONE		2000,1000 0,70000	IFU2_HR		NO
PLOT_NAME	5	ARG_H		AUTO	MJD_OBS	NONE	NONE		2000,1000 0,70000	Argus_HR	NO

PLOT_NAME	6	MED1_L		AUTO	MJD_OBS	AUTO	resolving_power_R 2000,1000 0,8000	Medusa1_LR	NO
PLOT_NAME	7	MED2_L		AUTO	MJD_OBS	NONE	NONE 		2000,1000 0,8000	Medusa2_LR	NO

# ==================================================================================
# 2.2 Plot events (optional)
# Define here optional events per PLOT_NAME (multiple lines supported)
# PLOT_NAME:	unique name of plot
# ETIME:	mjd-obs of event
# ECOLOR: 	plot color for event marker
# SHORT_ELABEL:	short event label for main plot, one word
# ELABEL:	event label on closeup plot, multiple words supported, enclose with &&...&&
# ==================================================================================
# EVENT		PLOT_NAME	ETIME	ECOLOR	SHORT_ELABEL	ELABEL
#EVENT		PLOT_NAME1	54585	2	new 		&&new CCD&&

# ==================================================================================
# 2.3 Plot FIT lines (optional)
# Define here optional straight lines per PLOT_NAME, to indicate correlations (multiple lines supported).
# Make sure they don't overlap with a FIT_RULE configured in Sect. 4.5. Those FIT_RULEs should only be used
# for fits more complex than a straight line. FIT lines are plotted on the main and on the close-up plots,
# FIT_RULEs only on the main plot.
# PLOT_NAME: 	unique name of plot
# LX1:		start X coordinate
# LY1:		start Y coordinate
# LX2:		end X coordinate
# LY2:		end Y coordinate
# LCOLOR:	plot color for line
# ==================================================================================
#LINE		PLOT_NAME	LX1	LY1	LX2	LY2	LCOLOR
#LINE		PLOT_NAME1	54585	132	56000	280	1

# ==================================================================================
# 3. Parameter set definition
# 3.1 Data definition
# Define here for each plot from section 2 one or more parameter sets. They are plotted in the same sequence
# you define them. 
#
# PLOT_NAME:    as defined in Section 2
# PARSET:       name for parameter set, unique per PLOT_NAME
# SOURCE:       data source: QC1DB or LOCAL
#               LOCAL: provide details under LOCAL_DATASET
# TABLE:        database table name (if SOURCE=QC1DB), or local table name (if LOCAL)
# XPARAM:       name of key for X axis (SOURCE=QC1DB), or string to be specified under LOCAL_DATASET
# YPARAM:       name of key for Y axis (SOURCE=QC1DB), or same string as under XPARAM (if LOCAL)
# DOWNLOAD:	YES/NO: offer links to QC1 database for data download (NO if these data are not available there)
# CONDITION:    name of condition to be applied (can be NONE)
# REMARK:       name of remark for result table (optional); avoid lengthy comments
# ==================================================================================

#PARSET_NAME	PLOT_NAME	PARSET		SOURCE	TABLE		XPARAM	YPARAM	DOWNLD	COND.	REMARK
PARSET_NAME	MED1_H		Medusa1		QC1DB	giraffe_wave	mjd_obs	mean_R YES	COND_M1H RMK_M1Ha
PARSET_NAME	MED1_H		Medusa1_reproc	QC1DB	giraffe_wave_reproc mjd_obs mean_R YES	COND_M1H RMK_M1Hb

PARSET_NAME	MED2_H		Medusa2	QC1DB	giraffe_wave	mjd_obs	mean_R YES	COND_M2H RMK_M2Ha
PARSET_NAME	MED2_H		Medusa2_reproc	QC1DB	giraffe_wave_reproc mjd_obs mean_R YES	COND_M2H RMK_M2Hb

PARSET_NAME	IFU1_H		IFU1	QC1DB	giraffe_wave	mjd_obs	mean_R YES	COND_I1H RMK_I1H
PARSET_NAME	IFU2_H		IFU2	QC1DB	giraffe_wave	mjd_obs	mean_R YES	COND_I2H RMK_I2H
PARSET_NAME	ARG_H		ARG	QC1DB	giraffe_wave	mjd_obs	mean_R YES	COND_ARH RMK_ARH

PARSET_NAME	MED1_L		Medusa1_L	QC1DB	giraffe_wave	mjd_obs	mean_R YES	COND_M1L RMK_M1La
PARSET_NAME	MED1_L		Medusa1_L_reproc	QC1DB	giraffe_wave_reproc mjd_obs mean_R YES	COND_M1L RMK_M1Lb

PARSET_NAME	MED2_L		Medusa2_L	QC1DB	giraffe_wave	mjd_obs	mean_R YES	COND_M2L RMK_M2La
PARSET_NAME	MED2_L		Medusa2_L_reproc	QC1DB	giraffe_wave_reproc mjd_obs mean_R YES	COND_M2L RMK_M2Lb

# ==================================================================================
# 3.2 Symbols and statistics
#
# PARSET:       name for parameter set, see above
# SYMBOLS:      description for plot symbols for parameter set
#       YSYMB:  number for symbol (MIDAS notation), e.g. 18 for filled circle
#       YSIZE:  relative size (MIDAS notation), e.g. 0.6
#       YCOLOR: color parameter for symbols, MIDAS notation (e.g. 2 - red, 4 - blue)
# LINE:         YES/NO; YES: data points connected by solid line, NO: no connection at all
# STATISTICS:
#       AVG:    MEAN/MEDIAN/FIXED=val/NONE: values are marked by solid line and written into result file
#       THRESH: NONE/VAL/PER/OFF: thresholds are marked by broken lines and written into result file
#               VAL=0.3,0.8: user-specified (static) thresholds; 
#		PER=3: 3% of AVG
#       OUTL:   YES/NO: mark outliers (data points outside the threshold lines)
# UNITS:        optional physical units for parameter set; single string, use SPACE to indicate space
# COMPUTE:      optional name for compute rule (to be defined below); NONE if other fields to come
# FIT:          optional name for fitting rule (to be defined below)
# CR_COMPENSATE: optional flag to indicate that the compute rule is compensated in scoreQC (YES/NO)
# CLOSEUP_FIT:	effective for INTERACTIVE=STATIC: optional flag to indicate if a FIT_RULE should be applied to the close-up plot (YES, default) or not (NO)
# ==================================================================================

#SYMBOLS PARSET		SYMBOLS...		LINE	STATISTICS...		UNITS	COMPUTE	FIT	CR_COMPENSATE	CLOSEUP_FIT
#			YSYMBOL	YSIZE	YCOLOR		AVG	THRESH	OUTLIER	
SYMBOLS	Medusa1		18	0.2	4	NO	NONE	NONE	NO	R	NONE	
SYMBOLS	Medusa1_reproc	18	0.3	2	NO	NONE	NONE	NO	R	NONE	

SYMBOLS	Medusa2		6	0.2	2	NO	NONE	NONE	NO	R	NONE	
SYMBOLS	Medusa2_reproc	6	0.3	4	NO	NONE	NONE	NO	R	

SYMBOLS	IFU1	7	0.3	1	NO	NONE	NONE	NO	R	NONE
SYMBOLS	IFU2	20	0.2	6	NO	NONE	NONE	NO	R	NONE	
SYMBOLS	ARG	18	0.2	7	NO	NONE	NONE	NO	R	NONE	

SYMBOLS	Medusa1_L		18	0.2	4	NO	NONE	NONE	NO 	R 	NONE	
SYMBOLS	Medusa1_L_reproc	18	0.3	2	NO	NONE	NONE	NO 	R 

SYMBOLS	Medusa2_L		6	0.2	2	NO	NONE	NONE	NO 	R 	NONE	
SYMBOLS	Medusa2_L_reproc	6	0.3	4	NO	NONE	NONE	NO 	R 

# ==================================================================================
# 4. Special definitions
# 4.1 Column definitions for local data sets
# TINDEX: index of mjd column; always required (to have a selection on mjd)
# ==================================================================================

#LOCAL_DATASET	NAME	XPARAM	XINDEX	YPARAM	YINDEX	TINDEX
LOCAL_DATASET   LOCAL3  mjd_obs $2      mean_R    $3      $2

# ==================================================================================
# 4.2 Conditions for data sets
# CONDITION: SQL syntax; can have multiple conditions, connected by AND
# CGI_COND:  same conditions in cgi syntax (see documentation for more)
# HC_COND:   same conditions in 'grep' syntax (no '"' permitted; for HEALTH only)
# SCORE_COND: same as CONDITION, for joins
# ==================================================================================

#CONDITION	COND_NAME	CONDITION
CONDITION	COND_M1H	&&ins_slit_name = "Medusa1" AND ins_exp_mode = "H525.8B"&&
CONDITION	COND_M2H	&&ins_slit_name = "Medusa2" AND ins_exp_mode = "H525.8B"&&
CONDITION	COND_I1H	&&ins_slit_name = "IFU1"    AND ins_exp_mode = "H525.8B"&&
CONDITION	COND_I2H	&&ins_slit_name = "IFU2"    AND ins_exp_mode = "H525.8B"&&
CONDITION	COND_ARH	&&ins_slit_name = "Argus"   AND ins_exp_mode = "H525.8B"&&

CONDITION	COND_M1L	&&ins_slit_name = "Medusa1" AND ins_exp_mode = "L543.1"&&
CONDITION	COND_M2L	&&ins_slit_name = "Medusa2" AND ins_exp_mode = "L543.1"&&

CGI_COND	COND_M1H	&&field_ins_slit_name=ins_slit_name&field_mean_resol=mean_resol&field_ins_exp_mode=ins_exp_mode&filter_ins_slit_name=Medusa1&filter_ins_exp_mode=H525.8B&&
CGI_COND	COND_M2H	&&field_ins_slit_name=ins_slit_name&field_mean_resol=mean_resol&field_ins_exp_mode=ins_exp_mode&filter_ins_slit_name=Medusa2&filter_ins_exp_mode=H525.8B&&
CGI_COND	COND_I1H	&&field_ins_slit_name=ins_slit_name&field_mean_resol=mean_resol&field_ins_exp_mode=ins_exp_mode&filter_ins_slit_name=IFU1&filter_ins_exp_mode=H525.8B&&
CGI_COND	COND_I2H	&&field_ins_slit_name=ins_slit_name&field_mean_resol=mean_resol&field_ins_exp_mode=ins_exp_mode&filter_ins_slit_name=IFU2&filter_ins_exp_mode=H525.8B&&
CGI_COND	COND_ARH	&&field_ins_slit_name=ins_slit_name&field_mean_resol=mean_resol&field_ins_exp_mode=ins_exp_mode&filter_ins_slit_name=Argus&filter_ins_exp_mode=H525.8B&&

CGI_COND	COND_M1L	&&field_ins_slit_name=ins_slit_name&field_mean_resol=mean_resol&field_ins_exp_mode=ins_exp_mode&filter_ins_slit_name=Medusa1&filter_ins_exp_mode=L543.1&&
CGI_COND	COND_M2L	&&field_ins_slit_name=ins_slit_name&field_mean_resol=mean_resol&field_ins_exp_mode=ins_exp_mode&filter_ins_slit_name=Medusa2&filter_ins_exp_mode=L543.1&&

HC_COND		COND_M1H	&&grep Medusa1|grep H525.8B&&
HC_COND		COND_M2H	&&grep Medusa2|grep H525.8B&&
HC_COND		COND_I1H	&&grep IFU1|grep H525.8B&&
HC_COND		COND_I2H	&&grep IFU2|grep H525.8B&&
HC_COND		COND_ARH	&&grep Argus|grep H525.8B&&

HC_COND		COND_M1L	&&grep Medusa1|grep L543.1&&
HC_COND		COND_M2L	&&grep Medusa2|grep L543.1&&
	
SCORE_COND	COND_M1H	&&QC.ins_slit_name = "Medusa1" AND QC.ins_exp_mode = "H525.8B"&&
SCORE_COND	COND_M2H	&&QC.ins_slit_name = "Medusa2" AND QC.ins_exp_mode = "H525.8B"&&
SCORE_COND	COND_I1H	&&QC.ins_slit_name = "IFU1"    AND QC.ins_exp_mode = "H525.8B"&&
SCORE_COND	COND_I2H	&&QC.ins_slit_name = "IFU2"    AND QC.ins_exp_mode = "H525.8B"&&
SCORE_COND	COND_ARH	&&QC.ins_slit_name = "Argus"   AND QC.ins_exp_mode = "H525.8B"&&

SCORE_COND	COND_M1L	&&QC.ins_slit_name = "Medusa1" AND QC.ins_exp_mode = "L543.1"&&
SCORE_COND	COND_M2L	&&QC.ins_slit_name = "Medusa2" AND QC.ins_exp_mode = "L543.1"&&

# ==================================================================================
# 4.3 Additional text for report header (2. line, initial string; max.length: about 22 chars)
# ==================================================================================

#ADD_TEXT       NAME            CONTENT
ADD_TEXT	ARCRESOL_TEXT	&&resolving power&&

# ==================================================================================
# 4.4 COMPUTE rules: Name and content of compute rules (PYTHON syntax)
# ==================================================================================

#COMPUTE_RULE   NAME            CONTENT
#COMPUTE_RULE	COMP_M2		&&select/tab Medusa1 all; select/tab Medusa2R all; comp/tab Medusa1 :mjd1 = int(:mjd_obs-53000); comp/tab Medusa2R :mjd1 = int(:mjd_obs-53000); set/refc Medusa1 :mjd1; set/refc Medusa2R :mjd1; copy/tt Medusa1 :lamp_effic Medusa2R :lamp_effic1; comp/tab Medusa2R :lamp_effic = :lamp_effic/:lamp_effic1

# ==================================================================================
# 4.5 FIT rules: Name and content of fit rules (PYTHON syntax)
# ==================================================================================

#FIT_RULE	NAME		CONTENT
#FIT_RULE	NOM1		&&pylab.plot([52000,65000],[31750,31750],'g--',linewidth=1.5); &&
#FIT_RULE	NOM3		&&pylab.plot([52000,65000],[50500,50500],'g--',linewidth=1.5); &&

# ==================================================================================
# 4.6 Remarks for result table
# ==================================================================================
#REMARK         NAME            CONTENT
REMARK          RMK_M1Ha       	&&<b>Resolving power R (&lambda;<sub>0</sub>/&Delta;&lambda;), high-resolution grating HR.</b><br>HC setting H525.8B<br>Medusa1&&
REMARK          RMK_M1Hb      	&&<i>same, initial years, from reprocessing</i>&&

REMARK          RMK_M2Ha    	&&Medusa2&&
REMARK          RMK_M2Hb      	&&<i>same, initial years, from reprocessing</i>&&

REMARK          RMK_I1H    	&&IFU1</i>&&
REMARK          RMK_I2H    	&&IFU2&&
REMARK          RMK_ARH     	&&Argus</td></tr><tr><td COLSPAN=20><hr noshade></td></tr>&&

REMARK          RMK_M1La       	&&<b>Resolving power R, low-resolution grating LR.</b><br>HC setting L543.1<br> Medusa1&&
REMARK          RMK_M1Lb      	&&<i>same, initial years, from reprocessing</i>&&

REMARK          RMK_M2La       	&&Medusa2&&
REMARK          RMK_M2Lb      	&&<i>same, initial years, from reprocessing</i>&&

# ==================================================================================
# 4.7 KPI: Definition of reference values
#     For KPI plots only
# TIME_RANGE
# VALUE:	numerical value of reference value
# ==================================================================================
#REF_VAL	PLOT_NAME	TIME_RANGE	VALUE
REF_VAL		MED1_H		FULL		31600
REF_VAL		MED2_H		FULL		31800
REF_VAL		IFU1_H		FULL		51000
REF_VAL		IFU2_H		FULL		51000
REF_VAL		ARG_H		FULL		51000

REF_VAL		MED1_L		FULL		5800
REF_VAL		MED2_L		FULL		5800

