From 08846432cf58f990fea54a54399622f5b6977117 Mon Sep 17 00:00:00 2001 From: Olivier Sauter <olivier.sauter@epfl.ch> Date: Fri, 19 May 2017 14:09:34 +0000 Subject: [PATCH] indent and remove empty lines git-svn-id: https://spcsvn.epfl.ch/repos/TCV/gdat/trunk@7331 d63d8f72-b253-0410-a779-e742ad2e26cf --- crpptbx/TCV/gdat_tcv.m | 494 ++++++++++++++++++----------------------- 1 file changed, 222 insertions(+), 272 deletions(-) diff --git a/crpptbx/TCV/gdat_tcv.m b/crpptbx/TCV/gdat_tcv.m index a860992c..83c950a1 100644 --- a/crpptbx/TCV/gdat_tcv.m +++ b/crpptbx/TCV/gdat_tcv.m @@ -864,7 +864,7 @@ elseif strcmp(mapping_for_tcv.method,'switchcase') end - + else disp('should not be here in ''mhd'', ask O. Sauter') return @@ -925,17 +925,17 @@ elseif strcmp(mapping_for_tcv.method,'switchcase') zeffshift=zshift; % set zeffshift time array same as psitdi switch length(zeffshift) - case 1 - zeffshift=zeffshift * ones(size(psitdi.dim{3})); - case length(psitdi.dim{3}) - % ok - case length(psiscatvol.dim{1}) - zeffshift=interp1(psiscatvol.dim{1},zeffshift,psitdi.dim{3}); - otherwise - if (gdat_params.nverbose>=1); - disp(' bad time dimension for zshift') - disp(['it should be 1 or ' num2str(length(psiscatvol.dim{1})) ' or ' num2str(length(psitdi.dim{3}))]) - end + case 1 + zeffshift=zeffshift * ones(size(psitdi.dim{3})); + case length(psitdi.dim{3}) + % ok + case length(psiscatvol.dim{1}) + zeffshift=interp1(psiscatvol.dim{1},zeffshift,psitdi.dim{3}); + otherwise + if (gdat_params.nverbose>=1); + disp(' bad time dimension for zshift') + disp(['it should be 1 or ' num2str(length(psiscatvol.dim{1})) ' or ' num2str(length(psitdi.dim{3}))]) + end end for it=1:length(psiscatvol.dim{1}) itpsitdi=iround(psitdi.dim{3},psiscatvol.dim{1}(it)); @@ -1037,9 +1037,9 @@ elseif strcmp(mapping_for_tcv.method,'switchcase') elseif strcmp(data_request_eff(1:2),'te') nodenameeff = [def_proffit 'teft']; else - if (gdat_params.nverbose>=1); - disp(['should not be here: data_request_eff, data_request_eff(1:2)= ',data_request_eff, data_request_eff(1:2)]); - end + if (gdat_params.nverbose>=1); + disp(['should not be here: data_request_eff, data_request_eff(1:2)= ',data_request_eff, data_request_eff(1:2)]); + end end end if isfield(gdat_data.gdat_params,'trialindx') && ~isempty(gdat_data.gdat_params.trialindx) && ... @@ -1398,270 +1398,220 @@ elseif strcmp(mapping_for_tcv.method,'switchcase') [qfit,~,~,phi]=interpos(q_rho.dim{1}(ij).^2,q_rho.data(ij,it),rhoequal.^2); dataeff = sqrt(phi .* psi_axis.data(it) ./ b0tpsi(it) ./ pi) ; % Delta_psi = -psi_axis else - dataeff = NaN; + dataeff = NaN; end if strcmp(data_request_eff,'rhotor_edge') - gdat_data.data(it) = dataeff(end); + gdat_data.data(it) = dataeff(end); elseif strcmp(data_request_eff,'rhotor') - gdat_data.data(:,it) = dataeff./dataeff(end); - gdat_data.rhotor_edge(it) = dataeff(end); + gdat_data.data(:,it) = dataeff./dataeff(end); + gdat_data.rhotor_edge(it) = dataeff(end); end gdat_data.b0 = b0tpsi(it); end %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - case {'rhovol','volume_rho','volume'} - % volume_rho = vol(rho); volume = vol(LCFS) = vol(rho=1); - % rhovol = sqrt(vol(rho)/vol(rho=1)); - nodenameeff='\results::psitbx:vol'; - if liuqe_version==-1 - nodenameeff=[begstr 'vol' substr_liuqe]; - end - tracetdi=tdi(nodenameeff); - if isempty(tracetdi.data) || isempty(tracetdi.dim) - % try to run psitbxput - psitbxput_version = 1.3; - psitbxput(psitbxput_version,shot); - ishot = mdsopen(shot); - tracetdi=tdi(nodenameeff); - if isempty(tracetdi.data) || isempty(tracetdi.dim) - return - end + case {'rhovol','volume_rho','volume'} + % volume_rho = vol(rho); volume = vol(LCFS) = vol(rho=1); + % rhovol = sqrt(vol(rho)/vol(rho=1)); + nodenameeff='\results::psitbx:vol'; + if liuqe_version==-1 + nodenameeff=[begstr 'vol' substr_liuqe]; + end + tracetdi=tdi(nodenameeff); + if isempty(tracetdi.data) || isempty(tracetdi.dim) + % try to run psitbxput + psitbxput_version = 1.3; + psitbxput(psitbxput_version,shot); + ishot = mdsopen(shot); + tracetdi=tdi(nodenameeff); + if isempty(tracetdi.data) || isempty(tracetdi.dim) + return + end + end + gdat_data.units = tracetdi.units; + if strcmp(data_request_eff,'volume') + gdat_data.data = tracetdi.data(end,:); + gdat_data.dim{1} = tracetdi.dim{2}; + gdat_data.data_fullpath=['\results::psitbx:vol(end,:)']; + gdat_data.dimunits{1} = tracetdi.dimunits{2}; + gdat_data.request_description = 'volume(LCFS)=volume(rhopol=1)'; + else + gdat_data.data = tracetdi.data; + gdat_data.dim = tracetdi.dim; + gdat_data.x = gdat_data.dim{1}; + gdat_data.dimunits = tracetdi.dimunits; + if strcmp(data_request_eff,'volume_rho') + gdat_data.data_fullpath=['\results::psitbx:vol']; + gdat_data.request_description = 'volume(rho)'; + elseif strcmp(data_request_eff,'rhovol') + gdat_data.volume_edge = gdat_data.data(end,:); + gdat_data.data = sqrt(gdat_data.data./repmat(reshape(gdat_data.volume_edge,1,size(gdat_data.data,2)),size(gdat_data.data,1),1)); + gdat_data.data_fullpath='sqrt(\results::psitbx:vol/vol_edge)'; + gdat_data.request_description = 'sqrt(volume(rho)/volume(edge))'; + else + if (gdat_params.nverbose>=1) + disp(['should not be here in vol cases with data_request = ' data_request_eff]); + end + return + end + end + gdat_data.t = gdat_data.dim{mapping_for_tcv.gdat_timedim}; + + %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + case {'rtc'} + % load all real-time memory signals for various nodes + + %Get the data from mds and fill the data structure defined by + %define_simulink_signals + + % If the rtccode/developemnet folder is not in your path + % read from Carpanese's folder ( he might have not + % updated the folder to the last version) + if exist('~/rtccode/development/tools/io_defs') + addpath('~/rtccode/development/tools/io_defs'); + else + addpath('/home/carpanes/rtccode/development/tools/io_defs'); + end + + sources_avail = {'defined', 'all'}; + %Check if varargins match source_avail + if ~isfield(gdat_data.gdat_params,'source') || isempty(gdat_data.gdat_params.source) % with no specifications all, defined, combined are taken + gdat_data.gdat_params.source = sources_avail; + elseif ~iscell(gdat_data.gdat_params.source) + if ischar(gdat_data.gdat_params.source) + gdat_data.gdat_params.source = lower(gdat_data.gdat_params.source); + if ~any(strmatch(gdat_data.gdat_params.source,lower(sources_avail))) + if (gdat_params.nverbose>=1) + warning(['source= ' gdat_data.gdat_params.source ' is not part of the available sources: ' sprintf('''%s'' ',sources_avail{:})]); end - gdat_data.units = tracetdi.units; - if strcmp(data_request_eff,'volume') - gdat_data.data = tracetdi.data(end,:); - gdat_data.dim{1} = tracetdi.dim{2}; - gdat_data.data_fullpath=['\results::psitbx:vol(end,:)']; - gdat_data.dimunits{1} = tracetdi.dimunits{2}; - gdat_data.request_description = 'volume(LCFS)=volume(rhopol=1)'; - else - gdat_data.data = tracetdi.data; - gdat_data.dim = tracetdi.dim; - gdat_data.x = gdat_data.dim{1}; - gdat_data.dimunits = tracetdi.dimunits; - if strcmp(data_request_eff,'volume_rho') - gdat_data.data_fullpath=['\results::psitbx:vol']; - gdat_data.request_description = 'volume(rho)'; - elseif strcmp(data_request_eff,'rhovol') - gdat_data.volume_edge = gdat_data.data(end,:); - gdat_data.data = sqrt(gdat_data.data./repmat(reshape(gdat_data.volume_edge,1,size(gdat_data.data,2)),size(gdat_data.data,1),1)); - gdat_data.data_fullpath='sqrt(\results::psitbx:vol/vol_edge)'; - gdat_data.request_description = 'sqrt(volume(rho)/volume(edge))'; - else - if (gdat_params.nverbose>=1) - disp(['should not be here in vol cases with data_request = ' data_request_eff]); - end - return - end + return + else + gdat_data.gdat_params.source = {gdat_data.gdat_params.source}; + end + else + if (gdat_params.nverbose>=1); warning([' source parameter not compatible with: ' sprintf('''%s'' ',sources_avail{:})]); end + return + end + else + tmp = {}; + for i=1:length(gdat_data.gdat_params.source) + gdat_data.gdat_params.source{i} = lower(gdat_data.gdat_params.source{i}); %put vargin in params + + if ~any(strmatch(gdat_data.gdat_params.source{i},lower(sources_avail))) + if gdat_data.gdat_params.nverbose>=1 + warning(['source = ' gdat_data.gdat_params.source{i} ' not expected with data_request= ' data_request_eff]) end - gdat_data.t = gdat_data.dim{mapping_for_tcv.gdat_timedim}; - - %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - case {'rtc'} - - % load all real-time memory signals for various nodes - - %Get the data from mds and fill the data structure defined by - %define_simulink_signals - - - % If the rtccode/developemnet folder is not in your path - % read from Carpanese's folder ( he might have not - % updated the folder to the last version) - if exist('~/rtccode/development/tools/io_defs') - addpath('~/rtccode/development/tools/io_defs'); - else - addpath('/home/carpanes/rtccode/development/tools/io_defs'); - end - - sources_avail = {'defined', 'all'}; - %Check if varargins match source_avail - if ~isfield(gdat_data.gdat_params,'source') || isempty(gdat_data.gdat_params.source) % with no specifications all, defined, combined are taken - gdat_data.gdat_params.source = sources_avail; - - elseif ~iscell(gdat_data.gdat_params.source) - if ischar(gdat_data.gdat_params.source) - gdat_data.gdat_params.source = lower(gdat_data.gdat_params.source); - if ~any(strmatch(gdat_data.gdat_params.source,lower(sources_avail))) - if (gdat_params.nverbose>=1) - warning(['source= ' gdat_data.gdat_params.source ' is not part of the available sources: ' sprintf('''%s'' ',sources_avail{:})]); - end - return - else - gdat_data.gdat_params.source = {gdat_data.gdat_params.source}; - end - else - if (gdat_params.nverbose>=1); warning([' source parameter not compatible with: ' sprintf('''%s'' ',sources_avail{:})]); end - return - end - else - tmp = {}; - for i=1:length(gdat_data.gdat_params.source) - gdat_data.gdat_params.source{i} = lower(gdat_data.gdat_params.source{i}); %put vargin in params + else + tmp{end+1} = gdat_data.gdat_params.source{i}; + end + end + gdat_data.gdat_params.source = tmp; + end + + % Get data for the source requested + for ii=1:numel(gdat_data.gdat_params.source) + switch gdat_data.gdat_params.source{ii} + case 'defined' + DS = take_all_signals(shot); %Read from mds + SDS_DS = define_simulink_signals(DS); %Put them in predifined structure + % Add the .data and .t structure + for ii=1:numel(SDS_DS) %iter over node + node = ii; + for jj=1:numel(SDS_DS{ii}) %iter over threads + thread = jj; + fieldnameslist = fieldnames(SDS_DS{ii}{jj}); + + if SDS_DS{ii}{1}.conf.hasthreads + is_with_threads = 1; + else + is_with_threads = 0; + end + for kk=2:numel(fieldnameslist) %iter over fieldnames (the first one is configuration) + indices = SDS_DS{ii}{jj}.(fieldnameslist{kk}).ind; + SDS_DS{ii}{jj}.(fieldnameslist{kk}).data = []; + for zz=1:numel(indices) %iter over indices + ind = indices(zz); + mdsconnect('scd'); + mdsopen('rtc', shot); + % data expression + if is_with_threads ==0 + expression = sprintf('\\top.crpprt%.2d.mems.mem_%.2d',node,ind); + else + expression = sprintf('\\top.crpprt%.2d.thread%.1d.mems.mem_%.3d',node,thread,ind); + end + tmp = tdi(expression); + if isnumeric(tmp.data) && ~isempty(tmp.data) + SDS_DS{ii}{jj}.(fieldnameslist{kk}).data =[SDS_DS{ii}{jj}.(fieldnameslist{kk}).data; tmp.data']; - if ~any(strmatch(gdat_data.gdat_params.source{i},lower(sources_avail))) - if gdat_data.gdat_params.nverbose>=1 - warning(['source = ' gdat_data.gdat_params.source{i} ' not expected with data_request= ' data_request_eff]) - end - else - tmp{end+1} = gdat_data.gdat_params.source{i}; - end + SDS_DS{ii}{jj}.(fieldnameslist{kk}).t = tmp.dim{1}; + else + fprintf('Warning node: %d thread: %d signal: %s ind %d not available\n', ii,jj,fieldnameslist{kk}, zz ); + end end - gdat_data.gdat_params.source = tmp; + end end - - - % Get data for the source requested - for ii=1:numel(gdat_data.gdat_params.source) - switch gdat_data.gdat_params.source{ii} - case 'defined' - - DS = take_all_signals(shot); %Read from mds - SDS_DS = define_simulink_signals(DS); %Put them in predifined structure - - - % Add the .data and .t structure - for ii=1:numel(SDS_DS) %iter over node - node = ii; - for jj=1:numel(SDS_DS{ii}) %iter over threads - thread = jj; - fieldnameslist = fieldnames(SDS_DS{ii}{jj}); - - if SDS_DS{ii}{1}.conf.hasthreads - is_with_threads = 1; - else - is_with_threads = 0; - end - - for kk=2:numel(fieldnameslist) %iter over fieldnames (the first one is configuration) - - indices = SDS_DS{ii}{jj}.(fieldnameslist{kk}).ind; - SDS_DS{ii}{jj}.(fieldnameslist{kk}).data = []; - - - for zz=1:numel(indices) %iter over indices - ind = indices(zz); - - - mdsconnect('scd'); - mdsopen('rtc', shot); - - % data expression - if is_with_threads ==0 - expression = sprintf('\\top.crpprt%.2d.mems.mem_%.2d',node,ind); - else - expression = sprintf('\\top.crpprt%.2d.thread%.1d.mems.mem_%.3d',node,thread,ind); - end - - tmp = tdi(expression); - - - if isnumeric(tmp.data) && ~isempty(tmp.data) - SDS_DS{ii}{jj}.(fieldnameslist{kk}).data =[SDS_DS{ii}{jj}.(fieldnameslist{kk}).data; tmp.data']; - - SDS_DS{ii}{jj}.(fieldnameslist{kk}).t = tmp.dim{1}; - else - fprintf('Warning node: %d thread: %d signal: %s ind %d not available\n', ii,jj,fieldnameslist{kk}, zz ); - end - - - end - - - - end - - end - end - - gdat_data.rtc_defined = SDS_DS; - mdsclose; - mdsdisconnect; - - case 'all' - mdsconnect('scd'); - mdsopen('rtc', shot); - - %[node, threads, #number of signals for each thread of the node] - global_node_thread_signals = ... - [1,1,32; - 2,1,32; - 3,1,32; - 6,4,256; - 7,2,32]; - - % Default signals initialization - AS = init_all_signals(global_node_thread_signals); - - % Put signals in standard data strucure (SDS) - SDS_AS = define_simulink_signals(AS); - - % Add the .data and .t structure - for ii=1:numel(SDS_AS) %iter over node - node = ii; - for jj=1:numel(SDS_AS{ii}) %iter over threads - thread = jj; - fieldnameslist = fieldnames(SDS_AS{ii}{jj}); - - if numel(SDS_AS{ii})>1 - is_with_threads = 1; - else - is_with_threads = 0; - end - - for kk=2:numel(fieldnameslist) %iter over fieldnames (the first one is configuration) - - indices = SDS_AS{ii}{jj}.(fieldnameslist{kk}).ind; - SDS_AS{ii}{jj}.(fieldnameslist{kk}).data = []; - - for zz=1:numel(indices) %iter over indices - ind = indices(zz); - - % data expression - if is_with_threads ==0 - expression = sprintf('\\top.crpprt%.2d.mems.mem_%.2d',node,ind); - else - expression = sprintf('\\top.crpprt%.2d.thread%.1d.mems.mem_%.3d',node,thread,ind); - end - - tmp = tdi(expression); - - - if isnumeric(tmp.data) - SDS_AS{ii}{jj}.(fieldnameslist{kk}).data =[SDS_AS{ii}{jj}.(fieldnameslist{kk}).data; tmp.data']; - - SDS_AS{ii}{jj}.(fieldnameslist{kk}).t = tmp.dim{1}; - - else - fprintf('Warning node: %d thread: %d signal: %s ind %d not available\n', ii,jj,fieldnameslist{kk}, zz ); - end - - - end - end - - end - end - - gdat_data.rtc_all = SDS_AS; - mdsclose; - mdsdisconnect; - - - otherwise - %to be added in case + end + gdat_data.rtc_defined = SDS_DS; + mdsclose; + mdsdisconnect; + + case 'all' + mdsconnect('scd'); + mdsopen('rtc', shot); + %[node, threads, #number of signals for each thread of the node] + global_node_thread_signals = ... + [1,1,32; + 2,1,32; + 3,1,32; + 6,4,256; + 7,2,32]; + % Default signals initialization + AS = init_all_signals(global_node_thread_signals); + % Put signals in standard data strucure (SDS) + SDS_AS = define_simulink_signals(AS); + % Add the .data and .t structure + for ii=1:numel(SDS_AS) %iter over node + node = ii; + for jj=1:numel(SDS_AS{ii}) %iter over threads + thread = jj; + fieldnameslist = fieldnames(SDS_AS{ii}{jj}); + if numel(SDS_AS{ii})>1 + is_with_threads = 1; + else + is_with_threads = 0; + end + for kk=2:numel(fieldnameslist) %iter over fieldnames (the first one is configuration) + indices = SDS_AS{ii}{jj}.(fieldnameslist{kk}).ind; + SDS_AS{ii}{jj}.(fieldnameslist{kk}).data = []; + for zz=1:numel(indices) %iter over indices + ind = indices(zz); + % data expression + if is_with_threads ==0 + expression = sprintf('\\top.crpprt%.2d.mems.mem_%.2d',node,ind); + else + expression = sprintf('\\top.crpprt%.2d.thread%.1d.mems.mem_%.3d',node,thread,ind); + end + tmp = tdi(expression); + if isnumeric(tmp.data) + SDS_AS{ii}{jj}.(fieldnameslist{kk}).data =[SDS_AS{ii}{jj}.(fieldnameslist{kk}).data; tmp.data']; + SDS_AS{ii}{jj}.(fieldnameslist{kk}).t = tmp.dim{1}; + else + fprintf('Warning node: %d thread: %d signal: %s ind %d not available\n', ii,jj,fieldnameslist{kk}, zz ); + end end + end end - - - - - - - - %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - case {'sxr', 'mpx'} + end + gdat_data.rtc_all = SDS_AS; + mdsclose; + mdsdisconnect; + otherwise + %to be added in case + end + end + + %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + case {'sxr', 'mpx'} if strcmp(data_request_eff,'mpx') data_request_eff = 'mpx'; % mpx chosen through parameter 'source' within 'sxr' @@ -1730,7 +1680,7 @@ elseif strcmp(mapping_for_tcv.method,'switchcase') gdat_data.(gdat_data.gdat_params.camera).x = gdat_data.x; gdat_data.(gdat_data.gdat_params.camera).channel = mpx.(gdat_data.gdat_params.camera(1:3)).signal.dim{2}; gdat_data.data_fullpath = ['MPX for ' gdat_data.gdat_params.camera ' camera in .data, "rho" in .x between [-1,1]' ... - char(10) gdat_data.data_fullpath]; + char(10) gdat_data.data_fullpath]; else gdat_data.data = mpx.signal.data'; gdat_data.t = mpx.signal.dim{1}; @@ -1745,7 +1695,7 @@ elseif strcmp(mapping_for_tcv.method,'switchcase') gdat_data.bottom.channel = mpx.bottom.signal.dim{2}; gdat_data.(gdat_data.gdat_params.camera).channel = mpx.(gdat_data.gdat_params.camera(1:3)).signal.dim{2}; gdat_data.data_fullpath = ['MPX for ' gdat_data.gdat_params.camera ' camera in .data, "rho" in .x between [-1,1]' ... - char(10) gdat_data.data_fullpath]; + char(10) gdat_data.data_fullpath]; gdat_data.x = gdat_data.dim{1}; end @@ -1815,7 +1765,7 @@ elseif strcmp(mapping_for_tcv.method,'switchcase') return end - + %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% case {'profnerho','profterho'} @@ -1825,9 +1775,9 @@ elseif strcmp(mapping_for_tcv.method,'switchcase') nodenameeff_vers = [nodenameeff ':version_num']; avers = tdi(nodenameeff_vers); if avers.data==0 - % may be because nodes not yet filled in, so call once a node - ab=tdi(nodenameeff); - avers = tdi(nodenameeff_vers); + % may be because nodes not yet filled in, so call once a node + ab=tdi(nodenameeff); + avers = tdi(nodenameeff_vers); end if avers.data>0 tracetdi=tdi(nodenameeff); @@ -1839,7 +1789,7 @@ elseif strcmp(mapping_for_tcv.method,'switchcase') gdat_data.t=tracetdi.dim{2}; error_status=0; else - error_status=2; + error_status=2; gdat_data.x=[]; gdat_data.t=[]; end @@ -1853,7 +1803,7 @@ elseif strcmp(mapping_for_tcv.method,'switchcase') else gdat_data.x=[]; gdat_data.t=[]; - error_status=2; + error_status=2; end end else -- GitLab