Changeset 715bb83 in sasmodels for sasmodels/data.py


Ignore:
Timestamp:
Mar 17, 2016 9:34:06 AM (8 years ago)
Author:
awashington
Children:
528bd8c
Parents:
4373d62
Message:

Plot TOF sesans data with wavelength normalisation

The SESANS polarizsation goes as P(Z) = e(-C(Z) λ²) for wavelength λ and some
C(Z) proporational to our actual signal. When the wavelength and C(Z)
is close to zero, then the polarisation stands in as a good proxy for
the actual sample. On time of flight, however, it's necessary to
perform a (log P(Z))/λ² to get a real understanding of the sample.

This patch checks to see whether a data set is time of flight (by check
to see if the wavelengths are all equal) and then changes the default
plotting method to use the log over lambda square plots for time of
flight data and raw polarisation for reactor data.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sasmodels/data.py

    r7824276 r715bb83  
    440440 
    441441    if use_data or use_theory: 
     442        is_tof = np.any(data.lam!=data.lam[0]) 
    442443        if num_plots > 1: 
    443444            plt.subplot(1, num_plots, 1) 
    444445        if use_data: 
    445             plt.errorbar(data.x, data.y, yerr=data.dy) 
     446            if is_tof: 
     447                plt.errorbar(data.x, np.log(data.y)/data.lam**2, yerr=data.dy/data.y/data.lam**2) 
     448            else: 
     449                plt.errorbar(data.x, data.y, yerr=data.dy) 
    446450        if theory is not None: 
    447             plt.plot(data.x, theory, '-', hold=True) 
     451            if is_tof: 
     452                plt.plot(data.x, np.log(theory)/data.lam**2, '-', hold=True) 
     453            else: 
     454                plt.plot(data.x, theory, '-', hold=True) 
    448455        if limits is not None: 
    449456            plt.ylim(*limits) 
    450457        plt.xlabel('spin echo length (nm)') 
    451         plt.ylabel('polarization (P/P0)') 
     458        if is_tof: 
     459            plt.ylabel('(Log (P/P$_0$))/$\lambda^2$') 
     460        else: 
     461            plt.ylabel('Polarisation (P/P0)') 
    452462 
    453463    if resid is not None: 
Note: See TracChangeset for help on using the changeset viewer.