apod_acf Subroutine

private subroutine apod_acf()

Note

Function that apodize the acf to prevent spectral leakage

Arguments

None

Calls

proc~~apod_acf~~CallsGraph proc~apod_acf apod_acf ellipse_acf ellipse_acf proc~apod_acf->ellipse_acf proc~apod2 apod2 proc~apod_acf->proc~apod2

Called by

proc~~apod_acf~~CalledByGraph proc~apod_acf apod_acf proc~read_job read_job proc~read_job->proc~apod_acf proc~prg_surf prg_surf proc~prg_surf->proc~read_job program~main main program~main->proc~prg_surf

Source Code

   subroutine apod_acf()
   !================================================================================================
   !<@note Function that apodize the acf to prevent spectral leakage
   !<
   !<@endnote
   !------------------------------------------------------------------------------------------------
   implicit none

      integer(kind=I4) :: w, h

      real(kind=R8) :: tau1, tau2, ang, coeff, c, s, R1, R2

      real(kind=R8), dimension(1:8) :: ana_res

      real(kind=R8), allocatable, dimension(:,:) :: tab_tmp

      logical(kind=I4) :: set_acf

      read(JOB,*) set_acf ; LINE_READ = LINE_READ +1 ; write(SPY,*) LINE_READ, "Set ACF ", set_acf

      w = PARAM%width
      h = PARAM%height

      call ellipse_acf( tabin = PARAM%acf_surf(1:w, 1:h),            &  ! IN
                         long = w,                                   &  ! IN
                         larg = h,                                   &  ! IN
                        p_acv = ana_res(1:8),                        &  ! OUT -> correlation lengths
                          cut = 0.5_R8,                              &  ! IN  -> z cut plane
                     scale_xy = [PARAM%surf_dx, PARAM%surf_dy],      &  ! IN  -> lags along x and y
                          omp = .true. )                                ! IN  -> use multithread?

      tau1 = ana_res(1)
      tau2 = ana_res(2)
      ang  = ana_res(4) * PI_R8 / 180

      c = cos(ang)
      s = sin(ang)

      ! ellipsis bounding box (half dimensions)
      R1 = sqrt( (c * tau1)**2 + (s * tau2)**2 )
      R2 = sqrt( (s * tau1)**2 + (c * tau2)**2 )

      ! scale factor for the apodization to take place within the surface
      ! 0.4 * image width is less than half width
      coeff = min( 0.4 * PARAM%surf_width / R1, 0.4 * PARAM%surf_height / R2 )

      allocate(  tab_tmp(1:w, 1:h) )

      ! modified Tuckey windowing
      call apod2(  tab_in = PARAM%acf_surf(1:w, 1:h),    &  ! IN
                  tab_out = tab_tmp(1:w, 1:h),           &  ! OUT
                     long = w,                           &  ! IN
                     larg = h,                           &  ! IN
                     tau1 = coeff * tau1 ,               &  ! IN
                     tau2 = coeff * tau2 ,               &  ! IN
                      ang = ang )                           ! IN

      if ( set_acf ) then

         ! acf calculated becomes prescribed acf
         PARAM%imp_acf(1:w, 1:h) = tab_tmp(1:w, 1:h)

      else

         PARAM%acf_surf(1:w, 1:h) = tab_tmp(1:w, 1:h)

      endif

      deallocate( tab_tmp )

   return
   endsubroutine apod_acf