%**************************************************************************
%hall2_anal_param
%This function sets the program parameters.
%
%Output:
%param, structure containing program parameters
%
%Zachary Wolf
%6/19/13

function [param] = hall2_anal_param(file_num)

%Set program parameters-----

%Input file information from list
hall2_anal_input_file_list;
INPUT_FILE_DIR = INPUT_FILE_DIRs{file_num};
INPUT_FILE_NAME = INPUT_FILE_NAMEs{file_num};
INPUT_FILE_TYPE = INPUT_FILE_TYPEs{file_num};
UND_POL_MODE = UND_POL_MODEs{file_num};

%Input file information
%INPUT_FILE_DIR = 'C:\Magdata\Delta Data\KR0707\';   %Directory where data is located, results go there also
%INPUT_FILE_DIR = 'C:\Magdata\Delta Data\KR1000\';   %Directory where data is located, results go there also
%INPUT_FILE_DIR = 'C:\Magdata\Delta Data\Run 531\';   %Directory where data is located, results go there also
%INPUT_FILE_NAME = 'DUTestOutput.001';             %Name of data file to analyze
%INPUT_FILE_NAME = 'DUTestStep+0.dat';             %Name of data file to analyze
%INPUT_FILE_NAME = 'DUTestOutput.dat';             %Name of data file to analyze
%INPUT_FILE_TYPE = 'ZVXYZVXYZH';                   %File type, gives format: ZVXYVXYH

%Alignment system information
%ALIGN_PROBE_POS_FILE_NAME = 'V:\MET\MagServe\MagData\DELTA\Delta data\Assembled Measurements\Probe Position Measurements\res_20141003 1514.mat';
%ALIGN_PROBE_POS_FILE_NAME = 'C:\Magdata\Delta Probe Position Measurements\res_20141005 1012.mat';
ALIGN_PROBE_POS_FILE_NAME = 'V:\MET\MagServe\MagData\DELTA\Delta data\Assembled Measurements\Probe Position Measurements\20141005 1012\res_20141005 1012.mat';
ALIGN_Z_AXIS_ENTER = 0;
ALIGN_Z_AXIS_EXIT = 3.3;

%Probe package parameters
PROBE2_OFFSET_DIR = 'Y';

%Undulator parameters
%UND_POL_MODE = 'LIN_POL_VERT_FIELD';
%UND_POL_MODE = 'LIN_POL_HORIZ_FIELD';
%UND_POL_MODE = 'CIRC_POL_RIGHT_HAND';
%UND_POL_MODE = 'CIRC_POL_LEFT_HAND';
%UND_POL_MODE = 'LIN_45_DEG';
UND_PERIOD_NOM = 0.032;  %(m)
NUM_END_POLES = 4;

%Probe 1 calibration information
PROBE1_BX_CALIB_FILE = 'V:\MET\MagServe\MagData\DELTA\Delta data\Assembled Measurements\Hall Probe Calibrations\SENIS_119-12\SENIS_119-12_X.ini';
PROBE1_BY_CALIB_FILE = 'V:\MET\MagServe\MagData\DELTA\Delta data\Assembled Measurements\Hall Probe Calibrations\SENIS_119-12\SENIS_119-12_Y.ini';

%Probe 2 calibration information
PROBE2_BX_CALIB_FILE = 'V:\MET\MagServe\MagData\DELTA\Delta data\Assembled Measurements\Hall Probe Calibrations\SENIS_120-12\SENIS_120-12_X.ini';
PROBE2_BY_CALIB_FILE = 'V:\MET\MagServe\MagData\DELTA\Delta data\Assembled Measurements\Hall Probe Calibrations\SENIS_120-12\SENIS_120-12_Y.ini';

%Zero Gauss measurements
NUM_ZERO_GAUSS_MEAS = 200;

%Calculate the fields on the nominal axis, linear polarization vertical field
X1_MINUS_XC_NOM = (40 + 62) * 1.e-6;  %(m)
Y1_MINUS_YC_NOM = (-15 - 75) * 1.e-6;  %(m)
KX_NOM = 222;  %(1/m) Vertical field
KY_NOM = 129i;  %(1/m)
% KX_NOM = 129i;  %(1/m) Horizontal field
% KY_NOM = 222;  %(1/m)
KU_NOM = 2 * pi / .032;  %(1/m)

%Put the probe parameters in the probe_param structure-----

%Put the probe parameters into a structure
probe1_param.bx_sensor.x = -.04e-3;
probe1_param.bx_sensor.y = .10e-3;
probe1_param.bx_sensor.z = -2.15e-3;
probe1_param.bx_sensor.roll = 0;
probe1_param.bx_sensor.pitch = 0;
probe1_param.bx_sensor.yaw = -.202 * pi / 180 + .00594;  %Correction from the data -
%
probe1_param.by_sensor.x = 0;
probe1_param.by_sensor.y = 0;
probe1_param.by_sensor.z = 0;
probe1_param.by_sensor.roll = 1.703 * pi / 180;
probe1_param.by_sensor.pitch = -.241 * pi / 180;
probe1_param.by_sensor.yaw = 0;
%
probe1_param.bz_sensor.x = -.19e-3;
probe1_param.bz_sensor.y = .15e-3;
probe1_param.bz_sensor.z = .8e-3;
probe1_param.bz_sensor.roll = 0;
probe1_param.bz_sensor.pitch = .025 * pi / 180;
probe1_param.bz_sensor.yaw = .208 * pi / 180;
%
probe2_param.bx_sensor.x = -.12e-3;
probe2_param.bx_sensor.y = .44e-3;
probe2_param.bx_sensor.z = -31.06e-3;
probe2_param.bx_sensor.roll = -.185 * pi / 180;
probe2_param.bx_sensor.pitch = 0;
probe2_param.bx_sensor.yaw = .994 * pi / 180 + .0176;  %Correction from the data -
%
probe2_param.by_sensor.x = -.05e-3;
probe2_param.by_sensor.y = .31e-3;
probe2_param.by_sensor.z = -28.82e-3;
probe2_param.by_sensor.roll = 1.653 * pi / 180;
probe2_param.by_sensor.pitch = -.094 * pi / 180;
probe2_param.by_sensor.yaw = 0;
%
probe2_param.bz_sensor.x = -.16e-3;
probe2_param.bz_sensor.y = .37e-3;
probe2_param.bz_sensor.z = -27.95e-3;
probe2_param.bz_sensor.roll = 0;
probe2_param.bz_sensor.pitch = .088 * pi / 180;
probe2_param.bz_sensor.yaw = -.158 * pi / 180;

%Put the parameters in the param structure-----

%Put the parameters in the parameter structure
param.input_file_dir = INPUT_FILE_DIR;
param.input_file_name = INPUT_FILE_NAME;
param.input_file_type = INPUT_FILE_TYPE;
param.align_probe_pos_file_name = ALIGN_PROBE_POS_FILE_NAME;
param.align_z_axis_enter = ALIGN_Z_AXIS_ENTER;
param.align_z_axis_exit = ALIGN_Z_AXIS_EXIT;
param.und_pol_mode = UND_POL_MODE;
param.und_period_nom = UND_PERIOD_NOM;
param.num_end_poles = NUM_END_POLES;
param.probe1_bx_calib_file = PROBE1_BX_CALIB_FILE;
param.probe1_by_calib_file = PROBE1_BY_CALIB_FILE;
param.probe2_bx_calib_file = PROBE2_BX_CALIB_FILE;
param.probe2_by_calib_file = PROBE2_BY_CALIB_FILE;
param.num_zero_gauss_meas = NUM_ZERO_GAUSS_MEAS;
param.x1_minus_xc_nom = X1_MINUS_XC_NOM;
param.y1_minus_yc_nom = Y1_MINUS_YC_NOM;
param.kx_nom = KX_NOM;
param.ky_nom = KY_NOM;
param.ku_nom = KU_NOM;
param.probe2_offset_dir = PROBE2_OFFSET_DIR;
param.probe1_param = probe1_param;
param.probe2_param = probe2_param;

%Done
