Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
LOFAR
Manage
Activity
Members
Labels
Plan
Issues
Wiki
Jira issues
Open Jira
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Code review analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
RadioObservatory
LOFAR
Commits
8e4b2944
Commit
8e4b2944
authored
5 years ago
by
Mattia Mancini
Browse files
Options
Downloads
Patches
Plain Diff
SSB-47
: improved plot look and feel
parent
43a1daa2
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!44
Merge back holography to master
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
CAL/CalibrationProcessing/lib/processing/inspect.py
+55
-16
55 additions, 16 deletions
CAL/CalibrationProcessing/lib/processing/inspect.py
with
55 additions
and
16 deletions
CAL/CalibrationProcessing/lib/processing/inspect.py
+
55
−
16
View file @
8e4b2944
...
...
@@ -44,7 +44,7 @@ def dft2_numba(x: numpy.ndarray,
v
:
numpy
.
ndarray
,
fourier_sign
):
arg_factor
=
(
fourier_sign
*
2
*
numpy
.
pi
*
freq_hz
/
light_speed
)
arg_factor
=
(
fourier_sign
*
2
.
*
numpy
.
pi
*
freq_hz
/
light_speed
)
result
=
numpy
.
zeros
((
len
(
x
),
len
(
y
)),
dtype
=
numpy
.
complex64
)
x_down
=
x
.
astype
(
numpy
.
float32
)
y_down
=
y
.
astype
(
numpy
.
float32
)
...
...
@@ -68,7 +68,7 @@ def dft2_numba_loop(x, y, l, m, v, arg_factor, result):
phases
[
i
,
j
,
k
]
=
arg_factor
*
(
x
[
j
]
*
l
[
k
]
+
y
[
i
]
*
m
[
k
])
real_factor
=
numpy
.
cos
(
phases
)
imag_factor
=
numpy
.
cos
(
phases
)
imag_factor
=
numpy
.
sin
(
phases
)
for
i
in
numba
.
prange
(
y_len
):
for
j
in
range
(
x_len
):
...
...
@@ -100,9 +100,9 @@ def complex_value_to_color(complex_array: numpy.ndarray, abs_max=None, abs_min=N
color_map
=
cm
.
get_cmap
(
'
hsv
'
)
colors
=
color_map
(
phase_array
)
colors
[:,
0
]
*
=
norm_abs_array
colors
[:,
1
]
*=
norm_abs_array
colors
[:,
2
]
*=
norm_abs_array
colors
[:,
3
]
=
norm_abs_array
#
colors[:, 1] *= norm_abs_array
#
colors[:, 2] *= norm_abs_array
old_shape
=
list
(
complex_array
.
shape
)
new_shape
=
old_shape
+
[
4
]
...
...
@@ -166,13 +166,31 @@ def _dft_visibilities_lm_plane(l, m, v, sampling, frequency, array_size):
return
fft_vis
def
_plot_complex_image
(
canvas
,
image
,
extent
=
None
,
log
=
False
):
color_mapped_vis
=
complex_value_to_color
(
image
,
log
=
log
)
def
_plot_complex_image
(
canvas
,
image
,
extent
=
None
,
log
=
False
,
abs_max
=
None
,
abs_min
=
None
):
color_mapped_vis
=
complex_value_to_color
(
image
,
log
=
log
,
abs_max
=
abs_max
,
abs_min
=
abs_min
)
canvas
.
imshow
(
color_mapped_vis
,
extent
=
extent
,
origin
=
'
lower
'
,
resample
=
True
)
def
_plot_station_averaged_visibilities_lm_plane_single_frequency_scatter
(
figure
:
Figure
,
l_m_v
):
l
,
m
,
v
,
flagged
=
list
(
zip
(
*
l_m_v
))
for
index
,
polarization
in
enumerate
((
'
XX
'
,
'
XY
'
,
'
YX
'
,
'
YY
'
)):
v_pol
=
numpy
.
array
(
list
(
map
(
lambda
x
:
x
[
polarization
],
v
)))
canvas
=
figure
.
add_subplot
(
2
,
2
,
index
+
1
)
canvas
.
set_title
(
polarization
)
canvas
.
set_xlabel
(
'
l
'
)
canvas
.
set_ylabel
(
'
m
'
)
canvas
.
set_xlim
(
-
1
,
1
)
canvas
.
set_ylim
(
-
1
,
1
)
plt
.
minorticks_on
()
v_intensity
=
numpy
.
abs
(
v_pol
)
canvas
.
scatter
(
l
,
m
,
c
=
v_intensity
,
s
=
5
,
vmin
=
0
,
vmax
=
1
,
cmap
=
'
viridis
'
)
def
_plot_station_averaged_visibilities_lm_plane_single_frequency
(
figure
:
Figure
,
l_m_v
,
sampling
=
512
):
sampling
=
512
,
abs_min
=
None
,
abs_max
=
None
):
l
,
m
,
v
,
flagged
=
list
(
zip
(
*
l_m_v
))
for
index
,
polarization
in
enumerate
((
'
XX
'
,
'
XY
'
,
'
YX
'
,
'
YY
'
)):
...
...
@@ -185,12 +203,14 @@ def _plot_station_averaged_visibilities_lm_plane_single_frequency(figure: Figure
canvas
.
set_ylim
(
-
1
,
1
)
vis
=
_grid_visibilities_lm_plane
(
l
,
m
,
v_pol
,
sampling
)
_plot_complex_image
(
canvas
,
vis
,
extent
=
[
-
1
,
1
,
-
1
,
1
],
log
=
True
)
_plot_complex_image
(
canvas
,
vis
,
extent
=
[
-
1
,
1
,
-
1
,
1
],
log
=
True
,
abs_min
=
abs_min
,
abs_max
=
abs_max
)
def
_plot_station_averaged_visibilities_station_plane_single_frequency
(
figure
:
Figure
,
l_m_v
,
frequency
:
float
,
sampling
=
50
):
sampling
=
50
,
abs_min
=
None
,
abs_max
=
None
):
l
,
m
,
v
,
flagged
=
list
(
zip
(
*
l_m_v
))
for
index
,
polarization
in
enumerate
((
'
XX
'
,
'
XY
'
,
'
YX
'
,
'
YY
'
)):
...
...
@@ -209,12 +229,15 @@ def _plot_station_averaged_visibilities_station_plane_single_frequency(figure: F
canvas
.
set_xlabel
(
'
x [m]
'
)
canvas
.
set_ylabel
(
'
y [m]
'
)
color_mapped_fft
=
complex_value_to_color
(
fft_vis
,
log
=
False
)
canvas
.
imshow
(
color_mapped_fft
[:,
::
-
1
],
origin
=
'
lower
'
,
extent
=
[
-
1
*
array_size
,
color_mapped_fft
=
complex_value_to_color
(
fft_vis
,
log
=
False
,
abs_min
=
abs_min
,
abs_max
=
abs_max
)
plt
.
minorticks_on
()
canvas
.
imshow
(
color_mapped_fft
[::,
::],
origin
=
'
lower
'
,
extent
=
[
-
1
*
array_size
,
1
*
array_size
,
-
1
*
array_size
,
1
*
array_size
],
resample
=
True
)
resample
=
True
)
canvas
.
set_title
(
polarization
)
...
...
@@ -243,11 +266,23 @@ def _plot_station_averaged_visibilities_lm_plane_datatable(data_table: __DATATAB
DEFAULT_FORMAT
)
figure
=
plt
.
figure
(
figure_title
)
figure
.
suptitle
(
figure_title
.
replace
(
'
_
'
,
'
'
))
_plot_station_averaged_visibilities_lm_plane_single_frequency
(
figure
,
l_m_v
)
if
save_to
:
__save_figure_to_path
(
figure
,
save_to
,
figure_title
)
plt
.
close
(
figure
)
figure_title
=
'
ABS_VISIBILITIES_{}-{:4.2f}_MHz.{}
'
.
format
(
station
,
frequency_in_mhz
,
DEFAULT_FORMAT
)
figure
=
plt
.
figure
(
figure_title
)
figure
.
suptitle
(
figure_title
.
replace
(
'
_
'
,
'
'
))
_plot_station_averaged_visibilities_lm_plane_single_frequency_scatter
(
figure
,
l_m_v
)
if
save_to
:
__save_figure_to_path
(
figure
,
save_to
,
figure_title
)
plt
.
close
(
figure
)
...
...
@@ -292,7 +327,9 @@ def _plot_gains_as_frequency(data_table: __DATATABLE_TYPE, target_station, save_
canvas
=
figure
.
add_subplot
(
2
,
2
,
polarization_index
+
1
)
canvas
.
set_title
(
polarization
)
canvas
.
set_ylim
(
-
numpy
.
pi
,
numpy
.
pi
)
canvas
.
set_xlabel
(
'
frequency (MHz)
'
)
canvas
.
set_ylabel
(
'
Phase
'
)
plt
.
minorticks_on
()
canvas
.
plot
(
frequencies
/
__MHZ_IN_HZ
,
numpy
.
angle
(
gains_per_antenna
),
'
+-
'
)
if
save_to
:
for
figure_name
in
opened_figures
:
...
...
@@ -362,13 +399,15 @@ def plot_gains_fit_per_antenna(dset: HolographyDataset,
canvas
.
set_ylabel
(
'
Amplitude
'
)
canvas
.
plot
(
frequencies
/
__MHZ_IN_HZ
,
numpy
.
abs
(
antenna_data
),
'
+
'
)
canvas
.
plot
(
frequencies
/
__MHZ_IN_HZ
,
amplitude_par
[
'
m
'
]
*
frequencies
+
amplitude_par
[
'
q
'
])
plt
.
minorticks_on
()
canvas
=
figure
.
add_subplot
(
2
,
2
,
polarization_index
+
3
)
__set_minor_ticks_for_canvas
(
canvas
)
canvas
.
set_title
(
polarization
)
canvas
.
set_xlabel
(
'
frequency (MHz)
'
)
canvas
.
set_ylabel
(
'
Phase
'
)
canvas
.
set_ylim
(
-
numpy
.
pi
,
numpy
.
pi
)
plt
.
minorticks_on
()
canvas
.
plot
(
frequencies
/
__MHZ_IN_HZ
,
numpy
.
angle
(
antenna_data
),
'
+
'
)
canvas
.
plot
(
frequencies
/
__MHZ_IN_HZ
,
phase_par
[
'
m
'
]
*
frequencies
+
phase_par
[
'
q
'
])
plt
.
tight_layout
()
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment