Skip to content

Commit a814f2a

Browse files
committed
^^ no cbar units for non IQUV dynspec
1 parent 5050c0d commit a814f2a

File tree

1 file changed

+60
-52
lines changed

1 file changed

+60
-52
lines changed

inspect_dynspec/inspect_dynspec.py

Lines changed: 60 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -102,8 +102,8 @@ def inspect_dynspec(
102102
"Stokes Q",
103103
"Stokes U",
104104
"Stokes V",
105-
"Circular Polarisation",
106-
"Linear Polarisation",
105+
"Circular Polarisation Fraction",
106+
"Linear Polarisation Fraction",
107107
"Total Polarised Power",
108108
"RM Synthesis",
109109
]
@@ -331,13 +331,13 @@ def inspect_dynspec(
331331
)
332332

333333
"""
334-
################### OPTIONALLY CALCULATE CIRCULAR POLARISATION ########################
334+
################### OPTIONALLY CALCULATE CIRCULAR POLARISATION FRACTION ########################
335335
"""
336336
if calc_circular_pol:
337337
# check that both I and V stokes parameters were specified:
338338
if 0 not in stokes_slice or 3 not in stokes_slice:
339339
LOGGER.warning(
340-
"To calculate circular polarisation, both Stokes I and V must be specified, skipping..."
340+
"To calculate circular polarisation fraction, both Stokes I and V must be specified, skipping..."
341341
)
342342
else:
343343
circ_data_e_a_denoised = calc_circ_polarisation(
@@ -355,13 +355,13 @@ def inspect_dynspec(
355355
)
356356

357357
"""
358-
################### OPTIONALLY CALCULATING LINEAR POLARISATION ##########################
358+
################### OPTIONALLY CALCULATING LINEAR POLARISATION FRACTION ##########################
359359
"""
360360
if calc_linear_pol:
361361
# check that I Q and U stokes parameters were specified:
362362
if 0 not in stokes_slice or 1 not in stokes_slice or 2 not in stokes_slice:
363363
LOGGER.warning(
364-
"To calculate linear polarisation, Stokes I, Q and U must be specified, skipping..."
364+
"To calculate linear polarisation fraction, Stokes I, Q and U must be specified, skipping..."
365365
)
366366
else:
367367
linear_data_e_a_denoised = calc_linear_polarisation(
@@ -437,52 +437,60 @@ def inspect_dynspec(
437437
cwgt
438438
) # i.e sSNR = sdata / sstd = sdata * sqrt(wgt)
439439

440+
"""
441+
################### OPTIONALLY CALCULATING RM SYNTHESIS ##########################
442+
"""
440443
if calc_rm_synth is not None:
441-
smoothed_target_data_var_denoised_nan = (
442-
smoothed_target_data_var_normalised * nanmask
443-
)
444-
rm_synth_cdata, phi_range = calc_rm_synthesis(
445-
smoothed_target_data_var_denoised_nan,
446-
target_header,
447-
mask,
448-
stokes_slice,
449-
calc_rm_synth[0],
450-
calc_rm_synth[1],
451-
calc_rm_synth[2],
452-
)
453-
rm_synth_data = np.abs(rm_synth_cdata)
454-
rm_synth_title = (
455-
""
456-
if plot_for_paper
457-
else f"RM Synthesis for {name_str}\nat {coord_str} with kernel {kern_str}"
458-
)
459-
rmsynth_plot_name = os.path.join(
460-
output_dir,
461-
f"{name_str.replace(' ', '_')}_{round(target_header['RA_RAD'],ndigits=2)}_{round(target_header['DEC_RAD'],ndigits=2)}_rm_synth_{int(nu_delta)}MHz_{int(t_delta)}s.png",
462-
)
463-
vminmax = (
464-
None,
465-
std_scale * np.nanstd(rm_synth_data[:, :]),
466-
)
467-
plot_smoothed_data(
468-
smoothed_data=rm_synth_data,
469-
nu_delta=nu_delta,
470-
t_delta=t_delta,
471-
output=rmsynth_plot_name,
472-
t_ticks=t_ticks,
473-
nu_ticks=phi_range,
474-
vminmax=vminmax,
475-
vcenter=0,
476-
dpi=dpi,
477-
cmap=cmap,
478-
title=rm_synth_title,
479-
cbar_label="mJy",
480-
figsize=figsize,
481-
ylabel="$\\phi$ (rad/$\mu\\text{m}^2$) $\\times 10^{-3}$",
482-
plot_ellipse=False,
483-
return_plot=False,
484-
)
485-
LOGGER.info(f"Wrote rm synth smoothed plot to {rmsynth_plot_name}")
444+
if 1 not in stokes_slice or 2 not in stokes_slice:
445+
LOGGER.warning(
446+
"To calculate rm synthesis, Stokes Q and U must be specified, skipping..."
447+
)
448+
else:
449+
smoothed_target_data_var_denoised_nan = (
450+
smoothed_target_data_var_normalised * nanmask
451+
)
452+
rm_synth_cdata, phi_range = calc_rm_synthesis(
453+
smoothed_target_data_var_denoised_nan,
454+
target_header,
455+
mask,
456+
stokes_slice,
457+
calc_rm_synth[0],
458+
calc_rm_synth[1],
459+
calc_rm_synth[2],
460+
)
461+
rm_synth_data = np.abs(rm_synth_cdata)
462+
rm_synth_title = (
463+
""
464+
if plot_for_paper
465+
else f"RM Synthesis for {name_str}\nat {coord_str} with kernel {kern_str}"
466+
)
467+
rmsynth_plot_name = os.path.join(
468+
output_dir,
469+
f"{name_str.replace(' ', '_')}_{round(target_header['RA_RAD'],ndigits=2)}_{round(target_header['DEC_RAD'],ndigits=2)}_rm_synth_{int(nu_delta)}MHz_{int(t_delta)}s.png",
470+
)
471+
vminmax = (
472+
None,
473+
std_scale * np.nanstd(rm_synth_data[:, :]),
474+
)
475+
plot_smoothed_data(
476+
smoothed_data=rm_synth_data,
477+
nu_delta=nu_delta,
478+
t_delta=t_delta,
479+
output=rmsynth_plot_name,
480+
t_ticks=t_ticks,
481+
nu_ticks=phi_range,
482+
vminmax=vminmax,
483+
vcenter=0,
484+
dpi=dpi,
485+
cmap=cmap,
486+
title=rm_synth_title,
487+
cbar_label="",
488+
figsize=figsize,
489+
ylabel="$\\phi$ (rad/$\mu\\text{m}^2$) $\\times 10^{-3}$",
490+
plot_ellipse=False,
491+
return_plot=False,
492+
)
493+
LOGGER.info(f"Wrote rm synth smoothed plot to {rmsynth_plot_name}")
486494

487495
if debug:
488496
# smooth target data
@@ -546,7 +554,7 @@ def inspect_dynspec(
546554
dpi=dpi,
547555
cmap=cmap,
548556
title=sdata_title,
549-
cbar_label="mJy",
557+
cbar_label="mJy" if stx_idx in [0, 1, 2, 3] else "",
550558
figsize=figsize,
551559
return_plot=False,
552560
)

0 commit comments

Comments
 (0)