
% Compute the STS-VCM curvature to bring the STS output pupil at a specific
% location



% % **************  AT4-STS J2-DL4  ********************
% % StationCoord case 'J2'
%         Station='J2';
%         StationPosition = struct('u',88.,'v',-96.);     % 88.016 -96.005 in ISS...      
% % UT output pupil position along u in meters  for DL4 
%         UTExitPupiluCoordinate = 54.125;   % OK, as in ISS
% % DL axis position  along v for DL4
%         DL='DL#4';
%         DLPosition = struct('v', -39.375, 'u0', 44.283); % v is OK but but DLMechZeroU=45.080 for DL3 and DL4 in ISS doc VLT-SPE-ESO-15410-2114
%       % DLPosition.vInRef    = DLPosition.v + 0.12; not taken into account
% %                  
    

% %%**************  AT3-STS G2-DL2  ********************
% % StationCoord case 'G2'-->STS G2-Dl2
%         Station='G2';
%         StationPosition = struct('u',32.,'v',-24.);  % 31.995 ;-24.003 in ISS doc....
%  % UT output pupil position along u in meters  for DL2
%         UTExitPupiluCoordinate = 49.875;  % OK, as in ISS
% % DL axis position  along v for DL2
%         DL='DL#2';
%         DLPosition = struct('v', -37.875, 'u0', 59.717); %  v is OK, but DLMechZeroU=58.920 for DL1 and DL2 in ISS doc VLT-SPE-ESO-15410-2114
% %                                                          % u0 does not play
% %                                                          % a role for VCM
% %                                                           % STS
% 


%% **************  AT3-STS I1-DL4  ********************
% % StationCoord case  'I1' -->STS I1-Dl4
%         Station='I1';
%         StationPosition = struct('u',72.,'v',-88.);
% % % UT output pupil position along u in meters  for DL4 
%         UTExitPupiluCoordinate = 54.125;   % OK, as in ISS
% % % DL axis position  along v for DL4
%         DL='DL#4';
%         DLPosition = struct('v', -39.375, 'u0', 44.283); % v is OK but but DLMechZeroU=45.080 for DL3 and DL4 in ISS doc VLT-SPE-ESO-15410-2114
% %       % DLPosition.vInRef    = DLPosition.v + 0.12; not taken into account
% 


% %************* A0 ********************
% % StationCoord case 'A0'-->AT3-STS A0
%         Station='A0';
%         StationPosition = struct('u',-32.,'v',-48.);  % -32.001 ;-48.013 in ISS doc....
%  
 %************* A1 ********************
 % StationCoord case 'A1'-->AT3-STS A1
        Station='A1';
        StationPosition = struct('u',-32.,'v',-64.);  % -32.001 ;-64.021 in ISS doc....
        
 %%************** DL#6  *******************************
 % UT output pupil position along u in meters  for DL6
        UTExitPupiluCoordinate = 46.375;  % as in ISS
 % DL axis position  along v for DL6
        DL='DL#6';
        DLPosition = struct('v', -41.375, 'u0', 59.717)
 
% %  %************** DL#1  ******************************   
%  % UT output pupil position along u in meters  for DL1
%         UTExitPupiluCoordinate = 50.625;  % as in ISS
%  % DL axis position  along v for DL1
%         DL='DL#1';
%         DLPosition = struct('v', -37.125, 'u0', 59.717);









                                                       
                                                         
fprintf('\n')
fprintf('**************** \n')
fprintf('Station %s \n', Station)
fprintf('Delay Line %s ', DL)       
[R_nom,Curv_nom,Pout_nom] = VCM_STS([StationPosition.u,StationPosition.v], UTExitPupiluCoordinate, DLPosition.v);
 

 
% % % % I scan the UTexitPupil by +/- a %
a=60/100
UTExitPupiluCoordinate = UTExitPupiluCoordinate*[1-a:a/20:1+a];

[R,Curv,Pout] = VCM_STS([StationPosition.u,StationPosition.v], UTExitPupiluCoordinate, DLPosition.v);


 figure(2);
 subplot(2,1,1); set(gca,'FontSize',13);
 plot(Curv,Pout,'r.-',Curv_nom,Pout_nom,'bd');grid
 xlabel('VCM Curvature in mm-1')
 ylabel(' Pupil distance from Station center (m)')
 title({['VCM CURV/ROC for various Pout'],['Nominal Pout for AT-',Station,' ', DL,' =' num2str(Pout_nom )]})

 subplot(2,1,2); set(gca,'FontSize',13);
 plot(R*1000,Pout,'r.-',R_nom*1000,Pout_nom,'bd');grid
 xlabel('VCM ROC in mm')
 ylabel(' Pupil distance from Station center (m)')


 