! rd_corr , here we define flags for vectors plottings
! Copyright (C) 1999,2010 Gauthier Delerce
!
! This program is free software; you can redistribute it and/or modify
! it under the terms of the GNU General Public License as published by
! the Free Software Foundation; either version 2, or (at your option)
! any later version.
!
! This program is distributed in the hope that it will be useful,
! but WITHOUT ANY WARRANTY; without even the implied warranty of
! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
! GNU General Public License for more details.
!
! You should have received a copy of the GNU General Public License
! along with this program; if not, write to the Free Software Foundation,
! Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
!
! Gauthier Delerce <gauthier@delerce.fr>
subroutine rd_corr
! HERE WE SETUP THE CORRELATION FLAGS
use mod_parameters
!use modresultats
!use modgrille
!use modvsv
!use modnetcdf
integer::ppp
ppp=0
nbFvect=0
nbMasked=0
nbAvgLessThan=0
nbAvgNull=0
nbAvgLessThanANDMaxCorrLessThan=0
nbInstable=0
nbIsTooSmall=0
nbInstableHart=0
nbInstableHartBis=0
nbHartPrefered=0
nbHartCorrTooLow=0
do i=1,mg*ng
if(grille(i,3)==0) nbMasked=nbMasked+1
if(grille(i,3)==3) nbAvgLessThan=nbAvgLessThan+1
if(grille(i,3)==3.1) nbAvgNull=nbAvgNull+1
if(grille(i,3)==3.2) nbAvgLessThanANDMAxCorrLessThan=nbAvgLessThanANDMaxCorrLessThan+1
if(grille(i,3)==3.3) nbInstable=nbInstable+1
if(grille(i,3)==-2.)then
! Print*,'Rarely this vectors are false'
ppp=ppp+1
!grille(i,6)=0.
nbIsTooSmall=nbIsTooSmall+1
endif
if(grille(i,3)==9) nbInstableHart=nbInstableHart+1
if(grille(i,3)==9.1) nbInstableHartBis=nbInstableHartBis+1
if(grille(i,3)==2) nbHartPrefered=nbHartPrefered+1
if(grille(i,3)==4) nbHartCorrTooLow=nbHartCorrTooLow+1
! print*,'putain ca chie ',i
! THE FOLLOWING VECTORS WONT BE PLOTTED :
! IF HART_INSTABLE && MAX_CORR CLOSE TO THE BORDER
! IF SOFTMASK OR A LACK OF INFORMATION IN THE IMAGE
! PROBLEMS WITH HART ( SELDOM APPEARS )
! IF SFIT INSTABLE
!
! IF HOLE+ (MAX_CORR CLOSE TO THE BORDER||TO KEEP HART RESULTS INSTEAD OR RECOMPUTE ONES
if( (grille(i,3)==9.).or.(grille(i,3)==3.).or.(grille(i,3)==4.).or.( ((grille(i,3)==-2.).or. &
( grille(i,3)==2.)).and.(hole)) ) nbFvect=nbFvect+1 ! compte les vecteurs cachés
enddo
if(nbMasked/=0) print*,"nbMasked = ",nbMasked
if(nbAvgLessThan/=0) print*,"nbAvgLessThan = ",nbAvgLessThan
if(nbAvgNull/=0) print*,"nbAvgNull = ",nbAvgNull
if(nbAvgLessThanANDMaxCorrLessThan/=0) print*,"nbAvgLessThanANDMaxCorrLessThan = ",nbAvgLessThanANDMaxCorrLessThan
if(nbInstable/=0) print*,"nbInstable = ",nbInstable
if(nbIsTooSmall/=0) print*,"nbIsTooSmall = ",nbIsTooSmall
if(nbInstableHart/=0) print*,"nbInstableHart = ",nbInstableHart
if(nbInstableHartBis/=0) print*,"nbInstableHartBis = ",nbInstableHartBis
if(nbHartPrefered/=0) print*,"nbHartPrefered = ",nbHartPrefered
if(nbHartCorrTooLow/=0) print*,"nbHartCorrTooLow = ",nbHartCorrTooLow
if(ppp>0) then
print*,''
print*,''
print*,'*****************************************************************'
print*,''
print*, ' Search Box SIZE is too SMALL for :',ppp,' vectors'
print*,''
print*,''
print*,'*****************************************************************'
print*,''
endif
return
end
! INFO ABOUT THE FLAG GRILLE(I,3)
! RD_GRILLE =0 IF HARD MASK
! =3 IF SOFT MASK
! =-1 IF NONMASKED
! XCORR =0 => CORR_TAB=1
! =3 IF ARMS<=RADIODT
! =3 IF BRMS==0 NOT GOOD AT ALL
! SUBHART =4 IF SUM(ABS(CORR_TAB_HART))<=0.01
! FIND_PEAK_HART =9 IF HART_INSTABLE && MAX_CORR CLOSE TO THE BORDER
! =-2 IF MAX_CORR CLOSE TO THE BORDER
! =2 CRITERE1 TO KEEP HART RESULTS INSTEAD OR RECOMPUTE ONES
! CRITERE1 : if ( ((nint(u(i))/=nint(l1)).or.(nint(v(i))/=nint(l2))).and.(grille(i,3)/=9.) ) then
! FIND PEAK =-2 IF COMPUTED MAX IS CLOSE TO THE CORRELATION FONCTION BORDER
! =1 IF EVERYTHING IS OK
! =3 IF SFIT=>INSTABLE