;*******************************************************************************
; Filename:               CREATION DATE
;   ONEFIX.M               03/22/05
;
; Description:
;        This module constructs zonal and meridional windfield components
;        for exactly one fix.
;
; Input Definition:
;        infile : suv.idl, nrmrayse10_15.idl
;        The input files are defined in fixshots15.pro
; Output Definition:
;        vystre : holds the meridional component of the wind at each grid point.
;        uxstre : holds the zonal component of the wind at each grid point.
;        zxystre: complex array containing the zonal and meridional wind compone
;nts
;                 at each grid point.
;
; Revision History:
;  MM/DD/YYYY   Username        Descriptions
;  03/22/05     Dr. G. Soukup   Generate the initial code
;
;*******************************************************************************
;ONEFIX.M
; This module constructs zonal and meridional windfield components for exactly one  fix

;... put purely radial functions on a polar grid
@genstrex.m

;...form storm-relative windfield
cfu=[0,0] & cfsg=[0,0] & scl=.01*[1,1]
udvs,cfu & sgdvs,cfsg

;...determine form factors
cfu=AMOEBA(1.e-6,p0=cfu,scale=scl,function_value=rsu,function_name='MNRDU') 
cfsg=AMOEBA(1.e-6,p0=cfsg,scale=scl,function_value=rssg,function_name='MNRDSG')
cfu=AMOEBA(1.e-6,p0=cfu,scale=scl,function_value=rsu,function_name='MNRDU') 
cfsg=AMOEBA(1.e-6,p0=cfsg,scale=scl,function_value=rssg,function_name='MNRDSG')
cfu=AMOEBA(1.e-6,p0=cfu,scale=scl,function_value=rsu,function_name='MNRDU')
cfsg=AMOEBA(1.e-6,p0=cfsg,scale=scl,function_value=rssg,function_name='MNRDSG') 
;print,cfu & print,cfsg & print,rsu & print,rssg

;...form earth relative windfield
vstre=vgstre+sgstre
uerstre=ustre+c*snstre & verstre=vstre+c*csstre
zerstre=complex(uerstre,verstre)

;...advance phase of wind maximum according to gradient wind profile
werstre=float(sqrt(zerstre*conj(zerstre)))
iwx=where(werstre eq max(werstre)) & iwx=iwx(0)
adisp=-180*atan(ynstre(iwx),xnstre(iwx))/!pi
twist= -adisp*vgstre+brg

;...orient windfield to track direction
j=complex(0,1) & rotor=exp(!pi*j*twist/180)
znstre=rotor*complex(xnstre,ynstre)
rxnstre=float(znstre) & rynstre=imaginary(znstre)
sdx=10*sstre & odx=18*(atan(rynstre,rxnstre)/!pi+1)+1
sdx(0,*)=0. & odx(0,*)=odx(150,*)
zerstre=interpolate(zerstre,sdx,odx,cubic=-.5)
;zerstre(0,*,*)=complex(0,0)
@shift.m
uerstre=float(zerstre) & verstre=imaginary(zerstre)

;...final e.r. surface wind on polar grid 
uxstre=uerstre*csstre-verstre*snstre 
vystre=uerstre*snstre+verstre*csstre
zxystre=complex(uxstre,vystre)
;END ONEFIX.M
