Home > mml > gcr2loco.m

gcr2loco

PURPOSE ^

LOCO2GCR - Converts the LOCO BPM output to gain, crunch, and roll parameterization

SYNOPSIS ^

function m = gcr2loco(gx, gy, c, r)

DESCRIPTION ^

LOCO2GCR - Converts the LOCO BPM output to gain, crunch, and roll parameterization
  M = gcr2loco(Gx, Gy, C, R)

  INPUTS
  1. Gx - Horizontal gain
  2. Gy - Vertical gain
  3. C - Crunch
  4. R - Roll [radians]

  OUTPUTS
  1. M - LOCO output matrix (gain/coupling) 
     Note: for vector inputs the output will have rows [Gx Gy C R]

  ALGORITHM
  The LOCO matrix for a BPM converts the model BPM data to the
  coordinate system of the actual BPM measurement.  The new BPM is   
  is defined as the calibrated BPM data.  The middle layer applies
  the coordinate conversion from the measured data to the model gcr2loco splits this matrix up
  into a Gain, Crunch, and Roll term.

  [Measured Coordinate System] = LOCO Matrix * [Model]                          (LOCO coordinate transform)
  [Calibrated to Model Coordinate System] = inv(LOCO Matrix) * [Measured Data]  (Middle layer coordinate transform)

  The middle layer stores the coordinate transform in terms of gain, crunch, and roll.
  The gain terms are use in real2raw/raw2real (hence hw2physics/physics2hw) and the 
  crunch and roll are used in programs like getpvmodel/setpvmodel.  That is, hw2physics/physics2hw
  does not make a coordinate rotation, it just corrects the gain.

  inv(LOCO Matrix) = Rotation Matrix  *  Crunch Matrix        *  Gain Matrix
                    | cos(R) sin(R) |   | 1  C |                 | Gx  0  |
                    |-sin(R) cos(R) |   | C  1 | / sqrt(1-C^2)   | 0   Gy |

  See also loco2gcr, getgain, getroll, getcrunch

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function m = gcr2loco(gx, gy, c, r)
0002 %LOCO2GCR - Converts the LOCO BPM output to gain, crunch, and roll parameterization
0003 %  M = gcr2loco(Gx, Gy, C, R)
0004 %
0005 %  INPUTS
0006 %  1. Gx - Horizontal gain
0007 %  2. Gy - Vertical gain
0008 %  3. C - Crunch
0009 %  4. R - Roll [radians]
0010 %
0011 %  OUTPUTS
0012 %  1. M - LOCO output matrix (gain/coupling)
0013 %     Note: for vector inputs the output will have rows [Gx Gy C R]
0014 %
0015 %  ALGORITHM
0016 %  The LOCO matrix for a BPM converts the model BPM data to the
0017 %  coordinate system of the actual BPM measurement.  The new BPM is
0018 %  is defined as the calibrated BPM data.  The middle layer applies
0019 %  the coordinate conversion from the measured data to the model gcr2loco splits this matrix up
0020 %  into a Gain, Crunch, and Roll term.
0021 %
0022 %  [Measured Coordinate System] = LOCO Matrix * [Model]                          (LOCO coordinate transform)
0023 %  [Calibrated to Model Coordinate System] = inv(LOCO Matrix) * [Measured Data]  (Middle layer coordinate transform)
0024 %
0025 %  The middle layer stores the coordinate transform in terms of gain, crunch, and roll.
0026 %  The gain terms are use in real2raw/raw2real (hence hw2physics/physics2hw) and the
0027 %  crunch and roll are used in programs like getpvmodel/setpvmodel.  That is, hw2physics/physics2hw
0028 %  does not make a coordinate rotation, it just corrects the gain.
0029 %
0030 %  inv(LOCO Matrix) = Rotation Matrix  *  Crunch Matrix        *  Gain Matrix
0031 %                    | cos(R) sin(R) |   | 1  C |                 | Gx  0  |
0032 %                    |-sin(R) cos(R) |   | C  1 | / sqrt(1-C^2)   | 0   Gy |
0033 %
0034 %  See also loco2gcr, getgain, getroll, getcrunch
0035 
0036 %  Written by Greg Portmann
0037 
0038 
0039 if nargin == 0
0040     error('At least one input required.');
0041 end
0042 
0043 
0044 if length(gx) > 1
0045     for i = 1:size(gx,1)
0046         if nargin < 2
0047             mm = gcr2loco(gx(i));
0048         elseif nargin < 3
0049             mm = gcr2loco(gx(i), gy(i));
0050         elseif nargin < 4
0051             mm = gcr2loco(gx(i), gy(i), c(i));
0052         else
0053             mm = gcr2loco(gx(i), gy(i), c(i), r(i));
0054         end
0055         m(i,:) = [mm(1) mm(2) mm(3) mm(4)];
0056     end
0057     return
0058 end
0059 
0060 
0061 % Roll term
0062 if nargin == 1
0063     m = [1/gx 0; 0 0];
0064     return
0065 else
0066     m = [1/gx 0; 0 1/gy];
0067 end
0068 
0069 
0070 % Crunch term
0071 if nargin >= 3
0072     m = m * [1 -c; -c 1] / sqrt(1-c^2);
0073 end
0074 
0075 
0076 % Roll term
0077 if nargin >= 4
0078     m = m * [cos(r) sin(r); -sin(r) cos(r)];
0079 end
0080

Generated on Fri 01-Aug-2008 10:57:33 by m2html © 2003