forked from pohuigin/smart_library
-
Notifications
You must be signed in to change notification settings - Fork 1
/
ar_losgrad.pro
37 lines (23 loc) · 889 Bytes
/
ar_losgrad.pro
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
;Take the gradient in the horizontal plane of the LOS magnetic field.
;
;Example: datagrad=ar_losgrad(datasm)
;
function ar_losgrad, data
;Buffer the image to reduce edge effects
imgsz=size(data,/dim)
;xinterp=[findgen(imgsz[0]+1),fltarr(imgsz[1]+1)+imgsz[0],findgen(imgsz[0]+1)-1,fltarr(imgsz[1]+1)-1]
;yinterp=[fltarr(imgsz[0]+1)+imgsz[1],findgen(imgsz[1]+1)-1,fltarr(imgsz[0]+1)-1,findgen(imgsz[1]+1)]
dataint=fltarr(imgsz[0]+10,imgsz[1]+10)-1d6
dataint[5:imgsz[0]+4,5:imgsz[1]+4]=data
fill_missing,dataint,-1d6,1,/extrap
fill_missing,dataint,-1d6,2,/extrap
;winterp=where(dataint eq -1d6)
;xinterp=winterp mod imgsz[0]+10
;yinterp=winterp/(imgsz[0]+10)
;interps=interpolate(data,xinterp,yinterp)
;dataint[xinterp+5,yinterp+5]=interps
xgrad=deriv(dataint)
ygrad=rot(deriv(rot(dataint,-90)),90)
gradmag=sqrt(xgrad^2.+ygrad^2.)
return, gradmag[5:imgsz[0]+4,5:imgsz[1]+4]
end