diff --git a/matlab/JET/gdat_jet.m b/matlab/JET/gdat_jet.m index ba994cfe2b5a527d699e0554367a16be9dc84a54..c38adeed9ba2b35f9be33392df5002b2f5ad68c2 100644 --- a/matlab/JET/gdat_jet.m +++ b/matlab/JET/gdat_jet.m @@ -215,6 +215,13 @@ if ~isempty(ij); % copy description of keyword gdat_data.request_description = data_request_names.all.(data_request_names_all{ij}).description; end +else + if ~iscell(data_request_eff) && ischar(data_request_eff) + warning(['data_request: ' data_request_eff ' is not a pre-defined data_request nor a cell array with signal to get' char(10) ... + 'data_request probably not yet defined, ask O. Sauter if needed; check data_requests defined with' char(10) ... + 'aa=gdat(''machine'',''jet'');aa.gdat_request']); + return + end end % special treatment if shot and data_request given within pairs diff --git a/matlab/JET/jet_requests_mapping.m b/matlab/JET/jet_requests_mapping.m index ee25bb3a2c541d4dd85d1847516efad316ca24f6..c7955071dbeccb3304285d21ba514b69b58e5f5f 100644 --- a/matlab/JET/jet_requests_mapping.m +++ b/matlab/JET/jet_requests_mapping.m @@ -204,23 +204,24 @@ switch lower(data_request) mapping.label = 'nG=Ip[MA]/(\pi a^2)*1e20 on nel times'; mapping.method = 'expression'; mapping.expression = ['params_eff = gdat_data.gdat_params;params_eff.data_request=''nel'';' ... - 'gdat_tmp=gdat_jet(shot,params_eff);params_eff.data_request=''ip'';' ... + 'gdat_tmp=gdat_jet(shot,params_eff);' ... + 'if ~isempty(gdat_tmp.t);params_eff.data_request=''ip'';' ... 'gdat_tmp2=gdat_jet(shot,params_eff);ij=find(gdat_tmp2.data==0);gdat_tmp2.data(ij)=NaN;' ... 'tmp_data2=interp1(gdat_tmp2.t,gdat_tmp2.data,gdat_tmp.t,[],NaN);' ... 'params_eff.data_request=''a_minor'';' ... 'gdat_tmp3=gdat_jet(shot,params_eff);ij=find(gdat_tmp3.data==0);gdat_tmp3.data(ij)=NaN;' ... 'tmp_data3=interp1(gdat_tmp3.t,gdat_tmp3.data,gdat_tmp.t,[],NaN);' ... 'gdat_tmp.data = abs(tmp_data2*1e-6./pi./(tmp_data3.^2+1e-5));' ... - 'ij=find(gdat_tmp.data<0 | gdat_tmp.data>4);gdat_tmp.data(ij)=NaN;gdat_tmp.data = gdat_tmp.data * 1e20;']; + 'ij=find(gdat_tmp.data<0 | gdat_tmp.data>4);gdat_tmp.data(ij)=NaN;gdat_tmp.data = gdat_tmp.data * 1e20;end;']; case {'ngf','greenwald_fraction','f_greenwald','ng_fraction'} mapping.timedim = 1; mapping.label = 'Greenwald\_fraction=n\_el/n\_G'; mapping.method = 'expression'; mapping.expression = ['params_eff = gdat_data.gdat_params;params_eff.data_request=''nel'';' ... - 'gdat_tmp=gdat_jet(shot,params_eff);params_eff.data_request=''n_greenwald'';' ... + 'gdat_tmp=gdat_jet(shot,params_eff);if ~isempty(gdat_tmp.t);params_eff.data_request=''n_greenwald'';' ... 'gdat_tmp2=gdat_jet(shot,params_eff);ij=find(gdat_tmp2.data==0);gdat_tmp2.data(ij)=NaN;' ... 'tmp_data2=interp1(gdat_tmp2.t,gdat_tmp2.data,gdat_tmp.t,[],NaN);' ... - 'gdat_tmp.data = gdat_tmp.data./(tmp_data2+1e-5);']; + 'gdat_tmp.data = gdat_tmp.data./(tmp_data2+1e-5);end;']; case 'ni' mapping.method = 'switchcase'; % especially since might have option fit, etc case {'phi_tor', 'phitor', 'toroidal_flux'} @@ -237,21 +238,21 @@ switch lower(data_request) mapping.timedim = 1; mapping.method = 'expression'; mapping.expression = ['params_eff = gdat_data.gdat_params;params_eff.data_request=''nel'';' ... - 'gdat_tmp=gdat_jet(shot,params_eff);params_eff.data_request=''b0'';gdat_tmpb0=gdat_jet(shot,params_eff);' ... + 'gdat_tmp=gdat_jet(shot,params_eff);if ~isempty(gdat_tmp.t);params_eff.data_request=''b0'';gdat_tmpb0=gdat_jet(shot,params_eff);' ... 'params_eff.data_request=''surface_edge'';gdat_tmp_s=gdat_jet(shot,params_eff);' ... - 's_nel=interpos(gdat_tmp_s.t,gdat_tmp_s.data,gdat_tmp.t,-1.);b0_nel=interpos(gdat_tmpb0.t,gdat_tmpb0.data,gdat_tmp.t,-1.);' ... - 'gdat_tmp.data = 0.0488e6.*(gdat_tmp.data/1e20).^0.717.*abs(b0_nel).^0.803.*s_nel.^0.941;' ... - 'gdat_tmp.label=''P\_LH threshold'';']; + 'if ~isempty(gdat_tmp_s.t); s_nel=interpos(gdat_tmp_s.t,gdat_tmp_s.data,gdat_tmp.t,-1.);b0_nel=interpos(gdat_tmpb0.t,gdat_tmpb0.data,gdat_tmp.t,-1.);' ... + 'gdat_tmp.data = 0.0488e6.*(gdat_tmp.data/1e20).^0.717.*abs(b0_nel).^0.803.*s_nel.^0.941;else;gdat_tmp=gdat_tmp_s;end;' ... + 'gdat_tmp.label=''P\_LH threshold'';end']; case {'p_lh_a_r', 'plh_a_r'} mapping.label = 'p\_lh threshold'; mapping.timedim = 1; mapping.method = 'expression'; mapping.expression = ['params_eff = gdat_data.gdat_params;params_eff.data_request=''nel'';' ... - 'gdat_tmp=gdat_jet(shot,params_eff);params_eff.data_request=''b0'';gdat_tmpb0=gdat_jet(shot,params_eff);' ... + 'gdat_tmp=gdat_jet(shot,params_eff);if ~isempty(gdat_tmp.t);params_eff.data_request=''b0'';gdat_tmpb0=gdat_jet(shot,params_eff);' ... 'params_eff.data_request=''a_minor'';gdat_tmp_a=gdat_jet(shot,params_eff);' ... 'a_nel=interpos(gdat_tmp_a.t,gdat_tmp_a.data,gdat_tmp.t,-1.);b0_nel=interpos(gdat_tmpb0.t,gdat_tmpb0.data,gdat_tmp.t,-1.);' ... 'gdat_tmp.data = 2.15e6.*abs(gdat_tmp.data/1e20).^0.782.*abs(b0_nel).^0.772.*abs(a_nel).^0.975.*abs(gdat_tmpb0.r0).^0.999;' ... - 'gdat_tmp.label=''P\_LH threshold'';']; + 'gdat_tmp.label=''P\_LH threshold'';end;']; case {'p_ohmic', 'p_ohm', 'pohm'} mapping.label = 'p\_ohmic'; mapping.timedim = 1; diff --git a/matlab/JET/rda_jet.m b/matlab/JET/rda_jet.m index 8b00c2a2fdbf0cbcab987e5fd8de88bb61859cbd..0aa49c96b8894464a20b83806c1926ec9d418556 100644 --- a/matlab/JET/rda_jet.m +++ b/matlab/JET/rda_jet.m @@ -28,12 +28,11 @@ end if usemdsplus % use mdsplus - + if ~unix('test -d /home/duval/mdsplus') - addpath('/home/duval/mdsplus') +% addpath('/home/duval/mdsplus') end mdsconnect('mdsplus.jet.efda.org'); - % defines trace to fetch % after '?' specific details separator='+'; @@ -96,9 +95,9 @@ if usemdsplus diag=rest(idiag+5:idiag+ii(1)-2); end end - + end - + % fetch value if ~isempty(uid) eval(['u=mdsvalue(''_sig=ppfuid("' uid '")'');']) @@ -149,7 +148,7 @@ if usemdsplus otherwise disp([' more than 3 dimensions for ' num2str(shot) ' ; ' pftype '/' tracename]) error('in rda_jet') - + end mdsdisconnect; diff --git a/matlab/TCV/gdat_tcv.m b/matlab/TCV/gdat_tcv.m index f5cd1e07d69e2b66178d5029874683ebc6442175..cb7460e24317e35146bb613a158033e16d7af2d0 100644 --- a/matlab/TCV/gdat_tcv.m +++ b/matlab/TCV/gdat_tcv.m @@ -995,6 +995,12 @@ elseif strcmp(mapping_for_tcv.method,'switchcase') gdat_data.gdat_params.nrz_out = nrz_out; end gdat_data.gdat_params.nrz_out = nrz_out; + sources_available = {'liuqe','chease'}; + if isfield(gdat_data.gdat_params,'source') && ~isempty(gdat_data.gdat_params.source) && ~isempty(intersect(sources_available,lower(gdat_data.gdat_params.source))) + source = gdat_data.gdat_params.source; + else + gdat_data.gdat_params.source = 'liuqe'; + end for itime=1:length(time) time_eff = time(itime); % use read_results updated to effectively obtain an eqdsk with sign correct with COCOS=2 @@ -1016,9 +1022,25 @@ elseif strcmp(mapping_for_tcv.method,'switchcase') for i=1:length(fnames_readresults) unix(['rm ' fnames_readresults{i}]); end - % transform to cocos=2 since read_results originally assumed it was cocos=2 + % + % run CHEASE if asked + % cocos_in = 2; - [eqdsk_cocos_in, eqdsk_cocosout_IpB0pos,cocos_inout]=eqdsk_cocos_transform(eqdskval,[cocos_read_results_for_chease cocos_in]); + if strcmp(lower(gdat_data.gdat_params.source),'chease') + % will give cocos_out (becoming cocos_in)=2 by default + [fname_out,globalsvalues,namelist_struct,namelistfile_eff] = run_chease(2,eqdskval,cocos_read_results_for_chease); + ij = strfind(fname_out,'EQDSK_COCOS_02.OUT'); + i = []; + for i=1:length(ij) + if ~isempty(ij(i)); break;end + end + eqdsk_cocos_in = read_eqdsk(fname_out{i},2,0); + else + % + % transform to cocos=2 since read_results originally assumed it was cocos=2 + [eqdsk_cocos_in, eqdsk_cocosout_IpB0pos,cocos_inout]=eqdsk_cocos_transform(eqdskval,[cocos_read_results_for_chease cocos_in]); + end + % fnamefull = fullfile(['/tmp/' getenv('USER')],['EQDSK_' num2str(shot) 't' num2str(time_eff,'%.4f')]); % We still write COCOS=2 case, since closer to standard (in /tmp) if gdat_data.gdat_params.write==1 @@ -1091,7 +1113,7 @@ elseif strcmp(mapping_for_tcv.method,'switchcase') %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% case {'ids'} ids_empty_path = fullfile(fileparts(mfilename('fullpath')),'..','TCV_IMAS','ids_empty'); - + params_eff = gdat_data.gdat_params; if isfield(params_eff,'source') && ~isempty(params_eff.source) ids_top_name = params_eff.source; @@ -1105,18 +1127,18 @@ elseif strcmp(mapping_for_tcv.method,'switchcase') return end ids_gen_ok = ~~exist('ids_gen','file'); - + if ids_gen_ok ids_empty = ids_gen(ids_top_name); % generate ids from gateway function ids_gen else % load empty ids structure from template file fname = sprintf('ids_empty_%s',ids_top_name); - + try assert(~~exist(ids_empty_path,'dir'),'folder %s not found',ids_empty_path); addpath(ids_empty_path); assert(~~exist(fname,'file'),'file %s does not exist in %s',fname,ids_empty_path); - + ids_empty = eval(fname); rmpath(ids_empty_path); catch ME @@ -1141,7 +1163,7 @@ elseif strcmp(mapping_for_tcv.method,'switchcase') end catch ME_tcv_get_ids disp(['there is a problem with: tcv_get_ids_' ids_top_name ... - ' , may be check if it exists in your path or test it by itself']) + ' , may be check if it exists in your path or test it by itself']) gdat_data.(ids_top_name) = ids_empty; gdat_data.([ids_top_name '_description']) = getReport(ME_tcv_get_ids); rethrow(ME_tcv_get_ids) diff --git a/matlab/TCV_IMAS/tcv_ids_circuit.m b/matlab/TCV_IMAS/tcv_ids_circuit.m index 30aab99ebb0ed8523a29bce8ac7b6d6aef3c0f1d..3b83cd4caa3cab2315759ab1305a67a55d96ef4e 100644 --- a/matlab/TCV_IMAS/tcv_ids_circuit.m +++ b/matlab/TCV_IMAS/tcv_ids_circuit.m @@ -33,8 +33,8 @@ for ii=1:tcv_circuit_info.ntotcircuits end ids_struct_out{ii}.current.data = tmpdata.data; ids_struct_out{ii}.current.time = tmpdata.dim{1}; - - + + ids_struct_out{ii}.connections = tcv_circuit_info.connection_matrix{ii}; ids_struct_out_description{ii}.connections = ... ['aa=tcv_ids_pf_active_definition, then from aa.connection_matrix{' num2str(ii) '}']; @@ -76,4 +76,3 @@ switch error_bar otherwise error(['tcv_ids_bpol_loop: error_bar option not known: ' error_bar]) end - diff --git a/matlab/TCV_IMAS/tcv_ids_supply.m b/matlab/TCV_IMAS/tcv_ids_supply.m index 954dc16dbff9d06fc20e7d53a409169d5db89e0d..0776a12a0e4fb0d6f56c1bd1e64cf2414a2a2fb7 100644 --- a/matlab/TCV_IMAS/tcv_ids_supply.m +++ b/matlab/TCV_IMAS/tcv_ids_supply.m @@ -32,7 +32,7 @@ for ii=1:tcv_circuit_info.ntotpowersupplies tmpdata = gdat_tcv(shot,['' tcv_circuit_info.mds_paths{ii} '']); % Get current ids_struct_out_description{ii}.current = ['abs value from ' tmpdata.data_fullpath]; end - + %ids_struct_out{ii}.current.data = abs(tmpdata.data); %%%%%%% FF:WHY ABS?? %%%%%%% ids_struct_out{ii}.current.data = tmpdata.data; %% FF removed abs() ids_struct_out{ii}.current.time = tmpdata.dim{1}; diff --git a/matlab/TCV_IMAS/test_tcv_get_ids.m b/matlab/TCV_IMAS/test_tcv_get_ids.m index d4642d48c8a2f01a35a0b95b8dd00bdeaabb92ca..a434d7a0dfb68343141af1428795d1fa2017a48a 100644 --- a/matlab/TCV_IMAS/test_tcv_get_ids.m +++ b/matlab/TCV_IMAS/test_tcv_get_ids.m @@ -1,19 +1,19 @@ classdef (SharedTestFixtures={... check_mds,setup_gdatpaths})... test_tcv_get_ids < matlab.unittest.TestCase - + properties(TestParameter) shot = {-1,40000,61400}; ids_name = {'pf_active','wall'}; end - + methods(Test,TestTags = {'imas'}) function test_get_ids_list(testCase,shot) gg = testCase.assertWarning(@() gdat(shot,'ids'),'gdat:EmptyIDSName'); - + testCase.assertTrue(iscell(gg.gdat_params.sources_available)); end - + function test_tcv2ids(testCase,shot,ids_name) if shot==-1 && strcmp(ids_name,'pf_active') ids = testCase.assertWarning(@() tcv2ids(shot,'ids_name',{ids_name}),'TCV:IDS:NoTimeData'); @@ -23,5 +23,5 @@ classdef (SharedTestFixtures={... testCase.assertTrue(~isempty(ids)) end end - -end \ No newline at end of file + +end diff --git a/matlab/gdat.m b/matlab/gdat.m index 48b33aa419965375f6de1734a987a7dadbe85aab..21e732d9549919e41112b0270f541d9586f6b661 100644 --- a/matlab/gdat.m +++ b/matlab/gdat.m @@ -92,6 +92,7 @@ if nargin>2 end end end + fusion_machine_defaultname=getenv('FUSION_MACHINE_DEFAULTNAME'); default_machine = 'tcv'; if ~isempty(fusion_machine_defaultname) diff --git a/matlab/gdat_plot.m b/matlab/gdat_plot.m index e50819bf8bf96fa805012fff11478a57c86e81b0..85b1d86acadfa61760da60d6b1fa69c40b71d389 100644 --- a/matlab/gdat_plot.m +++ b/matlab/gdat_plot.m @@ -98,7 +98,19 @@ if all(isfield(gdat_data,{'data','t'})) && ~isempty(gdat_data.data) && ~isempty( hylabel=ylabel(ylabel_eff,'interpreter','none'); end if iscell(gdat_data.label) && length(gdat_data.label)>=2; - legend(gdat_data.label,'interpreter','none'); + ab=get(gca,'children'); + if iscell(gdat_data.label) && length(ab) < length(gdat_data.label) + if length(ab) == 1 + % assume combine label is best + tempaaa = sprintf('%s/',gdat_data.label{:}); + hhhleg=legend(tempaaa(1:end-1)); + else + hhhleg=legend(gdat_data.label{1:length(ab)}); + end + else + hhhleg=legend(gdat_data.label); + end + set(hhhleg,'Interpreter','none'); end zoom on; end