#!/usr/bin/env python3
# -*- coding: utf-8 -*-

# System modules


# Custom modules
from utils.logger import log

# Other templates
from templates.basetemplate import BaseTemplate
from templates.observation import Template as Observation


class Template(BaseTemplate):
    def __init__(self):
        super().__init__()
        self.name = "flat"
        self.description = "Takes a set of flat calibrations"

    def content(self, params):

        ########################
        ##### Params check #####
        ########################

        try:
            binning = params["binning"]
            repeat = params.get("repeat") or 1
            filt = params["filter"]
            exptime = params["exptime"]
        except KeyError as e:
            log.error(f"Parameter {e} not found")

        fixed = {
            "objname": "Flat frame",
            "frametype": "Flat"
        }

        params.update(fixed)

        ##################################
        ##### Calling Observation tpl ####
        ##################################

        obs = Observation()
        obs.run(params)

        return
