In [1]:
import numpy as np
import matplotlib.pyplot as plt

In [2]:
import radprofile as RP

In [3]:
RPFILE = 'test_profile'

In [4]:
profile = RP.get_profile( RPFILE )

In [5]:
plt.errorbar(profile.rmid, profile.surbri, xerr=0.5*(profile.rright-profile.rleft), \
             yerr=profile.surbri_err, \
             marker='', capsize=0, ls='', color='k', lw=1, alpha=0.3)
plt.loglog()
plt.xlim(0.3,300.0)

plt.title('Test that profile was read properly', color='k')


Out[5]:
<matplotlib.text.Text at 0x10c2b9e50>

In [6]:
RP.plot_profile(profile, color='b', ls='', capsize=0)
plt.loglog()
plt.xlim(0.3,300.0)

plt.title('Test radprofile.plot_profile function', color='b')


Out[6]:
<matplotlib.text.Text at 0x10c2f6390>

Test error propagation -- addition


In [7]:
ADD_ERR = 0.2

prop_add_result = np.sqrt(profile.surbri_err**2 + ADD_ERR**2)

In [8]:
profile.minus(0.5, 0.2) # subtract 0.4 +/- 0.2

In [9]:
# The printed result should be zero
print np.sum(profile.surbri_err - prop_add_result)


0.0

Try out log-min error bars


In [10]:
RP.plot_profile(profile, logmin=0.1, color='r', ls='', capsize=0)
plt.loglog()
plt.xlim(0.3,300.0)
plt.ylim(0.1,1.e4)

plt.title('Test log-min error bars', color='r')


Utilizing logmin error bars
Out[10]:
<matplotlib.text.Text at 0x10c79a7d0>

Test error propagation -- multiply and divide


In [11]:
## Multiplication
MULT_FAC = 1.0
MULT_ERR = 0.5

prop_mult_result = np.sqrt( MULT_FAC**2 * profile.surbri_err**2 + profile.surbri**2 * MULT_ERR**2 )
#prop_mult_result = profile.surbri*MULT_FAC * \
#    np.sqrt( (profile.surbri_err/profile.surbri)**2 + (MULT_ERR/MULT_FAC)**2 )

In [12]:
profile.multiply(MULT_FAC, MULT_ERR)

In [13]:
# The printed result should read zero
print np.sum(profile.surbri_err - prop_mult_result)


-1.40443212615e-14

Close enough??


In [14]:
print prop_mult_result


[  8.82956797e+02   1.69714034e+03   1.15694420e+03   6.45567335e+02
   3.13833167e+02   1.58432100e+02   9.93252224e+01   5.86590579e+01
   3.20940876e+01   2.04300922e+01   1.35852844e+01   7.45040012e+00
   4.37159453e+00   3.43615240e+00   2.25467930e+00   1.33152423e+00
   8.43097181e-01   5.10306774e-01   2.99473383e-01   9.33753105e-02]

In [15]:
print profile.surbri_err


[  8.82956797e+02   1.69714034e+03   1.15694420e+03   6.45567335e+02
   3.13833167e+02   1.58432100e+02   9.93252224e+01   5.86590579e+01
   3.20940876e+01   2.04300922e+01   1.35852844e+01   7.45040012e+00
   4.37159453e+00   3.43615240e+00   2.25467930e+00   1.33152423e+00
   8.43097181e-01   5.10306774e-01   2.99473383e-01   9.33753105e-02]

Yes, looks like a numerical thing


In [16]:
## Division
DIV_FAC = 1.0
DIV_ERR = 0.1

prop_div_result = np.sqrt(profile.surbri_err**2 + (profile.surbri/DIV_FAC)**2*DIV_ERR**2) / DIV_FAC

In [17]:
profile.divide(DIV_FAC, DIV_ERR)

In [18]:
# The printed result should be zero
print np.sum(profile.surbri_err - prop_div_result)


0.0