fix global variables
This commit is contained in:
@@ -35,7 +35,7 @@ def main(target=None, proposal_id=None, infiles=None, output_dir="./data", crop=
|
||||
# Background estimation
|
||||
error_sub_type = 'freedman-diaconis' # sqrt, sturges, rice, scott, freedman-diaconis (default) or shape (example (51, 51))
|
||||
subtract_error = 0.50
|
||||
display_bkg = True
|
||||
display_bkg = False
|
||||
|
||||
# Data binning
|
||||
rebin = True
|
||||
|
||||
@@ -54,7 +54,6 @@ from astropy.wcs import WCS
|
||||
from astropy.io import fits
|
||||
from astropy.coordinates import SkyCoord
|
||||
from scipy.ndimage import zoom as sc_zoom
|
||||
from lib.fits import save_Stokes
|
||||
from lib.utils import rot2D, princ_angle, sci_not
|
||||
|
||||
|
||||
@@ -416,7 +415,7 @@ def polarisation_map(Stokes, data_mask=None, rectangle=None, SNRp_cut=3., SNRi_c
|
||||
X, Y = np.meshgrid(np.arange(stkI.data.shape[1]), np.arange(stkI.data.shape[0]))
|
||||
U, V = poldata*np.cos(np.pi/2.+pangdata*np.pi/180.), poldata*np.sin(np.pi/2.+pangdata*np.pi/180.)
|
||||
ax.quiver(X[::step_vec, ::step_vec], Y[::step_vec, ::step_vec], U[::step_vec, ::step_vec], V[::step_vec, ::step_vec], units='xy', angles='uv',
|
||||
scale=1./vec_scale, scale_units='xy', pivot='mid', headwidth=0., headlength=0., headaxislength=0., width=0.1, linewidth=0.5, color='w', edgecolor='k')
|
||||
scale=1./vec_scale, scale_units='xy', pivot='mid', headwidth=0., headlength=0., headaxislength=0., width=0.2, linewidth=0.3, color='w', edgecolor='k')
|
||||
pol_sc = AnchoredSizeBar(ax.transData, vec_scale, r"$P$= 100 %", 4, pad=0.5, sep=5, borderpad=0.5, frameon=False, size_vertical=0.005, color='w')
|
||||
|
||||
ax.add_artist(pol_sc)
|
||||
@@ -448,7 +447,7 @@ def polarisation_map(Stokes, data_mask=None, rectangle=None, SNRp_cut=3., SNRi_c
|
||||
if savename is not None:
|
||||
if savename[-4:] not in ['.png', '.jpg', '.pdf']:
|
||||
savename += '.pdf'
|
||||
fig.savefig(path_join(plots_folder, savename), bbox_inches='tight', dpi=300)
|
||||
fig.savefig(path_join(plots_folder, savename), bbox_inches='tight', dpi=200)
|
||||
|
||||
plt.show()
|
||||
return fig, ax
|
||||
|
||||
@@ -1101,16 +1101,16 @@ def compute_Stokes(data_array, error_array, data_mask, headers, FWHM=None, scale
|
||||
same_filt3 = np.array([filt3 == header['filtnam3'] for header in headers]).all()
|
||||
same_filt4 = np.array([filt4 == header['filtnam4'] for header in headers]).all()
|
||||
if (same_filt2 and same_filt3 and same_filt4):
|
||||
transmit2, transmit3, transmit4 = globals["trans2"][filt2.lower()], globals["trans3"][filt3.lower()], globals["trans4"][filt4.lower()]
|
||||
transmit2, transmit3, transmit4 = globals()["trans2"][filt2.lower()], globals()["trans3"][filt3.lower()], globals()["trans4"][filt4.lower()]
|
||||
else:
|
||||
print("WARNING : All images in data_array are not from the same \
|
||||
band filter, the limiting transmittance will be taken.")
|
||||
transmit2 = np.min([globals["trans2"][header['filtnam2'].lower()] for header in headers])
|
||||
transmit3 = np.min([globals["trans3"][header['filtnam3'].lower()] for header in headers])
|
||||
transmit4 = np.min([globals["trans4"][header['filtnam4'].lower()] for header in headers])
|
||||
transmit2 = np.min([globals()["trans2"][header['filtnam2'].lower()] for header in headers])
|
||||
transmit3 = np.min([globals()["trans3"][header['filtnam3'].lower()] for header in headers])
|
||||
transmit4 = np.min([globals()["trans4"][header['filtnam4'].lower()] for header in headers])
|
||||
if transmitcorr:
|
||||
transmit *= transmit2*transmit3*transmit4
|
||||
pol_eff = np.array([globals["pol_efficiency"]['pol0'], globals["pol_efficiency"]['pol60'], globals["pol_efficiency"]['pol120']])
|
||||
pol_eff = np.array([globals()["pol_efficiency"]['pol0'], globals()["pol_efficiency"]['pol60'], globals()["pol_efficiency"]['pol120']])
|
||||
|
||||
# Calculating correction factor
|
||||
corr = np.array([1.0*h['photflam']/h['exptime'] for h in pol_headers])*pol_headers[0]['exptime']/pol_headers[0]['photflam']
|
||||
@@ -1122,11 +1122,11 @@ def compute_Stokes(data_array, error_array, data_mask, headers, FWHM=None, scale
|
||||
coeff_stokes = np.zeros((3, 3))
|
||||
# Coefficients linking each polarizer flux to each Stokes parameter
|
||||
for i in range(3):
|
||||
coeff_stokes[0, i] = pol_eff[(i+1) % 3]*pol_eff[(i+2) % 3]*np.sin(-2.*globals["theta"][(i+1) % 3]+2.*globals["theta"][(i+2) % 3])*2./transmit[i]
|
||||
coeff_stokes[1, i] = (-pol_eff[(i+1) % 3]*np.sin(2.*globals["theta"][(i+1) % 3]) +
|
||||
pol_eff[(i+2) % 3]*np.sin(2.*globals["theta"][(i+2) % 3]))*2./transmit[i]
|
||||
coeff_stokes[2, i] = (pol_eff[(i+1) % 3]*np.cos(2.*globals["theta"][(i+1) % 3]) -
|
||||
pol_eff[(i+2) % 3]*np.cos(2.*globals["theta"][(i+2) % 3]))*2./transmit[i]
|
||||
coeff_stokes[0, i] = pol_eff[(i+1) % 3]*pol_eff[(i+2) % 3]*np.sin(-2.*globals()["theta"][(i+1) % 3]+2.*globals()["theta"][(i+2) % 3])*2./transmit[i]
|
||||
coeff_stokes[1, i] = (-pol_eff[(i+1) % 3]*np.sin(2.*globals()["theta"][(i+1) % 3]) +
|
||||
pol_eff[(i+2) % 3]*np.sin(2.*globals()["theta"][(i+2) % 3]))*2./transmit[i]
|
||||
coeff_stokes[2, i] = (pol_eff[(i+1) % 3]*np.cos(2.*globals()["theta"][(i+1) % 3]) -
|
||||
pol_eff[(i+2) % 3]*np.cos(2.*globals()["theta"][(i+2) % 3]))*2./transmit[i]
|
||||
|
||||
# Normalization parameter for Stokes parameters computation
|
||||
A = (coeff_stokes[0, :]*transmit/2.).sum()
|
||||
|
||||
Reference in New Issue
Block a user