#!/usr/bin/python3

##
# @file
# @ingroup examples_exampleDataTask_common_genFitsData
#
# @brief Implements the entry point for rtctkExampleDataTaskGenFitsData.
#
# @copyright
#   SPDX-FileCopyrightText: 2024 European Southern Observatory (ESO) @n
#   SPDX-License-Identifier: LGPL-3.0-only

"""
This is the entry point for the rtctkExampleDataTaskGenFitsData command line utility.
"""

import sys
from astropy.io import fits
import numpy as np


def create_fits(slopes, modes, filename):
    """
    Creates a FITS test file for a given number of slopes and modes.
    """

    slopes = int(sys.argv[1])
    modes = int(sys.argv[2])
    filename = sys.argv[3]
    mat = np.eye(modes, slopes, dtype=np.float32)

    # create fits
    hdu = fits.PrimaryHDU(mat)
    hdu.writeto(filename, overwrite=True)


if __name__ == "__main__":
    create_fits(int(sys.argv[1]), int(sys.argv[2]), sys.argv[3])
