astro-informatics / purify

Next-generation radio interferometric imaging.
https://astro-informatics.github.io/purify
GNU General Public License v2.0
16 stars 11 forks source link

WSClean interface #7

Closed aroffringa closed 8 years ago

aroffringa commented 9 years ago

Hi guys,

I suggest we use the interface as defined below for wsclean; other imagers like awimager can have the exact same interface (except with different function names). I have made it slightly more generalized by also having a wsclean_read(..) function and make WSClean count the number of (selected) visibilities in the set. This way, Purify never has to touch the measurement set.

Below first you find the proposed header file with the wsclean implementation of the functions. The structs should be in some common header, propably in the Purify code. Below the header file is a slight example how to call the methods.

The wsclean interface header:

ifndef WSCLEAN_PURIFY_INTERFACE_H

define WSCLEAN_PURIFY_INTERFACE_H

include

struct purify_domain_info { const char* msPath; int imageWidth; int imageHeight; double pixelScaleX; double pixelScaleY; const char* extraParameters; };

struct purify_domain_data_format { long data_size; // could also hold the fact that we are dealing with complex doubles. };

ifdef __cplusplus

extern "C" {

endif

/**

/**

/**

/**

void wsclean_operator_A( void* dataIn, void* dataOut, void* userData);

void wsclean_operator_At( void* dataIn, void* dataOut, void* userData);

ifdef __cplusplus

}

endif

endif


Example how to use this interface:

include "wscleaninterface.h"

include "math.h"

include

int main(int argc, char* argv[]) { struct purify_domain_info dinfo; struct purify_domain_data_format format;

void* userdata;
dinfo.msPath="myset.ms";
dinfo.imageWidth = 512;
dinfo.imageHeight = 512;
dinfo.pixelScaleX = 0.5 * M_PI/(180.0*60.0*60.0); // 0.5 asec
dinfo.pixelScaleY = 0.5 * M_PI/(180.0*60.0*60.0);
dinfo.extraParameters="-weight natural";

wsclean_initialize(&userdata, &dinfo, &format);

complex double* mydata = (complex double*) malloc(format.data_size * sizeof(complex double));
double* myimage = (double*) malloc(dinfo.imageWidth*dinfo.imageHeight);

wsclean_read(userdata, mydata);

wsclean_operator_At(mydata, myimage, userdata);
wsclean_operator_A(mydata, myimage, userdata);
// ...do the purification magic...

wsclean_write(userdata, myimage);

free(myimage);
free(mydata);

wsclean_deinitialize(userdata);

}

vijaykartik commented 9 years ago

+1

Thanks @aroffringa . I have the structs in a new branch (wsclean) already. We can test the init/finalise functions. @jasonmcewen @rafael-carrillo: Your thoughts/reservations? Seems this would go well towards "easily" incorporating AW-imager as well since they use the same (or similar) format.

Vijay

rafael-carrillo commented 9 years ago

Hi all,

First of all, a big thanks to @aroffringa https://github.com/aroffringa. This was really quick.

Just one comment: to keep the same format that we have for the solvers we need that functions have this signature:

A(data_out, data in, data_parameters)

Thus for the function wsclean_operatorAt the syntax should be

wsclean_operator_At(myimage, mydata, userdata); instead of

wsclean_operator_At(mydata, myimage, userdata);

Looking at your header file this is ok but the example is not. Maybe this is just a typo.

Cheers

On 25 Mar 2015, at 15:43, vijaykartik notifications@github.com wrote:

+1

Thanks @aroffringa https://github.com/aroffringa . I have the structs in a new branch (wsclean) already. We can test the init/finalise functions. @jasonmcewen https://github.com/jasonmcewen @rafael-carrillo https://github.com/rafael-carrillo: Your thoughts/reservations? Seems this would go well towards "easily" incorporating AW-imager as well since they use the same (or similar) format.

Vijay

— Reply to this email directly or view it on GitHub https://github.com/astro-informatics/purify/issues/7#issuecomment-86058793.

aroffringa commented 9 years ago

Thanks @rafael-carrillo , you are right, I'll change that in the example. One more change: I'm just discussing with @vijaykartik that the wsclean_read(..) function should read the weights and set flagged samples to have zero weight...

rafael-carrillo commented 9 years ago

Should we discuss this in slack?

On 25 Mar 2015, at 16:04, aroffringa notifications@github.com wrote:

Thanks @rafael-carrillo https://github.com/rafael-carrillo , you are right, I'll change that in the example. One more change: I'm just discussing with @vijaykartik https://github.com/vijaykartik that the wsclean_read(..) function should read the weights and set flagged samples to have zero weight...

— Reply to this email directly or view it on GitHub https://github.com/astro-informatics/purify/issues/7#issuecomment-86071123.

jasonmcewen commented 9 years ago

This looks like awesome progress guys! Design looks good.

aroffringa commented 9 years ago

Is there any progress on this?

vijaykartik commented 9 years ago

Hi @aroffringa , further to my last email reply, the bugs were on my side in the SDMM minimiser calls (computing matrix norms and so on to prepare the minimiser), but I haven't tried / am waiting for the ADMM C version - so not working. I have semester exams finishing this week (finally) and then I can drop other stuff and get on this!

mdavezac commented 8 years ago

@jasonmcewen, is this still current since the C interface is going? should we close this issue?

vijaykartik commented 8 years ago

Sorry guys. With the (then) planned move away from the Purify C functions I dropped this to wait and retake it with the new internal API. I would start from scratch on this with the current C++ interface but not right away.

Vijay

On 24 August 2016 at 12:21, mdavezac notifications@github.com wrote:

@jasonmcewen https://github.com/jasonmcewen, is this still current since the C interface is going? should we close this issue?

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/astro-informatics/purify/issues/7#issuecomment-242019033, or mute the thread https://github.com/notifications/unsubscribe-auth/AK-JA2gNcBXkk_XOCXIPq20-Xi0i8JC2ks5qjBspgaJpZM4D0jEp .

jasonmcewen commented 8 years ago

Hi @vijaykartik! Yes, let's close this. We can reconsider this with the C++ interface if needed. We should plan to deprecate the C code, since the C++ code @mdavezac and @Luke-Pratley have written is much, much nicer!

vijaykartik commented 8 years ago

Thanks @jasonmcewen https://github.com/jasonmcewen, I agree with you completely... and I had a sneak peek at the C++ code - very slick! I am looking forward to getting my hands on/in it!

On 24 August 2016 at 16:00, Jason McEwen notifications@github.com wrote:

Hi @vijaykartik https://github.com/vijaykartik! Yes, let's close this. We can reconsider this with the C++ interface if needed. We should plan to deprecate the C code, since the C++ code @mdavezac https://github.com/mdavezac and @Luke-Pratley https://github.com/Luke-Pratley have written is much, much nicer!

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/astro-informatics/purify/issues/7#issuecomment-242074544, or mute the thread https://github.com/notifications/unsubscribe-auth/AK-JAz9-MyT50UO4mswIx4paSoqdzScEks5qjE5zgaJpZM4D0jEp .