flux = spectres.spectres(
                wavel_resample,
                model_box.wavelength,
                model_box.flux,
                spec_errs=None,
                fill=np.nan,
                verbose=True,
            )

            model_box.wavelength = wavel_resample

        elif spec_res is not None and not smooth:
            index = np.where(np.isnan(model_box.flux))[0]

            if index.size > 0:
                raise ValueError(
                    "Flux values should not contains NaNs. Please make sure that "
                    "the parameter values and the wavelength range are within "
                    "the grid boundaries as stored in the database."
                )

            wavel_resample = read_util.create_wavelengths(
                (self.wl_points[0], self.wl_points[-1]), spec_res
            )

            indices = np.where(
                (wavel_resample > self.wl_points[0])
                & (wavel_resample < self.wl_points[-2])
            )[0]

            wavel_resample = wavel_resample[indices]

            model_box.flux = spectres.spectres(
                wavel_resample,
                model_box.wavelength,
                model_box.flux,
                spec_errs=None,
                fill=np.nan,
                verbose=True,
            )

            model_box.wavelength = wavel_resample

        # Convert flux to magnitude

        if magnitude:
            with h5py.File(self.database, "r") as h5_file:
                try:
                    h5_file["spectra/calibration/vega"]

                except KeyError:
                    h5_file.close()
                    species_db = database.Database()
                    species_db.add_spectra("vega")
                    h5_file = h5py.File(self.database, "r")

            readcalib = read_calibration.ReadCalibration("vega", filter_name=None)
            calibbox = readcalib.get_spectrum()

            flux_vega, _ = spectres.spectres(
                model_box.wavelength,
                calibbox.wavelength,
                calibbox.flux,
                spec_errs=calibbox.error,
                fill=np.nan,
                verbose=True,
            )

            model_box.flux = -2.5 * np.log10(model_box.flux / flux_vega)
            model_box.quantity = "magnitude"

        # Check if the contains NaNs

        if np.isnan(np.sum(model_box.flux)):
            warnings.warn(
                f"The resampled spectrum contains {np.sum(np.isnan(model_box.flux))} "
                f"NaNs, probably because the original wavelength range does not fully "
                f"encompass the new wavelength range. The happened with the "
                f"following parameters: {model_param}."
            )

        # Add the luminosity to the parameter dictionary

        if "radius" in model_box.parameters:
            model_box.parameters["luminosity"] = (
                4.0
                * np.pi
                * (model_box.parameters["radius"] * constants.R_JUP) ** 2
                * constants.SIGMA_SB
                * model_box.parameters["teff"] ** 4.0
                / constants.L_SUN
            )  # (Lsun)

        # Add the blackbody disk component to the luminosity

        if (
            "disk_teff" in model_box.parameters
            and "disk_radius" in model_box.parameters
        ):
            model_box.parameters["luminosity"] += (
                4.0
                * np.pi
                * (model_box.parameters["disk_radius"] * constants.R_JUP) ** 2
                * constants.SIGMA_SB
                * model_box.parameters["disk_teff"] ** 4.0
                / constants.L_SUN
            )  # (Lsun)

        # Add the planet mass to the parameter dictionary

        if "radius" in model_param and "logg" in model_param:
            model_param["mass"] = read_util.get_mass(
                model_param["logg"], model_param["radius"]
            )

        return model_box

    @typechecked
    def get_data(
        self,
        model_param: Dict[str, float],
        spec_res: Optional[float] = None,
        wavel_resample: Optional[np.ndarray] = None,
    ) -> box.ModelBox:
        """
        Function for selecting a model spectrum (without interpolation)
        for a set of parameter values that coincide with the grid
        points. The stored grid points can be inspected with
        :func:`~species.read.read_model.ReadModel.get_points`.

        Parameters
        ----------
        model_param : dict
            Model parameters and values. Only discrete values from the
            original grid are possible. Else, the nearest grid values
            are selected.
        spec_res : float, None
            Spectral resolution that is used for smoothing the spectrum
            with a Gaussian kernel. No smoothing is applied to the
            spectrum if the argument is set to ``None``.
        wavel_resample : np.ndarray, None
            Wavelength points (um) to which the spectrum will be
            resampled. In that case, ``spec_res`` can still be used for
            smoothing the spectrum with a Gaussian kernel. The original
            wavelength points are used if the argument is set to
            ``None``.

        Returns
        -------
        species.core.box.ModelBox
            Box with the model spectrum.
        """

        # Check if all parameters are present

        for key in self.get_parameters():
            if key not in model_param.keys():
                raise ValueError(
                    f"The '{key}' parameter is required by '{self.model}'. "
                    f"The mandatory parameters are {self.get_parameters()}."
                )

        # Print a warning if redundant parameters are included in the dictionary

        for key in model_param.keys():
            if key not in self.get_parameters() and key not in self.extra_param:
                warnings.warn(
                    f"The '{key}' parameter is not required by '{self.model}' so "
                    f"the parameter will be ignored. The mandatory parameters are "
                    f"{self.get_parameters()}."
                )

        # Open de HDF5 database

        h5_file = self.open_database()

        # Set the wavelength range

        if self.wavel_range is None:
            wl_points = self.get_wavelengths()
            self.wavel_range = (wl_points[0], wl_points[-1])

        # Create lists with the parameter names and values

        param_key = []
        param_val = []

        if "teff" in model_param:
            param_key.append("teff")
            param_val.append(model_param["teff"])

        if "logg" in model_param:
            param_key.append("logg")
            param_val.append(model_param["logg"])

        if "feh" in model_param:
            param_key.append("feh")
            param_val.append(model_param["feh"])

        if "c_o_ratio" in model_param:
            param_key.append("c_o_ratio")
            param_val.append(model_param["c_o_ratio"])

        if "fsed" in model_param:
            param_key.append("fsed")
            param_val.append(model_param["fsed"])

        if "log_kzz" in model_param:
            param_key.append("log_kzz")
            param_val.append(model_param["log_kzz"])

        # Read the grid of fluxes from the database

        flux = np.asarray(h5_file[f"models/{self.model}/flux"])

        # Find the indices of the grid points for which the spectrum will be extracted

        indices = []

        for item in param_key:
            data = np.asarray(h5_file[f"models/{self.model}/{item}"])
            data_index = np.argwhere(
                np.round(data, 4) == np.round(model_param[item], 4)
            )[0]

            if len(data_index)