Hmmm, true!  Maybe we can add a new argument of 'zero_r1' which
defaults to False, and then set it to True in the
relax_disp.plot_disp_curves user function backend?

Regards,

Edward



On 18 August 2014 10:43, Troels Emtekær Linnet <[email protected]> wrote:
> Hi Edward.
>
> As I remember, the plotting utility will also call this code.
>
> And that that give problems with On-resonance models, but as I recall,
> the plotting of R2eff model also give problems.
>
> You can try to flip to raising an Error instead, and see the problems arise.
>
> Best
> Troels
>
> 2014-08-18 10:19 GMT+02:00 Edward d'Auvergne <[email protected]>:
>> Hi Troels,
>>
>> Would it not be better to raise a RelaxError in both cases?  Or maybe
>> make a 3rd case - setting the value to 0.0 only makes sense in the
>> on-resonance R1rho models or CPMG models.  However in both these model
>> categories, R1 is not used anyway (in the future for certain CPMG
>> numeric models, this might change when off-resonance effects are
>> modelled).  So for the M61 models, for example, these checks are
>> skipped.  A special variable for on-resonace R1rho models could be
>> created for this.  But for off-resonance R1rho models, setting R1 to
>> 0.0 is just bad!  I added this for helping in the development of the
>> code, but is it a terrible kludge that should be eliminated.  It will
>> only result in relax users making mistakes in their analyses.
>>
>> Regards,
>>
>> Edward
>>
>>
>>
>> On 4 August 2014 16:27,  <[email protected]> wrote:
>>> Author: tlinnet
>>> Date: Mon Aug  4 16:27:49 2014
>>> New Revision: 24932
>>>
>>> URL: http://svn.gna.org/viewcvs/relax?rev=24932&view=rev
>>> Log:
>>> Modified return_r1_data(), to be dependent on fitting model.
>>>
>>> sr #3135(https://gna.org/support/?3135): Optimisation of the R1 relaxation 
>>> rate for the off-resonance R1rho relaxation dispersion models.
>>>
>>> Modified:
>>>     branches/R1_fitting/specific_analyses/relax_disp/data.py
>>>
>>> Modified: branches/R1_fitting/specific_analyses/relax_disp/data.py
>>> URL: 
>>> http://svn.gna.org/viewcvs/relax/branches/R1_fitting/specific_analyses/relax_disp/data.py?rev=24932&r1=24931&r2=24932&view=diff
>>> ==============================================================================
>>> --- branches/R1_fitting/specific_analyses/relax_disp/data.py    (original)
>>> +++ branches/R1_fitting/specific_analyses/relax_disp/data.py    Mon Aug  4 
>>> 16:27:49 2014
>>> @@ -4031,65 +4031,78 @@
>>>      # Initialise the data structure.
>>>      r1 = -ones((spin_num, field_count), float64)
>>>
>>> +    # Set testing flags.
>>> +    flags = [False]*field_count
>>> +
>>>      # Check for the presence of data.
>>> -    if not hasattr(cdp, 'ri_ids'):
>>> +    if not hasattr(cdp, 'ri_ids') and spins[0].model not in  
>>> MODEL_LIST_R1RHO_FIT_R1:
>>>          warn_text = "No R1 relaxation data has been loaded.  Setting it to 
>>> 0.0.  This is essential for the proper handling of offsets in off-resonance 
>>> R1rho experiments."
>>>          error_text = "No R1 relaxation data has been loaded.  This is 
>>> essential for the proper handling of offsets in off-resonance R1rho 
>>> experiments."
>>>          if has_r1rho_exp_type():
>>> -            # Spin loop.
>>> -            for si in range(spin_num):
>>> -                # Assign spin.
>>> -                spin=spins[si]
>>> -
>>> -                # For all R1rho models using R1, raise an error, if R1 has 
>>> not been loaded.
>>> -                if spin.model in MODEL_LIST_R1RHO_W_R1:
>>> -                    raise RelaxError(error_text)
>>> -
>>> -                # For all R1rho models fitting R1, raise an error, set 
>>> value to None.
>>> -                elif spin.model in MODEL_LIST_R1RHO_FIT_R1:
>>> -                    warn_text = "No R1 relaxation data has been loaded.  
>>> Setting it to None.  This is essential for the proper handling of offsets 
>>> in off-resonance R1rho experiments."
>>> -                    warn(RelaxWarning(warn_text))
>>> -                    for mi in range(field_count):
>>> -                        r1[si, mi] = None
>>> -
>>> -                # For all models not listed in R1rho models, raise a 
>>> warning, and set 0.0 as value.
>>> -                else:
>>> -                    warn(RelaxWarning(warn_text))
>>> -                    r1[si] = 0.0 * r1[si]
>>> +            # For all R1rho models using R1, raise an error, if R1 has not 
>>> been loaded.
>>> +            if spins[0].model in MODEL_LIST_R1RHO_W_R1:
>>> +                raise RelaxError(error_text)
>>> +
>>> +            # For all models not listed in R1rho models, raise a warning, 
>>> and set 0.0 as value.
>>> +            else:
>>> +                warn(RelaxWarning(warn_text))
>>> +                r1 = 0.0 * r1
>>>
>>>          # For all non-R1rho experiments, return 0.0.
>>>          else:
>>>              r1 = 0.0 * r1
>>>
>>> -        # Return r1
>>> +        # Return the data.
>>>          return r1
>>>
>>> -    # Loop over the Rx IDs.
>>> -    flags = [False]*field_count
>>> -    for ri_id in cdp.ri_ids:
>>> -        # Only use R1 data.
>>> -        if cdp.ri_type[ri_id] != 'R1':
>>> -            continue
>>> -
>>> -        # The frequency.
>>> -        frq = cdp.spectrometer_frq[ri_id]
>>> -        mi = return_index_from_frq(frq)
>>> -
>>> -        # Flip the flag.
>>> -        flags[mi] = True
>>> -
>>> +    # For all R1rho models fitting R1.
>>> +    elif spins[0].model in MODEL_LIST_R1RHO_FIT_R1:
>>>          # Spin loop.
>>>          for si in range(spin_num):
>>> -            # FIXME:  This is a kludge - the data randomisation needs to 
>>> be incorporated into the dispersion base_data_loop() method and the 
>>> standard Monte Carlo simulation pathway used.
>>> -            # Randomise the R1 data, when required.
>>> -            if sim_index != None and (not hasattr(spins[si], 
>>> 'ri_data_sim') or ri_id not in spins[si].ri_data_sim):
>>> -                randomise_R1(spin=spins[si], ri_id=ri_id, N=cdp.sim_number)
>>> -
>>> -            # Store the data.
>>> -            if sim_index != None:
>>> -                r1[si, mi] = spins[si].ri_data_sim[ri_id][sim_index]
>>> -            else:
>>> -                r1[si, mi] = spins[si].ri_data[ri_id]
>>> +            # Assign spin:
>>> +            spin = spins[si]
>>> +
>>> +            # Loop over exp type and frq.
>>> +            for exp_type, frq, ei, mi in loop_exp_frq(return_indices=True):
>>> +                # Assign key
>>> +                r20_key = generate_r20_key(exp_type=exp_type, frq=frq)
>>> +
>>> +                # If no data is available.
>>> +                if len(spin.r1_fit) == 0:
>>> +                    r1[si, mi] = None
>>> +
>>> +                else:
>>> +                    r1[si, mi] = spin.r1_fit[r20_key]
>>> +
>>> +                # Flip the flag.
>>> +                flags[mi] = True
>>> +
>>> +    else:
>>> +        # Loop over the Rx IDs.
>>> +        for ri_id in cdp.ri_ids:
>>> +            # Only use R1 data.
>>> +            if cdp.ri_type[ri_id] != 'R1':
>>> +                continue
>>> +
>>> +            # The frequency.
>>> +            frq = cdp.spectrometer_frq[ri_id]
>>> +            mi = return_index_from_frq(frq)
>>> +
>>> +            # Flip the flag.
>>> +            flags[mi] = True
>>> +
>>> +            # Spin loop.
>>> +            for si in range(spin_num):
>>> +                # FIXME:  This is a kludge - the data randomisation needs 
>>> to be incorporated into the dispersion base_data_loop() method and the 
>>> standard Monte Carlo simulation pathway used.
>>> +                # Randomise the R1 data, when required.
>>> +                if sim_index != None and (not hasattr(spins[si], 
>>> 'ri_data_sim') or ri_id not in spins[si].ri_data_sim):
>>> +                    randomise_R1(spin=spins[si], ri_id=ri_id, 
>>> N=cdp.sim_number)
>>> +
>>> +                # Store the data.
>>> +                if sim_index != None:
>>> +                    r1[si, mi] = spins[si].ri_data_sim[ri_id][sim_index]
>>> +                else:
>>> +                    r1[si, mi] = spins[si].ri_data[ri_id]
>>>
>>>      # Check the data to prevent user mistakes.
>>>      for mi in range(field_count):
>>>
>>>
>>> _______________________________________________
>>> relax (http://www.nmr-relax.com)
>>>
>>> This is the relax-commits mailing list
>>> [email protected]
>>>
>>> To unsubscribe from this list, get a password
>>> reminder, or change your subscription options,
>>> visit the list information page at
>>> https://mail.gna.org/listinfo/relax-commits
>>
>> _______________________________________________
>> relax (http://www.nmr-relax.com)
>>
>> This is the relax-devel mailing list
>> [email protected]
>>
>> To unsubscribe from this list, get a password
>> reminder, or change your subscription options,
>> visit the list information page at
>> https://mail.gna.org/listinfo/relax-devel

_______________________________________________
relax (http://www.nmr-relax.com)

This is the relax-devel mailing list
[email protected]

To unsubscribe from this list, get a password
reminder, or change your subscription options,
visit the list information page at
https://mail.gna.org/listinfo/relax-devel

Reply via email to