Commit 0f384497 authored by Zolnierczuk, Piotr's avatar Zolnierczuk, Piotr
Browse files

allow for missing phases, coord. sys. improvements

* allow for up to 2 last missing phase points
	- hard coded parameter,

* fixed mess with L, L1, L2. It did not affect the results - only L2 was used so far.
But for fixing monitor spectrum at SNS, we need the correct positions of detector and monitors.

	- L1 = distance from sample to source (negative)
	- L2 = distance from sample to detector (positive)
	- L  = total distance from the source to detecor
	- L = |L1| + |L2|
	- system variables
		i.det.src	 L
		i.det.sam	 L2
		i.src.sample L1
parent cd942326
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=0
export VERSION_RELEASE=1

export PROJLIB=lib$(PROJECT).a
export PROJARCH=$(PROJECT)-$(VERSION_MAJOR).$(VERSION_MINOR)
+15 −13
Original line number Diff line number Diff line
@@ -3,24 +3,26 @@
% ========================================================================================

\subsection{The NSE Laboratory Frame}
The NSE laboratory frame (also known as ella ``ELLA'') is a right-handed coordinate frame
The NSE laboratory frame (also known as ``ELLA'') is a right-handed coordinate frame
with the center (0,0,0) at the sample position, see Fig.~\ref{fig:ella_top_view}.
\begin{figure}[h!]
	\centering
	\includegraphics[height=7cm]{top_view}
	\caption[The top view of the NSE Laboratory Frame]{The top view of
	the NSE Laboratory Frame. The frame center is at the sample position.
	Two NSE carriers are shown in blue. L1 - is the source to sample distance
	and L2 is the distance from the sample to the detector.
	The polar angle $\varphi$ is measured with respect to the x-axis
	and the center of the of the detector is denoted by $\varphi_0$ (scattering angle).}
	\includegraphics[height=7cm,trim={0 4cm 0 4cm 0},clip]{top_view}
	\caption[The top view of the NSE Laboratory Frame]{The top view of the NSE Laboratory Frame:
    the reference frame center is at the sample position and the two NSE carriers are shown in blue, see text.}
	\label{fig:ella_top_view}
\end{figure}
The x-axis is horizontal and points downstream from the source toward
sample. The z-axis is vertical pointing up, and the y-axis is
horizontal completing the right handed coordinate system.
The polar angle $\varphi$ is measured with respect to the x-axis (polar
axis) and the azimuthal angle $\theta$ is measured in the y-z plane

The x-axis is horizontal and points downstream from the source toward sample, 
the z-axis is pointing up vertically, and the y-axis is horizontal completing the right handed coordinate system.
L1 denotes the sample to source distance (negative meaning the source location "upstream" from the sample);
L2 - the distance from the sample to the detector (positive, "downstream" from the sample) and $L=|L1|+|L2|$.
Note that at SNS, the control system reads the value of L as a mo\_l motor position.

%The polar angle $\varphi$ is measured with respect to the x-axis
%and the center of the of the detector is denoted by $\varphi_0$ (scattering angle).
The polar angle $\varphi$ is measured with respect to the x-axis (polar axis) 
and the azimuthal angle $\theta$ is measured in the y-z plane
with $0^{\circ}$ coinciding with the y-axis and clockwise direction when looking
downstream with the neutron flux direction.

+4.35 KiB (34.8 KiB)
Loading image diff...
+28 −17
Original line number Diff line number Diff line
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!-- Created with Inkscape (http://www.inkscape.org/) -->

<svg
   xmlns:dc="http://purl.org/dc/elements/1.1/"
   xmlns:cc="http://creativecommons.org/ns#"
@@ -14,9 +12,9 @@
   viewBox="0 0 744.09448819 1052.3622047"
   id="svg11822"
   version="1.1"
   inkscape:version="0.92.2 5c3e80d, 2017-08-06"
   inkscape:version="1.0.1 (c497b03c, 2020-09-10)"
   sodipodi:docname="top_view.svg"
   inkscape:export-filename="./top_view.png"
   inkscape:export-filename="/Users/zp1/bitmap.png"
   inkscape:export-xdpi="90"
   inkscape:export-ydpi="90">
  <defs
@@ -120,12 +118,13 @@
     inkscape:document-units="px"
     inkscape:current-layer="layer1"
     showgrid="true"
     inkscape:window-width="1440"
     inkscape:window-height="855"
     inkscape:window-width="1792"
     inkscape:window-height="1075"
     inkscape:window-x="0"
     inkscape:window-y="1"
     inkscape:window-y="23"
     inkscape:window-maximized="1"
     inkscape:snap-grids="true">
     inkscape:snap-grids="true"
     inkscape:document-rotation="0">
    <inkscape:grid
       type="xygrid"
       id="grid11830" />
@@ -203,7 +202,7 @@
         id="tspan12514"
         x="361.54407"
         y="398.63031"
         style="font-size:27.44093704px;line-height:1.25">Sample (0,0,0)</tspan></text>
         style="font-size:27.4409px;line-height:1.25">Sample (0,0,0)</tspan></text>
    <text
       xml:space="preserve"
       style="font-style:normal;font-weight:normal;line-height:0%;font-family:sans-serif;letter-spacing:0px;word-spacing:0px;fill:#000000;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
@@ -252,7 +251,7 @@
         id="tspan12514-4"
         x="358.43091"
         y="857.21368"
         style="font-size:27.94767761px;line-height:1.25">Source</tspan></text>
         style="font-size:27.9477px;line-height:1.25">Source</tspan></text>
    <text
       xml:space="preserve"
       style="font-style:normal;font-weight:normal;line-height:0%;font-family:sans-serif;text-align:start;letter-spacing:0px;word-spacing:0px;writing-mode:lr-tb;text-anchor:start;fill:#000000;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
@@ -263,7 +262,7 @@
         id="tspan12514-7"
         x="68.76104"
         y="137.07721"
         style="font-size:27.16168594px;line-height:0.5">Detector</tspan></text>
         style="font-size:27.1617px;line-height:0.5">Detector</tspan></text>
    <flowRoot
       xml:space="preserve"
       id="flowRoot12787"
@@ -275,7 +274,8 @@
           x="60"
           y="262.36221" /></flowRegion><flowPara
         id="flowPara12793"
         style="font-size:40px;line-height:1.25"> </flowPara></flowRoot>    <text
         style="font-size:40px;line-height:1.25"> </flowPara></flowRoot>
    <text
       xml:space="preserve"
       style="font-style:normal;font-weight:normal;line-height:0%;font-family:sans-serif;text-align:start;letter-spacing:0px;word-spacing:0px;writing-mode:lr-tb;text-anchor:start;fill:#000000;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
       x="460"
@@ -312,12 +312,12 @@
         id="tspan12514-4-7"
         x="462.96432"
         y="-314.41138"
         style="font-size:27.94767761px;line-height:1.25">Carrier1</tspan><tspan
         style="font-size:27.9477px;line-height:1.25">Carrier1</tspan><tspan
         sodipodi:role="line"
         x="462.96432"
         y="-279.47678"
         id="tspan4247"
         style="font-size:27.94767761px;line-height:1.25"> </tspan></text>
         style="font-size:27.9477px;line-height:1.25"> </tspan></text>
    <text
       xml:space="preserve"
       style="font-style:normal;font-weight:normal;line-height:0%;font-family:sans-serif;letter-spacing:0px;word-spacing:0px;fill:#000000;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
@@ -331,12 +331,12 @@
         id="tspan12514-4-7-3"
         x="301.96793"
         y="38.978447"
         style="font-size:27.94767761px;line-height:1.25">Carrier2</tspan><tspan
         style="font-size:27.9477px;line-height:1.25">Carrier2</tspan><tspan
         sodipodi:role="line"
         x="301.96793"
         y="73.91304"
         id="tspan4247-5"
         style="font-size:27.94767761px;line-height:1.25"> </tspan></text>
         style="font-size:27.9477px;line-height:1.25"> </tspan></text>
    <text
       xml:space="preserve"
       style="font-style:normal;font-weight:normal;line-height:0%;font-family:sans-serif;letter-spacing:0px;word-spacing:0px;fill:#000000;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
@@ -347,6 +347,17 @@
         id="tspan4220"
         x="311.81497"
         y="275.41382"
         style="font-size:26.60853004px;line-height:1.25">0</tspan></text>
         style="font-size:26.6085px;line-height:1.25">0</tspan></text>
    <text
       xml:space="preserve"
       style="font-style:normal;font-weight:normal;font-size:12px;line-height:0%;font-family:sans-serif;letter-spacing:0px;word-spacing:0px;fill:#000000;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
       x="56.278263"
       y="545.73859"
       id="text12508-2"><tspan
         sodipodi:role="line"
         id="tspan12510-1"
         x="56.278263"
         y="545.73859"
         style="font-size:40px;line-height:1.25;stroke-width:1px">L=L1+L2</tspan></text>
  </g>
</svg>
+28 −9
Original line number Diff line number Diff line
@@ -22,9 +22,9 @@ module instrument_config
  ! SNS-NSE DEFAULTS
  integer, parameter        :: SNS_NORM_DEFAULT = 0             ! default normalization monitor (proton charge)
  real(kind=DBL), parameter :: SNS_DET_SIZE =  0.300_DBL        ! detector size
  real(kind=DBL), parameter :: SNS_L1       =-21.300_DBL        ! source to sample
  real(kind=DBL), parameter :: SNS_L        = 21.300_DBL        ! abs. value source to detector (21.3m is the default (P2) SNS-NSE source to detector distance)
  real(kind=DBL), parameter :: SNS_L2       =  3.952_DBL        ! sample to detector
  real(kind=DBL), dimension(4), parameter :: SNS_MON_DIST = [ -2.668775_DBL, & ! sample to monitor1
  real(kind=DBL), dimension(4), parameter :: SNS_MON_DIST = [ -2.668775_DBL, & ! sample to monitor1 (negative - meaning upstream from the sample)
                                                              -2.708875_DBL, & ! sample to monitor2
                                                               SNS_L2      , &
                                                               SNS_L2      ]
@@ -32,7 +32,7 @@ module instrument_config
  ! J-NSE DEFAULTS
  integer, parameter        :: JNSE_NORM_DEFAULT = 5               ! default normalization monitor
  real(kind=DBL), parameter :: JNSE_DET_SIZE =  0.300_DBL          ! detector size
  real(kind=DBL), parameter :: JNSE_L1       =-46.000_DBL          ! source to sample
  real(kind=DBL), parameter :: JNSE_L        = 46.000_DBL          ! source to detector
  real(kind=DBL), parameter :: JNSE_L2       =  4.357_DBL          ! sample to detector
  real(kind=DBL), dimension(1), parameter :: JNSE_MON_DIST = [ -3.4_DBL] ! sample to monitor1

@@ -59,7 +59,7 @@ contains

            call init_config_struct(instrument_parameters, id,&
                                    pixel2d(0, 0, SNS_DET_SIZE, SNS_DET_SIZE),&
                                    SNS_L1, SNS_L2, SNS_MON_DIST)
                                    -SNS_L+SNS_L2, SNS_L2, SNS_MON_DIST)
            instrument_parameters%norm_counter = SNS_NORM_DEFAULT
            reduction_parameters%post_collection_qcatch = 0 ! switch off for SNS-NSE
        case (INST_JNSE)
@@ -67,7 +67,7 @@ contains
            call eshape_select(E_TG_ESHAPE)
            call init_config_struct(instrument_parameters, id,&
                                    pixel2d(0, 0, JNSE_DET_SIZE, JNSE_DET_SIZE),&
                                    JNSE_L1, JNSE_L2, JNSE_MON_DIST)
                                    -JNSE_L+JNSE_L2, JNSE_L2, JNSE_MON_DIST)
            instrument_parameters%norm_counter = JNSE_NORM_DEFAULT
            reduction_parameters%post_collection_qcatch = 0.005_DBL/ANGSTROEM
        case default
@@ -98,15 +98,18 @@ contains
    !! from drspine to new_com
    subroutine set_instrument_vars
        integer :: ier
        real(kind=DBL) :: det_src
        !
        det_src = instrument_parameters%detector%distance%value -  instrument_parameters%source%distance%value
        call setudf("i.instrument    ", real(instrument_parameters%id, kind=DBL), ier)
        call setudf("i.norm_counter  ", real(instrument_parameters%norm_counter, kind=DBL), ier)
        call setudf("i.det.src       ", instrument_parameters%source%distance%value, ier)
        call setudf("i.det.sam       ", instrument_parameters%detector%distance%value, ier)
        call setudf("i.det.sample    ", instrument_parameters%detector%distance%value, ier)
        call setudf("i.det.source    ", det_src, ier)
        call setudf("i.det.size_x    ", instrument_parameters%detector%detsize%size_x, ier)
        call setudf("i.det.size_y    ", instrument_parameters%detector%detsize%size_y, ier)
        call setudf("i.det.center_x  ", instrument_parameters%detector%detsize%center_x, ier)
        call setudf("i.det.center_y  ", instrument_parameters%detector%detsize%center_y, ier)
        call setudf("i.src.sample    ", instrument_parameters%source%distance%value, ier)
    end subroutine set_instrument_vars

    !?> get instrument config variables
@@ -114,6 +117,8 @@ contains
    subroutine get_instrument_vars
        !
        integer :: old_id, ierr
        real(kind=DBL) :: det_sample, src_sample
        real(kind=DBL) :: new_val

        ! instrument change
        old_id = instrument_parameters%id
@@ -127,13 +132,27 @@ contains
        ! normalization counter
        call extract("i.norm_counter  ", instrument_parameters%norm_counter, ierr)

        src_sample = instrument_parameters%source%distance%value
        det_sample = instrument_parameters%detector%distance%value
        !det_source = det_sample - src_sample

        ! detector configuration
        call extract("i.det.src       ", instrument_parameters%source%distance%value, ierr)
        call extract("i.det.sam       ", instrument_parameters%detector%distance%value, ierr)
        call extract("i.det.size_x    ", instrument_parameters%detector%detsize%size_x, ierr)
        call extract("i.det.size_y    ", instrument_parameters%detector%detsize%size_y, ierr)
        call extract("i.det.center_x  ", instrument_parameters%detector%detsize%center_x, ierr)
        call extract("i.det.center_y  ", instrument_parameters%detector%detsize%center_y, ierr)


        ! check if i.src.sample has changed
        call extract("i.det.sample    ", instrument_parameters%detector%distance%value, ierr)
        call extract("i.src.sample    ", instrument_parameters%source%distance%value, ierr)
        if (ierr==0 .and. &
            (det_sample /= instrument_parameters%detector%distance%value .or. &
             src_sample /= instrument_parameters%source%distance%value  )) then
            ! recalculate i.det.source
            new_val = instrument_parameters%detector%distance%value -  instrument_parameters%source%distance%value
            call setudf("i.det.source    ", new_val, ierr)
        end if
    end subroutine get_instrument_vars

end module instrument_config
Loading