import pandas as pd
import numpy as np
from aeri_qc.all_checks import checklist

@checklist.add_check(depends=['hatchOpen','sceneMirrorPosition'], affects_calibration=False, description='hatch is closed')
def hatch_check(frame, parameters):
    """
    Check that the hatch is open on sky views
    """
    return  ((frame.hatchOpen != 1) & (~frame.sceneMirrorPosition.isin([ord('H'), ord('A')])))


@checklist.add_check(depends=['hatchOpen','sceneMirrorPosition'], affects_calibration=True, description='hatch moving during calibration view, mirror might have safed')
def safing_check(frame, parameters):
    """
    Check that the mirror doesn't safe during a calibration view and contaminate other records
    """
    hatch_closing = (frame.hatchOpen == -3)
    return hatch_closing & frame.sceneMirrorPosition.isin([ord('H'), ord('A')])


def encoder_check(frame, parameters):
    return frame