33import sdp .java .arljava ;
44import sdp .java .ARLConf ;
55import sdp .java .ARLVis ;
6+ import sdp .java .Image ;
67import sdp .java .intArray ;
8+ import sdp .java .doubleArray ;
79
810public class FFIDemo {
911 public static void main (String [] args ) throws Exception {
@@ -14,15 +16,87 @@ public static void main(String[] args) throws Exception {
1416
1517
1618 ARLConf lowconfig =arljava .allocate_arlconf_default (config_name );;
17- /*
19+
1820 int nvis = lowconfig .getNbases ()*lowconfig .getNfreqs ()*lowconfig .getNtimes ();
1921
22+ System .out .println ("nvis: " + nvis );
23+
2024 ARLVis vt = arljava .allocate_vis_data (lowconfig .getNpol (), nvis );
25+
26+
2127 ARLVis vtmp = arljava .allocate_vis_data (lowconfig .getNpol (), nvis );
2228
2329 intArray shape =new intArray (4 );
2430 arljava .helper_get_image_shape (lowconfig .getFreqs (), cellsize ,
2531 shape .cast ());
26- */
32+
33+ Image model = arljava .allocate_image (shape .cast ());
34+ Image m31image = arljava .allocate_image (shape .cast ());
35+ Image dirty = arljava .allocate_image (shape .cast ());
36+ Image psf = arljava .allocate_image (shape .cast ());
37+ Image comp = arljava .allocate_image (shape .cast ());
38+ Image residual = arljava .allocate_image (shape .cast ());
39+ Image restored = arljava .allocate_image (shape .cast ());
40+
41+ arljava .arl_create_visibility (lowconfig , vt );
42+
43+ arljava .arl_create_test_image (lowconfig .getFreqs (),
44+ cellsize ,
45+ vt .getPhasecentre (),
46+ m31image );
47+
48+
49+ arljava .arl_predict_2d (vt , m31image , vtmp );
50+ vt = arljava .destroy_vis (vt );
51+ vt = vtmp ;
52+
53+ // BN: Why??
54+ // vtmp = NULL;
55+
56+ arljava .arl_create_image_from_visibility (vt , model );
57+
58+ doubleArray sumwt =new doubleArray (1 );
59+ arljava .arl_invert_2d (vt , model , false , dirty , sumwt .cast ());
60+ arljava .arl_invert_2d (vt , model , true , psf , sumwt .cast ());
61+
62+ arljava .arl_deconvolve_cube (dirty , psf , comp , residual );
63+ arljava .arl_restore_cube (comp , psf , residual , restored );
64+
65+ // FITS files output
66+
67+ // BN : to be done in JAVA:
68+ // status = mkdir("results", S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH);
69+
70+ int status = arljava .export_image_to_fits_c (m31image , "results/m31image.fits" );
71+ status = arljava .export_image_to_fits_c (dirty , "results/dirty.fits" );
72+ status = arljava .export_image_to_fits_c (psf , "results/psf.fits" );
73+ status = arljava .export_image_to_fits_c (residual , "results/residual.fits" );
74+ status = arljava .export_image_to_fits_c (restored , "results/restored.fits" );
75+ status = arljava .export_image_to_fits_c (comp , "results/solution.fits" );
76+
77+ model = arljava .destroy_image (model );
78+ m31image = arljava .destroy_image (m31image );
79+ dirty = arljava .destroy_image (dirty );
80+ psf = arljava .destroy_image (psf );
81+ residual = arljava .destroy_image (residual );
82+ restored = arljava .destroy_image (restored );
83+
84+
85+ ARLVis vtmodel = arljava .allocate_vis_data (lowconfig .getNpol (), nvis );
86+ vtmp = arljava .allocate_vis_data (lowconfig .getNpol (), nvis );
87+
88+ arljava .arl_create_visibility (lowconfig , vtmodel );
89+
90+ arljava .arl_predict_2d (vtmodel , comp , vtmp );
91+
92+ vtmodel = arljava .destroy_vis (vtmodel );
93+ vtmp = arljava .destroy_vis (vtmp );
94+
95+ comp = arljava .destroy_image (comp );
96+
97+ arljava .arl_finalize ();
98+
99+
100+ System .out .println ("Configuration: " + config_name );
27101 }
28102}
0 commit comments