Example #1
0
    def __init__(self, val, err, par):
        BaseDataPoint.__init__(self, val, err, par, PAR_DICT['par_conv'],
                               plot_data)

        self.par['ppm_to_rads_h'] = TWO_PI * self.par['h_larmor_frq']
        self.par['ppm_to_rads'] = TWO_PI * self.par['h_larmor_frq'] * RATIO_N

        temperature = self.par['temperature']
        h_larmor_frq = self.par['h_larmor_frq']
        resonance_id = self.par['resonance_id']
        experiment_name = self.par['experiment_name']

        assignment = parsing.parse_assignment(resonance_id)
        index_1, residue_type_1, nucleus_type_1 = assignment[0]
        index_2, residue_type_2, nucleus_type_2 = assignment[1]
        nucleus_name_1 = residue_type_1 + str(index_1) + nucleus_type_1
        nucleus_name_2 = residue_type_2 + str(index_2) + nucleus_type_2
        nuclei_name = parsing.assignment_name(assignment)

        self.par['_id'] = tuple((temperature, nucleus_name_2, h_larmor_frq))

        args = (
            self.par[arg]
            for arg in getargspec(make_calc_observable.__wrapped__).args
        )

        self.calc_observable = make_calc_observable(*args)

        self.short_long_par_names = (
            ('i0', ('i0', resonance_id, experiment_name)),
            ('pb', ('pb', temperature)),
            ('kex', ('kex', temperature)),
            ('dw_h', ('dw', nucleus_name_2)),
            ('dw_n', ('dw', nucleus_name_1)),
            ('cs_h', ('cs', nucleus_name_2)),
            ('cs_n', ('cs', nucleus_name_1)),
            ('r_nxy', ('r_nxy', nucleus_name_1, h_larmor_frq, temperature)),
            ('dr_nxy', ('dr_nxy', nucleus_name_1, h_larmor_frq, temperature)),
            ('r_nz', ('r_nz', nucleus_name_1, h_larmor_frq, temperature)),
            ('r_hxy', ('r_hxy', nucleus_name_2, h_larmor_frq, temperature)),
            ('r_hz', ('r_hz', nucleus_name_2, h_larmor_frq, temperature)),
            ('r_2hznz', ('r_2hznz', nuclei_name, h_larmor_frq, temperature)),
            (
            'r_2hxynxy', ('r_2hxynxy', nuclei_name, h_larmor_frq, temperature)),
            ('etaxy', ('etaxy', nuclei_name, h_larmor_frq, temperature)),
            ('etaz', ('etaz', nuclei_name, h_larmor_frq, temperature)),
            ('j_hn', ('j_hn', nuclei_name, temperature)),
        )

        self.fitting_parameter_names.update(
            long_name
            for short_name, long_name in self.short_long_par_names
            if short_name in PAR_DICT['fit']
        )

        self.fixed_parameter_names.update(
            long_name
            for short_name, long_name in self.short_long_par_names
            if short_name in PAR_DICT['fix']
        )
    def __init__(self, val, err, par):
        BaseDataPoint.__init__(self, val, err, par, PAR_DICT['par_conv'],
                               plot_data)

        self.par['ppm_to_rads'] = TWO_PI * self.par['h_larmor_frq'] * RATIO_N

        temperature = self.par['temperature']
        resonance_id = self.par['resonance_id']
        h_larmor_frq = self.par['h_larmor_frq']
        experiment_name = self.par['experiment_name']

        assignment = parse_assignment(resonance_id)
        index_1, residue_type_1, nucleus_type_1 = assignment[0]
        index_2, residue_type_2, nucleus_type_2 = assignment[1]
        nucleus_name_1 = residue_type_1 + str(index_1) + nucleus_type_1
        nucleus_name_2 = residue_type_2 + str(index_2) + nucleus_type_2

        self.par['_id'] = tuple((temperature, nucleus_name_1, h_larmor_frq))

        args = (self.par[arg]
                for arg in getargspec(make_calc_observable.__wrapped__).args)

        self.calc_observable = make_calc_observable(*args)

        self.kwargs_default = {'ncyc': self.par['ncyc']}

        self.short_long_par_names = (
            ('pb', ('pb', temperature)),
            ('pc', ('pc', temperature)),
            ('kex_ab', ('kex_ab', temperature)),
            ('kex_bc', ('kex_bc', temperature)),
            ('kex_ac', ('kex_ac', temperature)),
            ('dw_ab', ('dw_ab', nucleus_name_1)),
            ('dw_ac', ('dw_ac', nucleus_name_1)),
            ('cs', ('cs', nucleus_name_1, temperature)),
            ('i0', ('i0', resonance_id, experiment_name)),
            ('r_nxy', ('r_nxy', nucleus_name_1, h_larmor_frq, temperature)),
            ('dr_nxy_ab', ('dr_nxy_ab', nucleus_name_1, h_larmor_frq,
                           temperature)),
            ('dr_nxy_ac', ('dr_nxy_ac', nucleus_name_1, h_larmor_frq,
                           temperature)),
            ('r_nz', ('r_nz', nucleus_name_1, h_larmor_frq, temperature)),
            ('r_2hznz', ('r_2hznz', nucleus_name_1, nucleus_name_2,
                         h_larmor_frq, temperature)),
            ('etaxy', ('etaxy', nucleus_name_1, h_larmor_frq, temperature)),
            ('etaz', ('etaz', nucleus_name_1, h_larmor_frq, temperature)),
            ('j_hn', ('j_hn', nucleus_name_1, nucleus_name_2, temperature)),
            ('dj_hn_ab', ('dj_hn_ab', nucleus_name_1, nucleus_name_2,
                          temperature)),
            ('dj_hn_ac', ('dj_hn_ac', nucleus_name_1, nucleus_name_2,
                          temperature)),
        )

        self.fitting_parameter_names.update(
            long_name for short_name, long_name in self.short_long_par_names
            if short_name in PAR_DICT['fit'])

        self.fixed_parameter_names.update(
            long_name for short_name, long_name in self.short_long_par_names
            if short_name in PAR_DICT['fix'])
def read_parameter_file(filename, par_name):
    """
    Reads a file containing values associated with a nucleus name.
    The file should be formatted like sparky peak lists.

    For example:
      * To set G23N to 105.0 and G23H to 8.0:
          G23N-H  105.0  8.0
      * To set a parameter depending on multiple nuclei, eg. G23N and G23H, to 1.0:
          G23N-H  -93.0
    """

    try:
        raw_data = sp.genfromtxt(filename, dtype=None)
    except IOError:
        exit('The file \'{}\' is empty or does not exist!\n'.format(filename))

    # Hack to solve the problem of 0d-array when 'filename' is a single line
    # file
    if raw_data.ndim == 0:
        raw_data = sp.array([
            raw_data,
        ])

    parameters = []

    for line in raw_data:

        if line[0] in ['Assignment', '?-?']:
            continue

        assignment = parsing.parse_assignment(line[0])

        if len(assignment) == len(line) - 1:
            for index, an_assignment in enumerate(assignment, 1):
                name = parsing.assignment_name([an_assignment])
                full_par_name = par_name + [name]
                parameters.append((full_par_name, line[index]))

        elif len(line) == 2:
            name = parsing.assignment_name(assignment)
            full_par_name = par_name + [name]
            parameters.append((full_par_name, line[1]))

        else:

            error_message = '\n'.join([
                "Problem reading the parameter file '{}'.".format(filename),
                "The number of columns does not match to the number of nuclei"
                " contained in the assignment:"
            ])
            exit(error_message)

    return parameters
Example #4
0
def read_parameter_file(filename, par_name):
    """
    Reads a file containing values associated with a nucleus name.
    The file should be formatted like sparky peak lists.

    For example:
      * To set G23N to 105.0 and G23H to 8.0:
          G23N-H  105.0  8.0
      * To set a parameter depending on multiple nuclei, eg. G23N and G23H, to 1.0:
          G23N-H  -93.0
    """

    try:
        raw_data = sp.genfromtxt(filename, dtype=None)
    except IOError:
        exit('The file \'{}\' is empty or does not exist!\n'.format(filename))

    # Hack to solve the problem of 0d-array when 'filename' is a single line
    # file
    if raw_data.ndim == 0:
        raw_data = sp.array([raw_data, ])

    parameters = []

    for line in raw_data:

        if line[0] in ['Assignment', '?-?']:
            continue

        assignment = parsing.parse_assignment(line[0])

        if len(assignment) == len(line) - 1:
            for index, an_assignment in enumerate(assignment, 1):
                name = parsing.assignment_name([an_assignment])
                full_par_name = par_name + [name]
                parameters.append((full_par_name, line[index]))

        elif len(line) == 2:
            name = parsing.assignment_name(assignment)
            full_par_name = par_name + [name]
            parameters.append((full_par_name, line[1]))

        else:

            error_message = '\n'.join(
                ["Problem reading the parameter file '{}'.".format(filename),
                 "The number of columns does not match to the number of nuclei"
                 " contained in the assignment:"])
            exit(error_message)

    return parameters
Example #5
0
    def __init__(self, val, err, par):

        BaseDataPoint.__init__(self, val, err, par, PAR_DICT['par_conv'],
                               plot_data)

        temperature = self.par['temperature']
        resonance_id = self.par['resonance_id']
        h_larmor_frq = self.par['h_larmor_frq']
        experiment_name = self.par['experiment_name']

        index, residue_type, nucleus_type = parse_assignment(resonance_id)[0]
        nucleus_name = ''.join([residue_type, str(index), nucleus_type])

        try:
            self.par['ppm_to_rads'] = (
                2.0 * pi * self.par['h_larmor_frq'] * xi_ratio[
                    nucleus_type[0].upper()]
            )
        except KeyError:
            exit(
                "Unknown nucleus type \"{}\" for peak \"{}\" in experiment "
                "\"{}\""
                .format(nucleus_type, resonance_id, experiment_name)
            )

        self.par['_id'] = ((temperature, nucleus_name, h_larmor_frq),)

        args = (self.par[arg] for arg in
                getargspec(make_calc_observable.__wrapped__).args)
        self.calc_observable = make_calc_observable(*args)

        self.kwargs_default = {'ncyc': self.par['ncyc']}

        self.short_long_par_names = (
            ('i0', ('i0', resonance_id, experiment_name)),
            ('pb', ('pb', temperature)),
            ('kex', ('kex', temperature)),
            ('dw', ('dw', nucleus_name)),
            ('r_ixy', ('r_ixy', nucleus_name, h_larmor_frq, temperature)),
            ('dr_ixy', ('dr_ixy', nucleus_name, h_larmor_frq, temperature)),
        )

        self.fitting_parameter_names.update(long_name
                                            for short_name, long_name in
                                            self.short_long_par_names
                                            if short_name in PAR_DICT['fit'])

        self.fixed_parameter_names.update(long_name
                                          for short_name, long_name in
                                          self.short_long_par_names
                                          if short_name in PAR_DICT['fix'])
Example #6
0
def group_data(data):
    """Groups the data resonance specifically"""

    data_grouped = dict()

    for data_pt in data:
        resonance_id = data_pt.par['resonance_id']

        assignment = parse_assignment(resonance_id)
        index = int(assignment[0][0])

        data_grouped.setdefault((index, resonance_id), []).append(data_pt)

    return data_grouped
def group_data(dataset):
    """Groups the data resonance specifically"""

    data_grouped = dict()

    for data_pt in dataset:
        id_ = data_pt.par['resonance_id']

        assignment = parse_assignment(id_)
        index = int(assignment[0][0])

        data_grouped.setdefault((index, id_), []).append(data_pt)

    return data_grouped
Example #8
0
    def __init__(self, val, err, par):
        BaseDataPoint.__init__(self, val, err, par, PAR_DICT['par_conv'], plot_data)

        self.par['ppm_to_rads'] = TWO_PI * self.par['h_larmor_frq'] * RATIO_C

        self.kwargs_default = dict()

        temperature = self.par['temperature']
        resonance_id = self.par['resonance_id']
        h_larmor_frq = self.par['h_larmor_frq']
        experiment_name = self.par['experiment_name']

        assignment = parse_assignment(resonance_id)
        index, residue_type, nucleus_type = assignment[0]
        nucleus_name = ''.join([residue_type, str(index), nucleus_type])

        couplings = J_COUPLINGS[residue_type][nucleus_type]
        self.par['multiplet'] = calc_multiplet(couplings)

        self.par['_id'] = tuple((temperature, nucleus_name, h_larmor_frq))

        args = (self.par[arg] for arg in getargspec(make_calc_observable.__wrapped__).args)
        self.calc_observable = make_calc_observable(*args)

        self.short_long_par_names = (
            ('pb', ('pb', temperature)),
            ('kex', ('kex', temperature)),
            ('dw', ('dw', nucleus_name)),
            ('cs', ('cs', nucleus_name, temperature)),
            ('i0', ('i0', resonance_id, experiment_name)),
            ('r_cxy', ('r_cxy', nucleus_name, h_larmor_frq, temperature)),
            ('dr_cxy', ('dr_cxy', nucleus_name, h_larmor_frq, temperature)),
            ('r_cz', ('r_cz', nucleus_name, h_larmor_frq, temperature)),

        )

        self.fitting_parameter_names.update(
            long_name
            for short_name, long_name in self.short_long_par_names
            if short_name in PAR_DICT['fit']
        )

        self.fixed_parameter_names.update(
            long_name
            for short_name, long_name in self.short_long_par_names
            if short_name in PAR_DICT['fix']
        )
    def __init__(self, val, err, par):
        BaseDataPoint.__init__(self, val, err, par, PAR_DICT['par_conv'],
                               plot_data)

        self.par['ppm_to_rads'] = TWO_PI * self.par['h_larmor_frq'] * RATIO_C

        temperature = self.par['temperature']
        resonance_id = self.par['resonance_id']
        h_larmor_frq = self.par['h_larmor_frq']
        experiment_name = self.par['experiment_name']

        assignment = parse_assignment(resonance_id)
        index, residue_type, nucleus_type = assignment[0]
        nucleus_name = ''.join([residue_type, str(index), nucleus_type])

        self.par['_id'] = tuple((temperature, nucleus_name, h_larmor_frq))

        args = (self.par[arg] for arg in
                getargspec(make_calc_observable.__wrapped__).args)
        self.calc_observable = make_calc_observable(*args)

        self.kwargs_default = {'ncyc': self.par['ncyc']}

        self.short_long_par_names = (
            ('i0', ('i0', resonance_id, experiment_name)),
            ('pb', ('pb', temperature)),
            ('kex', ('kex', temperature)),
            ('dw', ('dw', nucleus_name)),
            ('cs', ('cs', nucleus_name, temperature)),
            ('r_cxy', ('r_cxy', nucleus_name, h_larmor_frq, temperature)),
            ('dr_cxy', ('dr_cxy', nucleus_name, h_larmor_frq, temperature)),
            ('r_cz', ('r_cz', nucleus_name, h_larmor_frq, temperature)),
        )

        self.fitting_parameter_names.update(
            long_name
            for short_name, long_name in self.short_long_par_names
            if short_name in PAR_DICT['fit']
        )

        self.fixed_parameter_names.update(
            long_name
            for short_name, long_name in self.short_long_par_names
            if short_name in PAR_DICT['fix']
        )
    def __init__(self, val, err, par):

        BaseDataPoint.__init__(self, val, err, par, PAR_DICT['par_conv'],
                               plot_data)

        temperature = self.par['temperature']
        resonance_id = self.par['resonance_id']
        h_larmor_frq = self.par['h_larmor_frq']
        experiment_name = self.par['experiment_name']

        index, residue_type, nucleus_type = parse_assignment(resonance_id)[0]
        nucleus_name = ''.join([residue_type, str(index), nucleus_type])

        try:
            self.par['ppm_to_rads'] = (2.0 * pi * self.par['h_larmor_frq'] *
                                       xi_ratio[nucleus_type[0].upper()])
        except KeyError:
            exit("Unknown nucleus type \"{}\" for peak \"{}\" in experiment "
                 "\"{}\"".format(nucleus_type, resonance_id, experiment_name))

        self.par['_id'] = ((temperature, nucleus_name, h_larmor_frq), )

        args = (self.par[arg]
                for arg in getargspec(make_calc_observable.__wrapped__).args)
        self.calc_observable = make_calc_observable(*args)

        self.kwargs_default = {'ncyc': self.par['ncyc']}

        self.short_long_par_names = (
            ('i0', ('i0', resonance_id, experiment_name)),
            ('pb', ('pb', temperature)),
            ('kex', ('kex', temperature)),
            ('dw', ('dw', nucleus_name)),
            ('r_ixy', ('r_ixy', nucleus_name, h_larmor_frq, temperature)),
            ('dr_ixy', ('dr_ixy', nucleus_name, h_larmor_frq, temperature)),
        )

        self.fitting_parameter_names.update(
            long_name for short_name, long_name in self.short_long_par_names
            if short_name in PAR_DICT['fit'])

        self.fixed_parameter_names.update(
            long_name for short_name, long_name in self.short_long_par_names
            if short_name in PAR_DICT['fix'])
Example #11
0
    def __init__(self, val, err, par):
        BaseDataPoint.__init__(self, val, err, par, PAR_DICT['par_conv'],
                               plot_data)

        self.par['ppm_to_rads_h'] = TWO_PI * self.par['h_larmor_frq']
        self.par['ppm_to_rads_n'] = TWO_PI * self.par['h_larmor_frq'] * RATIO

        temperature = self.par['temperature']
        resonance_id = self.par['resonance_id']

        assignment = parse_assignment(resonance_id)
        index_1, residue_type_1, nucleus_type_1 = assignment[0]
        index_2, residue_type_2, nucleus_type_2 = assignment[1]
        nucleus_name_1 = residue_type_1 + str(index_1) + nucleus_type_1
        nucleus_name_2 = residue_type_2 + str(index_2) + nucleus_type_2

        self.calc_observable = calc_observable

        self.kwargs_default = {
            'ppm_to_rads_h': self.par['ppm_to_rads_h'],
            'ppm_to_rads_n': self.par['ppm_to_rads_n'],
        }

        self.short_long_par_names = (
            ('pb', ('pb', temperature)),
            ('kex', ('kex', temperature)),
            ('dw_n', ('dw', nucleus_name_1)),
            ('dw_h', ('dw', nucleus_name_2)),
        )

        self.fitting_parameter_names.update(
            long_name
            for short_name, long_name in self.short_long_par_names
            if short_name in PAR_DICT['fit']
        )

        self.fixed_parameter_names.update(
            long_name
            for short_name, long_name in self.short_long_par_names
            if short_name in PAR_DICT['fix']
        )
Example #12
0
    def __init__(self, val, err, par):
        BaseDataPoint.__init__(self, val, err, par, PAR_DICT['par_conv'],
                               plot_data)

        self.par['ppm_to_rads_h'] = TWO_PI * self.par['h_larmor_frq']
        self.par['ppm_to_rads_n'] = TWO_PI * self.par['h_larmor_frq'] * RATIO

        temperature = self.par['temperature']
        resonance_id = self.par['resonance_id']

        assignment = parse_assignment(resonance_id)
        index_1, residue_type_1, nucleus_type_1 = assignment[0]
        index_2, residue_type_2, nucleus_type_2 = assignment[1]
        nucleus_name_1 = residue_type_1 + str(index_1) + nucleus_type_1
        nucleus_name_2 = residue_type_2 + str(index_2) + nucleus_type_2

        self.calc_observable = calc_observable

        self.kwargs_default = {
            'ppm_to_rads_h': self.par['ppm_to_rads_h'],
            'ppm_to_rads_n': self.par['ppm_to_rads_n'],
        }

        self.short_long_par_names = (
            ('pb', ('pb', temperature)),
            ('kex', ('kex', temperature)),
            ('dw_n', ('dw', nucleus_name_1)),
            ('dw_h', ('dw', nucleus_name_2)),
        )

        self.fitting_parameter_names.update(
            long_name for short_name, long_name in self.short_long_par_names
            if short_name in PAR_DICT['fit'])

        self.fixed_parameter_names.update(
            long_name for short_name, long_name in self.short_long_par_names
            if short_name in PAR_DICT['fix'])