Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

updated and added files related to Australian Synchrotron (ASP) #4

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
180 changes: 90 additions & 90 deletions machine/ASP/StorageRing/amp2k.m
Original file line number Diff line number Diff line change
@@ -1,90 +1,90 @@
function k = amp2k(Family, Field, Amps, DeviceList, Energy, C, K2AmpScaleFactor)
%AMP2K - Converts amperes to simulator values
% k = amp2k(Family, Field, Amps, DeviceList, Energy, Coefficients, K2AmpScaleFactor)
% or
% k = amp2k(Family, Field, Amps, DeviceList, Energy, MagnetCoreType, K2AmpScaleFactor)
%
% Calculates the "K-value" from the coefficients (or MagnetCoreType),
% current [amps], energy, and linear scale factor
%
% For dipole: k = B / Brho
% For quadrupole: k = B'/ Brho
% For sextupole: k = B"/ Brho / 2 (to be compatible with AT)
%
% A curve vector or a MagnetCoreType string (current curves found from
% magnetcoefficents.m) can be used. Amps and Coefficients must have equal
% number of rows or one must only have one row.
%
% Energy can be anything getenergy accepts, like 'Model' or 'Online'.
%
% The K2AmpScaleFactor linearly scales the input current: Amps = Amps ./ K2AmpScaleFactor
% This can be used to account for linear calibration errors of the power supply and magnet
%
% NOTES
% 1. If energy is not an input or empty, then the energy is obtained from getenergy.
% 2. Family and Field inputs are not used but there automatically part of the hw2physics call.
%
% Original structure set up using polynomials by M. Yoon 4/8/03
% Modified for ASP by E. Tan 31/05/2006

if nargin < 4
error('At least 4 inputs required');
end

if nargin < 6
C = [];
end
if isempty(C)
%[C, Leff, MagnetName] = magnetcoefficients(Family);
temp = getfamilydata(Family, Field, 'HW2PhysicsParams', DeviceList);
C = temp{1};
end

if nargin < 5
Energy = [];
end
if isempty(Energy)
Energy = getenergy;
elseif ischar(Energy)
Energy = getenergy(Energy);
end


% If Amps is a row vector make it a column vector
Amps = Amps(:);

brho = getbrho(Energy);

% Scale solution if required
if nargin >= 7
Amps = Amps ./ K2AmpScaleFactor;
end



if isstr(C)
[C, Leff, MagnetName] = magnetcoefficients(C);
end

if any(size(C,1) ~= length(Amps))
if length(Amps) == 1
Amps = ones(size(C,1),1) * Amps;
elseif size(C,1) == 1
%C = ones(size(Amps,1),1) * C;
else
error('Amps and Coefficients must have equal number of rows or one must only have one row');
end
end

% B, B', or B" scaled by energy. Applies to all other magnets other than
% the dipoles. The curve C is arranged such that the first half of the row
% vector contains the current data and the second half contains the B, B'
% and/or B" as a function of the current data.
splitind = size(C,2)/2;
for i = 1:length(Amps)
if size(C,1) == 1
k(i,1) = interp1(C(1,1:splitind),C(1,splitind+1:end),Amps(i),'linear','extrap') / brho;
else
k(i,1) = interp1(C(i,1:splitind),C(i,splitind+1:end),Amps(i),'linear','extrap') / brho;
end
end
function k = amp2k(Family, Field, Amps, DeviceList, Energy, C, K2AmpScaleFactor)
%AMP2K - Converts amperes to simulator values
% k = amp2k(Family, Field, Amps, DeviceList, Energy, Coefficients, K2AmpScaleFactor)
% or
% k = amp2k(Family, Field, Amps, DeviceList, Energy, MagnetCoreType, K2AmpScaleFactor)
%
% Calculates the "K-value" from the coefficients (or MagnetCoreType),
% current [amps], energy, and linear scale factor
%
% For dipole: k = B / Brho
% For quadrupole: k = B'/ Brho
% For sextupole: k = B"/ Brho / 2 (to be compatible with AT)
%
% A curve vector or a MagnetCoreType string (current curves found from
% magnetcoefficents.m) can be used. Amps and Coefficients must have equal
% number of rows or one must only have one row.
%
% Energy can be anything getenergy accepts, like 'Model' or 'Online'.
%
% The K2AmpScaleFactor linearly scales the input current: Amps = Amps ./ K2AmpScaleFactor
% This can be used to account for linear calibration errors of the power supply and magnet
%
% NOTES
% 1. If energy is not an input or empty, then the energy is obtained from getenergy.
% 2. Family and Field inputs are not used but there automatically part of the hw2physics call.
%
% Original structure set up using polynomials by M. Yoon 4/8/03
% Modified for ASP by E. Tan 31/05/2006
if nargin < 4
error('At least 4 inputs required');
end
if nargin < 6
C = [];
end
if isempty(C)
%[C, Leff, MagnetName] = magnetcoefficients(Family);
temp = getfamilydata(Family, Field, 'HW2PhysicsParams', DeviceList);
C = temp{1};
end
if nargin < 5
Energy = [];
end
if isempty(Energy)
Energy = getenergy;
elseif ischar(Energy)
Energy = getenergy(Energy);
end
% If Amps is a row vector make it a column vector
Amps = Amps(:);
brho = getbrho(Energy);
% Scale solution if required
if nargin >= 7
Amps = Amps ./ K2AmpScaleFactor;
end
if isstr(C)
[C, Leff, MagnetName] = magnetcoefficients(C);
end
if any(size(C,1) ~= length(Amps))
if length(Amps) == 1
Amps = ones(size(C,1),1) * Amps;
elseif size(C,1) == 1
%C = ones(size(Amps,1),1) * C;
else
error('Amps and Coefficients must have equal number of rows or one must only have one row');
end
end
% B, B', or B" scaled by energy. Applies to all other magnets other than
% the dipoles. The curve C is arranged such that the first half of the row
% vector contains the current data and the second half contains the B, B'
% and/or B" as a function of the current data.
splitind = size(C,2)/2;
for i = 1:length(Amps)
if size(C,1) == 1
k(i,1) = interp1(C(1,1:splitind),C(1,splitind+1:end),Amps(i),'linear','extrap') / brho;
else
k(i,1) = interp1(C(i,1:splitind),C(i,splitind+1:end),Amps(i),'linear','extrap') / brho;
end
end
46 changes: 22 additions & 24 deletions machine/ASP/StorageRing/aoinit.m
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,10 @@ function aoinit(SubMachineName)
%AOINIT - Initialization function for the Matlab Middle Layer (MML)


% The path does not needs to be set in Standalone mode
% The path does not needs to be set in Standalone mode. Standalone
% applications must not call addpath. If it needs to call external
% functions/libraries that may not be directly called within the files it
% needs to be "linked" when compiling.
if ~isdeployed_local

MMLROOT = getmmlroot;
Expand All @@ -15,15 +18,15 @@ function aoinit(SubMachineName)
%end

% mca (since some people use mca directly)
%addpath(fullfile(MMLROOT, 'links', 'mca_asp'));
addpath(fullfile(MMLROOT, 'online', 'mca', 'mca_asp'));

% orbit
addpath(fullfile(MMLROOT, 'applications', 'orbit'), '-begin');
addpath(fullfile(MMLROOT, 'applications', 'orbit', 'asp'), '-begin');
addpath(fullfile(MMLROOT, 'applications', 'orbit', 'lib'), '-begin');
% addpath(fullfile(MMLROOT, 'applications', 'orbit'), '-begin');
% addpath(fullfile(MMLROOT, 'applications', 'orbit', 'asp'), '-begin');
% addpath(fullfile(MMLROOT, 'applications', 'orbit', 'lib'), '-begin');

% SOFB
%addpath(fullfile(MMLROOT, 'applications', 'SOFB'), '-begin');
% addpath(fullfile(MMLROOT, 'applications', 'SOFB'), '-begin');

% Add magnet_calibration_curves
addpath(fullfile(MMLROOT, 'machine', 'ASP', 'StorageRing', 'magnet_calibration_curves'),'-begin');
Expand All @@ -32,32 +35,27 @@ function aoinit(SubMachineName)
addpath(fullfile(MMLROOT, 'machine', 'ASP', 'StorageRing', 'magnetcycling'),'-begin');

% BPM scripts
%addpath(fullfile(MMLROOT, 'machine', 'ASP', 'StorageRing', 'bpm_scripts'),'-begin');
addpath(fullfile(MMLROOT, 'machine', 'ASP', 'StorageRing', 'bpm_scripts'),'-begin');

% Add measurements directory
%dirs = {'beamsize','betas','emittance','iccd','ltb','screens','stability','streakcamera','tunes'};
%for i=1:length(dirs)
% addpath(fullfile([filesep 'asp'],'usr','measurements',dirs{i}),'-begin');
%end
% dirs = {'beamsize','betas','emittance','iccd','ltb','screens','stability','streakcamera','tunes'};
% for i=1:length(dirs)
% addpath(fullfile([filesep 'asp'],'usr','measurements',dirs{i}),'-begin');
% end

% Make ASP first on the path
addpath(fullfile(MMLROOT, 'machine', 'ASP', 'StorageRing'),'-begin');

end


% Initialize
aspinit;





function RunTimeFlag = isdeployed_local
% isdeployed is not in matlab 6.5
V = version;
if str2num(V(1,1)) < 7
RunTimeFlag = 0;
else
RunTimeFlag = isdeployed;
end
function RunTimeFlag = isdeployed_local
% isdeployed is not in matlab 6.5
V = version;
if str2num(V(1,1)) < 7
RunTimeFlag = 0;
else
RunTimeFlag = isdeployed;
end
76 changes: 38 additions & 38 deletions machine/ASP/StorageRing/aspinfo.m
Original file line number Diff line number Diff line change
@@ -1,38 +1,38 @@
function alsinfo
%ASPINFO - Prints hypertext for useful websites and commands to the command window
%
% Written by Greg Portmann

fprintf('\n Useful Documents\n');

fprintf(' <a href="%s">Matlab Middle Layer (MML) Manual</a> ', [getmmlroot, 'mml',filesep,'docs',filesep,'MatlabMiddleLayerManual.htm']);
fprintf(' <a href="%s">Matlab Middle Layer (MML) Quick Reference</a>\n', [getmmlroot, 'mml',filesep,'docs',filesep,'MiddleLayerQuickReference.htm']);

fprintf(' <a href="%s">Matlab Middle Layer (MML) Objects</a> ', [getmmlroot, 'mml',filesep,'docs',filesep,'MiddleLayerObjects.htm']);
fprintf(' <a href="%sindex.html">Matlab Middle Layer (MML) HTML Help</a>\n', [getmmlroot, 'mml',filesep,'doc_html',filesep]);
fprintf(' <a href="%sindex.html">Accelerator Toolbox (AT) HTML Help</a>\n', [getmmlroot, 'at', filesep,'doc_html',filesep]);

%fprintf('\n Useful Websites\n');
%fprintf(' <a href="http://www.asp.???">ASP Homepage</a> ');


%fprintf(' <a href="http://controls.als.lbl.gov/dynamic_pages/incoming/portmann/archiver">ALS Week Performance Data</a>');
%fprintf(' <a href="http://als.lbl.gov/data_access.html">ALS Data Access Facilities</a>\n');

fprintf('\n Useful Commands\n');
fprintf(' <a href="matlab: setpathmml;">setpathmml</a> - Sets the Matlab path for an accelerator (like <a href="matlab: setpathals;">ALS</a> or <a href="matlab: setpathspear3;">Spear3</a>)\n');

fprintf(' Possible ASP Middle Layers: <a href="matlab: setpathasp;">Storage Ring</a>, <a href="matlab: setpathasp booster;">Booster</a>, <a href="matlab: setpathasp BTS;">BTS</a>, or , <a href="matlab: setpathasp LTB;">LTB</a>\n' ');

fprintf(' <a href="matlab: setoperationalmode;">setoperationalmode</a> - Change the operational mode (like 1.5 GeV or 1.9 GeV).\n');
fprintf(' <a href="matlab: plotfamily;">plotfamily</a> - General purpose plotting and application launcher program\n');
fprintf(' <a href="matlab: mmlviewer;">mmlviewer</a> - View the MML setup variables as well as lattice files\n');
fprintf(' <a href="matlab: setorbitgui;">setorbitgui</a> - General SVD orbit correction application \n');
fprintf(' <a href="matlab: setorbitbumpgui;">setorbitbumpgui</a> - Orbit bump application\n');
fprintf(' <a href="matlab: plotorbit(''Golden'');">Plot the Orbit w.r.t. the Golden Orbit</a> <a href="matlab: plotgoldenorbit;">Plot the Golden Orbit</a>\n');
fprintf(' <a href="matlab: plotorbit(''Offset'');">Plot the Orbit w.r.t. the Offset Orbit</a> <a href="matlab: plotoffsetorbit;">Plot the Offset Orbit</a>\n');
fprintf(' <a href="matlab: plotbpmresp;">Plot the BPM Response Matrix</a> <a href="matlab: plotorbitdata([getfamilydata(''Directory'',''OpsData''),getfamilydata(''OpsData'',''BPMSigmaFile'')]);">Plot the BPM Standard Deviations</a>\n');
fprintf(' <a href="matlab: plotcm;">Plot the Correctors</a> <a href="matlab: plotdisp(''physics'');">Plot the Measured Dispersion Function</a>\n');
fprintf(' <a href="matlab: switch2online;">Online Mode</a> <a href="matlab: switch2sim;">Simulation Mode</a>\n');
fprintf(' <a href="matlab: switch2allbpms(''Display'');">Use All BPMs</a> <a href="matlab: switch2bergoz(''Display'');">Bergoz Only BPMs</a>\n');
fprintf(' <a href="matlab: figure;">New Figure Window</a> <a href="matlab: close all">Close All Figure Windows</a>\n');
function alsinfo
%ASPINFO - Prints hypertext for useful websites and commands to the command window
%
% Written by Greg Portmann
fprintf('\n Useful Documents\n');
fprintf(' <a href="%s">Matlab Middle Layer (MML) Manual</a> ', [getmmlroot, 'mml',filesep,'docs',filesep,'MatlabMiddleLayerManual.htm']);
fprintf(' <a href="%s">Matlab Middle Layer (MML) Quick Reference</a>\n', [getmmlroot, 'mml',filesep,'docs',filesep,'MiddleLayerQuickReference.htm']);
fprintf(' <a href="%s">Matlab Middle Layer (MML) Objects</a> ', [getmmlroot, 'mml',filesep,'docs',filesep,'MiddleLayerObjects.htm']);
fprintf(' <a href="%sindex.html">Matlab Middle Layer (MML) HTML Help</a>\n', [getmmlroot, 'mml',filesep,'doc_html',filesep]);
fprintf(' <a href="%sindex.html">Accelerator Toolbox (AT) HTML Help</a>\n', [getmmlroot, 'at', filesep,'doc_html',filesep]);
%fprintf('\n Useful Websites\n');
%fprintf(' <a href="http://www.asp.???">ASP Homepage</a> ');
%fprintf(' <a href="http://controls.als.lbl.gov/dynamic_pages/incoming/portmann/archiver">ALS Week Performance Data</a>');
%fprintf(' <a href="http://als.lbl.gov/data_access.html">ALS Data Access Facilities</a>\n');
fprintf('\n Useful Commands\n');
fprintf(' <a href="matlab: setpathmml;">setpathmml</a> - Sets the Matlab path for an accelerator (like <a href="matlab: setpathals;">ALS</a> or <a href="matlab: setpathspear3;">Spear3</a>)\n');
fprintf(' Possible ASP Middle Layers: <a href="matlab: setpathasp;">Storage Ring</a>, <a href="matlab: setpathasp booster;">Booster</a>, <a href="matlab: setpathasp BTS;">BTS</a>, or , <a href="matlab: setpathasp LTB;">LTB</a>\n' ');
fprintf(' <a href="matlab: setoperationalmode;">setoperationalmode</a> - Change the operational mode (like 1.5 GeV or 1.9 GeV).\n');
fprintf(' <a href="matlab: plotfamily;">plotfamily</a> - General purpose plotting and application launcher program\n');
fprintf(' <a href="matlab: mmlviewer;">mmlviewer</a> - View the MML setup variables as well as lattice files\n');
fprintf(' <a href="matlab: setorbitgui;">setorbitgui</a> - General SVD orbit correction application \n');
fprintf(' <a href="matlab: setorbitbumpgui;">setorbitbumpgui</a> - Orbit bump application\n');
fprintf(' <a href="matlab: plotorbit(''Golden'');">Plot the Orbit w.r.t. the Golden Orbit</a> <a href="matlab: plotgoldenorbit;">Plot the Golden Orbit</a>\n');
fprintf(' <a href="matlab: plotorbit(''Offset'');">Plot the Orbit w.r.t. the Offset Orbit</a> <a href="matlab: plotoffsetorbit;">Plot the Offset Orbit</a>\n');
fprintf(' <a href="matlab: plotbpmresp;">Plot the BPM Response Matrix</a> <a href="matlab: plotorbitdata([getfamilydata(''Directory'',''OpsData''),getfamilydata(''OpsData'',''BPMSigmaFile'')]);">Plot the BPM Standard Deviations</a>\n');
fprintf(' <a href="matlab: plotcm;">Plot the Correctors</a> <a href="matlab: plotdisp(''physics'');">Plot the Measured Dispersion Function</a>\n');
fprintf(' <a href="matlab: switch2online;">Online Mode</a> <a href="matlab: switch2sim;">Simulation Mode</a>\n');
fprintf(' <a href="matlab: switch2allbpms(''Display'');">Use All BPMs</a> <a href="matlab: switch2bergoz(''Display'');">Bergoz Only BPMs</a>\n');
fprintf(' <a href="matlab: figure;">New Figure Window</a> <a href="matlab: close all">Close All Figure Windows</a>\n');
Loading