C+ C NAME: C LOSTweak C PURPOSE: C Determines the corrections to be applied to the model line of C sight observations based on differences with the actual observations C [g = m/ ==> dm = dg] C CATEGORY: C CALLING SEQUENCE: subroutine LOSTweak(I__VD,XOBS,XMDL,NBAD,FIX,FIXMEAN,FIXSTDV) C INPUTS: C I__VD integer TOM__V: Fix V model C TOM__G: Fix G model C XOBS(NL) real Observed values (V, g^2) C XMDL(NL) real Model values (V, g^2) C OUTPUTS: C FIX(NL) real Ratio of observed to model values C FIX(I) = XOBS(I)/XMDL(I) C FIXMEAN real = 1. C FIXSTDV real sqrt( (1/NL)*Sum[I]{ ( (XOBS(I)-XMDL(I))/XMDL(I) )^2 } = C sqrt( (1/NL)*Sum[I]{ (XOBS(I)/XMDL(I)-1.)^2 } = C sqrt( (1/NL)*Sum[I]{ (FIX(I)-1.)^2 } C something like a standard deviation from an assumed mean of one. C CALLS: C T3D_iget, BadR4, Str2Str, Flt2Str, Say C INCLUDE: include 't3d_param.h' include 't3d_array.h' C PROCEDURE: C MODE integer = iand(MODE,TOM__DIFF)= 0: los ratios C = iand(MODE,TOM__DIFF)> 0: los differences C MODIFICATION HISTORY: C NOV-1995, B. Jackson (STEL,UCSD) C AUG-2001, Paul Hick (UCSD/CASS; pphick@ucsd.edu); introduced T3D_iget calls C- integer I__VD real XOBS (*) ! Observed G-levels real XMDL (*) ! Modeled G-levels integer NBAD (*) real FIX (*) ! Ratio of observed to modeled G-values real FIXMEAN real FIXSTDV character cSay*8 /'LOSTweak'/ character cStr*150 integer Str2Str integer Flt2Str logical bDiff real PREVSTDV(2) /-1.,-1./ real FRSTSTDV(2) /-1.,-1./ save PREVSTDV, FRSTSTDV call T3D_iget(T3D__MODE,0,MODE) if (I__VD .eq. TOM__V) call T3D_iget(T3D__NL_V,0,NL) if (I__VD .eq. TOM__G) call T3D_iget(T3D__NL_G,0,NL) bDiff = iand(MODE,TOM__DIFF) .ne. 0 Bad = BadR4() if (iand(MODE,TOM__DIFF) .eq. 0) then! Correction based on ratios FIXSTDV = 0. NG = 0 c SG = 0. c SGG = 0. do I=1,NL if (NBAD(I) .eq. 1) then! Good source R = XOBS(I)/XMDL(I) FIX(I) = R NG = NG +1 ! Count good sources c SG = SG +R c SGG = SGG+R*R R = R-1. FIXSTDV = FIXSTDV+R*R else ! Bad source FIX (I) = Bad end if end do FIXMEAN = 1. FIXSTDV = sqrt(FIXSTDV/NG) c FIXMEAN = SG/NG c FIXSTDV = sqrt( (SGG-SG*SG/NG)/(NG-1) ) else ! Correction based on differences NG = 0 SG = 0. SGG = 0. do I=1,NL if (NBAD(I) .eq. 1) then! Good source R = XOBS(I)-XMDL(I) FIX(I) = R NG = NG +1 ! Count good sources SG = SG +R SGG = SGG+R*R else ! Bad source FIX (I) = Bad end if end do FIXMEAN = SG/NG FIXSTDV = sqrt( (SGG-SG*SG/NG)/(NG-1) ) end if !------- ! What follows below is for display purpose only IVD = 1 if (I__VD .eq. TOM__V) IVD = 2 I = 0 I = I+Str2Str('los convergence:',cStr(I+1:))+1 I = I+Flt2Str(FIXSTDV,3, cStr(I+1:)) if (PREVSTDV(IVD) .ne. -1.) then I = I+Str2Str(' (', cStr(I+1:)) I = I+Flt2Str(FIXSTDV/PREVSTDV(IVD),3,cStr(I+1:)) I = I+Str2Str(' x previous;',cStr(I+1:))+1 I = I+Flt2Str(FIXSTDV/FRSTSTDV(IVD),3,cStr(I+1:)) I = I+Str2Str(' x first)', cStr(I+1:)) else I = I+Str2Str(' (REFERENCE)',cStr(I+1:)) end if call ArrR4GetMinMax(-NL,FIX,FIXMIN,FIXMAX) I = I+Str2Str('#min, average, max:',cStr(I+1:))+1 I = I+Flt2Str(FIXMIN,3, cStr(I+1:)) I = I+Str2Str(' -', cStr(I+1:))+1 I = I+Flt2Str(FIXMEAN,3,cStr(I+1:)) I = I+Str2Str(' -', cStr(I+1:))+1 I = I+Flt2Str(FIXMAX,3, cStr(I+1:)) I = I+Str2Str(' (', cStr(I+1:))+1 I = I+Flt2Str(FIXSTDV,3,cStr(I+1:)) I = I+Str2Str(')', cStr(I+1:)) call Say(cSay,'I',char(I__VD),cStr) PREVSTDV(IVD) = FIXSTDV if (FRSTSTDV(IVD) .eq. -1) FRSTSTDV(IVD) = FIXSTDV return end