WSClean
Functions
wscleaninterface.h File Reference

This is a low-level interface useful for using WSClean as the "operator" in functions such as compressed sensing. More...

#include <complex.h>
#include "imaginginterface.h"

Go to the source code of this file.

Functions

void wsclean_deinitialize (void *userData)
 Release all resources. More...
 
void wsclean_initialize (void **userData, const imaging_parameters *parameters, imaging_data *imgData)
 Initialize WSClean for use as measurement operator in compressed sensing application. More...
 
void wsclean_operator_A (void *userData, DCOMPLEX *dataOut, const double *dataIn)
 Calculate the unweighted visibilities for the given image data. More...
 
void wsclean_operator_At (void *userData, double *dataOut, const DCOMPLEX *dataIn)
 Calculate the dirty image from the visibilities. More...
 
double wsclean_parse_angle (const char *angle)
 Convert a string with units to an angle in radians. More...
 
void wsclean_read (void *userData, DCOMPLEX *data, double *weights)
 Reads the visibility data array from the measurement set. More...
 
void wsclean_write (void *userData, const char *filename, const double *image)
 Write the final image out. More...
 

Detailed Description

This is a low-level interface useful for using WSClean as the "operator" in functions such as compressed sensing.

It allows using the WSClean gridding / prediction operations. This header can be used both for C and for C++ programs.

This interface tries to abstract the measurement set, such that the interfacing program does not need to read/write to the measurement set at all.

The general order to call this is:

Methods are thread safe, in that one can e.g. call the operator methods at the same time from different threads, and things will still work. However, this is accomplished by using a global lock, such that this will actually not speed up processing.

Todo:
Currently, these methods write the visibilities to disk before performing the imaging or prediction operation. This is unnecessary overhead.

Function Documentation

void wsclean_deinitialize ( void *  userData)

Release all resources.

After this call, the userData should no longer be used. Every call to wsclean_initialize() should be followed by a call to wsclean_deinitialize().

Parameters
userDataA wsclean userdata struct as returned by wsclean_initialize().
void wsclean_initialize ( void **  userData,
const imaging_parameters parameters,
imaging_data imgData 
)

Initialize WSClean for use as measurement operator in compressed sensing application.

This should be called before any other function.

The way to pass the userdata pointer is as in the following example:

void* userdata;
wsclean_initialize(&userdata, ...)
// ...
Parameters
userDatashould be a pointer to a void pointer which will be set to a structure that WSClean internally uses.
parametersdomain specific information, containing the measurement set.
imgDatawill be filled with info describing the data.
void wsclean_operator_A ( void *  userData,
DCOMPLEX dataOut,
const double *  dataIn 
)

Calculate the unweighted visibilities for the given image data.

Parameters
userDataA wsclean userdata struct as returned by wsclean_initialize().
dataOutArray that will be filled with the predicted visibilities.
dataInThe image data: array of size width x height.
void wsclean_operator_At ( void *  userData,
double *  dataOut,
const DCOMPLEX dataIn 
)

Calculate the dirty image from the visibilities.

The weights will be applied while imaging, so the client should not already have multiplied the visibilities with the weights (see wsclean_read() ). If the client does not want to apply the weights, the client can divide the visibilities by the weights beforehand, and multiply the image by the sum of weights afterwards.

Parameters
userDataA wsclean userdata struct as returned by wsclean_initialize().
dataOutArray of size width x height that will be filled with the dirty image.
dataInThe visibility data to image.
double wsclean_parse_angle ( const char *  angle)

Convert a string with units to an angle in radians.

A client program can use this to convert a string like "10asec" or "1deg" to a numeric angle that can be passed to wsclean_initialize().

Parameters
angleA string specifying an angle.
Returns
the angle converted to double, in radians.
void wsclean_read ( void *  userData,
DCOMPLEX data,
double *  weights 
)

Reads the visibility data array from the measurement set.

The returned data are unweighted. The weights can be used by the client program to converge optimally, but should not be applied (or should be unapplied) to the data before calling the operator functions.

Parameters
userDataA wsclean userdata struct as returned by wsclean_initialize().
dataAn already allocated array of data which will be set to the selected data in the measurement set. The array should be of the size that wsclean_initialize() returned in the imaging_data struct.
weightsAn already allocated array which will be set to the weights, of equal size as the data.
void wsclean_write ( void *  userData,
const char *  filename,
const double *  image 
)

Write the final image out.

Parameters
userDataA wsclean userdata struct as returned by wsclean_initialize().
filenameFilename of fits output file.
imageThe image data of size width x height.