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]:
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]:
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)
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')
Out[10]:
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)
Close enough??
In [14]:
print prop_mult_result
In [15]:
print profile.surbri_err
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)