Skip to content
Snippets Groups Projects
Commit b13c261f authored by Luke Simons's avatar Luke Simons
Browse files

Revert changes to tcv2ids and adding tcv_get_deploymentinfo.m

parent 154da536
No related branches found
No related tags found
1 merge request!171Resolve "Add tcv_get_ids_bolometer to TCV_IMAS functions"
...@@ -117,25 +117,6 @@ for i=1:length(params_tcv2ids.ids_names) ...@@ -117,25 +117,6 @@ for i=1:length(params_tcv2ids.ids_names)
tmp = gdat(shot,gdat_params); tmp = gdat(shot,gdat_params);
ids_from_tcv.(ids_to_get) = tmp.(ids_to_get); ids_from_tcv.(ids_to_get) = tmp.(ids_to_get);
ids_from_tcv.([ids_to_get '_description']) = tmp.([ids_to_get '_description']); ids_from_tcv.([ids_to_get '_description']) = tmp.([ids_to_get '_description']);
% Retrieve versioning information from .this-deployment.info
if ~isempty(ids_from_tcv.(ids_to_get).code.name)
library_gitinfo= ...
tcv_get_deploymentinfo(fullfile(fileparts(which(ids_from_tcv.(ids_to_get).code.name)),'.this-deployment.info'));
ids_from_tcv.(ids_to_get).code.commit = library_gitinfo.git_commit;
ids_from_tcv.(ids_to_get).code.version = library_gitinfo.git_tag;
ids_from_tcv.(ids_to_get).code.repository =library_gitinfo.gitlab_project_url;
end
for ii = 1:numel(ids_from_tcv.(ids_to_get).code.library)
if ~isempty(ids_from_tcv.(ids_to_get).code.library{ii}.name)
library_gitinfo= ...
tcv_get_deploymentinfo(fullfile(fileparts(which(ids_from_tcv.(ids_to_get).code.library{ii}.name)),'.this-deployment.info'));
ids_from_tcv.(ids_to_get).code.library{ii}.commit = library_gitinfo.git_commit;
ids_from_tcv.(ids_to_get).code.library{ii}.version = library_gitinfo.git_tag;
ids_from_tcv.(ids_to_get).code.library{ii}.repository =library_gitinfo.gitlab_project_url;
end
end
end end
if nargout>=2 if nargout>=2
......
function info = tcv_get_deploymentinfo(function_name)
% Reads a deployment info file and extracts relevant details
% Author: L. Simons
% Date: 07/03/25
%
% Args:
% function_name: String, name of function
%
% Returns:
% info: Struct containing extracted information
% Initialize output struct
info = struct();
info.deployment_date='';
info.git_tag='';
info.git_commit='';
info.gitlab_project_url='';
try
filepath=fullfile(fileparts(which(function_name)),'.this-deployment.info');
info.repository=fileparts(filepath);
% Check if file exists
if exist(filepath, 'file') ~= 2
error('File does not exist: %s', filepath);
end
% Open file for reading
fid = fopen(filepath, 'r');
if fid == -1
error('Could not open file: %s', filepath);
end
% Read file line by line
while ~feof(fid)
line = fgetl(fid);
if ischar(line)
tokens = regexp(line, '^(\w+):\s(.+)$', 'tokens');
if ~isempty(tokens)
key = tokens{1}{1};
value = strtrim(tokens{1}{2});
% Store relevant fields in the struct
switch key
case 'DEPLOYMENT_DATE'
info.deployment_date = value;
case 'GIT_TAG'
info.git_tag = value;
case 'GIT_COMMIT'
info.git_commit = value;
case 'GIT_TAG_DATE'
info.git_tag_date = value;
case 'GITLAB_PROJECT_URL'
info.gitlab_project_url = value;
end
end
end
end
% Close the file
fclose(fid);
catch
warning('Failed to read .deployment at filepath: %s',filepath);
end
end
...@@ -30,7 +30,7 @@ ids_bolometer_description = struct(); ...@@ -30,7 +30,7 @@ ids_bolometer_description = struct();
% Load the bolometer geometry % Load the bolometer geometry
bolo_geom=bolou_load_geometry(); bolo_geom=bolou_load_geometry();
bolo_geom_gitinfo= tcv_get_deploymentinfo('bolou_load_geometry');
params_eff.data_request='\tcv_shot::top.results.bolo_u.intensity'; params_eff.data_request='\tcv_shot::top.results.bolo_u.intensity';
params_eff.trialindx=1; params_eff.trialindx=1;
...@@ -45,18 +45,16 @@ params_eff.data_request='\tcv_shot::top.results.bolo_u.confidence'; ...@@ -45,18 +45,16 @@ params_eff.data_request='\tcv_shot::top.results.bolo_u.confidence';
bolo_u_confidence = gdat(shot,params_eff); bolo_u_confidence = gdat(shot,params_eff);
status = ~ischar(bolo_u_intensity.data) & ~ischar(bolo_u_prad_core.data); status = ~ischar(bolo_u_intensity.data) & ~ischar(bolo_u_prad_core.data);
imas_version_number=getenv('IMAS_VERSION'); imas_version_number=getenv('IMAS_VERSION')
if status if status
nchannel = numel(bolo_u_intensity.x); nchannel = numel(bolo_u_intensity.x);
ids_bolometer.channel(1:nchannel) = ids_bolometer.channel(1); ids_bolometer.channel(1:nchannel) = ids_bolometer.channel(1);
for ii = 1:nchannel for ii = 1:nchannel
%% Fill geometry information
% Fill information from bolo_geom=bolou_load_geometry();
ids_bolometer.channel{ii}.name = bolo_geom.channel{ii}.name; ids_bolometer.channel{ii}.name = bolo_geom.channel{ii}.name;
if strcmp(imas_version_number(1),'3') if strcmp(aa(1),'3')
ids_bolometer.channel{ii}.identifier = bolo_geom.channel{ii}.identifier; ids_bolometer.channel{ii}.identifier = bolo_geom.channel{ii}.identifier;
elseif strcmp(imas_version_number(1),'4') elseif strcmp(aa(1),'4')
ids_bolometer.channel{ii}.description = bolo_geom.channel{ii}.identifier; ids_bolometer.channel{ii}.description = bolo_geom.channel{ii}.identifier;
end end
ids_bolometer.channel{ii}.detector.geometry_type= bolo_geom.channel{ii}.detector.geometry_type; ids_bolometer.channel{ii}.detector.geometry_type= bolo_geom.channel{ii}.detector.geometry_type;
...@@ -104,12 +102,6 @@ if status ...@@ -104,12 +102,6 @@ if status
ids_bolometer.channel{ii}.line_of_sight.second_point.r = bolo_geom.channel{ii}.line_of_sight.second_point.r; ids_bolometer.channel{ii}.line_of_sight.second_point.r = bolo_geom.channel{ii}.line_of_sight.second_point.r;
ids_bolometer.channel{ii}.line_of_sight.second_point.z = bolo_geom.channel{ii}.line_of_sight.second_point.z; ids_bolometer.channel{ii}.line_of_sight.second_point.z = bolo_geom.channel{ii}.line_of_sight.second_point.z;
%% Fill measurement information
% '\tcv_shot::top.results.bolo_u.prad';
% '\tcv_shot::top.results.bolo_u.prad_core';
% '\tcv_shot::top.results.bolo_u.confidence';
ids_bolometer.channel{ii}.power.data = bolo_u_intensity.data(ii,:); ids_bolometer.channel{ii}.power.data = bolo_u_intensity.data(ii,:);
ids_bolometer_description.channel{ii}.power.data = ... ids_bolometer_description.channel{ii}.power.data = ...
['From results.bolo_u.intensity data, Radiance measured by ' ... ['From results.bolo_u.intensity data, Radiance measured by ' ...
...@@ -141,34 +133,36 @@ if status ...@@ -141,34 +133,36 @@ if status
ids_bolometer.power_radiated_total = bolo_u_prad.data; ids_bolometer.power_radiated_total = bolo_u_prad.data;
ids_bolometer.power_radiated_validity = 0*bolo_u_prad.data; ids_bolometer.power_radiated_validity = 0*bolo_u_prad.data;
end end
%% Code legacy for rc_gti_prep
ids_bolometer.code.name = 'rc_gti_prep'; ids_bolometer.code.name = 'rc_gti_prep';
rc_gti_prep_gitinfo= tcv_get_deploymentinfo(ids_bolometer.code.name);
ids_bolometer.code.description = ... ids_bolometer.code.description = ...
'rc_gti_prep, RADCAM gitlab repo, calls GTI to generate emissivity profiles with liuqe.'; ['rc_gti_prep, RADCAM gitlab repo, calls GTI to generate emissivity profiles with liuqe.']
ids_bolometer.code.commit=rc_gti_prep_gitinfo.git_commit; % '/usr/local/bin/matlab960 -nojvm -nosplash -nodisplay -r ' ...
ids_bolometer.code.version=rc_gti_prep_gitinfo.git_tag; % '"anasrvmat(''rc_gti_prep'',$2,[0 2.2],''bolo'', 10, 1, 0.04, 30,' ...
ids_bolometer.code.repository= rc_gti_prep_gitinfo.repository; % 'false, false,false, [], ''automated'', 1)"'];
ids_bolometer.code.parameters= ... ids_bolometer.code.commit='';
['rc_gti_prep(shot,[0 2.2],''bolo'', 10, 1, 0.04, 30,' ... ids_bolometer.code.version='';
'false, false,false, [], ''automated'', 1)']; ids_bolometer.code.repository= ...
'https://gitlab.epfl.ch/spc/tcv/diag/radcam/';
%% Code legacy for TCV_EQ; FBTE ids_bolometer.code.parameters='';
% Call to gti: gti_get_disc ids_bolometer.code.library{1}.name = 'meq';
% Call to TCV_eq: temp=tdi('TCV_EQ("psi")',disc.s.equilsrc);
% https://spcwiki.epfl.ch/wiki/Tcv_eq
% a=gdat(shot,'TCV_EQ("psi")');
ids_bolometer.code.library{1}.name = 'fbte';
ids_bolometer.code.library{1}.description = 'Magnetic equilibrium'; ids_bolometer.code.library{1}.description = 'Magnetic equilibrium';
ids_bolometer.code.library{1}.parameters = 'TCV_EQ("psi")'; ids_bolometer.code.library{1}.commit = '';
ids_bolometer.code.library{1}.version = '';
%% Code legacy for GTI ids_bolometer.code.library{1}.repository = ...
ids_bolometer.code.library{2}.name = 'gti_do_inversion'; 'https://gitlab.epfl.ch/spc/tcv/tbx/meq';
ids_bolometer.code.library{1}.parameters = '';
ids_bolometer.code.library{2}.name = 'GTI';
ids_bolometer.code.library{2}.description = ... ids_bolometer.code.library{2}.description = ...
'General Tomographic Inversion'; 'General Tomographic Inversion';
ids_bolometer.code.library{2}.commit = '';
[a1,a2]=unix('git rev-parse --verify HEAD');
[b1,b2]=unix('git rev-parse --abbrev-ref HEAD');
ids_bolometer.code.library{2}.version = sprintf('%s_branch_%s',strtrim(a2),strtrim(b2));
ids_bolometer.code.library{2}.repository = ...
'https://gitlab.epfl.ch/spc/tcv/analysis/gti';
ids_bolometer.code.library{2}.parameters = ''; ids_bolometer.code.library{2}.parameters = '';
% FIXME: Values of bolo_u_confidence don't match output_flag % FIXME: Values of bolo_u_confidence don't match output_flag
ids_bolometer.code.output_flag=bolo_u_confidence; ids_bolometer.code.output_flag=bolo_u_confidence;
ids_bolometer.time = bolo_u_intensity.t; ids_bolometer.time = bolo_u_intensity.t;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment