# $Header: https://oberon.oapd.inaf.it/shins/trunk/shins/src/scripts/templates/tpl/SHARKNIR_di_mon_DetectorGain.py 3952 2022-05-19 08:30:53Z depa $

from shinsapp import SHINSApp
from util.shinsLogger import logger
from util import variables as uvars
from util import exception
from util import functions as ufun

from SHARKNIR_gen_base import SHARKNIR_gen_base

class SHARKNIR_di_mon_DetectorGain(SHINSApp):
    """This calibration is performed by reading the detector without any
    light illumination i.e. using an opaque position during 600s
    Continuous extended source in the calibration; various ND; various
    integration times. CI in B_H.

    """

    @exception.handler_for_run
    def run(self, ins_s=None, det_s=None, tel_s=None, rtc_s=None, **kwargs):
        """MDP: in my opinion detector gain is an OB, not a template"""

        logger.info(__name__)
        obsController = self.obsController
        self.status = uvars.EXIT_SUCCESS

        self.gen_base = SHARKNIR_gen_base();        gen_base = self.gen_base

        ###########################
        # Setup + image with BB_H #
        ###########################

        ins_s["SCI_FILT_W1"] = "BB_H"
        det_s["NDROPS"] = "18"
        
        gen_base.main(ins_s=ins_s, det_s=det_s)

        ###########################
        # Setup + image with BB_J #
        ###########################

        ins_s["SCI_FILT_W1"] = "BB_J"
        det_s["NDROPS"] = "15"

        gen_base.main(ins_s=ins_s, det_s=det_s)

        ###########################
        # Setup + image with BB_Y #
        ###########################

        ins_s["SCI_FILT_W1"] = "BB_Y"
        det_s["NDROPS"] = "15"

        gen_base.main(ins_s=ins_s, det_s=det_s)
