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

working version of mask

parent 84e1a2b2
Loading
Loading
Loading
Loading

examples/macro_mk_mask

0 → 100644
+45 −0
Original line number Diff line number Diff line
macro

! ==== set paths
! datapath ./examples
! savepath ./out

! ==== set binning
bins pix nbins 8
bins tof custom 2 13 26 39

! ==== set histogramming
set A  1e-10
set ns 1e-9

histo tau  nbins 20 min 0.002*ns max 200.0*ns log
histo q    nbins 20 min 0.000/A  max 0.5/A

c ==== read data
read s5848.echo s5849.echo !s5850.echo s5851.echo s5852.echo s5853.echo as resolution
read s5854.echo s5855.echo !s5857.echo s5858.echo s5859.echo s5860.echo s5861.echo as sample

c === process
match all
fit   all

mask tau set 1 run 5854     ! drop first tau from run 5854
dir details

! pixels with the non-zero mask value are excluded from "collection"
mask pix win 3 3 6 6 val -1 ! select the center of the detector only
     ! note -1 value used above is a shortcut for two commands
     ! mask pix set 1             ! disable the entire detector
     ! mask pix win 3 3 6 6 val 0 ! enable the center

collect

c report start
c report dir details
c report sqtplot
c report end nopdf

c === plot
c plot sqt

+2 −2
Original line number Diff line number Diff line
# Makefile.depend Wed Feb 19 15:36:03 EST 2020
# Makefile.depend Thu May 28 18:47:29 EDT 2020
drspine_version.o : drspine_version.F90 drspine_parameters.o 
os_utils.o : os_utils.F90 strings_module.o drspine_parameters.o 
new_com.o : new_com.F90 os_utils.o 
@@ -30,7 +30,7 @@ write_utils.o : write_utils.f90 strings_module.o constants_module.o data_types.o
fit_utils.o : fit_utils.f90 echo_shapes.o polynom.o logger.o data_types.o drspine_parameters.o 
read_data.o : read_data.f90 binning.o logger.o file_utils.o read_utils.o instrument_config.o geometry_types.o data_types.o base_types.o constants_module.o 
fit_data.o : fit_data.f90 logger.o mathutil.o fit_utils.o dump_data.o echo_shapes.o data_types.o constants_module.o 
reduce_data.o : reduce_data.f90 data_types.o constants_module.o 
reduce_data.o : reduce_data.f90 instrument_config.o data_types.o constants_module.o
instrument_config.o : instrument_config.f90 echo_shapes.o binning.o geometry_types.o strings_module.o drspine_parameters.o 
module_gen_makro.o : module_gen_makro.f90 strings_module.o 
gr_interface.o : gr_interface.f90 drspine_parameters.o 
+62 −32
Original line number Diff line number Diff line
@@ -243,6 +243,12 @@ program drspine
  !istat = add_tab_expansion('group')
  !
  istat = add_tab_expansion('mask')
  istat = add_tab_expansion('mask pix')
  istat = add_tab_expansion('mask pix set')
  istat = add_tab_expansion('mask pix win')
  istat = add_tab_expansion('mask pix ring')
  istat = add_tab_expansion('mask tau')
  istat = add_tab_expansion('mask tau set')
  !
  istat = add_tab_expansion('dump')
  istat = add_tab_expansion('dump file')
@@ -254,6 +260,7 @@ program drspine
  istat = add_tab_expansion('dir full details' )
  istat = add_tab_expansion('dir full details histo' )
  !
  !
  istat = add_tab_expansion('match' )
  istat = add_tab_expansion('match all' )
  istat = add_tab_expansion('match resolution' )
@@ -497,14 +504,28 @@ program drspine
     !> COMMAND: mask
     !-------------------------------------------------------------
     if(command('mask  ', &
          " mask set [val v]"//LF//&
          "   - set all pixels to mask value (default 0=disable)"//LF//&
          " mask win  x1 y1 x2 y2 [val v]"//LF//&
          "   - set a rectangular mask "//LF//&
          " mask ring x0 y0 r1 r2 [val v]"//LF//&
          "   - set a ring mask with center (x0,y0) and inner/outer radius r1/r2"//LF//&
          " mask"//LF//&
          "   - show current mask mask$")) then
            " mask pixel or tau"//LF//LF//&
            " mask pix"//LF//&
            "   - show pixel mask"//LF//&
            " mask pix set [val <value>]"//LF//&
            "     - mask *all* pixels with <value> (0=clear, default)"//LF//&
            " mask pix win  <x1> <y1> <x2> <y2> [val <value>]"//LF//&
            "     - create a rectangular pixel mask with (x1,y1) upper left and"//LF//&
            "       (x2,y2) lower right rectangle corners"//LF//&
            " mask pix ring <x0> <y0> <r1> <r2> [val <value>]"//LF//&
            "     - create a ring pixel mask with center (x0,y0) and"//LF//&
            "       inner/outer radius r1/r2"//LF//&
            " "//LF//&
            " mask tau"//LF//&
            "     - show tau mask (equivalent to 'dir details')"//LF//&
            " mask tau set <itau> [run <numor>] [clear]"//LF//&
            "     - mask <itau> tau in a given run"//LF//&
            "       if clear is given, the tau is 'restored'"//LF//&
            " "//LF//&
            " NOTE: negative value for pixel mask <value> means apply the mask to the complement"//LF//&
            "       so for example to use only the center of the detector (assuming 16x16 pixels)"//LF//&
            "       use: mask pix ring 8 8 0 4 val -1"//LF//&
            "$")) then
            call cmd_mask()
        cycle commandloop
     endif
@@ -1443,19 +1464,25 @@ CONTAINS
  !> COMMAND: mask
  !! mask [options]      - mask pixel or tau
  !-------------------------------------------------------------
  !! mask pix [show]
  !!     - show mask
  !! mask pix set [val value]
  !!     - set all pixels to mask value (default 0=enable)
  !! mask pix win  x1 x2 y1 y2 [val value]
  !!     - set a rectangular mask
  !! mask pix ring x0 y0 r1 r2 [val value]
  !!     - set a ring mask with center (x0,y0) and inner/outer radius r1/r2
  !! mask pix
  !!     - show pixel mask
  !! mask pix set [val <value>]
  !!     - mask *all* pixels with <value> (0=clear, default)
  !! mask pix win  <x1> <y1> <x2> <y2> [val <value>]
  !!     - create a rectangular pixel mask with (x1,y1) upper left and
  !!       (x2,y2) lower right rectangle corners
  !! mask pix ring <x0> <y0> <r1> <r2> [val <value>]
  !!     - create a ring pixel mask with center (x0,y0) and
  !!       inner/outer radius r1/r2
  !! NOTE: negative value for <value> means apply the mask to the complement
  !!       so for example to use only the center of the detector (assuming 16x16 pixels)
  !!       use: mask pix ring 8 8 0 4 val -1
  !!
  !! mask tau [show]
  !!
  !! mask tau set [itau] run [numor] [clear]
  !!     - set tau mask
  !! mask tau
  !!     - show tau mask (equivalent to 'dir details')
  !! mask tau set <itau> [run <numor>] [clear]
  !!     - mask <itau> tau in a given run
  !!       if clear is given, the tau is "restored"
  subroutine cmd_mask()
    logical :: do_pix, do_tau
    logical :: do_set, do_win, do_ring
@@ -1475,7 +1502,7 @@ CONTAINS
    irun    = int(program_param%last_run)
    xmask   = 0

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

    if ( do_pix .and. do_tau) then
@@ -1495,7 +1522,9 @@ CONTAINS
        !    return
        !end if

        if ( do_win ) then ! set a rectangular mask
        if ( do_set ) then ! set to a constant value
            call set_detector_mask(instrument_parameters%detector, 'const', ival, xmask)
        else if ( do_win ) then ! set a rectangular mask
            if (iparf()<4) then
                call msg_error('drspine/mask', 'mask win - need 4 window parameters (x1,y1,x2,y2)', ERROR_OPTION_ARG)
            else
@@ -1513,21 +1542,22 @@ CONTAINS
                end do
                call set_detector_mask(instrument_parameters%detector, 'ring', ival, xmask)
            end if
        else if ( do_set ) then ! set to a constant value
            call set_detector_mask(instrument_parameters%detector, 'const', ival, xmask)
        else
        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)
        print *, inew, itau
        if (inew>0) then
        irun = get_named_value('run', irun, inew)
        if (do_set) then
            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)%number_of_points, &
                data_scan(i)%scan_point(itau)%flag = SCAN_MASKED
                data_scan(i)%scan_point(itau)%flag = ival
            enddo
        else
            do i=1, data_manager_size()
+3 −0
Original line number Diff line number Diff line
@@ -5,6 +5,7 @@ module reduce_data
  use iso_fortran_env, only : output_unit !, error_unit
  use constants_module
  use data_types
  use instrument_config

  implicit none

@@ -515,6 +516,8 @@ bgr_pixel_bin(l)
       do it=0, sig_point%no_lam
          do ix=1, sig_point%no_xpix
             do iy=1, sig_point%no_ypix
                ! FIXME: accessing global variable
                if ( instrument_parameters%detector%mask(ix,iy) /= 0 ) cycle
                if ( sig_point%pixelbin(it, ix, iy)%status /= PIXEL_OK ) cycle
                if ( res_point%pixelbin(it, ix, iy)%status /= PIXEL_OK ) cycle
                call add_pix_to_sqt(coll_data, res_point%pixelbin(it, ix, iy), sig_point%pixelbin(it, ix, iy), &