Commit a79e5a91 authored by Zolnierczuk, Piotr's avatar Zolnierczuk, Piotr
Browse files

new global matching parameters

see vars? command in drspine
parent 69910a44
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -3,7 +3,7 @@ export PROJECT=drspine

export VERSION_MAJOR=1
export VERSION_MINOR=3
export VERSION_RELEASE=3
export VERSION_RELEASE=4

export PROJLIB=lib$(PROJECT).a
export PROJARCH=$(PROJECT)-$(VERSION_MAJOR).$(VERSION_MINOR)
+32 −0
Original line number Diff line number Diff line
@@ -787,6 +787,10 @@ program drspine
       '=    lam           <lambda>  lambda is within 0.1A                         ='//LF//&
       '=    t1 <> t2 <>   <t1> <t2> temp is in this range                         ='//LF//&
       ' -------------------$')) then
        if (instrument_parameters%id==INST_SNSNSE) then ! need to fix it for SNS-NSE (otherwise it crashes drspine)
            call msg_warning('cmd_explore', 'command explore not yet implemented for SNS-NSE')
            cycle commandloop
        end if
        call mxx_search( trim(chrval("m "," "))  , &
                         trim(chrval("s "," "))  , &
                         trim(chrval("c "," "))  , &
@@ -829,6 +833,11 @@ program drspine
       '=                                                                          ='//LF//&
       ' -------------------$')) then

        if (instrument_parameters%id==INST_SNSNSE) then ! need to fix it for SNS-NSE (otherwise it crashes drspine)
            call msg_warning('cmd_genmacro', 'command genmacro not yet implemented for SNS-NSE')
            cycle commandloop
        end if

        if(found("use_drpath")) call set_gen_macro_paths(mxx_path, data_path, save_path)

        ECHO_DIR_PATH      = chrval("dir  ",ECHO_DIR_PATH)
@@ -4742,6 +4751,14 @@ ntl2: do i=0, nt
    call setudf("r.postcoll_qcat ", reduction_parameters%post_collection_qcatch, ier)
    call setudf("r.max_field_var ", reduction_parameters%max_bfield_variation, ier)

    !
    call setudf("m.j0_abs ", matching_tolerance%J0_abs, ier)
    call setudf("m.j0_rel ", matching_tolerance%J0_rel, ier)
    call setudf("m.scat_angle ", matching_tolerance%scattering_angle, ier)
    call setudf("m.samp_angle ", matching_tolerance%sample_angle, ier)
    call setudf("m.lambda_min ", matching_tolerance%scattering_angle, ier)
    call setudf("m.lambda_max ", matching_tolerance%sample_angle, ier)

    ! instrument config
    call set_instrument_vars()

@@ -4772,6 +4789,13 @@ ntl2: do i=0, nt

    call extract("r.postcoll_qcat ", reduction_parameters%post_collection_qcatch, ier)
    call extract("r.max_field_var ", reduction_parameters%max_bfield_variation, ier)
    !
    call extract("m.j0_abs ", matching_tolerance%J0_abs, ier)
    call extract("m.j0_rel ", matching_tolerance%J0_rel, ier)
    call extract("m.scat_angle ", matching_tolerance%scattering_angle, ier)
    call extract("m.samp_angle ", matching_tolerance%sample_angle, ier)
    call extract("m.lambda_min ", matching_tolerance%scattering_angle, ier)
    call extract("m.lambda_max ", matching_tolerance%sample_angle, ier)

    ! instrument config
    call get_instrument_vars()
@@ -4802,6 +4826,14 @@ ntl2: do i=0, nt

    ! program config
    call msg_debug('get_progvar', msg_fmt("('c.last_run      = ', i0)", program_param%last_run))

    !
    call msg_debug('get_progvar', msg_fmt("('m.j0_abs        = ',g12.5)", matching_tolerance%J0_abs))
    call msg_debug('get_progvar', msg_fmt("('m.j0_rel        = ',g12.5)", matching_tolerance%J0_rel))
    call msg_debug('get_progvar', msg_fmt("('m.scat_angle    = ',g12.5)", matching_tolerance%scattering_angle))
    call msg_debug('get_progvar', msg_fmt("('m.samp_angle    = ',g12.5)", matching_tolerance%sample_angle))
    call msg_debug('get_progvar', msg_fmt("('m.lambda_min    = ',g12.5)", matching_tolerance%scattering_angle))
    call msg_debug('get_progvar', msg_fmt("('m.lambda_max    = ',g12.5)", matching_tolerance%sample_angle))
  end subroutine get_progvar


+30 −37
Original line number Diff line number Diff line
@@ -12,25 +12,30 @@ module matching

  implicit none


  private

  !> Parameters that control the matching tolerance , +initializing
  !! @note discrimating value for modes is still missing (e.g. current)


  real(kind=DBL)  :: J0_match_tolerance_abs           = 0.00001_DBL *30
  real(kind=DBL)  :: J0_match_tolerance_rel           = 0.003_DBL   *10 
  real(kind=DBL)  :: scattering_angle_match_tolerance = 0.15_DBL*DEGREE
  real(kind=DBL)  :: sample_angle_match_tolerance     = 180.0_DBL*DEGREE
  real(kind=DBL)  :: lambda_min_match_tolerance       = 0.1_DBL*ANGSTROEM
  real(kind=DBL)  :: lambda_max_match_tolerance       = 0.1_DBL*ANGSTROEM

  public :: J0_match_tolerance_abs, J0_match_tolerance_rel, &
       scattering_angle_match_tolerance, sample_angle_match_tolerance, &
       lambda_min_match_tolerance, lambda_max_match_tolerance
  type matching_tolerance_struct
    real(kind=DBL)  :: J0_abs
    real(kind=DBL)  :: J0_rel
    real(kind=DBL)  :: scattering_angle
    real(kind=DBL)  :: sample_angle
    real(kind=DBL)  :: lambda_min
    real(kind=DBL)  :: lambda_max
  end type matching_tolerance_struct

  type(matching_tolerance_struct) :: matching_tolerance = matching_tolerance_struct( &
                            30D-05, & !0.00001_DBL*30, & ! J0 abs tolerance (Tm)
                             3D-02, & !0.003_DBL  *10, & ! J0 relative tolerance
                              0.15*DEGREE,  &
                            180.00*DEGREE,  &
                            0.1*ANGSTROEM,  &
                            0.1*ANGSTROEM   &
                            )

  public  :: taupoint_match, taupoint_mismatch, match_scans, cformat_match_accuracy
  public  :: matching_tolerance

contains
  !--------------------------------------------------------------------------
@@ -75,22 +80,16 @@ contains

    taupoint_match = .false.

    if( diff_values(a%physics%field_integral, b%physics%field_integral)  > &
         J0_match_tolerance_abs ) return
    if( diff_relative(a%physics%field_integral, b%physics%field_integral)  > &
         J0_match_tolerance_rel ) return
    if( diff_values(a%physics%field_integral, b%physics%field_integral)   > matching_tolerance%J0_abs) return
    if( diff_relative(a%physics%field_integral, b%physics%field_integral) > matching_tolerance%J0_rel) return

    if( diff_values(a%physics%scattering_angle, b%physics%scattering_angle)  > &
         scattering_angle_match_tolerance ) return
    if( diff_values(a%physics%sample_angle, b%physics%sample_angle) > &
         sample_angle_match_tolerance ) return
    if( diff_values(a%physics%scattering_angle, b%physics%scattering_angle) > matching_tolerance%scattering_angle) return
    if( diff_values(a%physics%sample_angle, b%physics%sample_angle) > matching_tolerance%sample_angle) return

    if( a%spectrum(0)%no_lambda_bins .ne. b%spectrum(0)%no_lambda_bins    )  return

    if(abs( (spectrum_min_lambda(a%spectrum(0))-spectrum_min_lambda(b%spectrum(0))) ) &
         > lambda_min_match_tolerance                                    ) return
    if(abs( (spectrum_max_lambda(a%spectrum(0))-spectrum_max_lambda(b%spectrum(0))) ) &
         > lambda_min_match_tolerance                                    ) return
    if(abs( (spectrum_min_lambda(a%spectrum(0))-spectrum_min_lambda(b%spectrum(0))) ) > matching_tolerance%lambda_min) return
    if(abs( (spectrum_max_lambda(a%spectrum(0))-spectrum_max_lambda(b%spectrum(0))) ) > matching_tolerance%lambda_max) return

    taupoint_match = .true.

@@ -113,30 +112,24 @@ contains

    mismatch = 0

    del =  abs (a%physics%field_integral%value-b%physics%field_integral%value)   &
         /    J0_match_tolerance_abs
    del =  abs(a%physics%field_integral%value-b%physics%field_integral%value)/matching_tolerance%J0_abs
    if( del > mismatch) mismatch = del

    del = abs(2*(a%physics%field_integral%value-b%physics%field_integral%value) /   &
         (a%physics%field_integral%value+b%physics%field_integral%value)  )  &
         / J0_match_tolerance_rel
         (a%physics%field_integral%value+b%physics%field_integral%value)  ) / matching_tolerance%J0_rel
    if( del > mismatch) mismatch = del

    del = abs( (a%physics%scattering_angle%value-b%physics%scattering_angle%value)) &
         / scattering_angle_match_tolerance
    del = abs( (a%physics%scattering_angle%value-b%physics%scattering_angle%value)) / matching_tolerance%scattering_angle
    if( del > mismatch) mismatch = del

    del = abs( (a%physics%sample_angle%value    -b%physics%sample_angle%value)    ) &
         / sample_angle_match_tolerance
    del = abs( (a%physics%sample_angle%value    -b%physics%sample_angle%value)    ) / matching_tolerance%sample_angle
    if( del > mismatch) mismatch = del

    if(      a%spectrum(0)%no_lambda_bins .ne. b%spectrum(0)%no_lambda_bins    )  mismatch = HUGE(del)
    del = abs( (a%spectrum(0)%lambda_bin(1)  -b%spectrum(0)%lambda_bin(1))  )       &
         / lambda_min_match_tolerance
    del = abs( (a%spectrum(0)%lambda_bin(1)  -b%spectrum(0)%lambda_bin(1))  ) / matching_tolerance%lambda_min
    if( del > mismatch) mismatch = del
    del = abs( (a%spectrum(0)%lambda_bin(a%spectrum(0)%no_lambda_bins) -            &
         b%spectrum(0)%lambda_bin(b%spectrum(0)%no_lambda_bins))      )      &
         / lambda_max_match_tolerance
         b%spectrum(0)%lambda_bin(b%spectrum(0)%no_lambda_bins))      ) / matching_tolerance%lambda_max
    if( del > mismatch) mismatch = del

  end function taupoint_mismatch
+1 −1
Original line number Diff line number Diff line
@@ -3484,7 +3484,7 @@ CONTAINS
    else
       write(6,*)'defined uservars:'
       do i=1,nousev
          write(6,*)usenam(i),useval(i)
          write(6,'(1x,a16,1x,g15.6)')usenam(i),useval(i)
       enddo
    endif
    return