propagate options to multiple reductions, default SNRi_cut to 3
This commit is contained in:
@@ -35,11 +35,11 @@ def main(target=None, proposal_id=None, infiles=None, output_dir="./data", crop=
|
|||||||
# Background estimation
|
# Background estimation
|
||||||
error_sub_type = 'freedman-diaconis' # sqrt, sturges, rice, scott, freedman-diaconis (default) or shape (example (51, 51))
|
error_sub_type = 'freedman-diaconis' # sqrt, sturges, rice, scott, freedman-diaconis (default) or shape (example (51, 51))
|
||||||
subtract_error = 0.50
|
subtract_error = 0.50
|
||||||
display_bkg = False
|
display_bkg = True
|
||||||
|
|
||||||
# Data binning
|
# Data binning
|
||||||
rebin = True
|
rebin = True
|
||||||
pxsize = 0.10
|
pxsize = 0.05
|
||||||
px_scale = 'arcsec' # pixel, arcsec or full
|
px_scale = 'arcsec' # pixel, arcsec or full
|
||||||
rebin_operation = 'sum' # sum or average
|
rebin_operation = 'sum' # sum or average
|
||||||
|
|
||||||
@@ -50,7 +50,7 @@ def main(target=None, proposal_id=None, infiles=None, output_dir="./data", crop=
|
|||||||
|
|
||||||
# Smoothing
|
# Smoothing
|
||||||
smoothing_function = 'combine' # gaussian_after, weighted_gaussian_after, gaussian, weighted_gaussian or combine
|
smoothing_function = 'combine' # gaussian_after, weighted_gaussian_after, gaussian, weighted_gaussian or combine
|
||||||
smoothing_FWHM = 0.20 # If None, no smoothing is done
|
smoothing_FWHM = 0.075 # If None, no smoothing is done
|
||||||
smoothing_scale = 'arcsec' # pixel or arcsec
|
smoothing_scale = 'arcsec' # pixel or arcsec
|
||||||
|
|
||||||
# Rotation
|
# Rotation
|
||||||
@@ -58,7 +58,7 @@ def main(target=None, proposal_id=None, infiles=None, output_dir="./data", crop=
|
|||||||
rotate_stokes = True
|
rotate_stokes = True
|
||||||
|
|
||||||
# Polarization map output
|
# Polarization map output
|
||||||
SNRp_cut = 3. # P measurments with SNR>3
|
SNRp_cut = 5. # P measurments with SNR>3
|
||||||
SNRi_cut = 3. # I measurments with SNR>30, which implies an uncertainty in P of 4.7%.
|
SNRi_cut = 3. # I measurments with SNR>30, which implies an uncertainty in P of 4.7%.
|
||||||
flux_lim = None # lowest and highest flux displayed on plot, defaults to bkg and maximum in cut if None
|
flux_lim = None # lowest and highest flux displayed on plot, defaults to bkg and maximum in cut if None
|
||||||
vec_scale = 3
|
vec_scale = 3
|
||||||
@@ -78,7 +78,7 @@ def main(target=None, proposal_id=None, infiles=None, output_dir="./data", crop=
|
|||||||
target, products = retrieve_products(target, proposal_id, output_dir=output_dir)
|
target, products = retrieve_products(target, proposal_id, output_dir=output_dir)
|
||||||
prod = products.pop()
|
prod = products.pop()
|
||||||
for prods in products:
|
for prods in products:
|
||||||
main(target=target, infiles=["/".join(pr) for pr in prods], output_dir=output_dir)
|
main(target=target, infiles=["/".join(pr) for pr in prods], output_dir=output_dir, crop=crop, interactive=interactive)
|
||||||
data_folder = prod[0][0]
|
data_folder = prod[0][0]
|
||||||
try:
|
try:
|
||||||
plots_folder = data_folder.replace("data", "plots")
|
plots_folder = data_folder.replace("data", "plots")
|
||||||
|
|||||||
@@ -200,7 +200,7 @@ def plot_Stokes(Stokes, savename=None, plots_folder=""):
|
|||||||
return 0
|
return 0
|
||||||
|
|
||||||
|
|
||||||
def polarisation_map(Stokes, data_mask=None, rectangle=None, SNRp_cut=3., SNRi_cut=30.,
|
def polarisation_map(Stokes, data_mask=None, rectangle=None, SNRp_cut=3., SNRi_cut=3.,
|
||||||
flux_lim=None, step_vec=1, vec_scale=2., savename=None, plots_folder="", display="default"):
|
flux_lim=None, step_vec=1, vec_scale=2., savename=None, plots_folder="", display="default"):
|
||||||
"""
|
"""
|
||||||
Plots polarisation map from Stokes HDUList.
|
Plots polarisation map from Stokes HDUList.
|
||||||
@@ -673,7 +673,7 @@ class overplot_radio(align_maps):
|
|||||||
Inherit from class align_maps in order to get the same WCS on both maps.
|
Inherit from class align_maps in order to get the same WCS on both maps.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def overplot(self, levels=None, SNRp_cut=3., SNRi_cut=30., vec_scale=2, savename=None, **kwargs):
|
def overplot(self, levels=None, SNRp_cut=3., SNRi_cut=3., vec_scale=2, savename=None, **kwargs):
|
||||||
self.Stokes_UV = self.map
|
self.Stokes_UV = self.map
|
||||||
self.wcs_UV = self.map_wcs
|
self.wcs_UV = self.map_wcs
|
||||||
# Get Data
|
# Get Data
|
||||||
@@ -780,7 +780,7 @@ class overplot_radio(align_maps):
|
|||||||
|
|
||||||
self.fig_overplot.canvas.draw()
|
self.fig_overplot.canvas.draw()
|
||||||
|
|
||||||
def plot(self, levels=None, SNRp_cut=3., SNRi_cut=30., savename=None, **kwargs) -> None:
|
def plot(self, levels=None, SNRp_cut=3., SNRi_cut=3., savename=None, **kwargs) -> None:
|
||||||
while not self.aligned:
|
while not self.aligned:
|
||||||
self.align()
|
self.align()
|
||||||
self.overplot(levels=levels, SNRp_cut=SNRp_cut, SNRi_cut=SNRi_cut, savename=savename, **kwargs)
|
self.overplot(levels=levels, SNRp_cut=SNRp_cut, SNRi_cut=SNRi_cut, savename=savename, **kwargs)
|
||||||
@@ -793,7 +793,7 @@ class overplot_chandra(align_maps):
|
|||||||
Inherit from class align_maps in order to get the same WCS on both maps.
|
Inherit from class align_maps in order to get the same WCS on both maps.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def overplot(self, levels=None, SNRp_cut=3., SNRi_cut=30., vec_scale=2, zoom=1, savename=None, **kwargs):
|
def overplot(self, levels=None, SNRp_cut=3., SNRi_cut=3., vec_scale=2, zoom=1, savename=None, **kwargs):
|
||||||
self.Stokes_UV = self.map
|
self.Stokes_UV = self.map
|
||||||
self.wcs_UV = self.map_wcs
|
self.wcs_UV = self.map_wcs
|
||||||
# Get Data
|
# Get Data
|
||||||
@@ -899,7 +899,7 @@ class overplot_chandra(align_maps):
|
|||||||
|
|
||||||
self.fig_overplot.canvas.draw()
|
self.fig_overplot.canvas.draw()
|
||||||
|
|
||||||
def plot(self, levels=None, SNRp_cut=3., SNRi_cut=30., zoom=1, savename=None, **kwargs) -> None:
|
def plot(self, levels=None, SNRp_cut=3., SNRi_cut=3., zoom=1, savename=None, **kwargs) -> None:
|
||||||
while not self.aligned:
|
while not self.aligned:
|
||||||
self.align()
|
self.align()
|
||||||
self.overplot(levels=levels, SNRp_cut=SNRp_cut, SNRi_cut=SNRi_cut, zoom=zoom, savename=savename, **kwargs)
|
self.overplot(levels=levels, SNRp_cut=SNRp_cut, SNRi_cut=SNRi_cut, zoom=zoom, savename=savename, **kwargs)
|
||||||
@@ -912,7 +912,7 @@ class overplot_pol(align_maps):
|
|||||||
Inherit from class align_maps in order to get the same WCS on both maps.
|
Inherit from class align_maps in order to get the same WCS on both maps.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def overplot(self, levels=None, SNRp_cut=3., SNRi_cut=30., vec_scale=2., savename=None, **kwargs):
|
def overplot(self, levels=None, SNRp_cut=3., SNRi_cut=3., vec_scale=2., savename=None, **kwargs):
|
||||||
self.Stokes_UV = self.map
|
self.Stokes_UV = self.map
|
||||||
self.wcs_UV = self.map_wcs
|
self.wcs_UV = self.map_wcs
|
||||||
# Get Data
|
# Get Data
|
||||||
@@ -1019,7 +1019,7 @@ class overplot_pol(align_maps):
|
|||||||
|
|
||||||
self.fig_overplot.canvas.draw()
|
self.fig_overplot.canvas.draw()
|
||||||
|
|
||||||
def plot(self, levels=None, SNRp_cut=3., SNRi_cut=30., vec_scale=2., savename=None, **kwargs) -> None:
|
def plot(self, levels=None, SNRp_cut=3., SNRi_cut=3., vec_scale=2., savename=None, **kwargs) -> None:
|
||||||
while not self.aligned:
|
while not self.aligned:
|
||||||
self.align()
|
self.align()
|
||||||
self.overplot(levels=levels, SNRp_cut=SNRp_cut, SNRi_cut=SNRi_cut, vec_scale=vec_scale, savename=savename, **kwargs)
|
self.overplot(levels=levels, SNRp_cut=SNRp_cut, SNRi_cut=SNRi_cut, vec_scale=vec_scale, savename=savename, **kwargs)
|
||||||
@@ -1059,7 +1059,7 @@ class align_pol(object):
|
|||||||
|
|
||||||
self.kwargs = kwargs
|
self.kwargs = kwargs
|
||||||
|
|
||||||
def single_plot(self, curr_map, wcs, v_lim=None, ax_lim=None, SNRp_cut=3., SNRi_cut=30., savename=None, **kwargs):
|
def single_plot(self, curr_map, wcs, v_lim=None, ax_lim=None, SNRp_cut=3., SNRi_cut=3., savename=None, **kwargs):
|
||||||
# Get data
|
# Get data
|
||||||
stkI = curr_map['I_STOKES'].data
|
stkI = curr_map['I_STOKES'].data
|
||||||
stk_cov = curr_map['IQU_COV_MATRIX'].data
|
stk_cov = curr_map['IQU_COV_MATRIX'].data
|
||||||
@@ -1150,7 +1150,7 @@ class align_pol(object):
|
|||||||
self.wcs, self.wcs_other[i] = curr_align.align()
|
self.wcs, self.wcs_other[i] = curr_align.align()
|
||||||
self.aligned[i] = curr_align.aligned
|
self.aligned[i] = curr_align.aligned
|
||||||
|
|
||||||
def plot(self, SNRp_cut=3., SNRi_cut=30., savename=None, **kwargs):
|
def plot(self, SNRp_cut=3., SNRi_cut=3., savename=None, **kwargs):
|
||||||
while not self.aligned.all():
|
while not self.aligned.all():
|
||||||
self.align()
|
self.align()
|
||||||
eps = 1e-35
|
eps = 1e-35
|
||||||
@@ -1737,7 +1737,7 @@ class pol_map(object):
|
|||||||
Class to interactively study polarisation maps.
|
Class to interactively study polarisation maps.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def __init__(self, Stokes, SNRp_cut=3., SNRi_cut=30., flux_lim=None, selection=None):
|
def __init__(self, Stokes, SNRp_cut=3., SNRi_cut=3., flux_lim=None, selection=None):
|
||||||
|
|
||||||
if isinstance(Stokes, str):
|
if isinstance(Stokes, str):
|
||||||
Stokes = fits.open(Stokes)
|
Stokes = fits.open(Stokes)
|
||||||
|
|||||||
@@ -952,6 +952,10 @@ def polarizer_avg(data_array, error_array, data_mask, headers, FWHM=None, scale=
|
|||||||
err60_array = error_array[is_pol60]
|
err60_array = error_array[is_pol60]
|
||||||
err120_array = error_array[is_pol120]
|
err120_array = error_array[is_pol120]
|
||||||
|
|
||||||
|
# For a single observation, combination amount to a weighted gaussian
|
||||||
|
if np.max([is_pol0.sum(), is_pol60.sum(), is_pol120.sum()]) == 1 and smoothing.lower() in ['combine', 'combining']:
|
||||||
|
smoothing = 'weighted_gaussian'
|
||||||
|
|
||||||
if (FWHM is not None) and (smoothing.lower() in ['combine', 'combining']):
|
if (FWHM is not None) and (smoothing.lower() in ['combine', 'combining']):
|
||||||
# Smooth by combining each polarizer images
|
# Smooth by combining each polarizer images
|
||||||
pol0, err0 = smooth_data(pol0_array, err0_array, data_mask, headers0, FWHM=FWHM, scale=scale, smoothing=smoothing)
|
pol0, err0 = smooth_data(pol0_array, err0_array, data_mask, headers0, FWHM=FWHM, scale=scale, smoothing=smoothing)
|
||||||
|
|||||||
Reference in New Issue
Block a user