~i-martividal/apsynsim/trunk

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
APSYNSIM, A REAL-TIME APERTURE SYNTHESIS SIMULATOR
IVAN MARTI-VIDAL (2022) - University of Valencia


A warm acknowledgement to J. Girard, for very useful feedback!


INSTALLATION AND RUNNING INSTRUCTIONS:
-----------------------------------------


##########################
## RUNNING ON GNU/LINUX ##
##########################

1.- Just install the needed packages, i.e.:

python3
python3-numpy
python3-scipy
python3-matplotlib
python3-tk
python3-mpltoolkits.basemap
python3-astropy

(please, tell me if something else is missing in your system).


2.- Just run the script "APSYNSIM.py" (located in the "SCRIPT" directory):

python3 APSYNSIM.py


3.- You can also run "APSYNTRUE" (i.e., the real data imager!), which is located in the "APSYNTRU/SCRIPT" directory.


###########################
# RUNNING ON WINDOWS/MAC: #
###########################

Unfortunately, I do not have any Virtual Machine with the newest M$ Windblows versions, which means that I cannot generate binary files as before. 

But, fortunately, there are ways of running Python scripts in Windows (I'm afraid you will hae to "google" for them).

If you work on a Mac, try to run the script (located in either the SCRIPT
or the SOURCE_CODE directory) with the command:

pythonw APSYNSIM.py

(notice the "w" at the end of the "python").






##########
# USAGE: #
##########

You will find some examples of interferometer arrays and source models 
in the ARRAYS and SOURCE_MODELS directories, respectively, together with 
instructions on how you can build your own interferometers and source 
models (read, for instance, the content of the "default.array" and 
"default.model" files).

You can click and drag the antennas in the plot called "ARRAY CONFIGURATION".
When you drag an antenna, all other plots (UV PLANE, DIRTY BEAM, and DIRTY 
IMAGE) will be updated automatically (may need some time to refresh, 
especially if working on Windows and/or with many antennas).

You can also click on any point of the DIRTY BEAM, MODEL IMAGE, or DIRTY 
IMAGE plots, and the program will tell you the intensity value and the pixel 
coordinates.

If you click on the UV PLANE image, the program will print the value of the 
source Fourier transform at that point. If you click close to a point observed
with the interferometer, the program will tell you the baseline and hour
angle of observation.

You can also change the observing latitude, hour-angle coverage, source 
declination, and observing wavelength by clicking on the blue sliders at 
the bottom-right corner of the figure. The plots will be updated 
automatically (may also need some time to refresh all plots).

The dirty beam is computed using Briggs weighting. The robustness parameter
can be changed by shifting the corresponding blue slider (robustness of -2 
tends to uniform weighting, whereas +2 tends to natural weighting).

You can add and/or subtract antennas by pressing the "+ Antenna" and 
"- Antenna" buttons. New antennas are inserted at the array origin (0,0). 
If you add, drag, and subtract an antenna, the program will remember the 
last antenna positions if you add them again.

You can save the current array, load a new array (for instance, from the 
EXAMPLES folder), and/or load a new source model (for instance, from 
the EXAMPLES folder) by pressing the corresponding buttons "Save array", 
"Load array" and "Load model".

You can zoom in/out by pressing "Z" or "z" (respectively). The program will
then zoom using the current cursor position as zooming center.
 
The new "Reduce data" button opens a CLEAN GUI, where you can also corrupt
your visibilities, to see the effect on the DIRTY and CLEAN images.



------------------
NEW GUI FOR CLEAN
------------------

Here you can experiment with CLEAN deconvolution on (noise-free) 
visibilities. You can also corrupt the visibilities by adding a complex
gain to one of your antennas (or baselines). 

Clicking and dragging, with the LEFT mouse button, on the RESIDUALS image 
creates new CLEAN mask regions. Clicking and dragging with the RIGHT mouse
button removes CLEAN mask regions. You can add as many CLEAN mask regions
as you want.

The CLEAN gain and number of iterations can be changed in the text boxes.
Pressing CLEAN executes the iterations, refreshing all images in real time.
You can further click on CLEAN, to continue deconvolving.

Pressing RESET will undo all CLEANING. 

You also need to press RESET to refresh the images for CLEANing, if you 
change anything in the main program window (e.g., observing wavelength, 
antenna positions, etc.).

Pressing "+/- Resid" will add (or remove) the residuals from the CLEANed 
image.  By default, the residuals are NOT added (i.e., only the restored
CLEAN components are shown in the CLEAN image).

You can also add random noise to your visibilities. See the help, from the program window, for more information.


-----------------------------
HOW TO ADD A CORRUPTING GAIN
-----------------------------

Just select an antenna from the "Ant. 1" list to corrupt it. If you select
a different antenna from the "Ant. 2" list, only the baseline between 
the two antennas will be corrupted. But if the two antennas are the same,
then ALL the baselines to that antenna will be corrupted.

The two first sliders ("From integration" and "to integration") mark the 
first and last observing scans where the corruption term will be applied.
By default, the whole duration of the experiment is selected.

The last two sliders ("Amplitude gain" and "phase gain") define the gain 
that will be applied to the corrupted antenna. 

The button "APPLY GAIN" actually applies the gain and reloads the new
images. 

The button "RESET GAIN", undoes the gain correction (so the data become
perfectly calibrated again).

NOTICE THAT if a new antenna is added, or subtracted, the gains are 
reset automatically to 1.0 (but you will need to refresh the images in 
this window, by pressing the "RESET" button, just below the "CLEAN" 
button, to load the correct images). 




Enjoy!




P.S: Any bug report, comment or suggestion should be addressed to:

contact@nordic-alma.se