File: example-plot-result.py

package info (click to toggle)
aoflagger 3.4.0-4
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 8,960 kB
  • sloc: cpp: 83,076; python: 10,187; sh: 260; makefile: 178
file content (43 lines) | stat: -rw-r--r-- 1,152 bytes parent folder | download | duplicates (2)
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
import aoflagger as aof
import matplotlib.pyplot as plt
import numpy
import sys

nch = 256
ntimes = 1000
npol = 2

aoflagger = aof.AOFlagger()
path = aoflagger.find_strategy_file(aof.TelescopeId.Generic)
strategy = aoflagger.load_strategy_file(path)
data = aoflagger.make_image_set(ntimes, nch, npol * 2)

# Several consecutive values at the same frequency are increased
# in amplitude to simulate a RFI source. These values define
# the channel and the start and duration of the added signal.
rfi_y = int(nch * 0.3)
rfi_x_start = int(ntimes * 0.2)
rfi_x_end = int(ntimes * 0.4)
rfi_strength = 1  # 1 sigma above the noise

for imgindex in range(npol * 2):
    # Initialize data with random numbers
    values = numpy.random.normal(0, 1, [nch, ntimes])
    # Add fake transmitter
    values[rfi_y, rfi_x_start:rfi_x_end] = (
        values[rfi_y, rfi_x_start:rfi_x_end] + rfi_strength
    )
    data.set_image_buffer(imgindex, values)


flags = strategy.run(data)
flagvalues = flags.get_buffer()
flagvalues = flagvalues * 1

plt.imshow(values, cmap="viridis")
plt.colorbar()
plt.show()

plt.imshow(flagvalues, cmap="viridis")
plt.colorbar()
plt.show()