Commit 36267da0 authored by Zolnierczuk, Piotr's avatar Zolnierczuk, Piotr
Browse files

preparing for mask q command

fixed cmd_moni - it needed set_instrument_vars
parent 913d1950
Loading
Loading
Loading
Loading
+58 −22
Original line number Diff line number Diff line
@@ -519,7 +519,7 @@ program drspine
            " "//LF//&
            " mask tau"//LF//&
            "     - show tau mask (equivalent to 'dir details')"//LF//&
            " mask tau set <itau> [run <numor>] [clear]"//LF//&
            " mask tau [set|clear] <itau> [run <numor>]"//LF//&
            "     - mask <itau> tau in a given run"//LF//&
            "       if clear is given, the tau is 'restored'"//LF//&
            " "//LF//&
@@ -1444,6 +1444,7 @@ CONTAINS
    call msg_info('drspine', '===> moni')
    if (iparf() > 0 ) then
        instrument_parameters%norm_counter = int(rparf(1))
        call set_instrument_vars()
    else
        call msg_info('cmd_moni', msg_fmt("('norm_counter=',i0)",&
                        instrument_parameters%norm_counter))
@@ -1483,18 +1484,26 @@ CONTAINS
  !!
  !! mask tau
  !!     - show tau mask (equivalent to 'dir details')
  !! mask tau set <itau> [run <numor>] [clear]
  !! mask tau [set|clear] <itau> [run <numor>]
  !!     - mask <itau> tau in a given run
  !!       if clear is given, the tau is "restored"
  !!
  !! mask q
  !!     - show q mask (.......)
  !! mask q [set|clear] <qx> <qy> <qz>
  subroutine cmd_mask()
    logical :: do_pix, do_tau
    !logical :: do_pix, do_tau, do_q
    integer, parameter :: E_PIX  = 1,&
                          E_TAU  = 2,&
                          E_QVEC = 4
    logical :: do_set, do_win, do_ring
    integer :: iwhat
    integer :: ival, itau, irun
    integer :: inew, i
    real(kind=SGL), dimension(4) :: xmask ! pixel mask limits
    !
    do_pix  = .false.
    do_tau  = .false.
    !do_pix  = .false.
    !do_tau  = .false.
    ! pixel flags
    do_set  = .false.
    do_win  = .false.
@@ -1505,16 +1514,17 @@ CONTAINS
    irun    = int(program_param%last_run)
    xmask   = 0

    do_pix   = found('pix') .or. found('pixel')
    do_tau   = found('tau')

    if ( do_pix .and. do_tau) then
       call msg_error('drspine/mask', 'mask pix(el) and tau are mutually exclusive', ERROR_OPTION_SYNTAX)
    iwhat = parse_command_flags('pix,tau,q')
    if (iwhat<0) then               ! error both are present
       call msg_error('drspine', 'command mask: keywords "pix", "tau" and "q" are mutually exclusive', ERROR_OPTION_SYNTAX)
       return
    endif

    ! process pixel mask
    if (do_pix) then
    case_what: select case(iwhat)
    !! -------------------------------------------------------------------------
    !! process pixel mask
    !! -------------------------------------------------------------------------
    case (E_PIX)
        do_set  = found('set')
        do_win  = found('win')
        do_ring = found('ring')
@@ -1548,15 +1558,26 @@ CONTAINS
        else ! just show pixel mask
            call print_detector_mask(instrument_parameters%detector,output_unit)
        end if

    else if (do_tau) then
        do_set = found('set')

        itau = get_named_value('set', itau, inew)
    !! -------------------------------------------------------------------------
    !! process tau mask
    !! -------------------------------------------------------------------------
    case (E_TAU)
        if (data_manager_used()<=0) then
            call msg_info("drspine/mask", 'mask - no data in memory')
            exit case_what
        end if
        irun = get_named_value('run', irun, inew)
        if (do_set) then
        if (found('set')) then
            itau = get_named_value('set', itau, inew)
            ival = SCAN_MASKED
            if (found('clear')) ival =  SCAN_OK
            do i=1, data_manager_size()
                if ( .not. is_valid_scan(data_scan(i)) ) cycle
                if ( data_scan(i)%id /= irun ) cycle
                data_scan(i)%scan_point(itau)%flag = ival
            enddo
        else if (found('clear')) then
            itau = get_named_value('clear', itau, inew)
            ival = SCAN_OK
            do i=1, data_manager_size()
                if ( .not. is_valid_scan(data_scan(i)) ) cycle
                if ( data_scan(i)%id /= irun ) cycle
@@ -1575,9 +1596,23 @@ CONTAINS
                call print_details(data_scan(i), output_unit)
            enddo
        end if
    else
        call msg_warning("drspine/mask", 'mask - need at least one of pix or tau')
    !! -------------------------------------------------------------------------
    !! process q vector mask
    !! -------------------------------------------------------------------------
    case (E_QVEC)
        if (data_manager_used()<=0) then
            call msg_info("drspine/mask", 'mask - no data in memory')
            exit case_what
        end if

        call msg_warning("drspine/mask", 'mask - q mask not yet implemented')
    !! -------------------------------------------------------------------------
    !! default case (warning)
    !! -------------------------------------------------------------------------
    case default
        call msg_warning("drspine/mask", 'mask - need at least one of pix, tau or q ')
    end select case_what

    call unused( icmdus=1, ivnuse=1, irpuse=1, iretus=iunused)

  end subroutine cmd_mask
@@ -1665,6 +1700,7 @@ CONTAINS
    filename_length           = get_named_value('fnl  '                      ,filename_length          ,inew)


    if (data_manager_used()<=0) call msg_info("drspine/dir", 'dir - no data in memory')
    do i=1, data_manager_size()
       empty:  if ( is_valid_scan(data_scan(i)) ) then
          if (full.or.details) then