function vis_hermitianator,vis,inx,VERBOSE=verbose ; PURPOSE: ; Forces vis to be Hermitian, i.e., vis(-u,-v) = conj(vis(u,v)) ; Radio astronomical visibilities are Hermitian, as described in the AIPS glossary: ; http://www.atnf.csiro.au/computing/software/aips%2B%2B/docs/glossary/h.html#Hermitian_function ; See also Fundamentals of Radio Interferometry, VLA Summer School, R. Perley (2004) ; www.aoc.nrao.edu/~kdyer/2006/lectures/TuesdayJune13/Perley.ppt ; ; So this program turns RHESSI visibilities into quantities even more similar to those used in ; radio interferometry. ; ; NOTE: ; This would appear to be an unnecessary replacement for gh's hsi_vis_combine.pro ; but (a) this returns a visIbility structure with conjugate visibilities in the lower ; half complex visibility plane, whereas hsi_vis_combine leaves the LHP empty. ; (b) zero values are not completely ignored if their conjugate pair is non zero; ; (c) it does not cause mem_njit to crash, as do visibilities combined with hsi_vis_combine ; (d) it gives superior results for heights and albedo_ratios in hsi_vis_fwdfit applications ; (e) it makes it possible to use mathematical transforms that work only with Hermitian ; quantities. ; INPUTS: ; VIS = RHESSI visibility structure (not having has hsi_vis_edit or vis_vombine applied) ; if inx is a named variable, structure inx will be returned in it ; LIMITATIONS: ; The input visibility structure must have only one energy and one time. ; Weights for all averaging are simplistic at best. ; VERSION HISTORY: ; ejs February 2009 First version ; ejs February 2009 Added fix to case where vis=0 at (u,v) but vis ne 0 at (-u,-v) default,verbose,0 iscx=minmax(vis.isc) eps = 0.001 len=intarr(9)+1 vis_out=vis for j=iscx[0],iscx[1] do begin ;print,'ICOLL=',j w=where(vis.isc eq j,nw) len(j)=nw endfor inx={inx0:intarr(len[0]),inx1:intarr(len[1]),inx2:intarr(len[2]),$ inx3:intarr(len[3]),inx4:intarr(len[4]),inx5:intarr(len[5]),$ inx6:intarr(len[6]),inx7:intarr(len[7]),inx8:intarr(len[8])} for j=iscx[0],iscx[1] do begin w=where(vis.isc eq j,nw) phi=atan(vis[w].v,vis[w].u)/!dtor index=intarr(nw) for k=0,nw-1 do begin w1 = where((abs(phi[k]-phi) gt 180.-eps) and (abs(phi[k]-phi) lt 180+eps)) index[k]=w1[0] endfor;k inx.(j) = index endfor ; Now make vis Hermetian ; print,'inx=',inx for j=iscx[0],iscx[1] do begin w=where(vis.isc eq j,nw) ; check for nw=0 if nw eq 0 then message,'No vis with isc ='+strcompress(j) phi=atan(vis[w].v,vis[w].u)/!dtor obsvis = vis[w].obsvis sigamp = vis[w].sigamp sigamp_new = sigamp index = inx.(j) ; check for 0 sigamp without a corresponding 0 sigamp(index) w0 = where(sigamp eq 0, nw0) if nw0 ne 0 then begin print,'isc=',j print,'sigamp[w0]=',sigamp[w0],'sigamp[index(w0)]=',sigamp[index(w0)] if total(sigamp(w0)+sigamp(index[w0])) ne 0 then begin sigamp(w0)=sigamp(index[w0]) message,'replaced zero sigamp with its conjugate pair',/inf print,'sigamp(w0)=',sigamp(w0) obsvis(w0)=conj(obsvis(index[w0])) message,'replaced zero obsvis with its conjugate pair',/inf print,'obsvis(w0)=',obsvis(w0) print,'obsvis(index[w0])=',obsvis(index[w0]) endif endif obsvis_new = obsvis * 0 ninx = n_elements(index) for k=0,ninx-1 do begin ; proceed around the (u,v) circle z1=obsvis[k] & z2=obsvis[index(k)] ; if we have not yet changed the obsvis_new[k] then insert (z1+conj(z2))/2 & (conj(z1)+z2)/2) if (abs(obsvis_new[k]) lt eps) then begin ; check for zero value ; Note that this method replaces the old z1 with a new one that lies in the uhp if ; z1 is in the uhp and z2 is in the lhp, and conversely. That is, if the old z1,z2 pair ; are quasi-hermetian, then their imaginary signs are retained by the new z1, z2. obsvis_new(k) = (z1+conj(z2))/2 obsvis_new(index[k]) = conj(obsvis_new[k]) endif endfor ; k vis_out[w].obsvis = obsvis_new for k=0,ninx-1 do sigamp_new(k) = sqrt((sigamp[k]^2 + sigamp[index[k]]^2))/2 vis_out[w].sigamp = sigamp_new endfor ; j if keyword_set(verbose) then begin for j=iscx[0],iscx[1] do begin print,'j=',j w=where( vis_out.isc eq j) obsvis=vis_out[w].obsvis print,'obsvis=',obsvis index=inx.(j) print,'obsvis(index)=',obsvis[index] endfor endif return,vis_out end dir = '50516/' ; '20929/' ;'21003/' ; '20410/' ;'40713/' ; 40717/' filen = 'nrollfD1-9VIS20040713_001530E12-15' ;'nrollfD1-9VIS20040713_001530E20-30' ;'nrollfD1-9VIS20040713_001530E15-20' ; 12-15' ;15-20' ;filen = 'nrollfVIS20020410_123020E12-15' ;filen = 'nrollfVIS20020410_123020E15-20' ; ;filen = 'nrollfVIS20020410_123020E20-30' filen = 'nrolleVIS20021003_022040E20-30' ;filen = 'nrolleVIS20021003_022040E12-15' ;filen = 'nrolleVIS20021003_022040E15-20' ; filen = 'nrolleVIS20020929_063612E15-20' ; filen = 'nrolleVIS20020929_063612E20-30' ; filen = 'nrolleVIS20020929_063612E12-15' filen = 'nrolleVIS20050516_090559E12-15' ; filen = 'nrolleVIS20050516_090559E15-20' ; filen = 'nrolleVIS20050516_090559E20-30' restore, dir + filen + '.sav',/ver index=-1 vis_new = vis_hermitianator(vis,index,verbose=0) vis=vis_new save,vis,index,nroll,file=filen+'HERM'+'.sav',/ver end