; ; compute the weights for the fit. ; ; ARGS: ; RADXY[n] : double radius in xy plane for points ;KEYWORDS: ; scaling : int how to scale ; 1 [def]: 1/sqrt(m) where m is the number of points in the area ; 2 1/m ;rbin : double bin step for historam. def: 1 meter ; ; RETURNS: ; istat : 0 ok ; -1 error ; w[n] : weight for each point ; weight by the 1/sqrt(densityof points) ; ;the area of an annulus of thicknes delt is ; a=pi *((R+delt)^2 - R^2) = pi*(2*R*delt + delt^2) ; note: i'm cheating a bit computing the area. i'm using a 2d annulus rather ; rather than a 3d one. function fitsphere_cmpw,radxy,w,scaling=scaling,rbin=rbin ; ; npnts=n_elements(radxy) if n_elements(rbin) eq 0 then rbin=1. if n_elements(scaling) eq 0 then scaling=1 if (scaling lt 1) or (scaling gt 2) then begin print,"Scaling can be 1 or 2" return,-1 endif if n_elements(maxr) eq 0 then maxr=150. if n_elements(minr) eq 0 then minr=150. ; ; make a histogram of the data ; h=histogram(radxy,binsize=rbin,loc=hloc,reverse_indices=r) ; ; generate the w array for the data ; delt=rbin*1d delt2=delt*delt nh=n_elements(h) w=dblarr(npnts) for i=0,nh-1 do begin i0=r[i] i1=r[i+1]-1 ni=i1-i0 + 1 if ni ne 0 then begin area=!pi*(2*hloc[i]*delt + delt2) areaDen=(1d*ni)/area scl=(scaling eq 1)?1d/(sqrt(areaDen)):1d/areaDen w[r[i0:i1]]=scl endif endfor return,0 end