module wei_wavespace_mod
  use wei_wavespace_type_mod
  use wei_file_mod
  implicit none
  character(len=128)  :: data_axes(5),image_axes(5)

  contains

  subroutine sep3d_to_wavespace(file,wave)
    type(wspace)  :: wave
    type(sep3d)   :: file
    integer       :: i
#ifdef DEBUG
    write(0,*) "IN FILE TO WAVE SPACE"
#endif
  

    wave%n(1:4)=file%n(1:4)
    wave%o(1:4)=file%o(1:4)
    wave%d(1:4)=file%d(1:4)


#ifdef DEBUG
    write(0,*) "OUT FILE TO WAVE SPACE"
#endif

  end subroutine

  subroutine setup_shot_axes()

#ifdef DEBUG
    write(0,*) "IN SETUP_SHOT AXES"
#endif
    data_axes(1)="GX"        ;image_axes(1)="GX"
    data_axes(2)="GY"        ;image_axes(2)="GY"
    data_axes(3)="SX"        ;image_axes(3)="SX"
    data_axes(4)="SY"        ;image_axes(4)="SY"
    data_axes(5)="Frequency" ;image_axes(5)="Depth"

#ifdef DEBUG
    write(0,*) "OUT SETUP SG_AXES"
#endif
end subroutine

  subroutine setup_sg_axes()

#ifdef DEBUG
    write(0,*) "IN SETUP_SG_AXES"
#endif
  write(0,*) "IN IMNAGE AXES"
    data_axes(1)="CMP X"       ; image_axes(1)="CMP X"
    data_axes(2)="CMP Y"       ; image_axes(2)="CMP Y"
    data_axes(3)="HX"          ; image_axes(3)="HX"
    data_axes(4)="HY"          ; image_axes(4)="HY"
    data_axes(5)="Frequency"   ; image_axes(5)="Depth"

#ifdef DEBUG
    write(0,*) "OUT SETUP SG_AXES"
#endif
end subroutine

  subroutine set_reg_freq(wave,n,o,d)
    type(wspace)  :: wave
    integer       :: n
    real          :: o,d
    integer       :: i
#ifdef DEBUG
    write(0,*) "IN SET REG FREQ"
#endif

    allocate(wave%ws(n))
    do i=1,n
      wave%ws(i)=(o+d*(i-1))*8*atan(1.)
    end do

#ifdef DEBUG
    write(0,*) "OUT SET REG FREQ"
#endif
  end subroutine

  subroutine set_reg_dz(wave,n,o,d)
    type(wspace)  :: wave
    integer       :: n
    real          :: o,d
    integer       :: i
#ifdef DEBUG
    write(0,*) "IN SET REG DZ"
#endif

    wave%z0=o
    allocate(wave%dz(n))
    do i=1,n
      wave%dz(i)=d
    end do

#ifdef DEBUG
    write(0,*) "OUT SET REG DZ"
#endif
  end subroutine


end module
