Пример #1
0
    def __init__(self, inlist):
        """Initializer for the class

        Parameters
        ----------
        inlist: str
            name of list with the fits images
        """
        # initialize the list of spectra
        self._imalist = []

        # load the list with input images
        ilist = axe_asciidata.open(inlist)

        # go over the image names
        for item in ilist[0]:

            # check whether the file is there
            if not os.path.isfile(getSIMDATA(item)):
                error_message = ("\nDid not find image: {0:s} !!".format(
                    str(getSIMDATA(item))))
                raise aXeSIMError(error_message)

            # apend the fits to the liast
            self._imalist.append(ArtImage(getSIMDATA(item.strip())))
Пример #2
0
    def check_simdirim_input(self, incat, config, tpass_direct, model_spectra,
                             model_images, nx, ny, exptime, bck_flux):
        """Does basic checks on the parameters

        The method checks whether all input values are reasonable, e.g.
        the exposure time and background flux >= 0.0 and similar.
        Input files are checked for existence. Also the input type is
        checked for the numbers.

        Parameters
        ----------
        incat: str
            name of model object table
        config: str
            aXe configuration file name
        tpass_direct: str
            total passband file
        model_spectra: str
            name of model spectra
        model_images: str
            name of model images
        nx: int
            number of pixels in x
        ny: int
            number of pixels in y
        exptime: float
            exposure time
        bck_flux: float
            flux in background
        """

        # do the setup
        config_util.axe_setup(axesim=True)

        # check the existence of the
        # model object table
        if not os.path.isfile(config_util.getDATA(incat)):
            error_message = (
                "The Model Object Table does not exist: {0}".format(
                    config_util.getDATA(incat)))
            raise aXeSIMError(error_message)

        # check the existence of the
        # axe configuration file
        if not os.path.isfile(config_util.getCONF(config)):
            error_message = (
                "The aXe configuration file does not exist: {0}".format(
                    config_util.getCONF(config)))
            raise aXeSIMError(error_message)

        else:
            # load the aXe configuration file
            conf = configfile.ConfigFile(config_util.getCONF(config))

            # make the internal checks
            n_sens = conf.check_files(check_glob=False)

            # make sure there is
            # at least one sens. file
            if n_sens < 1:
                error_message = ("There must be at least one sensitivity "
                                 "file in: {0}".format(
                                     config_util.getCONF(config)))
                raise aXeSIMError(error_message)

        # check the existence of the
        # total passband file
        if not os.path.isfile(config_util.getSIMDATA(tpass_direct)):
            error_message = (
                "The total passband file does not exist: {0}".format(
                    config_util.getSIMDATA(tpass_direct)))
            raise aXeSIMError(error_message)

        if model_spectra is not None:
            # check the existence of the
            # model spectra file
            if not os.path.isfile(config_util.getDATA(model_spectra)):
                error_message = (
                    "The model spectra file does not exist: {0}".format(
                        config_util.getDATA(config)))
                raise aXeSIMError(error_message)

        if model_images is not None:
            # check the existence of the
            # model images file
            if not os.path.isfile(config_util.getDATA(model_images)):
                error_message = (
                    "The model images file does not exist: {0}".format(
                        config_util.getDATA(config)))
                raise aXeSIMError(error_message)

        # check the nx-value
        if ((nx is not None) and (nx <= 0.0)):
            error_message = ("Value for 'nx' or 'nx_dir' must be positive: "
                             "{0:s}".format(str(nx)))
            raise aXeSIMError(error_message)

        # check the ny-value
        if ((ny is not None) and (ny <= 0)):
            error_message = ("Value for 'ny' or 'ny_dir' must be positive: "
                             "{0:s}".format(str(ny)))
            raise aXeSIMError(error_message)

        # check the exptime-value
        if ((exptime is not None) and (exptime < 0)):
            error_message = ("Value for 'exptime' or 'exptime_dir' must be "
                             "positive: {0:s}".format(str(exptime)))
            raise aXeSIMError(error_message)

        if bck_flux is not None:
            # check the bck_flux-value
            try:
                # convert to float
                bck = float(bck_flux)

                # check for positive value
                if bck < 0:
                    error_message = ("Value for 'bck_flux' or 'bck_flux_dir'"
                                     " must be positive: {0:s}".format(
                                         str(bck_flux)))
                    raise aXeSIMError(error_message)

                # catch a string
            except ValueError:
                # check for existence of file
                if not os.path.isfile(config_util.getCONF(bck_flux)):
                    error_message = (
                        "The background file does not exist: {0}".format(
                            config_util.getCONF(bck_flux)))
                    raise aXeSIMError(error_message)