def parameters(self):
        """ Return the model parameters. """

        try:
            return self._parameters

        except AttributeError:
            None

        parameters = []
        parameters.extend(self.grid_points.dtype.names)

        model_configuration = self._configuration.get("model", {})

        # Continuum
        # Note: continuum cannot just be 'True', it should be a dictionary
        n = len(parameters)
        continuum_config = model_configuration.get("continuum", False)
        if continuum_config is not False:
            if not isinstance(continuum_config, dict):
                raise TypeError("incorrect continuum type")
            for name in set(self.channel_names).intersection(continuum_config):
                degree = continuum_config[name]
                if degree is False:
                    continue

                # Note: N_coefficients = degree + 1
                # Example: degree = 3: a^3 + b^2 + c^1 + d 
                parameters.extend(["continuum_{0}_{1}".format(name, n) \
                    for n in range(degree + 1)])

        # Redshift
        parameters.extend(channel_parameters("z", self.channel_names,
            model_configuration.get("redshift", False)))

        # Spectral resolution
        resolution_parameters = channel_parameters(
            "resolution", self.channel_names,
            model_configuration.get("spectral_resolution", False))
        parameters.extend(resolution_parameters)

        # Underestimated variance
        parameters.extend(channel_parameters(
            "ln_f", self.channel_names,
            model_configuration.get("underestimated_variance", False)))

        # Outlier pixels
        if model_configuration.get("outlier_pixels", False):
            parameters.extend(["Po", "Vo"])

        assert len(parameters) == len(set(parameters)), "Duplicate parameters!"

        self._resolution_parameters = resolution_parameters
        self._parameters = tuple(parameters)

        return self._parameters
def parameters ( self ) : try : return self . _parameters except AttributeError : None parameters = [ ] parameters . extend ( self . grid_points . dtype . names ) model_configuration = self . _configuration . get ( "model" , { } ) n = len ( parameters ) continuum_config = model_configuration . get ( "continuum" , False ) if continuum_config is not False : if not isinstance ( continuum_config , dict ) : raise TypeError ( "incorrect continuum type" ) for name in set ( self . channel_names ) . intersection ( continuum_config ) : degree = continuum_config [ name ] if degree is False : continue parameters . extend ( [ "continuum_{0}_{1}" . format ( name , n ) for n in range ( degree + 1 ) ] ) parameters . extend ( channel_parameters ( "z" , self . channel_names , model_configuration . get ( "redshift" , False ) ) ) resolution_parameters = channel_parameters ( "resolution" , self . channel_names , model_configuration . get ( "spectral_resolution" , False ) ) parameters . extend ( resolution_parameters ) parameters . extend ( channel_parameters ( "ln_f" , self . channel_names , model_configuration . get ( "underestimated_variance" , False ) ) ) if model_configuration . get ( "outlier_pixels" , False ) : parameters . extend ( [ "Po" , "Vo" ] ) assert len ( parameters ) == len ( set ( parameters ) ) , "Duplicate parameters!" self . _resolution_parameters = resolution_parameters self . _parameters = tuple ( parameters ) return self . _parameters
Return the model parameters.