Skip to content

Visibility class

pgabor edited this page Oct 3, 2017 · 2 revisions

Visibility class

Purpose

During synthesis imaging the data comes from different telescopes with different distance from each other. As a result of this we can create images with the same angular resolution what we would get by using a telescope with the size of what is the distance between our two most distant telescopes.

These telescopes measure the so called visibility values which is a phase and intensity information at the same time. This can be represented by complex values. The Visibility class is able to store the different needed informations.

How to use the class

First of all, you need to import the module:

from xrayvision.Visibility import Visibility

And most probably you will need numpy too:

import numpy as np

Creating a Visibility object

In this case you already have the the coordinates and the corresponding visibility values:

# The first line contains u values
# The second line contains the v values
# The values are matched by their position
uv_in = np.array([[0, 1, 7, 6],
                  [3, 8, 5, 2]])

# The complex visibility values
# The values are paired with the visibilities at the same position
vis_in = np.array([1.1j, 1+2j, -0.5-1j, 1.0], dtype=complex)

# Note: the dtype is not necessary if the values are complex

# Creating the Visibility object:
vis = Visibility(uv_in, vis_in)

Calculate visibility values from a given map

In this case a Visbility object have to be created first with the u, v coordinates where you would like to get the visibility values:

# Selecting the coordinates
uv_in = np.array([[0, 1, 7, 6],
                  [3, 8, 5, 2]])

# Providing fake visibilities
vis_in = np.zeros(4, dtype=complex)

# Creating the Visibility object
vis = Visibility(uv_in, vis_in)

# Let's say that we have our intensity image as a 2D np.array in image
new_visibilities = vis.from_map(image)

# The new_visibilities contains an np.array with the just calculated visibility values
# Note: this is not compatible format with Clean as it is, because it uses real coordinates
# instead of this one. For the compatible one check out from_map_v2() or from_sunpy_map().

Create an intensity image from the previously created visibilities

From the visibilities an image can be created with the real intensities. Note that this function works only on visibilities which were made on a basis that the coordinates are integer. See: from_map()

# Let's say our visibilities in vis in a Visibility object
# The first step is to create an np.array with the size of our final image
image_tmp = np.zeros((N, M))

# Convert the visibilities (from the result of from_map()) into the image
image = Visibility.to_map(image_tmp)

# image now stores the converted image

Calculate visibilities from a map (real coordinates)

In the case of this function you have a lots of options to customize the transformation. First you have to start off with the same way with creating a Visibility class with the UV coordinates set, but you are able to set to parameters (you can set them later on too).

You can specify the the center of the transformation in coordinates with the xyoffset=(0, 0) parameter. This example is pointing to the center of the image. x coordinates are growing to the right while the y coordinates from bottom to top.

The other parameter is the pixel_size=(1, 1) parameter. This specifies the size of a pixel. The first is for the x axis and the second one is for the y axis.

If you do not give these parameters at object creation it will use the default values and later on you can specify it for the function if you want to use a value.

Note: using the from_map with these parameters it will save them, for the computations later on!

# The first line contains u values
# The second line contains the v values
# The values are matched by their position
uv_in = np.array([[-0.4, 0.3, 0.45, 0.47],
                  [-0.48, -0.21, 0.15, 0.4]])

# The fake complex visibility values
# The values are paired with the visibilities at the same position
vis_in = np.zeros((4), dtype=complex)

# Creating the Visibility object with the additional parameters:
vis = Visibility(uv_in, vis_in, xyoffset=(0.2, -0.1), pixel_size(1., 2.))

# Converting a map (np.array) into the visibilities:
vis.from_map_v2(map_data) # Optional parameters: center, pixel_size

Calculate intensity map from the previously created visibilities

You can just use the

vis.to_map_v2(np.zeros((size)))

to simply convert back the data. Or you can give the pixel_size and center parameters just like in the case of from_map_v2().

Calculate visibilities from SunPy Map

This function will take the center set for the SunPy Map along with the pixel size information. This internally uses the v2 functions.

Simple use:

# The usual initialization of the object with the uv sampling points
uv_in = np.array([[-0.4, 0.3, 0.45, 0.47],
                  [-0.48, -0.21, 0.15, 0.4]])
vis_in = np.zeros((4), dtype=complex)
vis = Visibility(uv_in, vis_in)

# Creating the actual visibilities from the SunPy Map
vis.from_sunpy_map(sunpy_map)

Calculate intensity map and store it in a SunPy Map

It is very simple, just invoke it on the Visibility object

sunpy_map = vis.to_sunpy_map((x_pixel_count, y_pixel_count))