###############################################################################
#                                                                             #
# Copyright (C) 2004-2014 Edward d'Auvergne                                   #
# Copyright (C) 2007-2009 Sebastien Morin                                     #
#                                                                             #
# This file is part of the program relax (http://www.nmr-relax.com).          #
#                                                                             #
# This program is free software: you can redistribute it and/or modify        #
# it under the terms of the GNU General Public License as published by        #
# the Free Software Foundation, either version 3 of the License, or           #
# (at your option) any later version.                                         #
#                                                                             #
# This program is distributed in the hope that it will be useful,             #
# but WITHOUT ANY WARRANTY; without even the implied warranty of              #
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the               #
# GNU General Public License for more details.                                #
#                                                                             #
# You should have received a copy of the GNU General Public License           #
# along with this program.  If not, see <http://www.gnu.org/licenses/>.       #
#                                                                             #
###############################################################################

# Module docstring.
"""The module for the consistency testing parameter list object."""

# relax module imports.
from lib.physical_constants import N15_CSA
from specific_analyses.parameter_object import Param_list


class Consistency_tests_params(Param_list):
    """The consistency testing parameter list singleton."""

    # Class variable for storing the class instance (for the singleton design pattern).
    _instance = None

    def __init__(self):
        """Define all the parameters of the analysis."""

        # The object is already initialised.
        if self._initialised: return

        # Execute the base class __init__ method.
        Param_list.__init__(self)

        # Add the base information for the analysis.
        self._add_csa(default=N15_CSA)
        self._add('orientation', scope='spin', default=15.7, units='degrees', desc="Angle between the 15N-1H vector and the principal axis of the 15N chemical shift tensor", py_type=float, set='fixed', grace_string='\\q\\xq\\Q')
        self._add('tc', scope='spin', default=13 * 1e-9, units='ns', desc="The single global correlation time estimate/approximation", py_type=float, set='fixed', grace_string='\\q\\xt\\f{}c\\Q')

        # Add the model parameters.
        self._add('j0', scope='spin', desc='Spectral density value at 0 MHz (from Farrow et al. (1995) JBNMR, 6: 153-162)', py_type=float, set='params', grace_string='\\qJ(0)\\Q', err=True, sim=True)
        self._add('f_eta', scope='spin', desc='Eta-test (from Fushman et al. (1998) JACS, 120: 10947-10952)', py_type=float, set='params', grace_string='\\qF\\s\\xh\\Q', err=True, sim=True)
        self._add('f_r2', scope='spin', desc='R2-test (from Fushman et al. (1998) JACS, 120: 10947-10952)', py_type=float, set='params', grace_string='\\qF\\sR2\\Q', err=True, sim=True)

        # Set up the user function documentation.
        self._set_uf_title("Consistency testing parameters")
        self._uf_param_table(label="table: consistency testing parameters", caption="Consistency testing parameters.")
        self._uf_param_table(label="table: consistency testing parameter value setting", caption="Consistency testing parameters.")
        self._uf_param_table(label="table: consistency testing parameter value setting with defaults", caption="Consistency testing parameter value setting.", default=True)

        # Value setting documentation.
        for doc in self._uf_doc_loop(["table: consistency testing parameter value setting", "table: consistency testing parameter value setting with defaults"]):
            doc.add_paragraph("In consistency testing, the CSA value, angle Theta ('orientation') and global correlation time must be set prior to the calculation of consistency functions.")
