diff --git a/matlab/AUG/CEZ_CMZ_fit.m b/matlab/AUG/CEZ_CMZ_fit.m index 69e4ec5c552df7110a4705def2b18399a21259bb..9adb62c28c44f959695f61e2e5aff55d405c6622 100644 --- a/matlab/AUG/CEZ_CMZ_fit.m +++ b/matlab/AUG/CEZ_CMZ_fit.m @@ -81,7 +81,7 @@ for i=1:length(ij) it_cxrs = find(cxrs.t>=t1(i) & cxrs.t<t2(i)); it_cmz = find(cmz.t>=t1(i) & cmz.t<t2(i)); % construct 1D array with data from both cxrs, cmz - rhotor_data_tofit = []; + rhotor_data_tofit = []; tidata_tofit = []; vrotdata_tofit = []; tierr_tofit = []; @@ -90,11 +90,11 @@ for i=1:length(ij) for it=1:length(it_cxrs) idata = find(cxrs.ti.data(:,it_cxrs(it))>0 & cxrs.rhotornorm(:,it_cxrs(it))<1.01); if length(idata)>0 - rhotor_data_tofit(end+1:end+length(idata)) = cxrs.rhotornorm(idata,it_cxrs(it)); - tidata_tofit(end+1:end+length(idata)) = cxrs.ti.data(idata,it_cxrs(it)); - vrotdata_tofit(end+1:end+length(idata)) = cxrs.vrot.data(idata,it_cxrs(it)); - tierr_tofit(end+1:end+length(idata)) = cxrs.ti.error_bar(idata,it_cxrs(it))./ticoeff_err_cxrs; - vroterr_tofit(end+1:end+length(idata)) = cxrs.vrot.error_bar(idata,it_cxrs(it))./vrotcoeff_err_cxrs; + rhotor_data_tofit(end+1:end+length(idata)) = cxrs.rhotornorm(idata,it_cxrs(it)); + tidata_tofit(end+1:end+length(idata)) = cxrs.ti.data(idata,it_cxrs(it)); + vrotdata_tofit(end+1:end+length(idata)) = cxrs.vrot.data(idata,it_cxrs(it)); + tierr_tofit(end+1:end+length(idata)) = cxrs.ti.error_bar(idata,it_cxrs(it))./ticoeff_err_cxrs; + vroterr_tofit(end+1:end+length(idata)) = cxrs.vrot.error_bar(idata,it_cxrs(it))./vrotcoeff_err_cxrs; end end end @@ -102,11 +102,11 @@ for i=1:length(ij) for it=1:length(it_cmz) idata = find(cmz.ti.data(:,it_cmz(it))>0 & cmz.rhotornorm(:,it_cmz(it))<1.01); if length(idata)>0 - rhotor_data_tofit(end+1:end+length(idata)) = cmz.rhotornorm(idata,it_cmz(it)); - tidata_tofit(end+1:end+length(idata)) = cmz.ti.data(idata,it_cmz(it)); - vrotdata_tofit(end+1:end+length(idata)) = cmz.vrot.data(idata,it_cmz(it)); - tierr_tofit(end+1:end+length(idata)) = cmz.ti.error_bar(idata,it_cmz(it))./ticoeff_err_cmz; - vroterr_tofit(end+1:end+length(idata)) = cmz.vrot.error_bar(idata,it_cmz(it))./vrotcoeff_err_cmz; + rhotor_data_tofit(end+1:end+length(idata)) = cmz.rhotornorm(idata,it_cmz(it)); + tidata_tofit(end+1:end+length(idata)) = cmz.ti.data(idata,it_cmz(it)); + vrotdata_tofit(end+1:end+length(idata)) = cmz.vrot.data(idata,it_cmz(it)); + tierr_tofit(end+1:end+length(idata)) = cmz.ti.error_bar(idata,it_cmz(it))./ticoeff_err_cmz; + vroterr_tofit(end+1:end+length(idata)) = cmz.vrot.error_bar(idata,it_cmz(it))./vrotcoeff_err_cmz; end end rhotor_data_tofit_cmz = cmz.rhotornorm(:,it_cmz); @@ -166,4 +166,3 @@ cez_cmz_fit.vrotcoeff_err_cmz = vrotcoeff_err_cmz; cez_cmz_data.shot = shot; eval(['save ' filename_withfits ' cez_cmz_fit cez_cmz_data']) - diff --git a/matlab/AUG/aug_help_parameters.m b/matlab/AUG/aug_help_parameters.m index f936f614c00a1cd1f7140e13e5dc07c17e87d208..8f7f54a9122cdee58e47d2a0eec1abc060b41766 100644 --- a/matlab/AUG/aug_help_parameters.m +++ b/matlab/AUG/aug_help_parameters.m @@ -5,22 +5,22 @@ function help_struct = aug_help_parameters(parameter_list) % % return the whole help structure if parameter_list empty or not provided % -% do: +% do: % help_struct = aug_help_parameters(fieldnames(gdat_data.gdat_params)); -% +% % to get relevant help description % % Defaults help_struct_all = struct(... - 'data_request', ['automatically filled in by gdat, name of request used in gdat call.' char(10) ... - 'contains current list of keywords if gdat called with no arguments: aa=gdat;' char(10) ... - 'Note shot value should not be in params so params can be used to load same data from another shot'] ... - ,'machine', 'machine name like ''TCV'', ''AUG'', case insensitive' ... - ,'doplot', '0 (default), if 1 calls gdat_plot for a new figure, -1 plot over current figure with hold all, see gdat_plot for details' ... - ,'liuqe','liuqe version 1 (default), 2, 3 for LIUQE1, 2, 3 resp. or -1 for model values' ... - ,'nverbose','1 (default) displays warnings, 0: only errors, >=3: displays all extra information' ... - ); + 'data_request', ['automatically filled in by gdat, name of request used in gdat call.' char(10) ... + 'contains current list of keywords if gdat called with no arguments: aa=gdat;' char(10) ... + 'Note shot value should not be in params so params can be used to load same data from another shot'] ... + ,'machine', 'machine name like ''TCV'', ''AUG'', case insensitive' ... + ,'doplot', '0 (default), if 1 calls gdat_plot for a new figure, -1 plot over current figure with hold all, see gdat_plot for details' ... + ,'liuqe','liuqe version 1 (default), 2, 3 for LIUQE1, 2, 3 resp. or -1 for model values' ... + ,'nverbose','1 (default) displays warnings, 0: only errors, >=3: displays all extra information' ... + ); % AUG related % $$$ help_struct_all.cxrs_plot = '0 (default) no plots, 1 get plots from CXRS_get_profiles see ''help CXRS_get_profiles'' for k_plot values'; @@ -31,7 +31,7 @@ help_struct_all.extra_arg_sf2sig = 'extra parameters given to sf2sig type of cal help_struct_all.special_signal = 'specific parameter,area-base,param-set,time-base signal, can be provided as 4th signal in data_request if explicit. Example: ''special_signal'',''param:gyro_freq'''; help_struct_all.fit_tension = ['smoothing value used in interpos fitting routine, -30 means ''30 times default value'', thus -1 often a' ... ' good value' char(10) ... - 'cxrs, nete: if numeric, default for all cases, if structure, default for non given fields']; + 'cxrs, nete: if numeric, default for all cases, if structure, default for non given fields']; help_struct_all.time = 'time(s) value(s) if relevant, for example eqdsk is provided by default only for time=1.0s'; % $$$ help_struct_all.zshift = 'vertical shift of equilibrium, either for eqdsk (1 to shift to zaxis=0) or for mapping measurements on to rho surfaces [m]'; help_struct_all.cocos = ['cocos value desired in output, uses eqdsk_cocos_transform. Note should use latter if a specific Ip and/or B0 sign' ... @@ -41,8 +41,8 @@ help_struct_all.fit = '0, no fit profiles, 1 (default) if fit profiles desired a help_struct_all.fit_type = 'type of fits ''std'' (default) uses diagnostic error bars, ''pedestal'', uses manual error bars with smaller values outside 0.8'; help_struct_all.fit_nb_rho_points = 'nb of points for the radial mesh over which the fits are evaluated for the fitted profiles, it uses an equidistant mesh at this stage'; help_struct_all.source = ['sxr: ''G'' (default, with ssx), camera name ''J'', ''G'', ...[F-M], case insensitive;' char(10) ... - 'cxrs: ''CEZ'' (default), ''CMZ'',''CUZ'',''COZ'',''all'';' char(10) ... - 'raptor: ''observer'', ''predictive'' (or ''obs'', ''pre'') to restrict the ouput to these signals']; + 'cxrs: ''CEZ'' (default), ''CMZ'',''CUZ'',''COZ'',''all'';' char(10) ... + 'raptor: ''observer'', ''predictive'' (or ''obs'', ''pre'') to restrict the ouput to these signals']; help_struct_all.source_exp_name = ['ne_rho, te_rho, nete_rho for fit from TRA source typically or IDA when expname not the same as formain signal']; help_struct_all.camera = ['[] (default, all), [i1 i2 ...] chord nbs ([1 3 5] if only chords 1, 3 and 5 are desired), ''central'' uses J_049']; help_struct_all.freq = '''slow'', default (means ssx, 500kHz), lower sampling; ''fast'' full samples 2MHz; integer value nn for downsampling every nn''th points'; diff --git a/matlab/AUG/aug_requests_mapping.m b/matlab/AUG/aug_requests_mapping.m index 4ec989ebce289664a0df30a814a73b94cee0e5fb..43a991fbd99a2a8e3d054eec5134ee65c273898c 100644 --- a/matlab/AUG/aug_requests_mapping.m +++ b/matlab/AUG/aug_requests_mapping.m @@ -5,13 +5,13 @@ function mapping = aug_requests_mapping(data_request) % Defaults mapping = struct(... - 'label', '', ... - 'method', '', ... - 'expression','', ... - 'timedim', -1, ... % dim which is the time is the database, to copy in .t, the other dims are in .x (-1 means last dimension) - 'gdat_timedim',[], ... % if need to reshape data and dim orders to have timedim as gdat_timedim (shifting time to gdat_timedim) - 'min', -inf, ... - 'max', inf); + 'label', '', ... + 'method', '', ... + 'expression','', ... + 'timedim', -1, ... % dim which is the time is the database, to copy in .t, the other dims are in .x (-1 means last dimension) + 'gdat_timedim',[], ... % if need to reshape data and dim orders to have timedim as gdat_timedim (shifting time to gdat_timedim) + 'min', -inf, ... + 'max', inf); % Note that gdat_timedim is set to timedim at end of this function if empty % gdat_timedim should have effective index of the time dimension in gdat @@ -38,166 +38,166 @@ if iscell(data_request) % || (~ischar(data_request) && length(data_request)>1) end switch lower(data_request) - case 'a_minor' - mapping.timedim = 1; - mapping.label = 'a\_minor'; - mapping.method = 'expression'; - mapping.expression = ['params_eff = gdat_data.gdat_params;params_eff.data_request=''r_inboard'';' ... + case 'a_minor' + mapping.timedim = 1; + mapping.label = 'a\_minor'; + mapping.method = 'expression'; + mapping.expression = ['params_eff = gdat_data.gdat_params;params_eff.data_request=''r_inboard'';' ... 'gdat_tmp=gdat_aug(shot,params_eff);gdat_tmp.r_inboard=gdat_tmp.data;' ... - 'params_eff.data_request=''r_outboard'';' ... - 'gdat_tmp2=gdat_aug(shot,params_eff);gdat_tmp.r_outboard=gdat_tmp2.data;' ... - 'gdat_tmp.data = 0.5.*(gdat_tmp2.data-gdat_tmp.data);gdat_tmp.label=''' mapping.label ''';' ... - 'gdat_tmp.gdat_request=''' data_request ''';']; - case 'b0' - mapping.timedim = 1; - mapping.label = 'B_0'; - % mapping.method = 'signal'; - % mapping.expression = [{'FPC'},{'BTF'}]; - mapping.method = 'expression'; - mapping.expression = ['params_eff = gdat_data.gdat_params;params_eff.data_request=[{''FPC''},{''BTF''}];' ... - 'gdat_tmp=gdat_aug(shot,params_eff);r0exp=1.65;gdat_tmp.r0 = r0exp; gdat_tmp.request_description = ' ... - '[''vacuum magnetic field at R0='' num2str(r0exp) ''m; COCOS=17''];' ... + 'params_eff.data_request=''r_outboard'';' ... + 'gdat_tmp2=gdat_aug(shot,params_eff);gdat_tmp.r_outboard=gdat_tmp2.data;' ... + 'gdat_tmp.data = 0.5.*(gdat_tmp2.data-gdat_tmp.data);gdat_tmp.label=''' mapping.label ''';' ... + 'gdat_tmp.gdat_request=''' data_request ''';']; + case 'b0' + mapping.timedim = 1; + mapping.label = 'B_0'; + % mapping.method = 'signal'; + % mapping.expression = [{'FPC'},{'BTF'}]; + mapping.method = 'expression'; + mapping.expression = ['params_eff = gdat_data.gdat_params;params_eff.data_request=[{''FPC''},{''BTF''}];' ... + 'gdat_tmp=gdat_aug(shot,params_eff);r0exp=1.65;gdat_tmp.r0 = r0exp; gdat_tmp.request_description = ' ... + '[''vacuum magnetic field at R0='' num2str(r0exp) ''m; COCOS=17''];' ... 'gdat_tmp.label=''' mapping.label ''';' ... - 'gdat_tmp.gdat_request=''' data_request ''';']; - case 'beta' - mapping.timedim = 1; - mapping.label = '\beta'; - mapping.method = 'expression'; - mapping.expression = ['params_eff = gdat_data.gdat_params;params_eff.data_request=''betan'';' ... + 'gdat_tmp.gdat_request=''' data_request ''';']; + case 'beta' + mapping.timedim = 1; + mapping.label = '\beta'; + mapping.method = 'expression'; + mapping.expression = ['params_eff = gdat_data.gdat_params;params_eff.data_request=''betan'';' ... 'gdat_tmp=gdat_aug(shot,params_eff);' ... - 'params_eff.data_request=''ip'';gdat_tmp2=gdat_aug(shot,params_eff);' ... - 'params_eff.data_request=''b0'';gdat_tmp3=gdat_aug(shot,params_eff);' ... - 'params_eff.data_request=''a_minor'';gdat_tmp4=gdat_aug(shot,params_eff);' ... - 'tmp_data_ip=interp1(gdat_tmp2.t,gdat_tmp2.data,gdat_tmp.t,[],NaN);' ... - 'tmp_data_b0=interp1(gdat_tmp3.t,gdat_tmp3.data,gdat_tmp.t,[],NaN);' ... - 'tmp_data_a=interp1(gdat_tmp4.t,gdat_tmp4.data,gdat_tmp.t,[],NaN);' ... - 'gdat_tmp.data = 0.01.*abs(gdat_tmp.data.*tmp_data_ip./1e6./tmp_data_a./tmp_data_b0);']; - case 'betan' - mapping.timedim = 1; - mapping.label = '\beta_N'; - mapping.method = 'signal'; - mapping.expression = [{'TOT'},{'beta_N'}]; - % in many cases, in particular just after an experiment, betaN is not present in TOT, thus compute it from 2/3Wmhd/V /(B0^2/2mu0) + 'params_eff.data_request=''ip'';gdat_tmp2=gdat_aug(shot,params_eff);' ... + 'params_eff.data_request=''b0'';gdat_tmp3=gdat_aug(shot,params_eff);' ... + 'params_eff.data_request=''a_minor'';gdat_tmp4=gdat_aug(shot,params_eff);' ... + 'tmp_data_ip=interp1(gdat_tmp2.t,gdat_tmp2.data,gdat_tmp.t,[],NaN);' ... + 'tmp_data_b0=interp1(gdat_tmp3.t,gdat_tmp3.data,gdat_tmp.t,[],NaN);' ... + 'tmp_data_a=interp1(gdat_tmp4.t,gdat_tmp4.data,gdat_tmp.t,[],NaN);' ... + 'gdat_tmp.data = 0.01.*abs(gdat_tmp.data.*tmp_data_ip./1e6./tmp_data_a./tmp_data_b0);']; + case 'betan' + mapping.timedim = 1; + mapping.label = '\beta_N'; + mapping.method = 'signal'; + mapping.expression = [{'TOT'},{'beta_N'}]; + % in many cases, in particular just after an experiment, betaN is not present in TOT, thus compute it from 2/3Wmhd/V /(B0^2/2mu0) % $$$ mapping.method = 'expression'; % $$$ mapping.expression = ['params_eff = gdat_data.gdat_params;params_eff.data_request=[{''TOT''},{''beta_2N''},{''AUGD''}];' ... % $$$ 'gdat_tmp=gdat_aug(shot,params_eff); if isempty(gdat_tmp.data);' ... -% $$$ 'params_eff.data_request=''ip'';gdat_ip=gdat_aug(shot,params_eff);' ... -% $$$ 'params_eff.data_request=''b0'';gdat_b0=gdat_aug(shot,params_eff);' ... -% $$$ 'params_eff.data_request=''a_minor'';gdat_aminor=gdat_aug(shot,params_eff);' ... -% $$$ 'params_eff.data_request=''wmhd'';gdat_tmp=gdat_aug(shot,params_eff);' ... -% $$$ 'params_eff.data_request=''volume'';gdat_vol=gdat_aug(shot,params_eff);' ... -% $$$ 'tmp_data_ip=interp1(gdat_ip.t,gdat_ip.data,gdat_tmp.t,[],NaN);' ... -% $$$ 'tmp_data_b0=interp1(gdat_b0.t,gdat_b0.data,gdat_tmp.t,[],NaN);' ... -% $$$ 'tmp_data_a=interp1(gdat_aminor.t,gdat_aminor.data,gdat_tmp.t,[],NaN);' ... -% $$$ 'tmp_data_vol=interp1(gdat_vol.t,gdat_vol.data,gdat_tmp.t,[],NaN);' ... -% $$$ 'gdat_tmp.data = 100.*abs(2./3.*gdat_tmp.data./tmp_data_vol.*8e-7.*pi./tmp_data_b0.^2./tmp_data_ip.*1e6.*tmp_data_a.*tmp_data_b0);end;']; - case {'betap', 'beta_p', 'beta_pol'} - mapping.timedim = 1; - mapping.label = '\beta_p'; - mapping.method = 'signal'; - mapping.expression = [{'FPG'},{'betpol'}]; - case {'cxrs', 'cxrs_rho'} - mapping.timedim = 2; - mapping.label = 'cxrs'; - mapping.method = 'switchcase'; - mapping.expression = ''; - case 'delta' - mapping.timedim = 1; - mapping.label = 'delta'; - mapping.method = 'expression'; - mapping.expression = ['params_eff = gdat_data.gdat_params;params_eff.data_request=''delta_bottom''; ' ... +% $$$ 'params_eff.data_request=''ip'';gdat_ip=gdat_aug(shot,params_eff);' ... +% $$$ 'params_eff.data_request=''b0'';gdat_b0=gdat_aug(shot,params_eff);' ... +% $$$ 'params_eff.data_request=''a_minor'';gdat_aminor=gdat_aug(shot,params_eff);' ... +% $$$ 'params_eff.data_request=''wmhd'';gdat_tmp=gdat_aug(shot,params_eff);' ... +% $$$ 'params_eff.data_request=''volume'';gdat_vol=gdat_aug(shot,params_eff);' ... +% $$$ 'tmp_data_ip=interp1(gdat_ip.t,gdat_ip.data,gdat_tmp.t,[],NaN);' ... +% $$$ 'tmp_data_b0=interp1(gdat_b0.t,gdat_b0.data,gdat_tmp.t,[],NaN);' ... +% $$$ 'tmp_data_a=interp1(gdat_aminor.t,gdat_aminor.data,gdat_tmp.t,[],NaN);' ... +% $$$ 'tmp_data_vol=interp1(gdat_vol.t,gdat_vol.data,gdat_tmp.t,[],NaN);' ... +% $$$ 'gdat_tmp.data = 100.*abs(2./3.*gdat_tmp.data./tmp_data_vol.*8e-7.*pi./tmp_data_b0.^2./tmp_data_ip.*1e6.*tmp_data_a.*tmp_data_b0);end;']; + case {'betap', 'beta_p', 'beta_pol'} + mapping.timedim = 1; + mapping.label = '\beta_p'; + mapping.method = 'signal'; + mapping.expression = [{'FPG'},{'betpol'}]; + case {'cxrs', 'cxrs_rho'} + mapping.timedim = 2; + mapping.label = 'cxrs'; + mapping.method = 'switchcase'; + mapping.expression = ''; + case 'delta' + mapping.timedim = 1; + mapping.label = 'delta'; + mapping.method = 'expression'; + mapping.expression = ['params_eff = gdat_data.gdat_params;params_eff.data_request=''delta_bottom''; ' ... 'gdat_tmp=gdat_aug(shot,params_eff);params_eff.data_request=''delta_top'';' ... - 'gdat_tmp2=gdat_aug(shot,params_eff);gdat_tmp.data = 0.5.*(gdat_tmp.data+gdat_tmp2.data);']; - case 'delta_top' - mapping.label = 'delta\_top'; - mapping.timedim = 1; - mapping.method = 'signal'; - mapping.expression = [{'FPG'},{'delRoben'}]; - case 'delta_bottom' - mapping.label = 'delta\_bottom'; - mapping.timedim = 1; - mapping.method = 'signal'; - mapping.expression = [{'FPG'},{'delRuntn'}]; - case {'ece', 'eced', 'ece_rho', 'eced_rho'} - mapping.timedim = 2; - mapping.method = 'switchcase'; - mapping.expression = ''; - case 'eqdsk' - mapping.timedim = 2; - mapping.method = 'switchcase'; % could use function make_eqdsk directly? - mapping.expression = ''; - case 'equil' - mapping.gdat_timedim = 2; - mapping.method = 'switchcase'; % could use function make_eqdsk directly? - mapping.expression = ''; - case {'gas', 'gas_valve'} - mapping.gdat_timedim = 2; - mapping.method = 'switchcase'; - case 'halpha' - mapping.timedim = 1; - mapping.label = 'Halpha'; - mapping.method = 'signal'; - mapping.expression = [{'POT'},{'ELMa-Han'}]; - case 'h_scalings' - mapping.label = 'H_{scal}'; - mapping.timedim = 1; - mapping.method = 'signal'; - mapping.expression = [{'TTH'},{'H/L-facs'},{'AUGD'}]; - mapping.method = 'expression'; - mapping.expression = ['params_eff = gdat_data.gdat_params;params_eff.data_request=[{''TTH''},{''H/L-facs''},{''AUGD''}];params_eff.source=''TTH'';' ... + 'gdat_tmp2=gdat_aug(shot,params_eff);gdat_tmp.data = 0.5.*(gdat_tmp.data+gdat_tmp2.data);']; + case 'delta_top' + mapping.label = 'delta\_top'; + mapping.timedim = 1; + mapping.method = 'signal'; + mapping.expression = [{'FPG'},{'delRoben'}]; + case 'delta_bottom' + mapping.label = 'delta\_bottom'; + mapping.timedim = 1; + mapping.method = 'signal'; + mapping.expression = [{'FPG'},{'delRuntn'}]; + case {'ece', 'eced', 'ece_rho', 'eced_rho'} + mapping.timedim = 2; + mapping.method = 'switchcase'; + mapping.expression = ''; + case 'eqdsk' + mapping.timedim = 2; + mapping.method = 'switchcase'; % could use function make_eqdsk directly? + mapping.expression = ''; + case 'equil' + mapping.gdat_timedim = 2; + mapping.method = 'switchcase'; % could use function make_eqdsk directly? + mapping.expression = ''; + case {'gas', 'gas_valve'} + mapping.gdat_timedim = 2; + mapping.method = 'switchcase'; + case 'halpha' + mapping.timedim = 1; + mapping.label = 'Halpha'; + mapping.method = 'signal'; + mapping.expression = [{'POT'},{'ELMa-Han'}]; + case 'h_scalings' + mapping.label = 'H_{scal}'; + mapping.timedim = 1; + mapping.method = 'signal'; + mapping.expression = [{'TTH'},{'H/L-facs'},{'AUGD'}]; + mapping.method = 'expression'; + mapping.expression = ['params_eff = gdat_data.gdat_params;params_eff.data_request=[{''TTH''},{''H/L-facs''},{''AUGD''}];params_eff.source=''TTH'';' ... 'gdat_tmp=gdat_aug(shot,params_eff);S = rdaAUG_eff(shot,''TTH'',''scal_par'',''AUGD'',[],[],''param:descript'');gdat_tmp.dimunits{1}=cellstr(deblank(S.data''));' ... 'gdat_tmp.data = min(gdat_tmp.data,10.);']; - case 'ids' - mapping.timedim = 1; - mapping.label = 'ids ala imas'; - mapping.method = 'switchcase'; - case 'ioh' - mapping.timedim = 1; - mapping.label = 'I ohmic transformer'; - mapping.method = 'signal'; - mapping.expression = [{'MBI'},{'IOH'}]; - case 'ip' - mapping.timedim = 1; - mapping.label = 'Plasma current'; - mapping.method = 'signal'; - mapping.expression = [{'MAG'},{'Ipa'}]; - mapping.expression = [{'FPC'},{'IpiFP'}]; - case 'kappa' - mapping.timedim = 1; - mapping.label = '\kappa'; - mapping.method = 'signal'; - mapping.expression = [{'FPG'},{'k'}]; - case 'kappa_top' - mapping.timedim = 1; - mapping.label = '\kappa^{top}'; - mapping.method = 'signal'; - mapping.expression = [{'FPG'},{'koben'}]; - case 'kappa_bottom' - mapping.timedim = 1; - mapping.label = '\kappa_{bottom}'; - mapping.method = 'signal'; - mapping.expression = [{'FPG'},{'kuntn'}]; - case 'li' - mapping.timedim = 1; - mapping.label = 'l_i'; - mapping.method = 'signal'; - mapping.expression = [{'FPG'},{'li'}]; - case 'li3' - mapping.timedim = 1; - mapping.label = 'li3'; - mapping.method = 'expression'; - % li and betapol should have similar "normalization", using Bpa=int(Bp dlp)/int(dlp) and V=2pi R0 pi a^2 kappa and int(dlp)=2pi a sqrt(kappa) we get 2/R0 = int(dlp)^2/V so li3 is defined as [ - % li3 = 2 int(Bp^2 dV) / (mu0^2 Ip^2 R0) - % while li ala EFIT [https://iopscience.iop.org/article/10.1088/0029-5515/25/10/004 Eq.(5)] or CLISTE/IDE/GPEC [https://doi.org/10.13182/FST15-154 p.5] by - % li1 = int(Bp^2 dV) / (V Bpa^2) = int(Bp^2 dV) / (mu0^2 Ip^2) * int(dlp)^2 / V = CONVF * li3 - % CONVF = conversion_factor_liefit_li3 = int(dlp)^2/V * R0/2 - help_text = ['sprintf(''%s\n%s\n%s%s\n%s\n%s'',''li3 = 2 int(Bp^2 dV) / (mu0^2 Ip^2 R0), see Freidberg or '',', ... - '''CHEASE https://doi.org/10.1016/0010-4655(96)00046-X p. 5'',', ... - '''li ala EFIT [https://iopscience.iop.org/article/10.1088/0029-5515/25/10/004 Eq.(5)], CLISTE, IDE, '',', ... - '''GPEC [https://doi.org/10.13182/FST15-154 p.5]'',', ... - '''li = int(Bp^2 dV) / (V Bpa^2) = int(Bp^2 dV) / (mu0^2 Ip^2) * int(dlp)^2 / V = CONVF * li3'',', ... - '''CONVF = conversion_factor_liefit_li3 = int(dlp)^2/V * R0/2'')']; - mapping.expression = ['params_eff = gdat_data.gdat_params;params_eff.data_request=''li'';' ... + case 'ids' + mapping.timedim = 1; + mapping.label = 'ids ala imas'; + mapping.method = 'switchcase'; + case 'ioh' + mapping.timedim = 1; + mapping.label = 'I ohmic transformer'; + mapping.method = 'signal'; + mapping.expression = [{'MBI'},{'IOH'}]; + case 'ip' + mapping.timedim = 1; + mapping.label = 'Plasma current'; + mapping.method = 'signal'; + mapping.expression = [{'MAG'},{'Ipa'}]; + mapping.expression = [{'FPC'},{'IpiFP'}]; + case 'kappa' + mapping.timedim = 1; + mapping.label = '\kappa'; + mapping.method = 'signal'; + mapping.expression = [{'FPG'},{'k'}]; + case 'kappa_top' + mapping.timedim = 1; + mapping.label = '\kappa^{top}'; + mapping.method = 'signal'; + mapping.expression = [{'FPG'},{'koben'}]; + case 'kappa_bottom' + mapping.timedim = 1; + mapping.label = '\kappa_{bottom}'; + mapping.method = 'signal'; + mapping.expression = [{'FPG'},{'kuntn'}]; + case 'li' + mapping.timedim = 1; + mapping.label = 'l_i'; + mapping.method = 'signal'; + mapping.expression = [{'FPG'},{'li'}]; + case 'li3' + mapping.timedim = 1; + mapping.label = 'li3'; + mapping.method = 'expression'; + % li and betapol should have similar "normalization", using Bpa=int(Bp dlp)/int(dlp) and V=2pi R0 pi a^2 kappa and int(dlp)=2pi a sqrt(kappa) we get 2/R0 = int(dlp)^2/V so li3 is defined as [ + % li3 = 2 int(Bp^2 dV) / (mu0^2 Ip^2 R0) + % while li ala EFIT [https://iopscience.iop.org/article/10.1088/0029-5515/25/10/004 Eq.(5)] or CLISTE/IDE/GPEC [https://doi.org/10.13182/FST15-154 p.5] by + % li1 = int(Bp^2 dV) / (V Bpa^2) = int(Bp^2 dV) / (mu0^2 Ip^2) * int(dlp)^2 / V = CONVF * li3 + % CONVF = conversion_factor_liefit_li3 = int(dlp)^2/V * R0/2 + help_text = ['sprintf(''%s\n%s\n%s%s\n%s\n%s'',''li3 = 2 int(Bp^2 dV) / (mu0^2 Ip^2 R0), see Freidberg or '',', ... + '''CHEASE https://doi.org/10.1016/0010-4655(96)00046-X p. 5'',', ... + '''li ala EFIT [https://iopscience.iop.org/article/10.1088/0029-5515/25/10/004 Eq.(5)], CLISTE, IDE, '',', ... + '''GPEC [https://doi.org/10.13182/FST15-154 p.5]'',', ... + '''li = int(Bp^2 dV) / (V Bpa^2) = int(Bp^2 dV) / (mu0^2 Ip^2) * int(dlp)^2 / V = CONVF * li3'',', ... + '''CONVF = conversion_factor_liefit_li3 = int(dlp)^2/V * R0/2'')']; + mapping.expression = ['params_eff = gdat_data.gdat_params;params_eff.data_request=''li'';' ... 'gdat_tmp=gdat_aug(shot,params_eff);ij=find(gdat_tmp.data<=0);gdat_tmp.data(ij)=NaN;' ... 'r0exp=1.65;gdat_tmp.r0=r0exp;' ... 'params_eff.data_request=''volume'';' ... @@ -205,117 +205,117 @@ switch lower(data_request) 'params_eff.data_request=[{''FPG''},{''Circumf''}];' ... 'gdat_pol_length=gdat_aug(shot,params_eff);ij=find(gdat_pol_length.data<=0);gdat_pol_length.data(ij)=NaN;' ... 'gdat_tmp.conversion_factor_liefit_li3=gdat_tmp.r0./2.*gdat_pol_length.data.^2./max(abs(gdat_vol.data),1e-1);' ... - 'gdat_tmp.data = gdat_tmp.data./gdat_tmp.conversion_factor_liefit_li3;' ... + 'gdat_tmp.data = gdat_tmp.data./gdat_tmp.conversion_factor_liefit_li3;' ... 'gdat_tmp.help = ' help_text ';']; - case 'mhd' - mapping.timedim = 1; - mapping.label = {'n\_odd','n\_even'};% this superseeds the expression - mapping.method = 'expression'; - mapping.expression = ['params_eff = gdat_data.gdat_params;params_eff.data_request={''MOD'',''OddN''}; ' ... + case 'mhd' + mapping.timedim = 1; + mapping.label = {'n\_odd','n\_even'};% this superseeds the expression + mapping.method = 'expression'; + mapping.expression = ['params_eff = gdat_data.gdat_params;params_eff.data_request={''MOD'',''OddN''}; ' ... 'gdat_tmp=gdat_aug(shot,params_eff);gdat_tmp.data=reshape(gdat_tmp.data,length(gdat_tmp.data),1 );' ... - 'gdat_tmp.dim{1}=gdat_tmp.t;gdat_tmp.dim{2}=[1 2];gdat_tmp.x=gdat_tmp.dim{2};' ... - 'gdat_tmp.n_odd.data = gdat_tmp.data;gdat_tmp.n_odd.data_request=params_eff.data_request;' ... - 'params_eff.data_request={''MOD'',''EvenN''};' ... - 'gdat_tmp2=gdat_aug(shot,params_eff);gdat_tmp.data(:,2)=reshape(gdat_tmp2.data,length(gdat_tmp2.data),1);' ... - 'gdat_tmp.n_even.data = gdat_tmp2.data;gdat_tmp.n_even.data_request=params_eff.data_request;gdat_tmp.label={''n\_odd'',''n\_even''};' ... - 'params_eff.data_request={''MOD'',''OddNAmp''};' ... - 'gdat_tmp2=gdat_aug(shot,params_eff);gdat_tmp.n_odd.amp=reshape(gdat_tmp2.data,length(gdat_tmp2.data),1);' ... - 'gdat_tmp.n_odd.amp_t=gdat_tmp2.t;' ... - 'params_eff.data_request={''MOD'',''EvenNAmp''};' ... - 'gdat_tmp2=gdat_aug(shot,params_eff);gdat_tmp.n_even.amp=reshape(gdat_tmp2.data,length(gdat_tmp2.data),1);' ... - 'gdat_tmp.n_even.amp_t=gdat_tmp2.t;' ... - 'gdat_tmp.full_path=''MOD/Odd in data and .n_odd; .n_even'';' ... - 'gdat_tmp.gdat_request=''mhd'';gdat_tmp.gdat_params.data_request=gdat_tmp.gdat_request;']; - case 'ne' - mapping.timedim = 2; - mapping.method = 'switchcase'; - case 'neint' - mapping.timedim = 1; - mapping.label = 'line integrated el. density'; - % mapping.method = 'signal'; - mapping.method = 'expression'; - mapping.expression = [{'DCN'},{'H-1'},{'AUGD'}]; - mapping.expression = ['params_eff = gdat_data.gdat_params;params_eff.data_request={''DCN'',''H-1'',''AUGD''};' ... + 'gdat_tmp.dim{1}=gdat_tmp.t;gdat_tmp.dim{2}=[1 2];gdat_tmp.x=gdat_tmp.dim{2};' ... + 'gdat_tmp.n_odd.data = gdat_tmp.data;gdat_tmp.n_odd.data_request=params_eff.data_request;' ... + 'params_eff.data_request={''MOD'',''EvenN''};' ... + 'gdat_tmp2=gdat_aug(shot,params_eff);gdat_tmp.data(:,2)=reshape(gdat_tmp2.data,length(gdat_tmp2.data),1);' ... + 'gdat_tmp.n_even.data = gdat_tmp2.data;gdat_tmp.n_even.data_request=params_eff.data_request;gdat_tmp.label={''n\_odd'',''n\_even''};' ... + 'params_eff.data_request={''MOD'',''OddNAmp''};' ... + 'gdat_tmp2=gdat_aug(shot,params_eff);gdat_tmp.n_odd.amp=reshape(gdat_tmp2.data,length(gdat_tmp2.data),1);' ... + 'gdat_tmp.n_odd.amp_t=gdat_tmp2.t;' ... + 'params_eff.data_request={''MOD'',''EvenNAmp''};' ... + 'gdat_tmp2=gdat_aug(shot,params_eff);gdat_tmp.n_even.amp=reshape(gdat_tmp2.data,length(gdat_tmp2.data),1);' ... + 'gdat_tmp.n_even.amp_t=gdat_tmp2.t;' ... + 'gdat_tmp.full_path=''MOD/Odd in data and .n_odd; .n_even'';' ... + 'gdat_tmp.gdat_request=''mhd'';gdat_tmp.gdat_params.data_request=gdat_tmp.gdat_request;']; + case 'ne' + mapping.timedim = 2; + mapping.method = 'switchcase'; + case 'neint' + mapping.timedim = 1; + mapping.label = 'line integrated el. density'; + % mapping.method = 'signal'; + mapping.method = 'expression'; + mapping.expression = [{'DCN'},{'H-1'},{'AUGD'}]; + mapping.expression = ['params_eff = gdat_data.gdat_params;params_eff.data_request={''DCN'',''H-1'',''AUGD''};' ... 'if any(shot==[39311, 39599]);params_eff.data_request={''TTH'',''dcn_reco'',''PUETTI''};end;' ... 'gdat_tmp=gdat_aug(shot,params_eff);']; - case 'nel' - mapping.timedim = 1; - mapping.label = 'line-averaged el. density'; - mapping.expression = [{'FPG'},{'lenH-1'},{'AUGD'}]; - mapping.method = 'expression'; - mapping.expression = ['params_eff = gdat_data.gdat_params;params_eff.data_request=''neint'';' ... + case 'nel' + mapping.timedim = 1; + mapping.label = 'line-averaged el. density'; + mapping.expression = [{'FPG'},{'lenH-1'},{'AUGD'}]; + mapping.method = 'expression'; + mapping.expression = ['params_eff = gdat_data.gdat_params;params_eff.data_request=''neint'';' ... 'gdat_tmp=gdat_aug(shot,params_eff);params_eff.data_request=[{''FPG''},{''lenH-1''},{''AUGD''}];' ... - 'gdat_tmp2=gdat_aug(shot,params_eff);ij=find(gdat_tmp2.data==0);gdat_tmp2.data(ij)=NaN;' ... - 'tmp_data=interp1(gdat_tmp2.t,gdat_tmp2.data,gdat_tmp.t,[],NaN);' ... - 'gdat_tmp.data = gdat_tmp.data./(tmp_data+1e-5);']; - case 'ne_rho' - mapping.timedim = 2; - mapping.label = 'ne'; - mapping.method = 'switchcase'; - case 'nete_rho' - mapping.timedim = 2; - mapping.label = 'ne and Te'; - mapping.method = 'switchcase'; - case {'ng','ngreenwald','n_greenwald'} - mapping.timedim = 1; - 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_tmp2=gdat_aug(shot,params_eff);ij=find(gdat_tmp2.data==0);gdat_tmp2.data(ij)=NaN;' ... + 'tmp_data=interp1(gdat_tmp2.t,gdat_tmp2.data,gdat_tmp.t,[],NaN);' ... + 'gdat_tmp.data = gdat_tmp.data./(tmp_data+1e-5);']; + case 'ne_rho' + mapping.timedim = 2; + mapping.label = 'ne'; + mapping.method = 'switchcase'; + case 'nete_rho' + mapping.timedim = 2; + mapping.label = 'ne and Te'; + mapping.method = 'switchcase'; + case {'ng','ngreenwald','n_greenwald'} + mapping.timedim = 1; + 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_aug(shot,params_eff);params_eff.data_request=''ip'';' ... - 'gdat_tmp2=gdat_aug(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_tmp2=gdat_aug(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_aug(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 = 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;']; - 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_tmp3=gdat_aug(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 = 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;']; + 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_aug(shot,params_eff);params_eff.data_request=''n_greenwald'';' ... - 'gdat_tmp2=gdat_aug(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_tmp2=gdat_aug(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);']; % $$$ case 'ni' % $$$ mapping.method = 'switchcase'; % especially since might have option fit, etc - case 'pellet' - mapping.timedim = 1; - mapping.label = 'line integrated el. density'; - mapping.method = 'signal'; - mapping.expression = [{'PEL'},{'5Co'},{'AUGD'}]; - case 'pgyro' - mapping.timedim = 1; - mapping.label = 'EC gyros'; - mapping.method = 'switchcase'; - case 'powers' - mapping.timedim = 1; - mapping.label = 'various powers'; - mapping.method = 'switchcase'; - case {'prad', 'p_rad'} - mapping.timedim = 1; - mapping.label = 'P_{rad}'; - mapping.method = 'signal'; - mapping.expression = [{'BPD'},{'Pradtot'},{'AUGD'}]; - case 'psi_axis' - mapping.timedim = 1; - mapping.method = 'switchcase'; % there is psi_axis-psi_edge in FPG but otherwise complicated to get from equil, thus needs swticth case - mapping.label ='psi_\axis' ; - case 'psi_edge' - mapping.timedim = 1; - mapping.method = 'switchcase'; % is set to zero, so not in tree nodes - mapping.label = 'psi\_edge'; - case 'q0' - mapping.timedim = 1; - mapping.label = 'q_0'; - mapping.method = 'signal'; - mapping.expression = [{'FPG'},{'q0'},{'AUGD'}]; - case 'q95' - mapping.timedim = 1; - mapping.label = 'q_{95}'; - mapping.method = 'signal'; - mapping.expression = [{'FPG'},{'q95'},{'AUGD'}]; + case 'pellet' + mapping.timedim = 1; + mapping.label = 'line integrated el. density'; + mapping.method = 'signal'; + mapping.expression = [{'PEL'},{'5Co'},{'AUGD'}]; + case 'pgyro' + mapping.timedim = 1; + mapping.label = 'EC gyros'; + mapping.method = 'switchcase'; + case 'powers' + mapping.timedim = 1; + mapping.label = 'various powers'; + mapping.method = 'switchcase'; + case {'prad', 'p_rad'} + mapping.timedim = 1; + mapping.label = 'P_{rad}'; + mapping.method = 'signal'; + mapping.expression = [{'BPD'},{'Pradtot'},{'AUGD'}]; + case 'psi_axis' + mapping.timedim = 1; + mapping.method = 'switchcase'; % there is psi_axis-psi_edge in FPG but otherwise complicated to get from equil, thus needs swticth case + mapping.label ='psi_\axis' ; + case 'psi_edge' + mapping.timedim = 1; + mapping.method = 'switchcase'; % is set to zero, so not in tree nodes + mapping.label = 'psi\_edge'; + case 'q0' + mapping.timedim = 1; + mapping.label = 'q_0'; + mapping.method = 'signal'; + mapping.expression = [{'FPG'},{'q0'},{'AUGD'}]; + case 'q95' + mapping.timedim = 1; + mapping.label = 'q_{95}'; + mapping.method = 'signal'; + mapping.expression = [{'FPG'},{'q95'},{'AUGD'}]; % $$$ case 'q_edge' % should use q_rho and then take q_edge since does not make sense for diverted shots and mainly diverted shots... % $$$ mapping.timedim = 1; % $$$ mapping.label = 'q_{edge}}'; @@ -323,146 +323,146 @@ switch lower(data_request) % $$$ mapping.method = 'switchcase'; % $$$ mapping.expression = [{'FPG'},{'q95'},{'AUGD'}]; % $$$ mapping.expression = []; - case 'q_rho' - mapping.timedim = 2; - mapping.gdat_timedim = 2; - mapping.label = 'q'; - mapping.method = 'switchcase'; - case 'raptor' - mapping.timedim = 2; - mapping.gdat_timedim = 2; - mapping.label = 'Raptor signals'; - mapping.method = 'switchcase'; - case 'rgeom' - mapping.label = 'Rgeom'; - mapping.timedim = 1; - mapping.method = 'expression'; - mapping.expression = ['params_eff = gdat_data.gdat_params;params_eff.data_request=''r_inboard'';' ... + case 'q_rho' + mapping.timedim = 2; + mapping.gdat_timedim = 2; + mapping.label = 'q'; + mapping.method = 'switchcase'; + case 'raptor' + mapping.timedim = 2; + mapping.gdat_timedim = 2; + mapping.label = 'Raptor signals'; + mapping.method = 'switchcase'; + case 'rgeom' + mapping.label = 'Rgeom'; + mapping.timedim = 1; + mapping.method = 'expression'; + mapping.expression = ['params_eff = gdat_data.gdat_params;params_eff.data_request=''r_inboard'';' ... 'gdat_tmp=gdat_aug(shot,params_eff);gdat_tmp.r_inboard=gdat_tmp.data;' ... - 'params_eff.data_request=''r_outboard'';' ... - 'gdat_tmp2=gdat_aug(shot,params_eff);gdat_tmp.r_outboard=gdat_tmp2.data;' ... - 'gdat_tmp.data = 0.5.*(gdat_tmp2.data+gdat_tmp.data);gdat_tmp.label=''' mapping.label ''';' ... - 'gdat_tmp.gdat_request=''' data_request ''';']; - case 'r_inboard' - mapping.label = 'R\_inboard'; - mapping.timedim = 1; - mapping.method = 'signal'; - mapping.expression = [{'FPG'},{'Rin'},{'AUGD'}]; - case 'r_outboard' - mapping.label = 'R\_outboard'; - mapping.timedim = 1; - mapping.method = 'signal'; - mapping.expression = [{'FPG'},{'Raus'},{'AUGD'}]; - case 'rhotor' - mapping.timedim = 2; - mapping.method = 'switchcase'; - mapping.label = 'rhotor'; - case 'rhotor_edge' - mapping.timedim = 1; - mapping.method = 'switchcase'; - mapping.label = 'rhotor\_edge'; - case 'rhotor_norm' - mapping.timedim = 1; - mapping.method = 'switchcase'; - mapping.label = 'rhotor\_norm'; - case 'rhovol' - mapping.timedim = 2; - mapping.label = 'rhovol\_norm'; - mapping.method = 'switchcase'; - case {'rmag', 'r_axis', 'r_mag'} - mapping.label = 'R\_magaxis'; - mapping.timedim = 1; - mapping.method = 'signal'; - mapping.expression = [{'FPG'},{'Rmag'},{'AUGD'}]; - case 'sxr' - mapping.timedim = 1; - mapping.gdat_timedim = 2; - mapping.method = 'switchcase'; - case 'tau_tot' - mapping.label = '\tau_{tot}'; - mapping.timedim = 1; - mapping.method = 'signal'; - mapping.expression = [{'TOT'},{'tau_tot'},{'AUGD'}]; - case 'te' - mapping.timedim = 2; - mapping.label = 'Te'; - mapping.method = 'switchcase'; - case 'te_rho' - mapping.timedim = 2; - mapping.label = 'Te'; - mapping.method = 'switchcase'; + 'params_eff.data_request=''r_outboard'';' ... + 'gdat_tmp2=gdat_aug(shot,params_eff);gdat_tmp.r_outboard=gdat_tmp2.data;' ... + 'gdat_tmp.data = 0.5.*(gdat_tmp2.data+gdat_tmp.data);gdat_tmp.label=''' mapping.label ''';' ... + 'gdat_tmp.gdat_request=''' data_request ''';']; + case 'r_inboard' + mapping.label = 'R\_inboard'; + mapping.timedim = 1; + mapping.method = 'signal'; + mapping.expression = [{'FPG'},{'Rin'},{'AUGD'}]; + case 'r_outboard' + mapping.label = 'R\_outboard'; + mapping.timedim = 1; + mapping.method = 'signal'; + mapping.expression = [{'FPG'},{'Raus'},{'AUGD'}]; + case 'rhotor' + mapping.timedim = 2; + mapping.method = 'switchcase'; + mapping.label = 'rhotor'; + case 'rhotor_edge' + mapping.timedim = 1; + mapping.method = 'switchcase'; + mapping.label = 'rhotor\_edge'; + case 'rhotor_norm' + mapping.timedim = 1; + mapping.method = 'switchcase'; + mapping.label = 'rhotor\_norm'; + case 'rhovol' + mapping.timedim = 2; + mapping.label = 'rhovol\_norm'; + mapping.method = 'switchcase'; + case {'rmag', 'r_axis', 'r_mag'} + mapping.label = 'R\_magaxis'; + mapping.timedim = 1; + mapping.method = 'signal'; + mapping.expression = [{'FPG'},{'Rmag'},{'AUGD'}]; + case 'sxr' + mapping.timedim = 1; + mapping.gdat_timedim = 2; + mapping.method = 'switchcase'; + case 'tau_tot' + mapping.label = '\tau_{tot}'; + mapping.timedim = 1; + mapping.method = 'signal'; + mapping.expression = [{'TOT'},{'tau_tot'},{'AUGD'}]; + case 'te' + mapping.timedim = 2; + mapping.label = 'Te'; + mapping.method = 'switchcase'; + case 'te_rho' + mapping.timedim = 2; + mapping.label = 'Te'; + mapping.method = 'switchcase'; % $$$ case 'ti' % case to be set % $$$ mapping.label = 'Ti'; % $$$ mapping.method = 'switchcase'; - case 'vloop' - mapping.label = 'Vloop'; - mapping.timedim = 1; - % mapping.method = 'signal'; - % mapping.expression = [{'MAG'},{'ULid12'},{'AUGD'}]; - mapping.method = 'expression'; - mapping.expression = ['params_eff = gdat_data.gdat_params;params_eff.data_request=[{''MAG''},{''ULid12''},{''AUGD''}];' ... - 'gdat_tmp=gdat_aug(shot,params_eff);ij=find(~isnan(gdat_tmp.data));' ... - 'tmp_data=interpos(gdat_tmp.t,gdat_tmp.data,-3e4);' ... - 'gdat_tmp.data_smooth = tmp_data;gdat_tmp.gdat_request=''vloop'';gdat_tmp.gdat_params.data_request=gdat_tmp.gdat_request;']; - case {'volume', 'volume_edge'} - mapping.label = 'Volume'; - mapping.timedim = 1; - mapping.method = 'signal'; - mapping.expression = [{'FPG'},{'Vol'},{'AUGD'}]; - case 'volume_rho' - mapping.timedim = 2; - mapping.label = 'Volume'; - mapping.method = 'switchcase'; - case {'wmhd' 'w_mhd'} - mapping.label = 'Wmhd'; - mapping.timedim = 1; - mapping.method = 'signal'; - mapping.expression = [{'FPG'},{'Wmhd'},{'AUGD'}]; - mapping.method = 'expression'; - mapping.expression = ['params_eff = gdat_data.gdat_params;params_eff.data_request=[{''FPG''},{''Wmhd''},{''AUGD''}];' ... - 'gdat_tmp=gdat_aug(shot,params_eff);ij=find(~isnan(gdat_tmp.data)); gdat_tmp.data_raw=gdat_tmp.data;' ... - 'tmp_data=interpos(gdat_tmp.t(ij),gdat_tmp.data(ij),gdat_tmp.t,-1e5);' ... - 'gdat_tmp.data = max(tmp_data,0.);']; - case {'zeff', 'z_eff'} - mapping.timedim = 1; - mapping.label = 'zeff'; - mapping.method = 'switchcase'; + case 'vloop' + mapping.label = 'Vloop'; + mapping.timedim = 1; + % mapping.method = 'signal'; + % mapping.expression = [{'MAG'},{'ULid12'},{'AUGD'}]; + mapping.method = 'expression'; + mapping.expression = ['params_eff = gdat_data.gdat_params;params_eff.data_request=[{''MAG''},{''ULid12''},{''AUGD''}];' ... + 'gdat_tmp=gdat_aug(shot,params_eff);ij=find(~isnan(gdat_tmp.data));' ... + 'tmp_data=interpos(gdat_tmp.t,gdat_tmp.data,-3e4);' ... + 'gdat_tmp.data_smooth = tmp_data;gdat_tmp.gdat_request=''vloop'';gdat_tmp.gdat_params.data_request=gdat_tmp.gdat_request;']; + case {'volume', 'volume_edge'} + mapping.label = 'Volume'; + mapping.timedim = 1; + mapping.method = 'signal'; + mapping.expression = [{'FPG'},{'Vol'},{'AUGD'}]; + case 'volume_rho' + mapping.timedim = 2; + mapping.label = 'Volume'; + mapping.method = 'switchcase'; + case {'wmhd' 'w_mhd'} + mapping.label = 'Wmhd'; + mapping.timedim = 1; + mapping.method = 'signal'; + mapping.expression = [{'FPG'},{'Wmhd'},{'AUGD'}]; + mapping.method = 'expression'; + mapping.expression = ['params_eff = gdat_data.gdat_params;params_eff.data_request=[{''FPG''},{''Wmhd''},{''AUGD''}];' ... + 'gdat_tmp=gdat_aug(shot,params_eff);ij=find(~isnan(gdat_tmp.data)); gdat_tmp.data_raw=gdat_tmp.data;' ... + 'tmp_data=interpos(gdat_tmp.t(ij),gdat_tmp.data(ij),gdat_tmp.t,-1e5);' ... + 'gdat_tmp.data = max(tmp_data,0.);']; + case {'zeff', 'z_eff'} + mapping.timedim = 1; + mapping.label = 'zeff'; + mapping.method = 'switchcase'; % $$$ ZES obsolete, use cxrs % $$$ mapping.label = 'zeff from cxrs'; % $$$ mapping.timedim = 1; % $$$ mapping.method = 'signal'; % $$$ mapping.expression = [{'ZES'},{'Zeff'},{'AUGD'}]; - case 'zgeom' - mapping.label = 'Zgeom'; - mapping.timedim = 1; - mapping.method = 'expression'; - mapping.expression = ['params_eff = gdat_data.gdat_params;params_eff.data_request=[{''FPG''},{''Zoben''},{''AUGD''}];' ... + case 'zgeom' + mapping.label = 'Zgeom'; + mapping.timedim = 1; + mapping.method = 'expression'; + mapping.expression = ['params_eff = gdat_data.gdat_params;params_eff.data_request=[{''FPG''},{''Zoben''},{''AUGD''}];' ... 'gdat_tmp=gdat_aug(shot,params_eff);gdat_tmp.z_top=gdat_tmp.data;' ... - 'params_eff.data_request=[{''FPG''},{''Zunt''},{''AUGD''}];' ... - 'gdat_tmp2=gdat_aug(shot,params_eff);gdat_tmp.z_bottom=gdat_tmp2.data;' ... - 'gdat_tmp.data = 0.5.*(gdat_tmp2.data+gdat_tmp.data);gdat_tmp.label=''' mapping.label ''';' ... - 'gdat_tmp.gdat_request=''' data_request ''';']; + 'params_eff.data_request=[{''FPG''},{''Zunt''},{''AUGD''}];' ... + 'gdat_tmp2=gdat_aug(shot,params_eff);gdat_tmp.z_bottom=gdat_tmp2.data;' ... + 'gdat_tmp.data = 0.5.*(gdat_tmp2.data+gdat_tmp.data);gdat_tmp.label=''' mapping.label ''';' ... + 'gdat_tmp.gdat_request=''' data_request ''';']; - case {'zmag', 'z_mag', 'z_axis'} - mapping.label = 'Z\_magaxis'; - mapping.timedim = 1; - mapping.method = 'signal'; - mapping.expression = [{'FPG'},{'Zmag'},{'AUGD'}]; - % - % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - % extra AUG cases (not necessarily in official data_request name list) - % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - % - case 'transp' - mapping.label = 'transp output'; - mapping.method = 'switchcase'; + case {'zmag', 'z_mag', 'z_axis'} + mapping.label = 'Z\_magaxis'; + mapping.timedim = 1; + mapping.method = 'signal'; + mapping.expression = [{'FPG'},{'Zmag'},{'AUGD'}]; + % + % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + % extra AUG cases (not necessarily in official data_request name list) + % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + % + case 'transp' + mapping.label = 'transp output'; + mapping.method = 'switchcase'; - otherwise - mapping.label = data_request; - mapping.method = 'signal'; % assume a full tracename is given, so just try with tdi (could check there are some ":", etc...) - mapping.expression = data_request; - mapping.not_found = true; + otherwise + mapping.label = data_request; + mapping.method = 'signal'; % assume a full tracename is given, so just try with tdi (could check there are some ":", etc...) + mapping.expression = data_request; + mapping.not_found = true; end diff --git a/matlab/AUG/loadAUGdata.m b/matlab/AUG/loadAUGdata.m index 94704f20f2fb47df8eb5a749409674c6e51f939d..78341cdc44d5f400ed63e6d213afcc00d9983325 100644 --- a/matlab/AUG/loadAUGdata.m +++ b/matlab/AUG/loadAUGdata.m @@ -3,8 +3,8 @@ function [trace,error,varargout]=loadAUGdata(shot,data_type,varargin) % data_type: % 'Ip' = current % 'zmag' = vertical position of the center of the plasma (magnetic axis) -% 'rmag' = radial position of the center of the plasma -% 'sxr' = soft x-ray emission +% 'rmag' = radial position of the center of the plasma +% 'sxr' = soft x-ray emission % 'sxR' = soft x-ray emission with varargout{1} option (requires varargin{5}!) % 'SXB' = soft x-ray emission from (by default camera J) SXB/J_xx camera (sxb, sxB, etc all work) % 'SXF' = soft x-ray emission from (by default camera J) SXF/I_xx camera (sxf, sxF, etc all work) @@ -14,8 +14,8 @@ function [trace,error,varargout]=loadAUGdata(shot,data_type,varargin) % gdat(15133,'MAG/Ipa',1,'AUG') % uses experiment=AUGD shotfiles per default % gdat(15133,'MAG/Ipa',1) (sufficient at AUG since 'AUG' per defaut, same with gdat(15133,'ip',1) % gdat(15133,'AUGD/MAG/Ipa',1,'AUG') % to specify experiment explicitely like in: -% gdat(30230,'ECED/RMD/Trad-A',1,'AUG') % -% gdat(30230,'ECED/CEC/Trad-A',1,'AUG') % +% gdat(30230,'ECED/RMD/Trad-A',1,'AUG') % +% gdat(30230,'ECED/CEC/Trad-A',1,'AUG') % % gdat(31053,'MSP/IGP_07Co',1); % N gas opening at -6s (03 as well) % % INPUT: @@ -36,12 +36,12 @@ function [trace,error,varargout]=loadAUGdata(shot,data_type,varargin) % varargin{3}: zmag for varargout{1} computation % varargin{4}: time range [t1 t2] (to limit data collected) % varargin{5}: nth to keep only nth time points of traces -% varargin{6}: camera to use: 'B' (default), 'A', +% varargin{6}: camera to use: 'B' (default), 'A', % % OUTPUT: % trace.data: data structure -% trace.t: time of reference -% trace.x: space of reference +% trace.t: time of reference +% trace.x: space of reference % .... others related to data % error: error in loading signal (0=> OK, 1=> error) % @@ -59,20 +59,20 @@ function [trace,error,varargout]=loadAUGdata(shot,data_type,varargin) % % List of keywords (can be used in adition to 'DIAG/tracenam'), with comments when not obvious: % -% Ip : -% b0 : -% zmag : -% rmag : -% rgeo : -% zgeo : -% q0 : -% q95 : -% kappa : -% delta : -% deltatop : -% deltabot : -% neint : -% neterho : +% Ip : +% b0 : +% zmag : +% rmag : +% rgeo : +% zgeo : +% q0 : +% q95 : +% kappa : +% delta : +% deltatop : +% deltabot : +% neint : +% neterho : % cxrs : CXRS structure from CEZ with vrot, Ti, ... % cxrs_rho : same as cxrs but project on rho as well (using 'equil' information) % equil : equilibrium structure, rhopol, rhotor, rhovol, etc from EQI @@ -85,12 +85,12 @@ function [trace,error,varargout]=loadAUGdata(shot,data_type,varargin) % sxb : 'SXB/J' chords % sxf : 'SXF/I' chords % transp_EXPNAME : data from TRA using experiment name = "EXPNAME" -% ece : -% ece_rho : -% eced : -% eced_rho : -% eced_rmd : -% Halpha : +% ece : +% ece_rho : +% eced : +% eced_rho : +% eced_rmd : +% Halpha : % pgyro : for each gyrotrons, power, freq, etc (ask for more) % powers : power traces for each sources % @@ -112,7 +112,7 @@ if size(data_type,1)==1 for ij=1:length(inotok) ijk=find(iok>inotok(ij)); if ~isempty(ijk) - iok(ijk) = iok(ijk) - 1; + iok(ijk) = iok(ijk) - 1; end end end @@ -285,11 +285,11 @@ end % all keywords and corresponding case to run below AUGkeywrdall=[{'Ip'} {'b0'} {'zmag'} {'rmag'} {'rgeo'} {'zgeo'} {'vol'} {'qrho'} {'qrho_fpp'} {'q0'} {'q95'} {'kappa'} ... - {'delta'} {'deltatop'} {'deltabot'} {'neint'} {'ne'} {'te'} ... - {'nerho'} {'neterho'} {'terho'} {'cxrs'} {'cxrs_rho'} {'equil'} {'equil_fpp'} {'equil_eqm'} ... - {'equil_eqr'} {'equil_eqh'} {'sxr'} {'sxR'} {'sxb'} {'sxf'} {'ssx_g'} {'ssx_h'} {'ssx_i'} {'ssx_j'} {'ssx'} ... - {'transp'} {'ece'} {'ece_rho'} {'eced'} {'eced_rho'} {'eced_rmd'} {'Halpha'} {'pgyro'} {'powers'} ... - {'betan'} {'betap'}]; % rm, not yet implemented: {'rcont'} {'zcont'} + {'delta'} {'deltatop'} {'deltabot'} {'neint'} {'ne'} {'te'} ... + {'nerho'} {'neterho'} {'terho'} {'cxrs'} {'cxrs_rho'} {'equil'} {'equil_fpp'} {'equil_eqm'} ... + {'equil_eqr'} {'equil_eqh'} {'sxr'} {'sxR'} {'sxb'} {'sxf'} {'ssx_g'} {'ssx_h'} {'ssx_i'} {'ssx_j'} {'ssx'} ... + {'transp'} {'ece'} {'ece_rho'} {'eced'} {'eced_rho'} {'eced_rmd'} {'Halpha'} {'pgyro'} {'powers'} ... + {'betan'} {'betap'}]; % rm, not yet implemented: {'rcont'} {'zcont'} AUGsig.iip=strmatch('Ip',AUGkeywrdall,'exact'); AUGsig.ib0=strmatch('b0',AUGkeywrdall,'exact'); AUGsig.izmag=strmatch('zmag',AUGkeywrdall,'exact'); @@ -459,8 +459,8 @@ if size(data_type_eff,1)==2 % $$$ disp('********************') % $$$ disp('trace not yet registered.') % $$$ disp('If standard data, ask andrea.scarabosio@epfl.ch or olivier.sauter@epfl.ch to create a keyqord entry for this data') -% eval(['!mail -s ''' data_type_eff{1} ' ' data_type_eff{2} ' ' num2str(shot) ' ' ... -% getenv('USER') ' AUG'' olivier.sauter@epfl.ch < /dev/null']) + % eval(['!mail -s ''' data_type_eff{1} ' ' data_type_eff{2} ' ' num2str(shot) ' ' ... + % getenv('USER') ' AUG'' olivier.sauter@epfl.ch < /dev/null']) disp('********************') % temporarily add entry in arrays, so can work below index=length(AUGkeywrdall)+1; @@ -485,7 +485,7 @@ if size(data_type_eff,1)==2 AUGsiglocation(1:2,end+1)=[data_type_eff(1) ; {data_type_eff_noext}]; AUGexplocation{end+1}=shotfile_exp; AUGsigtimeindx(end+1)=0; - AUGkeywrdcase{index} + AUGkeywrdcase{index} end else index=strmatch(data_type_eff_noext,AUGkeywrdall,'exact'); @@ -506,9 +506,9 @@ else end disp(' ') if iscell(data_type_eff) - disp(['loading' ' ' data_type_eff{1} '/' data_type_eff{2} ' from AUG shot #' num2str(shot)]); + disp(['loading' ' ' data_type_eff{1} '/' data_type_eff{2} ' from AUG shot #' num2str(shot)]); else - disp(['loading' ' ' data_type_eff ' from AUG shot #' num2str(shot)]); + disp(['loading' ' ' data_type_eff ' from AUG shot #' num2str(shot)]); end disp(['case ' AUGkeywrdcase{index}]) disp(' ') @@ -520,7 +520,7 @@ switch AUGkeywrdcase{index} ppftype=AUGsiglocation{1,index}; shotfile_exp_eff = AUGexplocation{index}; - if i_efitm; + if i_efitm; tracename=['eftm' AUGsiglocation{2,index}(5:end) name_ext]; else tracename=[AUGsiglocation{2,index} name_ext]; @@ -528,10 +528,10 @@ switch AUGkeywrdcase{index} ij=find(tracename~=''''); tracename=tracename(ij) [a,e]=rdaAUG_eff(shot,ppftype,tracename,shotfile_exp_eff); -% switch tracename -% special cases if traces do not exist for some shot or other -% end - + % switch tracename + % special cases if traces do not exist for some shot or other + % end + trace=a; clear error error=e; @@ -549,23 +549,23 @@ switch AUGkeywrdcase{index} ilentime=length(trace.t); ij=find(size(trace.value)==ilentime); if ij==1; - % as expected - trace.x = [1:size(trace.value,2)]; - trace.dim=[{trace.t} ; {trace.x} ; {[1:size(trace.value,3)]}]; - trace.dimunits=[{'time [s]'} ; {''} ; {''}]; + % as expected + trace.x = [1:size(trace.value,2)]; + trace.dim=[{trace.t} ; {trace.x} ; {[1:size(trace.value,3)]}]; + trace.dimunits=[{'time [s]'} ; {''} ; {''}]; else - trace.dim=[{[]} ; {[]} ; {[]}]; - trace.dim{ij} = trace.t; - trace.dimunits=[{[]} ; {[]} ; {[]}]; - trace.dimunits{ij}='time [s]'; + trace.dim=[{[]} ; {[]} ; {[]}]; + trace.dim{ij} = trace.t; + trace.dimunits=[{[]} ; {[]} ; {[]}]; + trace.dimunits{ij}='time [s]'; end end trace.name=[num2str(shot) '/' ppftype '/' tracename]; - - %&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& + + %&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& case {'sxr','sxR'} - % LOAD MULTI CHANNEL DATA - % load AUG soft x-ray data + % LOAD MULTI CHANNEL DATA + % load AUG soft x-ray data shotfile_exp_eff = AUGexplocation{index}; @@ -610,7 +610,7 @@ switch AUGkeywrdcase{index} trace.t=trace.t(1:nth:end); trace.data=trace.data(:,1:nth:end); trace.dim{2}=trace.t; - % calculating intersection of the view lines with magnetics axis + % calculating intersection of the view lines with magnetics axis if strcmp(data_type_eff_noext,'sxR') if nargin>=5 & ~isempty(varargin{3}) zmag=varargin{3}; @@ -632,10 +632,10 @@ switch AUGkeywrdcase{index} trace.R=radius; end - %&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& + %&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& case {'sxb', 'sxf', 'ssx', 'ssx_g', 'ssx_h', 'ssx_i', 'ssx_j'} % LOAD MULTI CHANNEL DATA SXB/J_0xx (or other than J camera if specified in varargin{8}) - % load AUG soft x-ray data + % load AUG soft x-ray data shotfile_exp_eff = AUGexplocation{index}; @@ -670,15 +670,15 @@ switch AUGkeywrdcase{index} tracename=varargin{6}; else if strcmp(AUGkeywrdcase{index},'sxb') - tracename='J'; + tracename='J'; elseif strcmp(AUGkeywrdcase{index},'sxf') - tracename='I'; + tracename='I'; elseif strcmp(AUGkeywrdcase{index},'ssx') - tracename='G'; + tracename='G'; elseif strcmp(AUGkeywrdcase{index}(1:4),'ssx_') - tracename=upper(AUGkeywrdcase{index}(5)); + tracename=upper(AUGkeywrdcase{index}(5)); else - disp('should not be here, ask O. Sauter'); + disp('should not be here, ask O. Sauter'); end end trace.t=[]; @@ -688,25 +688,25 @@ switch AUGkeywrdcase{index} for ichord=starti:endi tracename_eff = [tracename '_' num2str(ichord,'%.3d')]; try - [a,e]=rdaAUG_eff(shot,ppftype,tracename_eff,shotfile_exp_eff,timerange); + [a,e]=rdaAUG_eff(shot,ppftype,tracename_eff,shotfile_exp_eff,timerange); catch - a = []; + a = []; end if isempty(a) || e~=0 - if ~exist('trace_all') - trace_all = struct([]); - else - end + if ~exist('trace_all') + trace_all = struct([]); + else + end else - if iok==0 - trace_all = a; - trace_all = rmfield(trace_all,[{'value'},{'data'}]); - iok = iok+1; - else - iok = iok+1; - end - trace_all.value(ichord,:) = a.value; - trace_all.data(ichord,:) = a.data; + if iok==0 + trace_all = a; + trace_all = rmfield(trace_all,[{'value'},{'data'}]); + iok = iok+1; + else + iok = iok+1; + end + trace_all.value(ichord,:) = a.value; + trace_all.data(ichord,:) = a.data; end end if ~isempty(trace_all) @@ -731,10 +731,10 @@ switch AUGkeywrdcase{index} trace.units = []; trace.name=[num2str(shot) '/' ppftype '/' tracename]; end - - %&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& + + %&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& case {'ece','eced','ece_rho','eced_rho'} - % LOAD MULTI CHANNEL DATA + % LOAD MULTI CHANNEL DATA % load AUG ece data shotfile_exp_eff = AUGexplocation{index}; @@ -793,8 +793,8 @@ switch AUGkeywrdcase{index} if domatchRtime % interpolate R structure on ece data time array, to ease plot vs R for i=starti:endi - radius.data(i,:) = interp1(aR.t,aR.data(i,:),trace.t); - zheight.data(i,:) = interp1(aZ.t,aZ.data(i,:),trace.t); + radius.data(i,:) = interp1(aR.t,aR.data(i,:),trace.t); + zheight.data(i,:) = interp1(aZ.t,aZ.data(i,:),trace.t); end radius.t=trace.t; zheight.t=trace.t; @@ -822,24 +822,24 @@ switch AUGkeywrdcase{index} time_equil=[1.5*equil.t(1)-0.5*equil.t(2) 0.5.*(equil.t(1:end-1)+equil.t(2:end)) 1.5*equil.t(end)-0.5*equil.t(end-1)]; iok=find(aR.data(:,1)>0); for itequil=1:length(time_equil)-1 - rr=equil.Rmesh(:,itequil); - zz=equil.Zmesh(:,itequil); - psirz_in = equil.psi2D(:,:,itequil); - it_ece_inequil = find(trace.R.t>=time_equil(itequil) & trace.R.t<=time_equil(itequil+1)); - if ~isempty(it_ece_inequil) - rout=trace.R.data(iok,it_ece_inequil); - ijok=find(~isnan(rout)); - if ~isempty(ijok) - zout=trace.Z.data(iok,it_ece_inequil); - psi_at_routzout = interpos2Dcartesian(rr,zz,psirz_in,rout,zout); - psi_out(iok,it_ece_inequil) = reshape(psi_at_routzout,length(iok),length(it_ece_inequil)); - rhopsinorm_out(iok,it_ece_inequil) = sqrt(abs((psi_out(iok,it_ece_inequil)-equil.psi_axis(itequil))./(equil.psi_lcfs(itequil)-equil.psi_axis(itequil)))); - for it_cx=1:length(it_ece_inequil) - rhotornorm_out(iok,it_ece_inequil(it_cx)) = interpos(equil.rhopolnorm(:,itequil),equil.rhotornorm(:,itequil),rhopsinorm_out(iok,it_ece_inequil(it_cx)),-3,[2 2],[0 1]); - rhovolnorm_out(iok,it_ece_inequil(it_cx)) = interpos(equil.rhopolnorm(:,itequil),equil.rhovolnorm(:,itequil),rhopsinorm_out(iok,it_ece_inequil(it_cx)),-3,[2 2],[0 1]); - end - end - end + rr=equil.Rmesh(:,itequil); + zz=equil.Zmesh(:,itequil); + psirz_in = equil.psi2D(:,:,itequil); + it_ece_inequil = find(trace.R.t>=time_equil(itequil) & trace.R.t<=time_equil(itequil+1)); + if ~isempty(it_ece_inequil) + rout=trace.R.data(iok,it_ece_inequil); + ijok=find(~isnan(rout)); + if ~isempty(ijok) + zout=trace.Z.data(iok,it_ece_inequil); + psi_at_routzout = interpos2Dcartesian(rr,zz,psirz_in,rout,zout); + psi_out(iok,it_ece_inequil) = reshape(psi_at_routzout,length(iok),length(it_ece_inequil)); + rhopsinorm_out(iok,it_ece_inequil) = sqrt(abs((psi_out(iok,it_ece_inequil)-equil.psi_axis(itequil))./(equil.psi_lcfs(itequil)-equil.psi_axis(itequil)))); + for it_cx=1:length(it_ece_inequil) + rhotornorm_out(iok,it_ece_inequil(it_cx)) = interpos(equil.rhopolnorm(:,itequil),equil.rhotornorm(:,itequil),rhopsinorm_out(iok,it_ece_inequil(it_cx)),-3,[2 2],[0 1]); + rhovolnorm_out(iok,it_ece_inequil(it_cx)) = interpos(equil.rhopolnorm(:,itequil),equil.rhovolnorm(:,itequil),rhopsinorm_out(iok,it_ece_inequil(it_cx)),-3,[2 2],[0 1]); + end + end + end end trace.rhos.psi_on_rztime = psi_out; trace.rhos.rhopsinorm_on_rztime = rhopsinorm_out; @@ -848,10 +848,10 @@ switch AUGkeywrdcase{index} trace.rhos.t = trace.R.t; end - %&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& + %&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& case {'cxrs', 'cxrs_rho'} % LOAD CEZ data - % + % shotfile_exp_eff = AUGexplocation{index}; @@ -889,39 +889,39 @@ switch AUGkeywrdcase{index} cxrs.ti_c.error = aerr.value; % if strcmp(AUGkeywrdcase{index},'cxrs_rho') - equil=gdat(shot,'equil',0); - inb_chord_cxrs=size(cxrs.r_time,1); - inb_time_cxrs=size(cxrs.r_time,2); - psi_out = NaN*ones(inb_chord_cxrs,inb_time_cxrs); - rhopsinorm_out = NaN*ones(inb_chord_cxrs,inb_time_cxrs); - rhotornorm_out = NaN*ones(inb_chord_cxrs,inb_time_cxrs); - rhovolnorm_out = NaN*ones(inb_chord_cxrs,inb_time_cxrs); - % constructs intervals within which a given equil is used: [time_equil(i),time_equil(i+1)] - time_equil=[1.5*equil.t(1)-0.5*equil.t(2) 0.5.*(equil.t(1:end-1)+equil.t(2:end)) 1.5*equil.t(end)-0.5*equil.t(end-1)]; - iok=find(cxrs.r_time(:,1)>0); - for itequil=1:length(time_equil)-1 - rr=equil.Rmesh(:,itequil); - zz=equil.Zmesh(:,itequil); - psirz_in = equil.psi2D(:,:,itequil); - it_cxrs_inequil = find(cxrs.t>=time_equil(itequil) & cxrs.t<=time_equil(itequil+1)); - if ~isempty(it_cxrs_inequil) - rout=cxrs.r_time(iok,it_cxrs_inequil); - zout=cxrs.z_time(iok,it_cxrs_inequil); - psi_at_routzout = interpos2Dcartesian(rr,zz,psirz_in,rout,zout); - psi_out(iok,it_cxrs_inequil) = reshape(psi_at_routzout,length(iok),length(it_cxrs_inequil)); - rhopsinorm_out(iok,it_cxrs_inequil) = sqrt((psi_out(iok,it_cxrs_inequil)-equil.psi_axis(itequil))./(equil.psi_lcfs(itequil)-equil.psi_axis(itequil))); - for it_cx=1:length(it_cxrs_inequil) - rhotornorm_out(iok,it_cxrs_inequil(it_cx)) = interpos(equil.rhopolnorm(:,itequil),equil.rhotornorm(:,itequil),rhopsinorm_out(iok,it_cxrs_inequil(it_cx)),-3,[2 2],[0 1]); - rhovolnorm_out(iok,it_cxrs_inequil(it_cx)) = interpos(equil.rhopolnorm(:,itequil),equil.rhovolnorm(:,itequil),rhopsinorm_out(iok,it_cxrs_inequil(it_cx)),-3,[2 2],[0 1]); - end - end - end - cxrs.psi_on_rztime = psi_out; - cxrs.rhopsinorm_on_rztime = rhopsinorm_out; - cxrs.rhotornorm_on_rztime = rhotornorm_out; - cxrs.rhovolnorm_on_rztime = rhovolnorm_out; + equil=gdat(shot,'equil',0); + inb_chord_cxrs=size(cxrs.r_time,1); + inb_time_cxrs=size(cxrs.r_time,2); + psi_out = NaN*ones(inb_chord_cxrs,inb_time_cxrs); + rhopsinorm_out = NaN*ones(inb_chord_cxrs,inb_time_cxrs); + rhotornorm_out = NaN*ones(inb_chord_cxrs,inb_time_cxrs); + rhovolnorm_out = NaN*ones(inb_chord_cxrs,inb_time_cxrs); + % constructs intervals within which a given equil is used: [time_equil(i),time_equil(i+1)] + time_equil=[1.5*equil.t(1)-0.5*equil.t(2) 0.5.*(equil.t(1:end-1)+equil.t(2:end)) 1.5*equil.t(end)-0.5*equil.t(end-1)]; + iok=find(cxrs.r_time(:,1)>0); + for itequil=1:length(time_equil)-1 + rr=equil.Rmesh(:,itequil); + zz=equil.Zmesh(:,itequil); + psirz_in = equil.psi2D(:,:,itequil); + it_cxrs_inequil = find(cxrs.t>=time_equil(itequil) & cxrs.t<=time_equil(itequil+1)); + if ~isempty(it_cxrs_inequil) + rout=cxrs.r_time(iok,it_cxrs_inequil); + zout=cxrs.z_time(iok,it_cxrs_inequil); + psi_at_routzout = interpos2Dcartesian(rr,zz,psirz_in,rout,zout); + psi_out(iok,it_cxrs_inequil) = reshape(psi_at_routzout,length(iok),length(it_cxrs_inequil)); + rhopsinorm_out(iok,it_cxrs_inequil) = sqrt((psi_out(iok,it_cxrs_inequil)-equil.psi_axis(itequil))./(equil.psi_lcfs(itequil)-equil.psi_axis(itequil))); + for it_cx=1:length(it_cxrs_inequil) + rhotornorm_out(iok,it_cxrs_inequil(it_cx)) = interpos(equil.rhopolnorm(:,itequil),equil.rhotornorm(:,itequil),rhopsinorm_out(iok,it_cxrs_inequil(it_cx)),-3,[2 2],[0 1]); + rhovolnorm_out(iok,it_cxrs_inequil(it_cx)) = interpos(equil.rhopolnorm(:,itequil),equil.rhovolnorm(:,itequil),rhopsinorm_out(iok,it_cxrs_inequil(it_cx)),-3,[2 2],[0 1]); + end + end + end + cxrs.psi_on_rztime = psi_out; + cxrs.rhopsinorm_on_rztime = rhopsinorm_out; + cxrs.rhotornorm_on_rztime = rhotornorm_out; + cxrs.rhovolnorm_on_rztime = rhovolnorm_out; end - + trace = cxrs; else trace.data = []; @@ -932,9 +932,9 @@ switch AUGkeywrdcase{index} trace.units = []; trace.name=[num2str(shot) '/' ppftype '/' 'vrot, Ti_c,...']; end - - %&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& - case {'neterho'} % 'nerho', 'terho', + + %&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& + case {'neterho'} % 'nerho', 'terho', % LOAD VTA data % Vertical Thomson core and edge @@ -943,7 +943,7 @@ switch AUGkeywrdcase{index} trace.t=[]; trace.x=[]; ppftype='VTA'; - % if strcmp(AUGkeywrdcase{index},'terho') + % if strcmp(AUGkeywrdcase{index},'terho') [a,e]=rdaAUG_eff(shot,ppftype,'Te_c',shotfile_exp_eff); if isempty(a) || e~=0 thomson = struct([]); @@ -997,67 +997,67 @@ switch AUGkeywrdcase{index} thomson.z_edge_time = z_time.value' * ones(1,size(thomson.te_edge.value,2)); % if strcmp(AUGkeywrdcase{index},'neterho') - equil=gdat(shot,'equil',0); - % core - inb_chord_thomson_core=size(thomson.r_core_time,1); - inb_time_thomson_core=size(thomson.r_core_time,2); - psi_out_core = NaN*ones(inb_chord_thomson_core,inb_time_thomson_core); - rhopsinorm_out_core = NaN*ones(inb_chord_thomson_core,inb_time_thomson_core); - rhotornorm_out_core = NaN*ones(inb_chord_thomson_core,inb_time_thomson_core); - rhovolnorm_out_core = NaN*ones(inb_chord_thomson_core,inb_time_thomson_core); - % edge - inb_chord_thomson_edge=size(thomson.r_edge_time,1); - inb_time_thomson_edge=size(thomson.r_edge_time,2); - psi_out_edge = NaN*ones(inb_chord_thomson_edge,inb_time_thomson_edge); - rhopsinorm_out_edge = NaN*ones(inb_chord_thomson_edge,inb_time_thomson_edge); - rhotornorm_out_edge = NaN*ones(inb_chord_thomson_edge,inb_time_thomson_edge); - rhovolnorm_out_edge = NaN*ones(inb_chord_thomson_edge,inb_time_thomson_edge); - % constructs intervals within which a given equil is used: [time_equil(i),time_equil(i+1)] - time_equil=[1.5*equil.t(1)-0.5*equil.t(2) 0.5.*(equil.t(1:end-1)+equil.t(2:end)) 1.5*equil.t(end)-0.5*equil.t(end-1)]; - for itequil=1:length(time_equil)-1 - rr=equil.Rmesh(:,itequil); - zz=equil.Zmesh(:,itequil); - psirz_in = equil.psi2D(:,:,itequil); - it_thomson_core_inequil = find(thomson.time_core>=time_equil(itequil) & thomson.time_core<=time_equil(itequil+1)); - if ~isempty(it_thomson_core_inequil) - rout_core=thomson.r_core_time(:,it_thomson_core_inequil); - zout_core=thomson.z_core_time(:,it_thomson_core_inequil); - psi_at_routzout = interpos2Dcartesian(rr,zz,psirz_in,rout_core,zout_core); - psi_out_core(:,it_thomson_core_inequil) = reshape(psi_at_routzout,inb_chord_thomson_core,length(it_thomson_core_inequil)); - rhopsinorm_out_core(:,it_thomson_core_inequil) = sqrt((psi_out_core(:,it_thomson_core_inequil)-equil.psi_axis(itequil))./(equil.psi_lcfs(itequil)-equil.psi_axis(itequil))); - for it_cx=1:length(it_thomson_core_inequil) - rhotornorm_out_core(:,it_thomson_core_inequil(it_cx)) = ... - interpos(equil.rhopolnorm(:,itequil),equil.rhotornorm(:,itequil),rhopsinorm_out_core(:,it_thomson_core_inequil(it_cx)),-3,[2 2],[0 1]); - rhovolnorm_out_core(:,it_thomson_core_inequil(it_cx)) = ... - interpos(equil.rhopolnorm(:,itequil),equil.rhovolnorm(:,itequil),rhopsinorm_out_core(:,it_thomson_core_inequil(it_cx)),-3,[2 2],[0 1]); - end - end - % edge - it_thomson_edge_inequil = find(thomson.time_edge>=time_equil(itequil) & thomson.time_edge<=time_equil(itequil+1)); - if ~isempty(it_thomson_edge_inequil) - rout_edge=thomson.r_edge_time(:,it_thomson_edge_inequil); - zout_edge=thomson.z_edge_time(:,it_thomson_edge_inequil); - psi_at_routzout = interpos2Dcartesian(rr,zz,psirz_in,rout_edge,zout_edge); - psi_out_edge(:,it_thomson_edge_inequil) = reshape(psi_at_routzout,inb_chord_thomson_edge,length(it_thomson_edge_inequil)); - rhopsinorm_out_edge(:,it_thomson_edge_inequil) = sqrt((psi_out_edge(:,it_thomson_edge_inequil)-equil.psi_axis(itequil))./(equil.psi_lcfs(itequil)-equil.psi_axis(itequil))); - for it_cx=1:length(it_thomson_edge_inequil) - rhotornorm_out_edge(:,it_thomson_edge_inequil(it_cx)) = ... - interpos(equil.rhopolnorm(:,itequil),equil.rhotornorm(:,itequil),rhopsinorm_out_edge(:,it_thomson_edge_inequil(it_cx)),-3,[2 2],[0 1]); - rhovolnorm_out_edge(:,it_thomson_edge_inequil(it_cx)) = ... - interpos(equil.rhopolnorm(:,itequil),equil.rhovolnorm(:,itequil),rhopsinorm_out_edge(:,it_thomson_edge_inequil(it_cx)),-3,[2 2],[0 1]); - end - end - end - thomson.core_psi_on_rztime = psi_out_core; - thomson.core_rhopsinorm_on_rztime = rhopsinorm_out_core; - thomson.core_rhotornorm_on_rztime = rhotornorm_out_core; - thomson.core_rhovolnorm_on_rztime = rhovolnorm_out_core; - thomson.edge_psi_on_rztime = psi_out_edge; - thomson.edge_rhopsinorm_on_rztime = rhopsinorm_out_edge; - thomson.edge_rhotornorm_on_rztime = rhotornorm_out_edge; - thomson.edge_rhovolnorm_on_rztime = rhovolnorm_out_edge; + equil=gdat(shot,'equil',0); + % core + inb_chord_thomson_core=size(thomson.r_core_time,1); + inb_time_thomson_core=size(thomson.r_core_time,2); + psi_out_core = NaN*ones(inb_chord_thomson_core,inb_time_thomson_core); + rhopsinorm_out_core = NaN*ones(inb_chord_thomson_core,inb_time_thomson_core); + rhotornorm_out_core = NaN*ones(inb_chord_thomson_core,inb_time_thomson_core); + rhovolnorm_out_core = NaN*ones(inb_chord_thomson_core,inb_time_thomson_core); + % edge + inb_chord_thomson_edge=size(thomson.r_edge_time,1); + inb_time_thomson_edge=size(thomson.r_edge_time,2); + psi_out_edge = NaN*ones(inb_chord_thomson_edge,inb_time_thomson_edge); + rhopsinorm_out_edge = NaN*ones(inb_chord_thomson_edge,inb_time_thomson_edge); + rhotornorm_out_edge = NaN*ones(inb_chord_thomson_edge,inb_time_thomson_edge); + rhovolnorm_out_edge = NaN*ones(inb_chord_thomson_edge,inb_time_thomson_edge); + % constructs intervals within which a given equil is used: [time_equil(i),time_equil(i+1)] + time_equil=[1.5*equil.t(1)-0.5*equil.t(2) 0.5.*(equil.t(1:end-1)+equil.t(2:end)) 1.5*equil.t(end)-0.5*equil.t(end-1)]; + for itequil=1:length(time_equil)-1 + rr=equil.Rmesh(:,itequil); + zz=equil.Zmesh(:,itequil); + psirz_in = equil.psi2D(:,:,itequil); + it_thomson_core_inequil = find(thomson.time_core>=time_equil(itequil) & thomson.time_core<=time_equil(itequil+1)); + if ~isempty(it_thomson_core_inequil) + rout_core=thomson.r_core_time(:,it_thomson_core_inequil); + zout_core=thomson.z_core_time(:,it_thomson_core_inequil); + psi_at_routzout = interpos2Dcartesian(rr,zz,psirz_in,rout_core,zout_core); + psi_out_core(:,it_thomson_core_inequil) = reshape(psi_at_routzout,inb_chord_thomson_core,length(it_thomson_core_inequil)); + rhopsinorm_out_core(:,it_thomson_core_inequil) = sqrt((psi_out_core(:,it_thomson_core_inequil)-equil.psi_axis(itequil))./(equil.psi_lcfs(itequil)-equil.psi_axis(itequil))); + for it_cx=1:length(it_thomson_core_inequil) + rhotornorm_out_core(:,it_thomson_core_inequil(it_cx)) = ... + interpos(equil.rhopolnorm(:,itequil),equil.rhotornorm(:,itequil),rhopsinorm_out_core(:,it_thomson_core_inequil(it_cx)),-3,[2 2],[0 1]); + rhovolnorm_out_core(:,it_thomson_core_inequil(it_cx)) = ... + interpos(equil.rhopolnorm(:,itequil),equil.rhovolnorm(:,itequil),rhopsinorm_out_core(:,it_thomson_core_inequil(it_cx)),-3,[2 2],[0 1]); + end + end + % edge + it_thomson_edge_inequil = find(thomson.time_edge>=time_equil(itequil) & thomson.time_edge<=time_equil(itequil+1)); + if ~isempty(it_thomson_edge_inequil) + rout_edge=thomson.r_edge_time(:,it_thomson_edge_inequil); + zout_edge=thomson.z_edge_time(:,it_thomson_edge_inequil); + psi_at_routzout = interpos2Dcartesian(rr,zz,psirz_in,rout_edge,zout_edge); + psi_out_edge(:,it_thomson_edge_inequil) = reshape(psi_at_routzout,inb_chord_thomson_edge,length(it_thomson_edge_inequil)); + rhopsinorm_out_edge(:,it_thomson_edge_inequil) = sqrt((psi_out_edge(:,it_thomson_edge_inequil)-equil.psi_axis(itequil))./(equil.psi_lcfs(itequil)-equil.psi_axis(itequil))); + for it_cx=1:length(it_thomson_edge_inequil) + rhotornorm_out_edge(:,it_thomson_edge_inequil(it_cx)) = ... + interpos(equil.rhopolnorm(:,itequil),equil.rhotornorm(:,itequil),rhopsinorm_out_edge(:,it_thomson_edge_inequil(it_cx)),-3,[2 2],[0 1]); + rhovolnorm_out_edge(:,it_thomson_edge_inequil(it_cx)) = ... + interpos(equil.rhopolnorm(:,itequil),equil.rhovolnorm(:,itequil),rhopsinorm_out_edge(:,it_thomson_edge_inequil(it_cx)),-3,[2 2],[0 1]); + end + end + end + thomson.core_psi_on_rztime = psi_out_core; + thomson.core_rhopsinorm_on_rztime = rhopsinorm_out_core; + thomson.core_rhotornorm_on_rztime = rhotornorm_out_core; + thomson.core_rhovolnorm_on_rztime = rhovolnorm_out_core; + thomson.edge_psi_on_rztime = psi_out_edge; + thomson.edge_rhopsinorm_on_rztime = rhopsinorm_out_edge; + thomson.edge_rhotornorm_on_rztime = rhotornorm_out_edge; + thomson.edge_rhovolnorm_on_rztime = rhovolnorm_out_edge; end - + trace = thomson; else trace.data = []; @@ -1068,12 +1068,12 @@ switch AUGkeywrdcase{index} trace.units = []; trace.name=[num2str(shot) '/' ppftype '/' tracename]; end - - %&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& + + %&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& case {'te', 'ne'} shotfile_exp_eff = AUGexplocation{index} - + if strcmp(AUGkeywrdcase{index},'te') [a,e]=rdaAUG_eff(shot,'YPR','Te',shotfile_exp_eff); else @@ -1091,9 +1091,9 @@ switch AUGkeywrdcase{index} % In shotfiles time is 1st index in 2D arrays while gdat convention is to have time as last dimension % so change equil.xxx to (rho,time) on the way... - + shotfile_exp_eff = AUGexplocation{index}; - + if strcmp(AUGkeywrdcase{index},'equil_fpp') || strcmp(AUGkeywrdcase{index},'qrho_fpp') DIAG = 'FPP'; elseif strcmp(AUGkeywrdcase{index},'equil_eqm') @@ -1193,9 +1193,9 @@ switch AUGkeywrdcase{index} ijok=find(qpsi.value(:,1)); % note: eqr fills in only odd points radially % set NaNs to zeroes if qpsi.value(ijok(1),1)<0 - equil.qvalue(:,it) = max(qpsi.value(it,Lpf1:-1:1)',-max_qValue); + equil.qvalue(:,it) = max(qpsi.value(it,Lpf1:-1:1)',-max_qValue); else - equil.qvalue(:,it) = min(qpsi.value(it,Lpf1:-1:1)',max_qValue); + equil.qvalue(:,it) = min(qpsi.value(it,Lpf1:-1:1)',max_qValue); end % get x values equil.psi(:,it)=psi_tree.value(it,Lpf1:-1:1)'; @@ -1203,74 +1203,74 @@ switch AUGkeywrdcase{index} equil.psi_lcfs(it)= equil.psi(end,it); equil.rhopolnorm(:,it) = sqrt(abs((equil.psi(:,it)-equil.psi_axis(it)) ./(equil.psi_lcfs(it)-equil.psi_axis(it)))); if strcmp(DIAG,'EQR'); - % q value has only a few values and from center to edge, assume they are from central rhopol values on - % But they are every other point starting from 3rd - ijk=find(equil.qvalue(:,it)~=0); - if length(ijk)>2 - % now shots have non-zero axis values in eqr - rhoeff=equil.rhopolnorm(ijk,it); - qeff=equil.qvalue(ijk,it); % radial order was already inverted above - if ijk(1)>1 - rhoeff = [0.; rhoeff]; - qeff = [qeff(1) ;qeff]; - end - ij_nonan=find(~isnan(equil.rhopolnorm(:,it))); - qfit = zeros(size(equil.rhopolnorm(:,it))); - qfit(ij_nonan)=interpos(rhoeff,qeff,equil.rhopolnorm(ij_nonan,it),-0.01,[1 0],[0 0],[300; ones(size(qeff(1:end-1)))]); - else - qfit = zeros(size(equil.rhopolnorm(:,it))); - end - equil.qvalue(:,it) = qfit; - end + % q value has only a few values and from center to edge, assume they are from central rhopol values on + % But they are every other point starting from 3rd + ijk=find(equil.qvalue(:,it)~=0); + if length(ijk)>2 + % now shots have non-zero axis values in eqr + rhoeff=equil.rhopolnorm(ijk,it); + qeff=equil.qvalue(ijk,it); % radial order was already inverted above + if ijk(1)>1 + rhoeff = [0.; rhoeff]; + qeff = [qeff(1) ;qeff]; + end + ij_nonan=find(~isnan(equil.rhopolnorm(:,it))); + qfit = zeros(size(equil.rhopolnorm(:,it))); + qfit(ij_nonan)=interpos(rhoeff,qeff,equil.rhopolnorm(ij_nonan,it),-0.01,[1 0],[0 0],[300; ones(size(qeff(1:end-1)))]); + else + qfit = zeros(size(equil.rhopolnorm(:,it))); + end + equil.qvalue(:,it) = qfit; + end % get rhotor values equil.phi(:,it) = phi_tree.value(it,Lpf1:-1:1)'; equil.rhotornorm(:,it) = sqrt(abs(equil.phi(:,it) ./ equil.phi(end,it))); % get rhovol values - equil.vol(:,it)=Vol.value(it,2*Lpf1-1:-2:1)'; + equil.vol(:,it)=Vol.value(it,2*Lpf1-1:-2:1)'; equil.dvoldpsi(:,it)=Vol.value(it,2*Lpf1:-2:2)'; % 2nd index are dV/dpsi equil.rhovolnorm(:,it) = sqrt(abs(equil.vol(:,it) ./ equil.vol(end,it))); - equil.area(:,it)=Area.value(it,2*Lpf1-1:-2:1)'; + equil.area(:,it)=Area.value(it,2*Lpf1-1:-2:1)'; equil.dareadpsi(:,it)=Area.value(it,2*Lpf1:-2:2)'; % 2nd index are dV/dpsi equil.Rmesh(:,it) = Ri.value(it,1:M_Rmesh); equil.Zmesh(:,it) = Zj.value(it,1:N_Zmesh); equil.psi2D(1:M_Rmesh,1:N_Zmesh,it) = PFM_tree.value(1:M_Rmesh,1:N_Zmesh,it); - equil.pressure(:,it)=Pres.value(it,2*Lpf1-1:-2:1)'; + equil.pressure(:,it)=Pres.value(it,2*Lpf1-1:-2:1)'; equil.dpressuredpsi(:,it)=Pres.value(it,2*Lpf1:-2:2)'; % 2nd index are dV/dpsi if ~isempty(Jpol.value) - equil.jpol(:,it)=Jpol.value(it,2*Lpf1-1:-2:1)'; - equil.djpolpsi(:,it)=Jpol.value(it,2*Lpf1:-2:2)'; % 2nd index are dV/dpsi + equil.jpol(:,it)=Jpol.value(it,2*Lpf1-1:-2:1)'; + equil.djpolpsi(:,it)=Jpol.value(it,2*Lpf1:-2:2)'; % 2nd index are dV/dpsi else - equil.jpol = []; - equil.djpolpsi = []; + equil.jpol = []; + equil.djpolpsi = []; end equil.ffprime(:,it) = FFP.value(it,Lpf1:-1:1)'; equil.Xpoints.psi(1:LPFx.value(it)+1,it) = PFxx.value(it,1:LPFx.value(it)+1); equil.Xpoints.Rvalue(1:LPFx.value(it)+1,it) = RPFx.value(it,1:LPFx.value(it)+1); equil.Xpoints.Zvalue(1:LPFx.value(it)+1,it) = zPFx.value(it,1:LPFx.value(it)+1); if ~isempty(Rinv.value) - equil.rinv(:,it) = Rinv.value(it,Lpf1:-1:1)'; + equil.rinv(:,it) = Rinv.value(it,Lpf1:-1:1)'; else - equil.rinv = []; + equil.rinv = []; end if ~isempty(R2inv.value) - equil.r2inv(:,it) = R2inv.value(it,Lpf1:-1:1)'; + equil.r2inv(:,it) = R2inv.value(it,Lpf1:-1:1)'; else - equil.r2inv = []; + equil.r2inv = []; end if ~isempty(Bave.value) - equil.bave(:,it) = Bave.value(it,Lpf1:-1:1)'; + equil.bave(:,it) = Bave.value(it,Lpf1:-1:1)'; else - equil.bave = []; + equil.bave = []; end if ~isempty(B2ave.value) - equil.b2ave(:,it) = B2ave.value(it,Lpf1:-1:1)'; + equil.b2ave(:,it) = B2ave.value(it,Lpf1:-1:1)'; else - equil.b2ave = []; + equil.b2ave = []; end if ~isempty(FTRA.value) - equil.ftra(:,it) = FTRA.value(it,Lpf1:-1:1)'; + equil.ftra(:,it) = FTRA.value(it,Lpf1:-1:1)'; else - equil.ftra = []; + equil.ftra = []; end % end @@ -1297,10 +1297,10 @@ switch AUGkeywrdcase{index} trace.dimunits{1} = ''; trace.dimunits{2} = 's'; - %&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& + %&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& case {'pgyro'} % LOAD MULTI CHANNEL DATA ECS - % powers, frequencies, etc + % powers, frequencies, etc shotfile_exp_eff = AUGexplocation{index}; @@ -1324,94 +1324,94 @@ switch AUGkeywrdcase{index} [a,e]=rdaAUG_eff(shot,ppftype,tracename_eff,shotfile_exp_eff); if isempty(a) || e~=0 else - trace_all.ecrh1(i) = a; - trace_all.pgyro(:,i) = reshape(a.data,nb_timepoints,1); + trace_all.ecrh1(i) = a; + trace_all.pgyro(:,i) = reshape(a.data,nb_timepoints,1); end try - a = sf2par('ECS',shot,'gyr_freq',['P_sy1_g' num2str(i)]); + a = sf2par('ECS',shot,'gyr_freq',['P_sy1_g' num2str(i)]); catch - % gyr_freq not present (old shots for example) - a=[]; + % gyr_freq not present (old shots for example) + a=[]; end if isempty(a) else - trace_all.freq_ecrh1(i) = a; - trace_all.freq_ech(i) = a.value; + trace_all.freq_ecrh1(i) = a; + trace_all.freq_ech(i) = a.value; end try - a = sf2par('ECS',shot,'GPolPos',['P_sy1_g' num2str(i)]); + a = sf2par('ECS',shot,'GPolPos',['P_sy1_g' num2str(i)]); catch - % GPolPos not present - a=[]; + % GPolPos not present + a=[]; end if isempty(a) else - trace_all.polpos_ecs(i) = a.value; + trace_all.polpos_ecs(i) = a.value; end try - a = sf2par('ECS',shot,'GTorPos',['P_sy1_g' num2str(i)]); + a = sf2par('ECS',shot,'GTorPos',['P_sy1_g' num2str(i)]); catch - a=[]; + a=[]; end if isempty(a) else - trace_all.torpos_ecs(i) = a.value; + trace_all.torpos_ecs(i) = a.value; end % "new" ECRH2 gyrotrons: gyro 5 to 8 in pgyro tracename_eff = ['PG' num2str(i) 'N']; [a,e]=rdaAUG_eff(shot,ppftype,tracename_eff,shotfile_exp_eff); if isempty(a) || e~=0 else - trace_all.ecrh2(i) = a; - trace_all.pgyro(:,i+4) = reshape(a.data,nb_timepoints,1); + trace_all.ecrh2(i) = a; + trace_all.pgyro(:,i+4) = reshape(a.data,nb_timepoints,1); end try - a = sf2par('ECS',shot,'gyr_freq',['P_sy2_g' num2str(i)]); + a = sf2par('ECS',shot,'gyr_freq',['P_sy2_g' num2str(i)]); catch - a=[]; + a=[]; end if isempty(a) else - trace_all.freq_ecrh2(i) = a; - trace_all.freq_ech(i+4) = a.value; + trace_all.freq_ecrh2(i) = a; + trace_all.freq_ech(i+4) = a.value; end try - a = sf2par('ECS',shot,'GPolPos',['P_sy2_g' num2str(i)]); + a = sf2par('ECS',shot,'GPolPos',['P_sy2_g' num2str(i)]); catch - a=[]; + a=[]; end if isempty(a) else - trace_all.polpos_ecs(i+4) = a.value; + trace_all.polpos_ecs(i+4) = a.value; end try - a = sf2par('ECS',shot,'GTorPos',['P_sy2_g' num2str(i)]); + a = sf2par('ECS',shot,'GTorPos',['P_sy2_g' num2str(i)]); catch - a=[]; + a=[]; end if isempty(a) else - trace_all.torpos_ecs(i+4) = a.value; + trace_all.torpos_ecs(i+4) = a.value; end [a,e]=rdaAUG_eff(shot,'ECN',['G' num2str(i) 'POL'],shotfile_exp_eff); if isempty(a) || e~=0 else - trace_all.gpol_ecn(i+4) = a; + trace_all.gpol_ecn(i+4) = a; end [a,e]=rdaAUG_eff(shot,'ECN',['G' num2str(i) 'TOR'],shotfile_exp_eff); if isempty(a) || e~=0 else - trace_all.gtor_ecn(i+4) = a; + trace_all.gtor_ecn(i+4) = a; end [a,e]=rdaAUG_eff(shot,'ECN',['G' num2str(i) 'PO4'],shotfile_exp_eff); if isempty(a) || e~=0 else - trace_all.gpo4_ecn(i+4) = a; + trace_all.gpo4_ecn(i+4) = a; end [a,e]=rdaAUG_eff(shot,'ECN',['G' num2str(i) 'PO8'],shotfile_exp_eff); if isempty(a) || e~=0 else - trace_all.gpo8_ecn(i+4) = a; + trace_all.gpo8_ecn(i+4) = a; end end if ~isempty(trace_all) @@ -1431,13 +1431,13 @@ switch AUGkeywrdcase{index} trace.t = []; trace.units = []; trace.freq_ech_units =[]'; - trace.name=[num2str(shot) '/' ppftype '/' 'PGi and PGiN']; + trace.name=[num2str(shot) '/' ppftype '/' 'PGi and PGiN']; end - - %&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& + + %&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& case {'powers'} % load powers from TOT timebase as well - % + % shotfile_exp_eff = AUGexplocation{index}; @@ -1519,10 +1519,10 @@ switch AUGkeywrdcase{index} trace.t = []; trace.units = []; trace.freq_ech_units =[]'; - trace.name=[num2str(shot) '/' ppftype '/' 'P_OH, PNBI_TOT, PECR_TOT, PICR_TOT']; + trace.name=[num2str(shot) '/' ppftype '/' 'P_OH, PNBI_TOT, PECR_TOT, PICR_TOT']; end -%&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& + %&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& case {'transp'} % for TRANSP % LOAD TRA data into substructures shotfile_exp_eff = AUGexplocation{index} @@ -1535,31 +1535,31 @@ switch AUGkeywrdcase{index} TRANSP_signals; for i=1:size(transp_sig,1) if strcmp(lower(transp_sig{i,2}),'signal') || strcmp(lower(transp_sig{i,2}),'signal-group') - try - eval(['[trace.' transp_sig{i,1} ',e]=rdaAUG_eff(shot,ppftype,''' transp_sig{i,1} ''',shotfile_exp_eff);']); - catch - eval(['trace.' transp_sig{i,1} '=[];']); - end + try + eval(['[trace.' transp_sig{i,1} ',e]=rdaAUG_eff(shot,ppftype,''' transp_sig{i,1} ''',shotfile_exp_eff);']); + catch + eval(['trace.' transp_sig{i,1} '=[];']); + end elseif strcmp(lower(transp_sig{i,2}),'area-base') - clear adata_area - try - [adata_area]=sf2ab(ppftype,shot,transp_sig{i,1},'-exp',shotfile_exp_eff); - catch - adata_area.value = cell(0); - end - eval(['trace.' transp_sig{i,1} '=adata_area;']); + clear adata_area + try + [adata_area]=sf2ab(ppftype,shot,transp_sig{i,1},'-exp',shotfile_exp_eff); + catch + adata_area.value = cell(0); + end + eval(['trace.' transp_sig{i,1} '=adata_area;']); elseif strcmp(lower(transp_sig{i,2}),'time-base') - clear adata_time - try - [adata_time]=sf2tb(ppftype,shot,transp_sig{i,1},'-exp',shotfile_exp_eff); - catch - adata_time.value = cell(0); - end - eval(['trace.' transp_sig{i,1} '=adata_time;']); + clear adata_time + try + [adata_time]=sf2tb(ppftype,shot,transp_sig{i,1},'-exp',shotfile_exp_eff); + catch + adata_time.value = cell(0); + end + eval(['trace.' transp_sig{i,1} '=adata_time;']); end end otherwise disp('case not yet defined') - + end diff --git a/matlab/AUG/plot_torbeam.m b/matlab/AUG/plot_torbeam.m index 2943eb9056773eab5fcb6eecfdb8e3347b60057b..a8a0955c133cba958da8eb176db0183a1d56481e 100644 --- a/matlab/AUG/plot_torbeam.m +++ b/matlab/AUG/plot_torbeam.m @@ -28,7 +28,7 @@ if nargin >= 2 h_for_waitfor=figure; global field_chosen h1=uicontrol('Style','listbox','string',tb_fields,'pos',[20 20 200 300],'Max',20, ... - 'callback', ['global field_chosen;field_chosen=get(gcbo,''value'') ;']); + 'callback', ['global field_chosen;field_chosen=get(gcbo,''value'') ;']); h2=uicontrol('Style','text','pos',[20 330 200 30],'string','choose fields to plot (ctrl-enter for multiple choices) then quit'); h3=uicontrol('Style','pushbutton','string','quit','pos',[300 20 30 20],'callback', ['close gcf;']); waitfor(h_for_waitfor); diff --git a/matlab/AUG/rdaAUG_eff.m b/matlab/AUG/rdaAUG_eff.m index d1ac063d39559dd2bee11f50758cffaf606ad2c8..e023ab44a0b16e22b32d6d2f24cc63afe63c61b6 100644 --- a/matlab/AUG/rdaAUG_eff.m +++ b/matlab/AUG/rdaAUG_eff.m @@ -90,15 +90,15 @@ time_base=false; time_base_name=[]; time_base_dimof=[]; if nargin_eff>=7 && ~isempty(varargin_eff{3}) && ischar(varargin_eff{3}) ... - && length(varargin_eff{3})>=7 && strcmp(lower(varargin_eff{3}(1:6)),'param:') + && length(varargin_eff{3})>=7 && strcmp(lower(varargin_eff{3}(1:6)),'param:') param_name=varargin_eff{3}(7:end); end if nargin_eff>=7 && ~isempty(varargin_eff{3}) && ischar(varargin_eff{3}) ... - && length(varargin_eff{3})>=11 && strcmp(lower(varargin_eff{3}(1:10)),'param-set:') + && length(varargin_eff{3})>=11 && strcmp(lower(varargin_eff{3}(1:10)),'param-set:') param_set_name=varargin_eff{3}(11:end); end if nargin_eff>=7 && ~isempty(varargin_eff{3}) && ischar(varargin_eff{3}) ... - && length(varargin_eff{3})>=9 && strcmp(lower(varargin_eff{3}(1:9)),'area-base') + && length(varargin_eff{3})>=9 && strcmp(lower(varargin_eff{3}(1:9)),'area-base') area_base = true; ij=findstr(varargin_eff{3},':'); if length(ij)==2 @@ -109,7 +109,7 @@ if nargin_eff>=7 && ~isempty(varargin_eff{3}) && ischar(varargin_eff{3}) ... end end if nargin_eff>=7 && ~isempty(varargin_eff{3}) && ischar(varargin_eff{3}) ... - && length(varargin_eff{3})>=9 && strcmp(lower(varargin_eff{3}(1:9)),'time-base') + && length(varargin_eff{3})>=9 && strcmp(lower(varargin_eff{3}(1:9)),'time-base') time_base = true; ij=findstr(varargin_eff{3},':'); if length(ij)==2 @@ -166,7 +166,7 @@ if usemdsplus if isempty(param_name) && isempty(param_set_name) && ~area_base && ~time_base % use augsignal to get effective layout as in ISIS and sf2sig, for example for EQI/PFM eval(['[data,error]=mdsvalue(''_rdaeff' user diagname '=augsignal(' num2str(shot) ',"' diagname '","' sigtype '","' shotfile_exp ... - '",' ed_number ',' tstart ',' tend ',_oshot' user diagname ',_oed' user diagname ',' ask_raw ')'');']); + '",' ed_number ',' tstart ',' tend ',_oshot' user diagname ',_oed' user diagname ',' ask_raw ')'');']); if isnumeric(data) data=double(data); end @@ -242,42 +242,42 @@ if usemdsplus if prod(ss)==length(data); nbofdim=1; end nbofdim=max(nbofdim,1); switch nbofdim - case 1 - adata.data=reshape(adata.data,1,length(adata.data)); - idim0 = 0; - eval(['time=mdsvalue(''dim_of(_rdaeff' user diagname ',' num2str(idim0) ')'');']); - if numel(time) ~= numel(adata.data) - idim0 = 1; + case 1 + adata.data=reshape(adata.data,1,length(adata.data)); + idim0 = 0; eval(['time=mdsvalue(''dim_of(_rdaeff' user diagname ',' num2str(idim0) ')'');']); - if numel(time) ~= numel(adata.data) && (ischar(adata.data) && isempty(strfind(lower(adata.data),'abort'))) - warning(['problem with dim for: ' diagname ', ' sigtype]) + if numel(time) ~= numel(adata.data) + idim0 = 1; + eval(['time=mdsvalue(''dim_of(_rdaeff' user diagname ',' num2str(idim0) ')'');']); + if numel(time) ~= numel(adata.data) && (ischar(adata.data) && isempty(strfind(lower(adata.data),'abort'))) + warning(['problem with dim for: ' diagname ', ' sigtype]) + end end - end - time = reshape(time,1,length(time)); - x=[]; - adata.dim = {time}; - eval(['tunits=mdsvalue(''units_of(dim_of(_rdaeff' user diagname ',' num2str(idim0) '))'');']); - adata.dimunits = {tunits}; - case 2 - if strcmp(upper(diagname),'IDA') && ~usemdsplus - % rho, time in original dimension, so do not transpose (seems different with mdsplus... to check) - idim_x = 0; - idim_t = 1; - else - adata.data = adata.data'; - did_transpose = 1; - idim_x = 1; - idim_t = 0; - end - % transposed because of C relation and backward compatibility with sf2sig part - eval(['x=mdsvalue(''dim_of(_rdaeff' user diagname ',' num2str(idim_x) ')'');']); - if prod(size(x))==length(x); x = reshape(x,1,length(x)); end - eval(['time=mdsvalue(''dim_of(_rdaeff' user diagname ',' num2str(idim_t) ')'');']); - time = reshape(time,1,length(time)); - adata.dim = {x, time}; - eval(['xunits=deblank(mdsvalue(''units_of(dim_of(_rdaeff' user diagname ',' num2str(idim_x) '))''));']); - eval(['tunits=deblank(mdsvalue(''units_of(dim_of(_rdaeff' user diagname ',' num2str(idim_t) '))''));']); - adata.dimunits = {xunits, tunits}; + time = reshape(time,1,length(time)); + x=[]; + adata.dim = {time}; + eval(['tunits=mdsvalue(''units_of(dim_of(_rdaeff' user diagname ',' num2str(idim0) '))'');']); + adata.dimunits = {tunits}; + case 2 + if strcmp(upper(diagname),'IDA') && ~usemdsplus + % rho, time in original dimension, so do not transpose (seems different with mdsplus... to check) + idim_x = 0; + idim_t = 1; + else + adata.data = adata.data'; + did_transpose = 1; + idim_x = 1; + idim_t = 0; + end + % transposed because of C relation and backward compatibility with sf2sig part + eval(['x=mdsvalue(''dim_of(_rdaeff' user diagname ',' num2str(idim_x) ')'');']); + if prod(size(x))==length(x); x = reshape(x,1,length(x)); end + eval(['time=mdsvalue(''dim_of(_rdaeff' user diagname ',' num2str(idim_t) ')'');']); + time = reshape(time,1,length(time)); + adata.dim = {x, time}; + eval(['xunits=deblank(mdsvalue(''units_of(dim_of(_rdaeff' user diagname ',' num2str(idim_x) '))''));']); + eval(['tunits=deblank(mdsvalue(''units_of(dim_of(_rdaeff' user diagname ',' num2str(idim_t) '))''));']); + adata.dimunits = {xunits, tunits}; % $$$ case 3 % $$$ eval(['x=mdsvalue(''dim_of(_rdaeff' user diagname ',0)'');']); @@ -307,20 +307,20 @@ if usemdsplus % $$$ hsigunits = adata.dimunits{ihsig}; % $$$ adata.dimunits = {xunits, tunits, hsigunits}; - otherwise - itime = 1; % default - for i=1:nbofdim - eval(['dimarray=mdsvalue(''dim_of(_rdaeff' user diagname ',' num2str(i-1) ')'');']); - if prod(size(dimarray)) == length(dimarray) - eval(['adata.dim{' num2str(i) '}=reshape(dimarray,1,length(dimarray));']); - else + otherwise + itime = 1; % default + for i=1:nbofdim + eval(['dimarray=mdsvalue(''dim_of(_rdaeff' user diagname ',' num2str(i-1) ')'');']); + if prod(size(dimarray)) == length(dimarray) + eval(['adata.dim{' num2str(i) '}=reshape(dimarray,1,length(dimarray));']); + else eval(['adata.dim{' num2str(i) '} = dimarray;']); + end + eval(['adata.dimunits{' num2str(i) '}=deblank(mdsvalue(''units_of(dim_of(_rdaeff' user diagname ',' num2str(i-1) '))''));']); + if strcmp(adata.dimunits{i},'s'); itime = i; end end - eval(['adata.dimunits{' num2str(i) '}=deblank(mdsvalue(''units_of(dim_of(_rdaeff' user diagname ',' num2str(i-1) '))''));']); - if strcmp(adata.dimunits{i},'s'); itime = i; end - end - x = adata.dim{min(setdiff([1:2],itime))}; - time = adata.dim{itime}; + x = adata.dim{min(setdiff([1:2],itime))}; + time = adata.dim{itime}; end adata.value = adata.data; % for backward compatibility might need to keep .value, to be checked later, .data for sure @@ -346,7 +346,7 @@ else else [adata,adata_time, adata_area]=sf2sig(diagname,shot,sigtype,'-exp',shotfile_exp); end - adata.data = adata.value; % at this stage keep both but try to work only on .data + adata.data = adata.value; % at this stage keep both but try to work only on .data catch ME throw(ME) end @@ -358,7 +358,7 @@ else else [adata,adata_time, adata_area]=sf2sig(diagname,shot,sigtype,[time_int(1);time_int(end)],'-exp',shotfile_exp); end - adata.data = adata.value; % at this stage keep both but try to work only on .data (for adata which can be from sf2.. or mds) + adata.data = adata.value; % at this stage keep both but try to work only on .data (for adata which can be from sf2.. or mds) catch ME throw(ME) end @@ -444,13 +444,13 @@ else end end adata.units = adata.unit; -elseif isempty(param_set_name) && ~area_base && ~time_base + elseif isempty(param_set_name) && ~area_base && ~time_base % use sf2par try if ~isempty(extra_arg_sf2sig) && ~strcmp(extra_arg_sf2sig,'[]') - eval(['[adata]=sf2par(diagname,shot,param_name,sigtype,''-exp'',shotfile_exp,' extra_arg_sf2sig ');']); + eval(['[adata]=sf2par(diagname,shot,param_name,sigtype,''-exp'',shotfile_exp,' extra_arg_sf2sig ');']); else - eval(['[adata]=sf2par(diagname,shot,param_name,sigtype,''-exp'',shotfile_exp);']); + eval(['[adata]=sf2par(diagname,shot,param_name,sigtype,''-exp'',shotfile_exp);']); end adata.data = adata.value; catch ME @@ -460,9 +460,9 @@ elseif isempty(param_set_name) && ~area_base && ~time_base % use sf2ps try if ~isempty(extra_arg_sf2sig) && ~strcmp(extra_arg_sf2sig,'[]') - eval(['[adata]=sf2ps(diagname,shot,param_set_name,sigtype,''-exp'',shotfile_exp,' extra_arg_sf2sig ');']); + eval(['[adata]=sf2ps(diagname,shot,param_set_name,sigtype,''-exp'',shotfile_exp,' extra_arg_sf2sig ');']); else - eval(['[adata]=sf2ps(diagname,shot,param_set_name,sigtype,''-exp'',shotfile_exp);']); + eval(['[adata]=sf2ps(diagname,shot,param_set_name,sigtype,''-exp'',shotfile_exp);']); end adata.data = adata.value; catch ME diff --git a/matlab/AUG/run_torbeam_fullshot.m b/matlab/AUG/run_torbeam_fullshot.m index cc84f4ac30cd26b25ead58fae36929d6358740d3..6b1c1fdb05de0fcdf5276fecadbf178b6877d84d 100644 --- a/matlab/AUG/run_torbeam_fullshot.m +++ b/matlab/AUG/run_torbeam_fullshot.m @@ -4,7 +4,7 @@ function [torbeam_out_struct, file_out_prefix]=run_torbeam_fullshot(shot,varargi % % Run tbdemo, using line command execution of TORBEAM, to run torbeam acroos full shot on reduced time axis % -% shot: shot number for which to run Torbeam. +% shot: shot number for which to run Torbeam. % If empty or not given, ask for it % if negative, assume output file exists, do not re-run TORBEAM and just reads data into structure torbeam_out_struct % @@ -32,13 +32,13 @@ if nargin>=3 && mod(length(varargin),2)==0 for i=1:2:length(varargin)-1 if ~isempty(varargin{i}) && ~isempty(varargin{i+1}) switch lower(varargin{i}) - case {'time'} - time_array = varargin{i+1}; - case {'file_prefix'} - file_out_prefix = varargin{i+1}; - otherwise - disp(['case ' lower(varargin{i}) ' not yet implemented, ask Olivier.Sauter@epfl.ch']) - return + case {'time'} + time_array = varargin{i+1}; + case {'file_prefix'} + file_out_prefix = varargin{i+1}; + otherwise + disp(['case ' lower(varargin{i}) ' not yet implemented, ask Olivier.Sauter@epfl.ch']) + return end end end @@ -74,7 +74,7 @@ if shot>0 else disp('do not use IDA since shotfile does not seem to exist') end - + for igyro=1:8 filename=[file_out_prefix num2str(igyro) '.dat']; unix(['rm ' filename ' >& /dev/null']); % since cannot write over an existing file by default @@ -84,14 +84,14 @@ if shot>0 if ~isempty(itt) itt_tok=find(time_array>=pgyro.t(itt(1)) & time_array<=pgyro.t(itt(end))); if ~isempty(itt_tok) - pgyro_tok=interp1(pgyro.data(itt,igyro),time_array(itt_tok)); - disp(['running system ' num2str(igyro) '...']); - for j=1:length(itt_tok) - if pgyro_tok(j)>1e5 - [a,b]=unix(['~rem/public/tbm_demo/tbmdemo -batch -silent -shot ' num2str(shot) ' -time ' num2str(time_array(itt_tok(j))) ' -system ' num2str(igyro) ' -ntm ' dousedcr ' ' dousebetapol ' -eqdiag EQI -usemirror -cdrive 1 >> ' ['.' filename]]); % -exp AUGE - end - end - [a,b]=unix(['egrep -e ''^Shot''' ' .' filename ' > ' filename]); + pgyro_tok=interp1(pgyro.data(itt,igyro),time_array(itt_tok)); + disp(['running system ' num2str(igyro) '...']); + for j=1:length(itt_tok) + if pgyro_tok(j)>1e5 + [a,b]=unix(['~rem/public/tbm_demo/tbmdemo -batch -silent -shot ' num2str(shot) ' -time ' num2str(time_array(itt_tok(j))) ' -system ' num2str(igyro) ' -ntm ' dousedcr ' ' dousebetapol ' -eqdiag EQI -usemirror -cdrive 1 >> ' ['.' filename]]); % -exp AUGE + end + end + [a,b]=unix(['egrep -e ''^Shot''' ' .' filename ' > ' filename]); end end end @@ -100,16 +100,16 @@ end for igyro=1:8 try eval(['[shot_tbnam,tbout{igyro}.shot,time_tbnam,tbout{igyro}.time,gyro_tbnam,tbout{igyro}.gyro,pol_tbnam,tbout{igyro}.pol,tor_tbnam,tbout{igyro}.tor,' ... - 'pow_tbnam,tbout{igyro}.pow,r_tbnam,tbout{igyro}.r,z_tbnam,tbout{igyro}.z,rho_tbnam,tbout{igyro}.rhopol_dep,pwr_dep_tbnam,tbout{igyro}.rhopol_pwr_dep,rhopol_cd_dep_tbnam,tbout{igyro}.rhopol_cd_dep,pdens_peak_tbnam,' ... - 'tbout{igyro}.pdens_peak,rhopol_pdens_wid_tbnam,tbout{igyro}.rhopol_pdens_width,jcd_peak_tbnam,tbout{igyro}.jcd_peak,rhopol_c_wid_tbnam,tbout{igyro}.rhopol_jcd_width,pni_tbnam,tbout{igyro}.pni,picr_tbnam,tbout{igyro}.picr,prad_tbnam,tbout{igyro}.prad,' ... - 'betan_tbnam,tbout{igyro}.betan,ipl_tbnam,tbout{igyro}.ipl,bt_tbnam,tbout{igyro}.bt,a1_tbnam,tbout{igyro}.ampN1,a2_tbnam,tbout{igyro}.ampN2,rhopolntm_tbnam,tbout{igyro}.rhopolntm]=' ... - 'textread(''' file_out_prefix num2str(igyro) '.dat'',''%s%d%s%f%s%f%s%f%s%f%s%f%s%f%s%f%s%f%s%f%s%f%s%f%s%f%s%f%s%f%s%f%s%f%s%f%s%f%s%f%s%f%s%f%s%f%s%f'');']); + 'pow_tbnam,tbout{igyro}.pow,r_tbnam,tbout{igyro}.r,z_tbnam,tbout{igyro}.z,rho_tbnam,tbout{igyro}.rhopol_dep,pwr_dep_tbnam,tbout{igyro}.rhopol_pwr_dep,rhopol_cd_dep_tbnam,tbout{igyro}.rhopol_cd_dep,pdens_peak_tbnam,' ... + 'tbout{igyro}.pdens_peak,rhopol_pdens_wid_tbnam,tbout{igyro}.rhopol_pdens_width,jcd_peak_tbnam,tbout{igyro}.jcd_peak,rhopol_c_wid_tbnam,tbout{igyro}.rhopol_jcd_width,pni_tbnam,tbout{igyro}.pni,picr_tbnam,tbout{igyro}.picr,prad_tbnam,tbout{igyro}.prad,' ... + 'betan_tbnam,tbout{igyro}.betan,ipl_tbnam,tbout{igyro}.ipl,bt_tbnam,tbout{igyro}.bt,a1_tbnam,tbout{igyro}.ampN1,a2_tbnam,tbout{igyro}.ampN2,rhopolntm_tbnam,tbout{igyro}.rhopolntm]=' ... + 'textread(''' file_out_prefix num2str(igyro) '.dat'',''%s%d%s%f%s%f%s%f%s%f%s%f%s%f%s%f%s%f%s%f%s%f%s%f%s%f%s%f%s%f%s%f%s%f%s%f%s%f%s%f%s%f%s%f%s%f%s%f'');']); % eval(['[gyro_tbnam,tbout{igyro}.gyro,shot_tbnam,tbout{igyro}.shot,time_tbnam,tbout{igyro}.time,pol_tbnam,tbout{igyro}.pol,tor_tbnam,tbout{igyro}.tor,' ... % 'pow_tbnam,tbout{igyro}.pow,r_tbnam,tbout{igyro}.r,z_tbnam,tbout{igyro}.z,pwr_dep_tbnam,tbout{igyro}.rhopol_pwr_dep,rhopol_cd_dep_tbnam,tbout{igyro}.rhopol_cd_dep,jcd_peak_tbnam,' ... % 'tbout{igyro}.jcd_peak,rhopol_c_wid_tbnam,tbout{igyro}.rhopol_c_wid,pni_tbnam,tbout{igyro}.pni,picr_tbnam,tbout{igyro}.picr,prad_tbnam,tbout{igyro}.prad,' ... - % 'betan_tbnam,tbout{igyro}.betan,ipl_tbnam,tbout{igyro}.ipl,bt_tbnam,tbout{igyro}.bt,a1_tbnam,tbout{igyro}.a1,a2_tbnam,tbout{igyro}.a2,rhopolntm_tbnam,tbout{igyro}.rhopolntm]=' ... - % 'textread(''' file_out_prefix num2str(igyro) '.dat'',''%s%d%s%d%s%f%s%f%s%f%s%f%s%f%s%f%s%f%s%f%s%f%s%f%s%f%s%f%s%f%s%f%s%f%s%f%s%f%s%f%s%f'');']); + % 'betan_tbnam,tbout{igyro}.betan,ipl_tbnam,tbout{igyro}.ipl,bt_tbnam,tbout{igyro}.bt,a1_tbnam,tbout{igyro}.a1,a2_tbnam,tbout{igyro}.a2,rhopolntm_tbnam,tbout{igyro}.rhopolntm]=' ... + % 'textread(''' file_out_prefix num2str(igyro) '.dat'',''%s%d%s%d%s%f%s%f%s%f%s%f%s%f%s%f%s%f%s%f%s%f%s%f%s%f%s%f%s%f%s%f%s%f%s%f%s%f%s%f%s%f'');']); catch disp(['problems reading file ' file_out_prefix num2str(igyro) '.dat: may be some errors with tbdemo, check file, skipped']) @@ -127,11 +127,11 @@ end % comments for hiytory backup: -% [a,b]=unix(['ssh sxaug21.aug.ipp.mpg.de ~rem/public/tbm_demo/tbmdemo -batch -silent -shot ' num2str(shot) ' -time ' num2str(time_array(itt_tok(j))) ' -system ' num2str(igyro) ' -usedcr -eqdiag EQI -betapol -usemirror -cdrive 1 >> ' ['.' filename]]); +% [a,b]=unix(['ssh sxaug21.aug.ipp.mpg.de ~rem/public/tbm_demo/tbmdemo -batch -silent -shot ' num2str(shot) ' -time ' num2str(time_array(itt_tok(j))) ' -system ' num2str(igyro) ' -usedcr -eqdiag EQI -betapol -usemirror -cdrive 1 >> ' ['.' filename]]); -% [a,b]=unix(['ssh sxaug21.aug.ipp.mpg.de ~rem/public/tbm_demo/tbmdemo -batch -silent -shot ' num2str(shot) ' -time ' num2str(time_array(itt_tok(j))) ' -system ' num2str(igyro) ' -ntm -usedcr -eqdiag EQI -betapol -usemirror -cdrive 1 >> ' ['.' filename]]); +% [a,b]=unix(['ssh sxaug21.aug.ipp.mpg.de ~rem/public/tbm_demo/tbmdemo -batch -silent -shot ' num2str(shot) ' -time ' num2str(time_array(itt_tok(j))) ' -system ' num2str(igyro) ' -ntm -usedcr -eqdiag EQI -betapol -usemirror -cdrive 1 >> ' ['.' filename]]); % -shot 29672 -time 3.0 -system 5 -batch -ntm -silent -usemirror -cdrive 1 -% [a,b]=unix(['ssh sxaug21.aug.ipp.mpg.de ~rem/public/tbm_demo/tbmdemo -batch -silent -shot ' num2str(shot) ' -time ' num2str(time_array(itt_tok(j))) ' -system ' num2str(igyro) ' -ntm -usemirror -cdrive 1 >> ' ['.' filename]]); +% [a,b]=unix(['ssh sxaug21.aug.ipp.mpg.de ~rem/public/tbm_demo/tbmdemo -batch -silent -shot ' num2str(shot) ' -time ' num2str(time_array(itt_tok(j))) ' -system ' num2str(igyro) ' -ntm -usemirror -cdrive 1 >> ' ['.' filename]]); % [a,b]=unix(['grep -v ''could not''' ' .' filename '| grep -v ''invalid'' | grep -v ''Error'' | egrep -e ''^$'' -v > ' filename]); diff --git a/matlab/AUG/torbeam_prepare_inputs_and_run.m b/matlab/AUG/torbeam_prepare_inputs_and_run.m index efc7d853c74f58ced7e48ed255a9e4f3e0695112..295ad894da2cfdf10b7ed3e3781c289144a9f6e3 100644 --- a/matlab/AUG/torbeam_prepare_inputs_and_run.m +++ b/matlab/AUG/torbeam_prepare_inputs_and_run.m @@ -1,7 +1,7 @@ function [torbeam_out,torbeam_in,varargout] = torbeam_prepare_inputs_and_run(shot,times_in,varargin); % % [torbeam_out,torbeam_in,varargout] = torbeam_prepare_inputs_and_run(shot,times_in,varargin); -% +% % varargin{1}: torbeam_in (from a previous run, so avoids to reload all the data) % leave then times_in empty to rerun at all times in torbeam_in.inbeam.t_some_beam_on or select times points from that array % varargin{2}: source for gdat profiles/equilibrium related: [] (default sources), 'IDA' (IDA/IDE sources), {'TRA','expname'} for TRANSP @@ -93,7 +93,7 @@ if doload && (~exist('times_for_torbeam_eff') || isempty(times_for_torbeam_eff)) times_for_torbeam_eff = torbeam_in.nete.fit.t(torbeam_in.nete.fit.t>0); end % load beam releated data including theta,phi in torbeam reference -if doload, +if doload, [torbeam_in.inbeam] = read_ech_py(shot,times_for_torbeam_eff,[],tbangles_source); times_for_torbeam_eff = torbeam_in.inbeam.t_some_beam_on; else @@ -134,7 +134,7 @@ if doload; disp(['time for reading data: ' num2str(toc)]); end if doload, nb_points_prof = 46; rhofit = linspace(0,1,nb_points_prof)'; - + tb_par_fields=fieldnames(torbeam_in.inbeam.tb_par); itime_te = iround_os(torbeam_in.nete.fit.t,times_for_torbeam_eff); @@ -202,7 +202,7 @@ if doload, fprintf(fid,'%14.6f %14.6f %14.6f %14.6f %14.6f %14.6f %14.6f %14.6f\n',eqd_with_b.psi(1:nb_rmesh,1:nb_zmesh)); if mod(nb_rmesh*nb_zmesh,8) ~= 0; fprintf(fid,'\n'); end fclose(fid); - + if isempty(torbeam_in.zeff.data) || torbeam_in.prepare_run_options.zeff_default < 0. zeff_eff = abs(torbeam_in.prepare_run_options.zeff_default); else @@ -214,10 +214,10 @@ if doload, torbeam_in.fname{it}.inbeam{ibeam} = fullfile(torbeam_in.dir_torbeam,['inbeam' '_t' num2str(torbeam_in.inbeam.t_some_beam_on(it)) 'g' num2str(ibeam) '.dat']); [aa,bb]=unix(['cp /afs/ipp-garching.mpg.de/home/o/osauter/TORBEAM/inbeam_default.dat ' torbeam_in.fname{it}.inbeam{ibeam}]); fid=fopen(torbeam_in.fname{it}.inbeam{ibeam},'a'); - fprintf(fid,' xf = %f, ! wave frequency om=2*pi*xf\n',torbeam_in.inbeam.freq(ibeam)); - fprintf(fid,' nmod = %d, ! mode selection: O-mode (1), X-mode (-1)\n',torbeam_in.inbeam.rfmod(ibeam)); - fprintf(fid,' xtordeg = %f, ! geom. optics injection angle\n',torbeam_in.inbeam.phi_t(ibeam,it_inb(it))); - fprintf(fid,' xpoldeg = %f, ! geom. optics injection angle\n',torbeam_in.inbeam.theta_t(ibeam,it_inb(it))); + fprintf(fid,' xf = %f, ! wave frequency om=2*pi*xf\n',torbeam_in.inbeam.freq(ibeam)); + fprintf(fid,' nmod = %d, ! mode selection: O-mode (1), X-mode (-1)\n',torbeam_in.inbeam.rfmod(ibeam)); + fprintf(fid,' xtordeg = %f, ! geom. optics injection angle\n',torbeam_in.inbeam.phi_t(ibeam,it_inb(it))); + fprintf(fid,' xpoldeg = %f, ! geom. optics injection angle\n',torbeam_in.inbeam.theta_t(ibeam,it_inb(it))); % may be position and curvature, but get defaults from tb_gui. Check with tb_gui how several launchers are given for i=1:length(tb_par_fields) fprintf(fid,[' ' tb_par_fields{i} ' = %f,\n'],torbeam_in.inbeam.tb_par.(tb_par_fields{i})(ibeam)); @@ -230,7 +230,7 @@ if doload, end disp(['time for creating all input files: ' num2str(toc)]) end - + % run TORBEAM current_dir = pwd; eval(['cd ' torbeam_in.dir_torbeam]) diff --git a/matlab/D3D/d3d_help_parameters.m b/matlab/D3D/d3d_help_parameters.m index ec8d86a7d139db3a5d5a77e3ef1e8252b8066558..e88c176dd9ddaa9734574f5dfd6645972010821a 100644 --- a/matlab/D3D/d3d_help_parameters.m +++ b/matlab/D3D/d3d_help_parameters.m @@ -5,9 +5,9 @@ function help_struct = d3d_help_parameters(parameter_list) % % return the whole help structure if parameter_list empty or not provided % -% do: +% do: % help_struct = d3d_help_parameters(fieldnames(gdat_data.gdat_params)); -% +% % to get relevant help description % @@ -29,7 +29,7 @@ help_struct_all = struct(... % $$$ ' as well']; help_struct_all.fit_tension = ['smoothing value used in interpos fitting routine, -30 means ''30 times default value'', thus -1 often a' ... ' good value' char(10) ... - 'cxrs, nete: if numeric, default for all cases, if structure, default for non given fields']; + 'cxrs, nete: if numeric, default for all cases, if structure, default for non given fields']; help_struct_all.time = 'time(s) value(s) if relevant, for example eqdsk is provided by default only for time=1.0s'; % $$$ help_struct_all.zshift = 'vertical shift of equilibrium, either for eqdsk (1 to shift to zaxis=0) or for mapping measurements on to rho surfaces [m]'; help_struct_all.cocos = ['cocos value desired in output, uses eqdsk_cocos_transform. Note should use latter if a specific Ip and/or B0 sign' ... diff --git a/matlab/D3D/d3d_requests_mapping.m b/matlab/D3D/d3d_requests_mapping.m index 8eb80c6cbd70ab8405269fff92b77b90d362c98d..f3789d1c9ea3c580ad858d56dfa15119a416dda2 100644 --- a/matlab/D3D/d3d_requests_mapping.m +++ b/matlab/D3D/d3d_requests_mapping.m @@ -4,13 +4,13 @@ function mapping = d3d_requests_mapping(data_request) % % Defaults mapping = struct(... - 'label', '', ... - 'method', '', ... - 'expression','', ... - 'timedim', -1, ... % dim which is the time is the database, to copy in .t, the other dims are in .x (-1 means last dimension) - 'gdat_timedim',[], ... % if need to reshape data and dim orders to have timedim as gdat_timedim (shifting time to gdat_timedim) - 'min', -inf, ... - 'max', inf); + 'label', '', ... + 'method', '', ... + 'expression','', ... + 'timedim', -1, ... % dim which is the time is the database, to copy in .t, the other dims are in .x (-1 means last dimension) + 'gdat_timedim',[], ... % if need to reshape data and dim orders to have timedim as gdat_timedim (shifting time to gdat_timedim) + 'min', -inf, ... + 'max', inf); % Note that gdat_timedim is set to timedim at end of this function if empty % gdat_timedim should have effective index of the time dimension in gdat @@ -41,100 +41,100 @@ if iscell(data_request) % || (~ischar(data_request) && length(data_request)>1) end switch lower(data_request) - case 'a_minor' - mapping.timedim = 1; - mapping.label = 'a\_minor'; - mapping.method = 'signal'; - mapping.expression = [{'EFIT01'},{'\aminor'}]; - case 'b0' - mapping.timedim = 1; - mapping.label = 'B_0'; - mapping.method = 'signal'; - mapping.expression = [{'EFIT01'},{'\bcentr'}]; - case 'beta' - mapping.timedim = 1; - mapping.label = '\beta'; - mapping.method = 'signal'; - mapping.expression = [{'EFIT01'},{'\betat'}]; - case 'betan' - mapping.timedim = 1; - mapping.label = '\beta_N'; - mapping.method = 'signal'; - mapping.expression = [{'EFIT01'},{'\betan'}]; - case 'betap' - mapping.timedim = 1; - mapping.label = '\beta_p'; - mapping.method = 'signal'; - mapping.expression = [{'EFIT01'},{'\betap'}]; - case {'bolo', 'bolom'} - mapping.timedim = 1; - mapping.gdat_timedim = 2; - mapping.method = 'switchcase'; - case 'delta' - mapping.timedim = 1; - mapping.label = 'delta'; - mapping.method = 'expression'; - mapping.expression = ['params_eff = gdat_data.gdat_params;params_eff.data_request=''delta_bottom''; ' ... + case 'a_minor' + mapping.timedim = 1; + mapping.label = 'a\_minor'; + mapping.method = 'signal'; + mapping.expression = [{'EFIT01'},{'\aminor'}]; + case 'b0' + mapping.timedim = 1; + mapping.label = 'B_0'; + mapping.method = 'signal'; + mapping.expression = [{'EFIT01'},{'\bcentr'}]; + case 'beta' + mapping.timedim = 1; + mapping.label = '\beta'; + mapping.method = 'signal'; + mapping.expression = [{'EFIT01'},{'\betat'}]; + case 'betan' + mapping.timedim = 1; + mapping.label = '\beta_N'; + mapping.method = 'signal'; + mapping.expression = [{'EFIT01'},{'\betan'}]; + case 'betap' + mapping.timedim = 1; + mapping.label = '\beta_p'; + mapping.method = 'signal'; + mapping.expression = [{'EFIT01'},{'\betap'}]; + case {'bolo', 'bolom'} + mapping.timedim = 1; + mapping.gdat_timedim = 2; + mapping.method = 'switchcase'; + case 'delta' + mapping.timedim = 1; + mapping.label = 'delta'; + mapping.method = 'expression'; + mapping.expression = ['params_eff = gdat_data.gdat_params;params_eff.data_request=''delta_bottom''; ' ... 'gdat_tmp=gdat_d3d(shot,params_eff);params_eff.data_request=''delta_top'';' ... - 'gdat_tmp2=gdat_d3d(shot,params_eff);gdat_tmp.data = 0.5.*(gdat_tmp.data+gdat_tmp2.data);']; - case 'delta_top' - mapping.label = 'delta\_top'; - mapping.timedim = 1; - mapping.method = 'signal'; - mapping.expression = [{'EFIT01'},{'\tritop'}]; - case 'delta_bottom' - mapping.label = 'delta\_bottom'; - mapping.timedim = 1; - mapping.method = 'signal'; - mapping.expression = [{'EFIT01'},{'\tribot'}]; - case 'den_target' - mapping.timedim = 1; - mapping.label = {'density_ref','density'}; - mapping.method = 'expression'; - mapping.expression = ['params_eff = gdat_data.gdat_params;params_eff.data_request=''\dstdenp'';' ... + 'gdat_tmp2=gdat_d3d(shot,params_eff);gdat_tmp.data = 0.5.*(gdat_tmp.data+gdat_tmp2.data);']; + case 'delta_top' + mapping.label = 'delta\_top'; + mapping.timedim = 1; + mapping.method = 'signal'; + mapping.expression = [{'EFIT01'},{'\tritop'}]; + case 'delta_bottom' + mapping.label = 'delta\_bottom'; + mapping.timedim = 1; + mapping.method = 'signal'; + mapping.expression = [{'EFIT01'},{'\tribot'}]; + case 'den_target' + mapping.timedim = 1; + mapping.label = {'density_ref','density'}; + mapping.method = 'expression'; + mapping.expression = ['params_eff = gdat_data.gdat_params;params_eff.data_request=''\dstdenp'';' ... 'gdat_tmp=gdat_d3d(shot,params_eff);params_eff.data_request=''\dssdenest'';' ... 'gdat_tmp2=gdat_d3d(shot,params_eff);' ... - 'gdat_tmp.data(:,2) = gdat_tmp2.data;' ... + 'gdat_tmp.data(:,2) = gdat_tmp2.data;' ... 'gdat_tmp.dim{2}=[1 2];gdat_tmp.dimunits{1}=''s'';gdat_tmp.dimunits{2}={''dstdenp'',''dssdenest''};' ... 'gdat_tmp.gdat_request=''' data_request ''';']; - case {'ece', 'ece_rho'} - mapping.timedim = 1; - mapping.method = 'switchcase'; - mapping.expression = ''; - case 'eqdsk' - mapping.timedim = 2; - mapping.method = 'switchcase'; - mapping.expression = ''; - case 'equil' - mapping.gdat_timedim = 2; - mapping.method = 'switchcase'; - mapping.expression = ''; - case 'halpha' - mapping.timedim = 1; - mapping.label = 'Halpha'; - mapping.method = 'signal'; - mapping.expression = [{'SPECTROSCOPY'},{'\fs04'}]; - case {'h_scalings', 'h98y2'} - mapping.label = 'H_{98y2}'; - mapping.timedim = 1; - mapping.method = 'signal'; - mapping.expression = [{'EFIT01'},{'results.confinement.times.scalings:h_thh98y2'}]; - mapping.expression = [{'D3D'},{'\h_thh98y2'}]; - case 'ioh' - mapping.timedim = 1; - mapping.label = 'I ohmic transformer'; - mapping.method = 'signal'; - mapping.expression = [{'MBI'},{'IOH'}]; - case 'ip' - mapping.timedim = 1; - mapping.label = 'Plasma current'; - mapping.method = 'signal'; - mapping.expression = [{'efit01'},{'\cpasma'}]; - case 'kappa' - mapping.timedim = 1; - mapping.label = '\kappa'; - mapping.method = 'signal'; - mapping.expression = [{'efit01'},{'\kappa'}]; + case {'ece', 'ece_rho'} + mapping.timedim = 1; + mapping.method = 'switchcase'; + mapping.expression = ''; + case 'eqdsk' + mapping.timedim = 2; + mapping.method = 'switchcase'; + mapping.expression = ''; + case 'equil' + mapping.gdat_timedim = 2; + mapping.method = 'switchcase'; + mapping.expression = ''; + case 'halpha' + mapping.timedim = 1; + mapping.label = 'Halpha'; + mapping.method = 'signal'; + mapping.expression = [{'SPECTROSCOPY'},{'\fs04'}]; + case {'h_scalings', 'h98y2'} + mapping.label = 'H_{98y2}'; + mapping.timedim = 1; + mapping.method = 'signal'; + mapping.expression = [{'EFIT01'},{'results.confinement.times.scalings:h_thh98y2'}]; + mapping.expression = [{'D3D'},{'\h_thh98y2'}]; + case 'ioh' + mapping.timedim = 1; + mapping.label = 'I ohmic transformer'; + mapping.method = 'signal'; + mapping.expression = [{'MBI'},{'IOH'}]; + case 'ip' + mapping.timedim = 1; + mapping.label = 'Plasma current'; + mapping.method = 'signal'; + mapping.expression = [{'efit01'},{'\cpasma'}]; + case 'kappa' + mapping.timedim = 1; + mapping.label = '\kappa'; + mapping.method = 'signal'; + mapping.expression = [{'efit01'},{'\kappa'}]; % $$$ case 'kappa_top' % $$$ mapping.timedim = 1; % $$$ mapping.label = '\kappa^{top}'; @@ -145,16 +145,16 @@ switch lower(data_request) % $$$ mapping.label = '\kappa_{bottom}'; % $$$ mapping.method = 'signal'; % $$$ mapping.expression = [{'FPG'},{'kuntn'}]; - case 'li' - mapping.timedim = 1; - mapping.label = 'l_i'; - mapping.method = 'signal'; - mapping.expression = [{'efit01'},{'\li3'}]; - case 'mhd' - mapping.timedim = 1; - mapping.label = 'Odd and Even n'; - mapping.method = 'expression'; - table_mhd_from_Strait = { ... + case 'li' + mapping.timedim = 1; + mapping.label = 'l_i'; + mapping.method = 'signal'; + mapping.expression = [{'efit01'},{'\li3'}]; + case 'mhd' + mapping.timedim = 1; + mapping.label = 'Odd and Even n'; + mapping.method = 'expression'; + table_mhd_from_Strait = { ... 'MPI66M020D', 19.5 , 'MPI66M200D' , 199.7, 180.2; ... 'MPI66M067D', 67.5 , 'MPI66M247D' , 246.4, 178.9; ... 'MPI66M097D', 97.4, 'MPI66M277D', 277.5, 180.1; ... @@ -163,43 +163,43 @@ switch lower(data_request) 'MPI66M137D', 137.4, 'MPI66M322D', 317.4, 180.0; ... 'MPI66M157D', 157.6, 'MPI66M340D', 339.7, 182.2}; - mapping.expression = ['params_eff = gdat_data.gdat_params;params_eff.data_request={''MOD'',''OddN''}; ' ... + mapping.expression = ['params_eff = gdat_data.gdat_params;params_eff.data_request={''MOD'',''OddN''}; ' ... 'gdat_tmp=gdat_d3d(shot,params_eff);gdat_tmp.data=reshape(gdat_tmp.data,length(gdat_tmp.data),1 );' ... - 'gdat_tmp.dim{1}=gdat_tmp.t;gdat_tmp.dim{2}=[1 2];gdat_tmp.x=gdat_tmp.dim{2};' ... - 'gdat_tmp.n_odd.data = gdat_tmp.data;gdat_tmp.n_odd.data_request=params_eff.data_request;' ... - 'params_eff.data_request={''MOD'',''EvenN''};' ... - 'gdat_tmp2=gdat_d3d(shot,params_eff);gdat_tmp.data(:,2)=reshape(gdat_tmp2.data,length(gdat_tmp2.data),1);' ... - 'gdat_tmp.n_even.data = gdat_tmp2.data;gdat_tmp.n_even.data_request=params_eff.data_request;gdat_tmp.label={''n\_odd'',''n\_even''};' ... - 'params_eff.data_request={''MOD'',''OddNAmp''};' ... - 'gdat_tmp2=gdat_d3d(shot,params_eff);gdat_tmp.n_odd.amp=reshape(gdat_tmp2.data,length(gdat_tmp2.data),1);' ... - 'gdat_tmp.n_odd.amp_t=gdat_tmp2.t;' ... - 'params_eff.data_request={''MOD'',''EvenNAmp''};' ... - 'gdat_tmp2=gdat_d3d(shot,params_eff);gdat_tmp.n_even.amp=reshape(gdat_tmp2.data,length(gdat_tmp2.data),1);' ... - 'gdat_tmp.n_even.amp_t=gdat_tmp2.t;' ... - 'gdat_tmp.full_path=''MOD/Odd in data and .n_odd; .n_even'';' ... - 'gdat_tmp.gdat_request=''mhd'';gdat_tmp.gdat_params.data_request=gdat_tmp.gdat_request;']; - case 'nbi' - mapping.timedim = 1; - mapping.label = 'Pnbi [W]'; + 'gdat_tmp.dim{1}=gdat_tmp.t;gdat_tmp.dim{2}=[1 2];gdat_tmp.x=gdat_tmp.dim{2};' ... + 'gdat_tmp.n_odd.data = gdat_tmp.data;gdat_tmp.n_odd.data_request=params_eff.data_request;' ... + 'params_eff.data_request={''MOD'',''EvenN''};' ... + 'gdat_tmp2=gdat_d3d(shot,params_eff);gdat_tmp.data(:,2)=reshape(gdat_tmp2.data,length(gdat_tmp2.data),1);' ... + 'gdat_tmp.n_even.data = gdat_tmp2.data;gdat_tmp.n_even.data_request=params_eff.data_request;gdat_tmp.label={''n\_odd'',''n\_even''};' ... + 'params_eff.data_request={''MOD'',''OddNAmp''};' ... + 'gdat_tmp2=gdat_d3d(shot,params_eff);gdat_tmp.n_odd.amp=reshape(gdat_tmp2.data,length(gdat_tmp2.data),1);' ... + 'gdat_tmp.n_odd.amp_t=gdat_tmp2.t;' ... + 'params_eff.data_request={''MOD'',''EvenNAmp''};' ... + 'gdat_tmp2=gdat_d3d(shot,params_eff);gdat_tmp.n_even.amp=reshape(gdat_tmp2.data,length(gdat_tmp2.data),1);' ... + 'gdat_tmp.n_even.amp_t=gdat_tmp2.t;' ... + 'gdat_tmp.full_path=''MOD/Odd in data and .n_odd; .n_even'';' ... + 'gdat_tmp.gdat_request=''mhd'';gdat_tmp.gdat_params.data_request=gdat_tmp.gdat_request;']; + case 'nbi' + mapping.timedim = 1; + mapping.label = 'Pnbi [W]'; % $$$ mapping.method = 'signal'; % $$$ mapping.expression = [{'nb'},{'pinj'}]; % in kW, use expression to have it in W - mapping.method = 'expression'; - mapping.expression = ['params_eff = gdat_data.gdat_params;params_eff.data_request=[{''nb''},{''pinj''}];' ... + mapping.method = 'expression'; + mapping.expression = ['params_eff = gdat_data.gdat_params;params_eff.data_request=[{''nb''},{''pinj''}];' ... 'gdat_tmp=gdat_d3d(shot,params_eff);gdat_tmp.units=''W'';' ... - 'gdat_tmp.data = 1e3.*gdat_tmp.data;gdat_tmp.label=''' mapping.label ''';' ... + 'gdat_tmp.data = 1e3.*gdat_tmp.data;gdat_tmp.label=''' mapping.label ''';' ... 'gdat_tmp.gdat_request=''' data_request ''';' ... 'gdat_tmp.data_smooth=interpos(gdat_tmp.t,gdat_tmp.data,-3e7);' ... 'gdat_tmp.data_smooth=max(0.,gdat_tmp.data_smooth);']; - case {'neint'} - mapping.timedim = 1; - mapping.label = 'line integrated el. density'; - mapping.method = 'signal'; - mapping.expression = {'d3d','\d3d::top.electrons.bci:denv1'}; - case {'neints'} - mapping.timedim = 1; - mapping.label = {'denv1','denv2','denv3'}; - mapping.method = 'expression'; - mapping.expression = ['params_eff = gdat_data.gdat_params;params_eff.data_request=''\d3d::top.electrons.bci:denv1'';' ... + case {'neint'} + mapping.timedim = 1; + mapping.label = 'line integrated el. density'; + mapping.method = 'signal'; + mapping.expression = {'d3d','\d3d::top.electrons.bci:denv1'}; + case {'neints'} + mapping.timedim = 1; + mapping.label = {'denv1','denv2','denv3'}; + mapping.method = 'expression'; + mapping.expression = ['params_eff = gdat_data.gdat_params;params_eff.data_request=''\d3d::top.electrons.bci:denv1'';' ... 'gdat_tmp=gdat_d3d(shot,params_eff);gdat_tmp.denv1=gdat_tmp;' ... 'params_eff.data_request=''\d3d::top.electrons.bci:denv2'';gdat_denv2=gdat_d3d(shot,params_eff);' ... 'gdat_tmp.denv2=gdat_denv2;gdat_tmp.data(:,2)=gdat_denv2.data;' ... @@ -207,26 +207,26 @@ switch lower(data_request) 'gdat_tmp.denv3=gdat_denv3;gdat_tmp.data(:,3)=gdat_denv3.data;' ... 'gdat_tmp.dim{2} = [1:3];gdat_tmp.dimunits{2} = {''denv1'',''denv2'',''denv3''};' ... ';gdat_tmp.dimunits{1}=''s'';']; - case 'nel' - mapping.timedim = 1; - mapping.label = 'NEBAR\_R0'; - mapping.method = 'signal'; - mapping.expression = [{'efit01'},{'\NEBAR_R0'}]; - case {'ne', 'ne_rho'} - mapping.timedim = 2; - mapping.label = 'ne'; - mapping.method = 'switchcase'; - case 'nete_rho' - mapping.timedim = 2; - mapping.label = 'ne and Te'; - mapping.method = 'switchcase'; - case 'ni' - mapping.method = 'switchcase'; % especially since might have option fit, etc - case {'ng','ngreenwald','n_greenwald'} - mapping.timedim = 1; - 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'';' ... + case 'nel' + mapping.timedim = 1; + mapping.label = 'NEBAR\_R0'; + mapping.method = 'signal'; + mapping.expression = [{'efit01'},{'\NEBAR_R0'}]; + case {'ne', 'ne_rho'} + mapping.timedim = 2; + mapping.label = 'ne'; + mapping.method = 'switchcase'; + case 'nete_rho' + mapping.timedim = 2; + mapping.label = 'ne and Te'; + mapping.method = 'switchcase'; + case 'ni' + mapping.method = 'switchcase'; % especially since might have option fit, etc + case {'ng','ngreenwald','n_greenwald'} + mapping.timedim = 1; + 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_d3d(shot,params_eff);params_eff.data_request=''ip'';' ... 'gdat_tmp2=gdat_d3d(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);' ... @@ -235,39 +235,39 @@ switch lower(data_request) '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;']; - 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'';' ... + 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_d3d(shot,params_eff);params_eff.data_request=''n_greenwald'';' ... 'gdat_tmp2=gdat_d3d(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*1e6./(tmp_data2+1e-5);' ... 'gdat_tmp.units='''';gdat_tmp.dimunits{1}=''s'';']; - case {'f2b', 'pcf2b'} - mapping.label = {'pcf2b','f2b'}'; - mapping.timedim = 1; - mapping.method = 'expression'; - mapping.expression = ['params_eff = gdat_data.gdat_params;params_eff.data_request=[{''d3d''},{''ptdata("pcf2b")''}];' ... + case {'f2b', 'pcf2b'} + mapping.label = {'pcf2b','f2b'}'; + mapping.timedim = 1; + mapping.method = 'expression'; + mapping.expression = ['params_eff = gdat_data.gdat_params;params_eff.data_request=[{''d3d''},{''ptdata("pcf2b")''}];' ... 'gdat_tmp=gdat_d3d(shot,params_eff);params_eff = gdat_data.gdat_params;' ... 'params_eff.data_request=[{''d3d''},{''ptdata("f2b")''}];gdat_tmp2=gdat_d3d(shot,params_eff);' ... - 'if ~isempty(gdat_tmp2.t); gdat_tmp.data(:,2) = interp1(gdat_tmp2.t,gdat_tmp2.data,gdat_tmp.t);else;' ... + 'if ~isempty(gdat_tmp2.t); gdat_tmp.data(:,2) = interp1(gdat_tmp2.t,gdat_tmp2.data,gdat_tmp.t);else;' ... 'gdat_tmp.data(:,2) = NaN(size(gdat_tmp.t)); end;' ... 'gdat_tmp.gdat_request=''' data_request ''';']; - case 'pgyro' - mapping.timedim = 1; - mapping.label = 'EC gyros'; - mapping.method = 'switchcase'; - case 'powers' - mapping.timedim = 1; - mapping.label = 'various powers'; - mapping.method = 'switchcase'; - case {'prad','prad_tot','rad','rad_tot'} - mapping.timedim = 1; - mapping.label = {'PRAD_divl','PRAD_divu','prad_core','tot-divL-divU','PRAD_TOT'}; - mapping.method = 'expression'; - mapping.expression = ['params_eff = gdat_data.gdat_params;params_eff.data_request={''bolom'',''PRAD_01.PRAD:PRAD_divl''};' ... + case 'pgyro' + mapping.timedim = 1; + mapping.label = 'EC gyros'; + mapping.method = 'switchcase'; + case 'powers' + mapping.timedim = 1; + mapping.label = 'various powers'; + mapping.method = 'switchcase'; + case {'prad','prad_tot','rad','rad_tot'} + mapping.timedim = 1; + mapping.label = {'PRAD_divl','PRAD_divu','prad_core','tot-divL-divU','PRAD_TOT'}; + mapping.method = 'expression'; + mapping.expression = ['params_eff = gdat_data.gdat_params;params_eff.data_request={''bolom'',''PRAD_01.PRAD:PRAD_divl''};' ... 'gdat_tmp=gdat_d3d(shot,params_eff);gdat_tmp.divl=gdat_tmp;' ... 'params_eff.data_request{2}=''PRAD_01.PRAD:PRAD_divu'';gdat_tmpU=gdat_d3d(shot,params_eff);' ... 'gdat_tmp.divu=gdat_tmpU;gdat_tmp.data(:,2)=gdat_tmpU.data;' ... @@ -278,175 +278,175 @@ switch lower(data_request) 'gdat_tmp.data(:,4) = gdat_tmp.data(:,5)-gdat_tmp.data(:,1)-gdat_tmp.data(:,2);' ... 'gdat_tmp.dim{2} = [1:5];gdat_tmp.dimunits{2} = {''divl'',''divu'',''core'',''tot-divl-divu'',''prad_tot''};' ... 'gdat_tmp.units=''W'';gdat_tmp.dimunits{1}=''s'';']; - case 'psi_axis' - mapping.timedim = 1; - mapping.label ='psi_\axis' ; - mapping.method = 'signal'; - mapping.expression = [{'EFIT01'},{'\ssimag'}]; - case 'psi_edge' - mapping.timedim = 1; - mapping.label = 'psi\_edge'; - mapping.method = 'signal'; - mapping.expression = [{'EFIT01'},{'\ssibry'}]; - case 'q0' - mapping.timedim = 1; - mapping.label = 'q_0'; - mapping.method = 'signal'; - mapping.expression = [{'EFIT01'},{'\q0'}]; - case 'qmin' - mapping.timedim = 1; - mapping.label = 'q_min'; - mapping.method = 'signal'; - mapping.expression = [{'EFIT01'},{'\qmin'}]; - case 'q95' - mapping.timedim = 1; - mapping.label = 'q_{95}'; - mapping.method = 'signal'; - mapping.expression = [{'EFIT01'},{'\q95'}]; - case 'q_edge' - mapping.timedim = 1; - mapping.label = 'q_{edge}}'; - mapping.method = 'signal'; - mapping.expression = [{'EFIT01'},{'\ql'}]; - case 'q_rho' - mapping.timedim = 2; - mapping.gdat_timedim = 2; - mapping.label = 'q'; - mapping.method = 'switchcase'; - case {'rot', 'cerqrot'} - mapping.timedim = 2; - mapping.label = 'cerqrot'; - mapping.method = 'switchcase'; - mapping.expression = ''; - case 'r0' - mapping.timedim = 1; - mapping.label = 'R_0'; - mapping.method = 'signal'; - mapping.expression = [{'EFIT01'},{'\rzero'}]; - case 'rgeom' - mapping.label = 'Rgeom'; - mapping.timedim = 1; - mapping.method = 'expression'; - mapping.expression = ['params_eff = gdat_data.gdat_params;params_eff.data_request=[{''EFIT01''},{''results.geqdsk:rbbbs''}];' ... + case 'psi_axis' + mapping.timedim = 1; + mapping.label ='psi_\axis' ; + mapping.method = 'signal'; + mapping.expression = [{'EFIT01'},{'\ssimag'}]; + case 'psi_edge' + mapping.timedim = 1; + mapping.label = 'psi\_edge'; + mapping.method = 'signal'; + mapping.expression = [{'EFIT01'},{'\ssibry'}]; + case 'q0' + mapping.timedim = 1; + mapping.label = 'q_0'; + mapping.method = 'signal'; + mapping.expression = [{'EFIT01'},{'\q0'}]; + case 'qmin' + mapping.timedim = 1; + mapping.label = 'q_min'; + mapping.method = 'signal'; + mapping.expression = [{'EFIT01'},{'\qmin'}]; + case 'q95' + mapping.timedim = 1; + mapping.label = 'q_{95}'; + mapping.method = 'signal'; + mapping.expression = [{'EFIT01'},{'\q95'}]; + case 'q_edge' + mapping.timedim = 1; + mapping.label = 'q_{edge}}'; + mapping.method = 'signal'; + mapping.expression = [{'EFIT01'},{'\ql'}]; + case 'q_rho' + mapping.timedim = 2; + mapping.gdat_timedim = 2; + mapping.label = 'q'; + mapping.method = 'switchcase'; + case {'rot', 'cerqrot'} + mapping.timedim = 2; + mapping.label = 'cerqrot'; + mapping.method = 'switchcase'; + mapping.expression = ''; + case 'r0' + mapping.timedim = 1; + mapping.label = 'R_0'; + mapping.method = 'signal'; + mapping.expression = [{'EFIT01'},{'\rzero'}]; + case 'rgeom' + mapping.label = 'Rgeom'; + mapping.timedim = 1; + mapping.method = 'expression'; + mapping.expression = ['params_eff = gdat_data.gdat_params;params_eff.data_request=[{''EFIT01''},{''results.geqdsk:rbbbs''}];' ... 'gdat_tmp2=gdat_d3d(shot,params_eff);params_eff = gdat_data.gdat_params;' ... 'params_eff.data_request=[{''EFIT01''},{''\zmaxis''}];gdat_tmp=gdat_d3d(shot,params_eff);' ... 'ij=find(gdat_tmp2.data==0);if (~isempty(ij));gdat_tmp2.data(ij)=NaN;end;' ... - 'gdat_tmp.data = 0.5.*(nanmax(gdat_tmp2.data'',[],2)+nanmin(gdat_tmp2.data'',[],2));gdat_tmp.label=''' mapping.label ''';' ... + 'gdat_tmp.data = 0.5.*(nanmax(gdat_tmp2.data'',[],2)+nanmin(gdat_tmp2.data'',[],2));gdat_tmp.label=''' mapping.label ''';' ... 'gdat_tmp.gdat_request=''' data_request ''';']; - case 'r_inboard' - mapping.label = 'R\_inboard'; - mapping.timedim = 1; - mapping.method = 'signal'; - mapping.expression = [{'FPG'},{'Rin'}]; - case 'r_outboard' - mapping.label = 'R\_outboard'; - mapping.timedim = 1; - mapping.method = 'signal'; - mapping.expression = [{'FPG'},{'Raus'},{'D3DD'}]; - case 'rhotor' - mapping.timedim = 2; - mapping.method = 'switchcase'; - mapping.label = 'rhotor'; - case 'rhotor_edge' - mapping.timedim = 1; - mapping.method = 'switchcase'; - mapping.label = 'rhotor\_edge'; - case 'rhotor_norm' - mapping.timedim = 1; - mapping.method = 'switchcase'; - mapping.label = 'rhotor\_norm'; - case 'rhovol' - mapping.timedim = 2; - mapping.label = 'rhovol\_norm'; - mapping.method = 'switchcase'; - case {'rmag', 'r_mag', 'r_axis'} - mapping.label = 'R\_magaxis'; - mapping.timedim = 1; - mapping.method = 'signal'; - mapping.expression = [{'EFIT01'},{'\rmaxis'}]; - case 'sxr' - mapping.timedim = 1; - mapping.gdat_timedim = 2; - mapping.method = 'switchcase'; - case 'tau_tot' - mapping.label = '\tau_{tot}'; - mapping.timedim = 1; - mapping.method = 'signal'; - mapping.expression = [{'TOT'},{'tau_tot'},{'D3DD'}]; - case {'te', 'te_rho'} - mapping.timedim = 2; - mapping.label = 'Te'; - mapping.method = 'switchcase'; - case 'ti' - mapping.label = 'Ti'; - mapping.method = 'switchcase'; - case 'vloop' - mapping.label = 'Vloop'; - mapping.timedim = 1; - mapping.method = 'signal'; - mapping.expression = [{'EFIT01'},{'\vloopmhd'}]; - case 'volume' - mapping.label = 'Volume'; - mapping.timedim = 1; - mapping.method = 'signal'; - mapping.expression = [{'EFIT01'},{'\volume'}]; - case 'volume_rho' - mapping.timedim = 2; - mapping.label = 'volume\_norm'; - mapping.method = 'switchcase'; - case 'wmhd' - mapping.label = 'Wmhd'; - mapping.timedim = 1; - mapping.method = 'signal'; - mapping.expression = [{'EFIT01'},{'\Wmhd'}]; - case 'zeff' - mapping.label = 'zeff from cxrs'; - mapping.timedim = 1; - mapping.method = 'signal'; - mapping.expression = [{'ZES'},{'Zeff'},{'D3DD'}]; - case 'zeff_cerq' - mapping.timedim = 2; - mapping.method = 'switchcase'; - case 'zgeom' - mapping.label = 'Zgeom'; - mapping.timedim = 1; - mapping.method = 'expression'; - mapping.expression = ['params_eff = gdat_data.gdat_params;params_eff.data_request=[{''EFIT01''},{''results.geqdsk:zbbbs''}];' ... + case 'r_inboard' + mapping.label = 'R\_inboard'; + mapping.timedim = 1; + mapping.method = 'signal'; + mapping.expression = [{'FPG'},{'Rin'}]; + case 'r_outboard' + mapping.label = 'R\_outboard'; + mapping.timedim = 1; + mapping.method = 'signal'; + mapping.expression = [{'FPG'},{'Raus'},{'D3DD'}]; + case 'rhotor' + mapping.timedim = 2; + mapping.method = 'switchcase'; + mapping.label = 'rhotor'; + case 'rhotor_edge' + mapping.timedim = 1; + mapping.method = 'switchcase'; + mapping.label = 'rhotor\_edge'; + case 'rhotor_norm' + mapping.timedim = 1; + mapping.method = 'switchcase'; + mapping.label = 'rhotor\_norm'; + case 'rhovol' + mapping.timedim = 2; + mapping.label = 'rhovol\_norm'; + mapping.method = 'switchcase'; + case {'rmag', 'r_mag', 'r_axis'} + mapping.label = 'R\_magaxis'; + mapping.timedim = 1; + mapping.method = 'signal'; + mapping.expression = [{'EFIT01'},{'\rmaxis'}]; + case 'sxr' + mapping.timedim = 1; + mapping.gdat_timedim = 2; + mapping.method = 'switchcase'; + case 'tau_tot' + mapping.label = '\tau_{tot}'; + mapping.timedim = 1; + mapping.method = 'signal'; + mapping.expression = [{'TOT'},{'tau_tot'},{'D3DD'}]; + case {'te', 'te_rho'} + mapping.timedim = 2; + mapping.label = 'Te'; + mapping.method = 'switchcase'; + case 'ti' + mapping.label = 'Ti'; + mapping.method = 'switchcase'; + case 'vloop' + mapping.label = 'Vloop'; + mapping.timedim = 1; + mapping.method = 'signal'; + mapping.expression = [{'EFIT01'},{'\vloopmhd'}]; + case 'volume' + mapping.label = 'Volume'; + mapping.timedim = 1; + mapping.method = 'signal'; + mapping.expression = [{'EFIT01'},{'\volume'}]; + case 'volume_rho' + mapping.timedim = 2; + mapping.label = 'volume\_norm'; + mapping.method = 'switchcase'; + case 'wmhd' + mapping.label = 'Wmhd'; + mapping.timedim = 1; + mapping.method = 'signal'; + mapping.expression = [{'EFIT01'},{'\Wmhd'}]; + case 'zeff' + mapping.label = 'zeff from cxrs'; + mapping.timedim = 1; + mapping.method = 'signal'; + mapping.expression = [{'ZES'},{'Zeff'},{'D3DD'}]; + case 'zeff_cerq' + mapping.timedim = 2; + mapping.method = 'switchcase'; + case 'zgeom' + mapping.label = 'Zgeom'; + mapping.timedim = 1; + mapping.method = 'expression'; + mapping.expression = ['params_eff = gdat_data.gdat_params;params_eff.data_request=[{''EFIT01''},{''results.geqdsk:zbbbs''}];' ... 'gdat_tmp2=gdat_d3d(shot,params_eff);params_eff = gdat_data.gdat_params;' ... 'params_eff.data_request=[{''EFIT01''},{''\zmaxis''}];gdat_tmp=gdat_d3d(shot,params_eff);' ... 'ij=find(gdat_tmp2.data==0);if (~isempty(ij));gdat_tmp2.data(ij)=NaN;end;' ... - 'gdat_tmp.data = 0.5.*(nanmax(gdat_tmp2.data'',[],2)+nanmin(gdat_tmp2.data'',[],2));gdat_tmp.label=''' mapping.label ''';' ... + 'gdat_tmp.data = 0.5.*(nanmax(gdat_tmp2.data'',[],2)+nanmin(gdat_tmp2.data'',[],2));gdat_tmp.label=''' mapping.label ''';' ... 'gdat_tmp.gdat_request=''' data_request ''';']; - case 'zmag' - mapping.label = 'Z\_magaxis'; - mapping.timedim = 1; - mapping.method = 'signal'; - mapping.expression = [{'EFIT01'},{'\zmaxis'}]; - % - % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - % extra D3D cases (not necessarily in official data_request name list) - % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - % - case {'zxpt1', 'xpt'} - mapping.label = 'zxpt1'; - mapping.timedim = 1; - mapping.method = 'signal'; - mapping.expression = [{'EFIT01'},{'\zxpt1'}]; - case 'transp' - mapping.label = 'transp output'; - mapping.method = 'switchcase'; + case 'zmag' + mapping.label = 'Z\_magaxis'; + mapping.timedim = 1; + mapping.method = 'signal'; + mapping.expression = [{'EFIT01'},{'\zmaxis'}]; + % + % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + % extra D3D cases (not necessarily in official data_request name list) + % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + % + case {'zxpt1', 'xpt'} + mapping.label = 'zxpt1'; + mapping.timedim = 1; + mapping.method = 'signal'; + mapping.expression = [{'EFIT01'},{'\zxpt1'}]; + case 'transp' + mapping.label = 'transp output'; + mapping.method = 'switchcase'; - otherwise - mapping.label = data_request; - mapping.method = 'signal'; % assume a full tracename is given, so just try with tdi (could check there are some ":", etc...) - % pseudo point name: '\ptdata' given, or {'\ptdata'} add D3D as tree - if ischar(data_request) && strcmp(data_request(1),'\') - mapping.expression = {'d3d',data_request}; - else - mapping.expression = data_request; - end - + otherwise + mapping.label = data_request; + mapping.method = 'signal'; % assume a full tracename is given, so just try with tdi (could check there are some ":", etc...) + % pseudo point name: '\ptdata' given, or {'\ptdata'} add D3D as tree + if ischar(data_request) && strcmp(data_request(1),'\') + mapping.expression = {'d3d',data_request}; + else + mapping.expression = data_request; + end + end if isempty(mapping.gdat_timedim) diff --git a/matlab/D3D/gdat_d3d.m b/matlab/D3D/gdat_d3d.m index a4fe1657e61f1cc9f87a582c1f75707723aa8ab7..89596d87d6e5bbdd0dfa8bc6281957440e43fe17 100644 --- a/matlab/D3D/gdat_d3d.m +++ b/matlab/D3D/gdat_d3d.m @@ -359,260 +359,260 @@ elseif strcmp(mapping_for_d3d.method,'expression') %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% elseif strcmp(mapping_for_d3d.method,'switchcase') switch data_request_eff % not lower(...) since data_request_eff should be lower case already at this stage - case {'cxrs', 'cxrs_rho'} - % if 'fit' option is added: 'fit',1, then the fitted profiles are returned which means "_rho" is effectively called - if ~isfield(gdat_data.gdat_params,'fit') || isempty(gdat_data.gdat_params.fit) || ~isnumeric(gdat_data.gdat_params.fit) - gdat_data.gdat_params.fit = 0; - elseif gdat_data.gdat_params.fit==1 - data_request_eff = 'cxrs_rho'; - end - exp_name_eff = gdat_data.gdat_params.exp_name; - if ~isfield(gdat_data.gdat_params,'source') || isempty(gdat_data.gdat_params.source) || strcmp(upper(gdat_data.gdat_params.source),'CEZ') - gdat_data.gdat_params.source = 'CEZ'; - r_node = 'R_time'; - z_node = 'z_time'; - elseif strcmp(upper(gdat_data.gdat_params.source),'CMZ') - gdat_data.gdat_params.source = 'CMZ'; - r_node = 'R'; - z_node = 'z'; - else - warning(['source = ' gdat_data.gdat_params.source ' not expected with data_request= ' data_request_eff]); - return - end - diag_name = gdat_data.gdat_params.source; - % R, Z positions of measurements - try - [r_time]=sf2ab(diag_name,shot,r_node,'-exp',exp_name_eff); - catch ME_R_time - % assume no shotfile - getReport(ME_R_time,'basic'); - return - end - gdat_data.r = r_time.value{1}; - inotok=find(gdat_data.r<=0); - gdat_data.r(inotok) = NaN; - [z_time]=sf2ab(diag_name,shot,z_node,'-exp',exp_name_eff); - gdat_data.z = z_time.value{1}; - inotok=find(gdat_data.z<=0); - gdat_data.z(inotok) = NaN; - [time]=sf2tb(diag_name,shot,'time','-exp',exp_name_eff); - gdat_data.t = time.value; - gdat_data.dim{1} = {gdat_data.r , gdat_data.z}; - gdat_data.dimunits{1} = 'R, Z [m]'; - gdat_data.dim{2} = gdat_data.t; - gdat_data.dimunits{2} = 't [s]'; - gdat_data.x = gdat_data.dim{1}; - % vrot - [a,error_status]=rdaD3D_eff(shot,diag_name,'vrot',exp_name_eff); - if isempty(a.data) || isempty(a.t) || error_status>0 - if gdat_params.nverbose>=3; - a - disp(['with data_request= ' data_request_eff]) + case {'cxrs', 'cxrs_rho'} + % if 'fit' option is added: 'fit',1, then the fitted profiles are returned which means "_rho" is effectively called + if ~isfield(gdat_data.gdat_params,'fit') || isempty(gdat_data.gdat_params.fit) || ~isnumeric(gdat_data.gdat_params.fit) + gdat_data.gdat_params.fit = 0; + elseif gdat_data.gdat_params.fit==1 + data_request_eff = 'cxrs_rho'; end - end - gdat_data.vrot.data = a.data; - if any(strcmp(fieldnames(a),'units')); gdat_data.vrot.units=a.units; end - if any(strcmp(fieldnames(a),'name')); gdat_data.vrot.name=a.name; end - gdat_data.vrot.label = 'vrot_tor'; - [aerr,e]=rdaD3D_eff(shot,diag_name,'err_vrot',exp_name_eff); - gdat_data.vrot.error_bar = aerr.data; - % Ti - % [a,e]=rdaD3D_eff(shot,diag_name,'Ti',exp_name_eff); - % [aerr,e]=rdaD3D_eff(shot,diag_name,'err_Ti',exp_name_eff); - [a,e]=rdaD3D_eff(shot,diag_name,'Ti_c',exp_name_eff); - [aerr,e]=rdaD3D_eff(shot,diag_name,'err_Ti_c',exp_name_eff); - gdat_data.ti.data = a.data; - gdat_data.data = a.data; - gdat_data.label = [gdat_data.label '/Ti']; - if any(strcmp(fieldnames(a),'units')); gdat_data.ti.units=a.units; end - if any(strcmp(fieldnames(a),'units')); gdat_data.units=a.units; end - if any(strcmp(fieldnames(a),'name')); gdat_data.ti.name=a.name; end - gdat_data.ti.label = 'Ti_c'; - gdat_data.ti.error_bar = aerr.data; - gdat_data.error_bar = aerr.data; - gdat_data.data_fullpath=[exp_name_eff '/' diag_name '/' a.name ';vrot, Ti in data, {r;z} in .x']; - % - if strcmp(data_request_eff,'cxrs_rho') - params_equil = gdat_data.gdat_params; - params_equil.data_request = 'equil'; - [equil,params_equil,error_status] = gdat_d3d(shot,params_equil); - if error_status>0 - if gdat_params.nverbose>=3; disp(['problems with ' params_equil.data_request]); end - return + exp_name_eff = gdat_data.gdat_params.exp_name; + if ~isfield(gdat_data.gdat_params,'source') || isempty(gdat_data.gdat_params.source) || strcmp(upper(gdat_data.gdat_params.source),'CEZ') + gdat_data.gdat_params.source = 'CEZ'; + r_node = 'R_time'; + z_node = 'z_time'; + elseif strcmp(upper(gdat_data.gdat_params.source),'CMZ') + gdat_data.gdat_params.source = 'CMZ'; + r_node = 'R'; + z_node = 'z'; + else + warning(['source = ' gdat_data.gdat_params.source ' not expected with data_request= ' data_request_eff]); + return end - gdat_data.gdat_params.equil = params_equil.equil; - gdat_data.equil = equil; - inb_chord_cxrs=size(gdat_data.data,1); - inb_time_cxrs=size(gdat_data.data,2); - psi_out = NaN*ones(inb_chord_cxrs,inb_time_cxrs); - rhopolnorm_out = NaN*ones(inb_chord_cxrs,inb_time_cxrs); - rhotornorm_out = NaN*ones(inb_chord_cxrs,inb_time_cxrs); - rhovolnorm_out = NaN*ones(inb_chord_cxrs,inb_time_cxrs); - % constructs intervals within which a given equil is used: [time_equil(i),time_equil(i+1)] - time_equil=[min(gdat_data.t(1)-0.1,equil.t(1)-0.1) 0.5.*(equil.t(1:end-1)+equil.t(2:end)) max(equil.t(end)+0.1,gdat_data.t(end)+0.1)]; - iok=find(~isnan(gdat_data.r(:,1))); - for itequil=1:length(time_equil)-1 - rr=equil.Rmesh(:,itequil); - zz=equil.Zmesh(:,itequil); - psirz_in = equil.psi2D(:,:,itequil); - it_cxrs_inequil = find(gdat_data.t>time_equil(itequil) & gdat_data.t<=time_equil(itequil+1)); - if ~isempty(it_cxrs_inequil) - if strcmp(upper(gdat_data.gdat_params.source),'CEZ') - rout=gdat_data.r(iok,it_cxrs_inequil); - zout=gdat_data.z(iok,it_cxrs_inequil); - else - rout=gdat_data.r(iok); - zout=gdat_data.z(iok); - end - psi_at_routzout = interpos2Dcartesian(rr,zz,psirz_in,rout,zout); - if strcmp(upper(gdat_data.gdat_params.source),'CEZ') - psi_out(iok,it_cxrs_inequil) = reshape(psi_at_routzout,length(iok),length(it_cxrs_inequil)); - else - psi_out(iok,it_cxrs_inequil) = repmat(psi_at_routzout,[1,length(it_cxrs_inequil)]); - end - rhopolnorm_out(iok,it_cxrs_inequil) = sqrt((psi_out(iok,it_cxrs_inequil)-equil.psi_axis(itequil))./(equil.psi_lcfs(itequil)-equil.psi_axis(itequil))); - for it_cx=1:length(it_cxrs_inequil) - rhotornorm_out(iok,it_cxrs_inequil(it_cx)) = interpos(equil.rhopolnorm(:,itequil),equil.rhotornorm(:,itequil),rhopolnorm_out(iok,it_cxrs_inequil(it_cx)),-3,[2 2],[0 1]); - rhovolnorm_out(iok,it_cxrs_inequil(it_cx)) = interpos(equil.rhopolnorm(:,itequil),equil.rhovolnorm(:,itequil),rhopolnorm_out(iok,it_cxrs_inequil(it_cx)),-3,[2 2],[0 1]); - end - end - end - gdat_data.psi = psi_out; - gdat_data.rhopolnorm = rhopolnorm_out; - gdat_data.rhotornorm = rhotornorm_out; - gdat_data.rhovolnorm = rhovolnorm_out; - % defaults for fits, so user always gets std structure - gdat_data.fit.rhotornorm = []; % same for both ti and vrot - gdat_data.fit.rhopolnorm = []; - gdat_data.fit.t = []; - gdat_data.fit.ti.data = []; - gdat_data.fit.ti.drhotornorm = []; - gdat_data.fit.vrot.data = []; - gdat_data.fit.vrot.drhotornorm = []; - gdat_data.fit.raw.rhotornorm = []; - gdat_data.fit.raw.ti.data = []; - gdat_data.fit.raw.vrot.data = []; - fit_tension_default = -1; - if isfield(gdat_data.gdat_params,'fit_tension') - fit_tension = gdat_data.gdat_params.fit_tension; + diag_name = gdat_data.gdat_params.source; + % R, Z positions of measurements + try + [r_time]=sf2ab(diag_name,shot,r_node,'-exp',exp_name_eff); + catch ME_R_time + % assume no shotfile + getReport(ME_R_time,'basic'); + return + end + gdat_data.r = r_time.value{1}; + inotok=find(gdat_data.r<=0); + gdat_data.r(inotok) = NaN; + [z_time]=sf2ab(diag_name,shot,z_node,'-exp',exp_name_eff); + gdat_data.z = z_time.value{1}; + inotok=find(gdat_data.z<=0); + gdat_data.z(inotok) = NaN; + [time]=sf2tb(diag_name,shot,'time','-exp',exp_name_eff); + gdat_data.t = time.value; + gdat_data.dim{1} = {gdat_data.r , gdat_data.z}; + gdat_data.dimunits{1} = 'R, Z [m]'; + gdat_data.dim{2} = gdat_data.t; + gdat_data.dimunits{2} = 't [s]'; + gdat_data.x = gdat_data.dim{1}; + % vrot + [a,error_status]=rdaD3D_eff(shot,diag_name,'vrot',exp_name_eff); + if isempty(a.data) || isempty(a.t) || error_status>0 + if gdat_params.nverbose>=3; + a + disp(['with data_request= ' data_request_eff]) + end + end + gdat_data.vrot.data = a.data; + if any(strcmp(fieldnames(a),'units')); gdat_data.vrot.units=a.units; end + if any(strcmp(fieldnames(a),'name')); gdat_data.vrot.name=a.name; end + gdat_data.vrot.label = 'vrot_tor'; + [aerr,e]=rdaD3D_eff(shot,diag_name,'err_vrot',exp_name_eff); + gdat_data.vrot.error_bar = aerr.data; + % Ti + % [a,e]=rdaD3D_eff(shot,diag_name,'Ti',exp_name_eff); + % [aerr,e]=rdaD3D_eff(shot,diag_name,'err_Ti',exp_name_eff); + [a,e]=rdaD3D_eff(shot,diag_name,'Ti_c',exp_name_eff); + [aerr,e]=rdaD3D_eff(shot,diag_name,'err_Ti_c',exp_name_eff); + gdat_data.ti.data = a.data; + gdat_data.data = a.data; + gdat_data.label = [gdat_data.label '/Ti']; + if any(strcmp(fieldnames(a),'units')); gdat_data.ti.units=a.units; end + if any(strcmp(fieldnames(a),'units')); gdat_data.units=a.units; end + if any(strcmp(fieldnames(a),'name')); gdat_data.ti.name=a.name; end + gdat_data.ti.label = 'Ti_c'; + gdat_data.ti.error_bar = aerr.data; + gdat_data.error_bar = aerr.data; + gdat_data.data_fullpath=[exp_name_eff '/' diag_name '/' a.name ';vrot, Ti in data, {r;z} in .x']; + % + if strcmp(data_request_eff,'cxrs_rho') + params_equil = gdat_data.gdat_params; + params_equil.data_request = 'equil'; + [equil,params_equil,error_status] = gdat_d3d(shot,params_equil); + if error_status>0 + if gdat_params.nverbose>=3; disp(['problems with ' params_equil.data_request]); end + return + end + gdat_data.gdat_params.equil = params_equil.equil; + gdat_data.equil = equil; + inb_chord_cxrs=size(gdat_data.data,1); + inb_time_cxrs=size(gdat_data.data,2); + psi_out = NaN*ones(inb_chord_cxrs,inb_time_cxrs); + rhopolnorm_out = NaN*ones(inb_chord_cxrs,inb_time_cxrs); + rhotornorm_out = NaN*ones(inb_chord_cxrs,inb_time_cxrs); + rhovolnorm_out = NaN*ones(inb_chord_cxrs,inb_time_cxrs); + % constructs intervals within which a given equil is used: [time_equil(i),time_equil(i+1)] + time_equil=[min(gdat_data.t(1)-0.1,equil.t(1)-0.1) 0.5.*(equil.t(1:end-1)+equil.t(2:end)) max(equil.t(end)+0.1,gdat_data.t(end)+0.1)]; + iok=find(~isnan(gdat_data.r(:,1))); + for itequil=1:length(time_equil)-1 + rr=equil.Rmesh(:,itequil); + zz=equil.Zmesh(:,itequil); + psirz_in = equil.psi2D(:,:,itequil); + it_cxrs_inequil = find(gdat_data.t>time_equil(itequil) & gdat_data.t<=time_equil(itequil+1)); + if ~isempty(it_cxrs_inequil) + if strcmp(upper(gdat_data.gdat_params.source),'CEZ') + rout=gdat_data.r(iok,it_cxrs_inequil); + zout=gdat_data.z(iok,it_cxrs_inequil); + else + rout=gdat_data.r(iok); + zout=gdat_data.z(iok); + end + psi_at_routzout = interpos2Dcartesian(rr,zz,psirz_in,rout,zout); + if strcmp(upper(gdat_data.gdat_params.source),'CEZ') + psi_out(iok,it_cxrs_inequil) = reshape(psi_at_routzout,length(iok),length(it_cxrs_inequil)); + else + psi_out(iok,it_cxrs_inequil) = repmat(psi_at_routzout,[1,length(it_cxrs_inequil)]); + end + rhopolnorm_out(iok,it_cxrs_inequil) = sqrt((psi_out(iok,it_cxrs_inequil)-equil.psi_axis(itequil))./(equil.psi_lcfs(itequil)-equil.psi_axis(itequil))); + for it_cx=1:length(it_cxrs_inequil) + rhotornorm_out(iok,it_cxrs_inequil(it_cx)) = interpos(equil.rhopolnorm(:,itequil),equil.rhotornorm(:,itequil),rhopolnorm_out(iok,it_cxrs_inequil(it_cx)),-3,[2 2],[0 1]); + rhovolnorm_out(iok,it_cxrs_inequil(it_cx)) = interpos(equil.rhopolnorm(:,itequil),equil.rhovolnorm(:,itequil),rhopolnorm_out(iok,it_cxrs_inequil(it_cx)),-3,[2 2],[0 1]); + end + end + end + gdat_data.psi = psi_out; + gdat_data.rhopolnorm = rhopolnorm_out; + gdat_data.rhotornorm = rhotornorm_out; + gdat_data.rhovolnorm = rhovolnorm_out; + % defaults for fits, so user always gets std structure + gdat_data.fit.rhotornorm = []; % same for both ti and vrot + gdat_data.fit.rhopolnorm = []; + gdat_data.fit.t = []; + gdat_data.fit.ti.data = []; + gdat_data.fit.ti.drhotornorm = []; + gdat_data.fit.vrot.data = []; + gdat_data.fit.vrot.drhotornorm = []; + gdat_data.fit.raw.rhotornorm = []; + gdat_data.fit.raw.ti.data = []; + gdat_data.fit.raw.vrot.data = []; + fit_tension_default = -1; + if isfield(gdat_data.gdat_params,'fit_tension') + fit_tension = gdat_data.gdat_params.fit_tension; + else + fit_tension = fit_tension_default; + end + if ~isstruct(fit_tension) + fit_tension_eff.ti = fit_tension; + fit_tension_eff.vrot = fit_tension; + fit_tension = fit_tension_eff; + else + if ~isfield(fit_tension,'ti'); fit_tension.ti = fit_tension_default; end + if ~isfield(fit_tension,'vrot '); fit_tension.vrot = fit_tension_default; end + end + gdat_data.gdat_params.fit_tension = fit_tension; + if isfield(gdat_data.gdat_params,'fit_nb_rho_points') + fit_nb_rho_points = gdat_data.gdat_params.fit_nb_rho_points; + else + fit_nb_rho_points = 201; + end + gdat_data.gdat_params.fit_nb_rho_points = fit_nb_rho_points; + % + if gdat_data.gdat_params.fit==1 + % add fits + gdat_data.fit.raw.rhotornorm = NaN*ones(size(gdat_data.ti.data)); + gdat_data.fit.raw.ti.data = NaN*ones(size(gdat_data.ti.data)); + gdat_data.fit.raw.vrot.data = NaN*ones(size(gdat_data.vrot.data)); + rhotornormfit = linspace(0,1,fit_nb_rho_points)'; + gdat_data.fit.rhotornorm = rhotornormfit; + gdat_data.fit.t = gdat_data.t; + for it=1:length(gdat_data.t) + % make rhotor->rhopol transformation for each time since equilibrium might have changed + irhook=find(gdat_data.rhotornorm(:,it)>0 & gdat_data.rhotornorm(:,it)<1); % no need for ~isnan + [rhoeff isort]=sort(gdat_data.rhotornorm(irhook,it)); + gdat_data.fit.rhopolnorm(:,it)=interpos([0; rhoeff; 1],[0; gdat_data.rhopolnorm(irhook(isort),it); 1],rhotornormfit,-0.1,[2 2],[0 1]); + idata = find(gdat_data.ti.data(:,it)>0 & gdat_data.rhotornorm(:,it)<1.01); + if length(idata)>0 + gdat_data.fit.ti.raw.rhotornorm(idata,it) = gdat_data.rhotornorm(idata,it); + gdat_data.fit.ti.raw.data(idata,it) = gdat_data.ti.data(idata,it); + gdat_data.fit.ti.raw.error_bar(idata,it) = gdat_data.ti.error_bar(idata,it); + gdat_data.fit.vrot.raw.rhotornorm(idata,it) = gdat_data.rhotornorm(idata,it); + gdat_data.fit.vrot.raw.data(idata,it) = gdat_data.vrot.data(idata,it); + gdat_data.fit.vrot.raw.error_bar(idata,it) = gdat_data.vrot.error_bar(idata,it); + [rhoeff,irhoeff] = sort(gdat_data.rhotornorm(idata,it)); + rhoeff = [0; rhoeff]; + % they are some strange low error_bars, so remove these by max(Ti/error_bar)<=10; and changing it to large error bar + tieff = gdat_data.ti.data(idata(irhoeff),it); + ti_err_eff = gdat_data.ti.error_bar(idata(irhoeff),it); + ij=find(tieff./ti_err_eff>10.); + if ~isempty(ij); ti_err_eff(ij) = tieff(ij)./0.1; end + vroteff = gdat_data.vrot.data(idata(irhoeff),it); + vrot_err_eff = gdat_data.vrot.error_bar(idata(irhoeff),it); + ij=find(vroteff./vrot_err_eff>10.); + if ~isempty(ij); vrot_err_eff(ij) = vroteff(ij)./0.1; end + % + tieff = [tieff(1); tieff]; + ti_err_eff = [1e4; ti_err_eff]; + vroteff = [vroteff(1); vroteff]; + vrot_err_eff = [1e5; vrot_err_eff]; + [gdat_data.fit.ti.data(:,it), gdat_data.fit.ti.drhotornorm(:,it)] = interpos(rhoeff,tieff,rhotornormfit,fit_tension.ti,[1 0],[0 0],ti_err_eff); + [gdat_data.fit.vrot.data(:,it), gdat_data.fit.vrot.drhotornorm(:,it)] = interpos(rhoeff,vroteff,rhotornormfit,fit_tension.vrot,[1 0],[0 0],vrot_err_eff); + end + end + end + end + + %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + case {'ece', 'ece_rho'} + nth_points = 13; + if isfield(gdat_data.gdat_params,'nth_points') && ~isempty(gdat_data.gdat_params.nth_points) + nth_points = gdat_data.gdat_params.nth_points; else - fit_tension = fit_tension_default; + gdat_data.gdat_params.nth_points = nth_points; end - if ~isstruct(fit_tension) - fit_tension_eff.ti = fit_tension; - fit_tension_eff.vrot = fit_tension; - fit_tension = fit_tension_eff; + channels = -1; + if isfield(gdat_data.gdat_params,'channels') && ~isempty(gdat_data.gdat_params.channels) + channels = gdat_data.gdat_params.channels; + end + diag_name = 'ece'; + if nth_points>=10 + match_rz_to_time = 1; else - if ~isfield(fit_tension,'ti'); fit_tension.ti = fit_tension_default; end - if ~isfield(fit_tension,'vrot '); fit_tension.vrot = fit_tension_default; end + match_rz_to_time = 0; end - gdat_data.gdat_params.fit_tension = fit_tension; - if isfield(gdat_data.gdat_params,'fit_nb_rho_points') - fit_nb_rho_points = gdat_data.gdat_params.fit_nb_rho_points; + if isfield(gdat_data.gdat_params,'match_rz_to_time') && ~isempty(gdat_data.gdat_params.match_rz_to_time) + match_rz_to_time = gdat_data.gdat_params.match_rz_to_time; else - fit_nb_rho_points = 201; + gdat_data.gdat_params.match_rz_to_time = match_rz_to_time; + end + time_interval = [-Inf +Inf]; + if isfield(gdat_data.gdat_params,'time_interval') && ~isempty(gdat_data.gdat_params.time_interval) + time_interval = gdat_data.gdat_params.time_interval; + else + gdat_data.gdat_params.time_interval = time_interval; end - gdat_data.gdat_params.fit_nb_rho_points = fit_nb_rho_points; % - if gdat_data.gdat_params.fit==1 - % add fits - gdat_data.fit.raw.rhotornorm = NaN*ones(size(gdat_data.ti.data)); - gdat_data.fit.raw.ti.data = NaN*ones(size(gdat_data.ti.data)); - gdat_data.fit.raw.vrot.data = NaN*ones(size(gdat_data.vrot.data)); - rhotornormfit = linspace(0,1,fit_nb_rho_points)'; - gdat_data.fit.rhotornorm = rhotornormfit; - gdat_data.fit.t = gdat_data.t; - for it=1:length(gdat_data.t) - % make rhotor->rhopol transformation for each time since equilibrium might have changed - irhook=find(gdat_data.rhotornorm(:,it)>0 & gdat_data.rhotornorm(:,it)<1); % no need for ~isnan - [rhoeff isort]=sort(gdat_data.rhotornorm(irhook,it)); - gdat_data.fit.rhopolnorm(:,it)=interpos([0; rhoeff; 1],[0; gdat_data.rhopolnorm(irhook(isort),it); 1],rhotornormfit,-0.1,[2 2],[0 1]); - idata = find(gdat_data.ti.data(:,it)>0 & gdat_data.rhotornorm(:,it)<1.01); - if length(idata)>0 - gdat_data.fit.ti.raw.rhotornorm(idata,it) = gdat_data.rhotornorm(idata,it); - gdat_data.fit.ti.raw.data(idata,it) = gdat_data.ti.data(idata,it); - gdat_data.fit.ti.raw.error_bar(idata,it) = gdat_data.ti.error_bar(idata,it); - gdat_data.fit.vrot.raw.rhotornorm(idata,it) = gdat_data.rhotornorm(idata,it); - gdat_data.fit.vrot.raw.data(idata,it) = gdat_data.vrot.data(idata,it); - gdat_data.fit.vrot.raw.error_bar(idata,it) = gdat_data.vrot.error_bar(idata,it); - [rhoeff,irhoeff] = sort(gdat_data.rhotornorm(idata,it)); - rhoeff = [0; rhoeff]; - % they are some strange low error_bars, so remove these by max(Ti/error_bar)<=10; and changing it to large error bar - tieff = gdat_data.ti.data(idata(irhoeff),it); - ti_err_eff = gdat_data.ti.error_bar(idata(irhoeff),it); - ij=find(tieff./ti_err_eff>10.); - if ~isempty(ij); ti_err_eff(ij) = tieff(ij)./0.1; end - vroteff = gdat_data.vrot.data(idata(irhoeff),it); - vrot_err_eff = gdat_data.vrot.error_bar(idata(irhoeff),it); - ij=find(vroteff./vrot_err_eff>10.); - if ~isempty(ij); vrot_err_eff(ij) = vroteff(ij)./0.1; end - % - tieff = [tieff(1); tieff]; - ti_err_eff = [1e4; ti_err_eff]; - vroteff = [vroteff(1); vroteff]; - vrot_err_eff = [1e5; vrot_err_eff]; - [gdat_data.fit.ti.data(:,it), gdat_data.fit.ti.drhotornorm(:,it)] = interpos(rhoeff,tieff,rhotornormfit,fit_tension.ti,[1 0],[0 0],ti_err_eff); - [gdat_data.fit.vrot.data(:,it), gdat_data.fit.vrot.drhotornorm(:,it)] = interpos(rhoeff,vroteff,rhotornormfit,fit_tension.vrot,[1 0],[0 0],vrot_err_eff); - end - end + if channels(1)<=0 + channels = [1:40]; end - end - - %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - case {'ece', 'ece_rho'} - nth_points = 13; - if isfield(gdat_data.gdat_params,'nth_points') && ~isempty(gdat_data.gdat_params.nth_points) - nth_points = gdat_data.gdat_params.nth_points; - else - gdat_data.gdat_params.nth_points = nth_points; - end - channels = -1; - if isfield(gdat_data.gdat_params,'channels') && ~isempty(gdat_data.gdat_params.channels) - channels = gdat_data.gdat_params.channels; - end - diag_name = 'ece'; - if nth_points>=10 - match_rz_to_time = 1; - else - match_rz_to_time = 0; - end - if isfield(gdat_data.gdat_params,'match_rz_to_time') && ~isempty(gdat_data.gdat_params.match_rz_to_time) - match_rz_to_time = gdat_data.gdat_params.match_rz_to_time; - else - gdat_data.gdat_params.match_rz_to_time = match_rz_to_time; - end - time_interval = [-Inf +Inf]; - if isfield(gdat_data.gdat_params,'time_interval') && ~isempty(gdat_data.gdat_params.time_interval) - time_interval = gdat_data.gdat_params.time_interval; - else - gdat_data.gdat_params.time_interval = time_interval; - end - % - if channels(1)<=0 - channels = [1:40]; - end - chanelles=sort(channels); - gdat_data.dim{1} = channels; - gdat_data.gdat_params.channels = channels; - for i=channels - a = gdat_d3d(shot,{'ece',['\tece' num2str(i,'%.2d')]}); - if nth_points>1 - gdat_data.data(i,:) = a.data(1:nth_points:end); - gdat_data.dim{2} = a.t(1:nth_points:end); - else - gdat_data.data(i,:) = a.data; - gdat_data.dim{2} = a.t; + chanelles=sort(channels); + gdat_data.dim{1} = channels; + gdat_data.gdat_params.channels = channels; + for i=channels + a = gdat_d3d(shot,{'ece',['\tece' num2str(i,'%.2d')]}); + if nth_points>1 + gdat_data.data(i,:) = a.data(1:nth_points:end); + gdat_data.dim{2} = a.t(1:nth_points:end); + else + gdat_data.data(i,:) = a.data; + gdat_data.dim{2} = a.t; + end end - end - gdat_data.x = gdat_data.dim{1}; - gdat_data.t = gdat_data.dim{2}; - gdat_data.dimunits=[{'channels'} ; {'time [s]'}]; - if any(strcmp(fieldnames(a),'units')); gdat_data.units=a.units; end + gdat_data.x = gdat_data.dim{1}; + gdat_data.t = gdat_data.dim{2}; + gdat_data.dimunits=[{'channels'} ; {'time [s]'}]; + if any(strcmp(fieldnames(a),'units')); gdat_data.units=a.units; end % $$$ if match_rz_to_time % $$$ % interpolate R structure on ece data time array, to ease plot vs R % $$$ for i=1:length(channels) -% $$$ radius.data(i,:) = interp1(aR.t,aR.data(channels(i),:),gdat_data.t); -% $$$ zheight.data(i,:) = interp1(aZ.t,aZ.data(channels(i),:),gdat_data.t); +% $$$ radius.data(i,:) = interp1(aR.t,aR.data(channels(i),:),gdat_data.t); +% $$$ zheight.data(i,:) = interp1(aZ.t,aZ.data(channels(i),:),gdat_data.t); % $$$ end % $$$ radiuszheight.t=gdat_data.t; % $$$ else @@ -620,12 +620,12 @@ elseif strcmp(mapping_for_d3d.method,'switchcase') % $$$ radiuszheight.t=aR.t; % $$$ zheight.data = aZ.data(channels,:); % $$$ end - ij=find(gdat_data.data<=0); - gdat_data.data(ij)=NaN; + ij=find(gdat_data.data<=0); + gdat_data.data(ij)=NaN; % $$$ gdat_data.rz.r=radius.data; % $$$ gdat_data.rz.z=zheight.data; % $$$ gdat_data.rz.t = radiuszheight.t; - gdat_data.data_fullpath = [diag_name '\tece' num2str(channels(1)) '...' num2str(channels(end))]; + gdat_data.data_fullpath = [diag_name '\tece' num2str(channels(1)) '...' num2str(channels(end))]; % $$$ gdat_data.rhos.psi = psi_out; % $$$ gdat_data.rhos.rhopolnorm = rhopolnorm_out; @@ -634,1208 +634,1208 @@ elseif strcmp(mapping_for_d3d.method,'switchcase') % $$$ gdat_data.rhos.t = gdat_data.rz.t; % $$$ end - %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - case {'eqdsk'} - % - time_eqdsks=2000.; % default time - if isfield(gdat_data.gdat_params,'time') && ~isempty(gdat_data.gdat_params.time) - time_eqdsks = gdat_data.gdat_params.time; - else - gdat_data.gdat_params.time = time_eqdsks; - disp(['"time" is expected as an option, choose default time = ' num2str(time_eqdsks)]); - end - if time_eqdsks < 10; - % assume given in seconds, d3d time is in ms - time_eqdsks = time_eqdsks * 1e3; - end - gdat_data.gdat_params.time = time_eqdsks; - gdat_data.t = time_eqdsks; - zshift = 0.; - if isfield(gdat_data.gdat_params,'zshift') && ~isempty(gdat_data.gdat_params.zshift) - zshift = gdat_data.gdat_params.zshift; - else - gdat_data.gdat_params.zshift = zshift; - end - gdat_data.gdat_params.zshift = zshift; - params_equil = gdat_data.gdat_params; - params_equil.data_request = 'equil'; - [equil,params_equil,error_status] = gdat_d3d(shot,params_equil); - if error_status>0 - if gdat_params.nverbose>=3; disp(['problems with ' params_equil.data_request]); end - return - end - gdat_data.gdat_params = params_equil; - gdat_data.equil = equil; - for itime=1:length(time_eqdsks) - time_eff = time_eqdsks(itime); - % use read_results updated to effectively obtain an eqdsk with sign correct with COCOS=2 - [eqdskD3D, equil_all_t, equil_t_index]=get_eqdsk_d3d(equil,time_eff,gdat_data.gdat_params.zshift,'source',gdat_data.gdat_params.equil); - eqdskD3D.fnamefull = fullfile(['/tmp/' getenv('USER')],['EQDSK_' num2str(shot) 't' num2str(time_eff,'%.4f')]); - cocos_out = equil.cocos; - if isfield(gdat_data.gdat_params,'cocos') && ~isempty(gdat_data.gdat_params.cocos) - cocos_out = gdat_data.gdat_params.cocos; + %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + case {'eqdsk'} + % + time_eqdsks=2000.; % default time + if isfield(gdat_data.gdat_params,'time') && ~isempty(gdat_data.gdat_params.time) + time_eqdsks = gdat_data.gdat_params.time; else - gdat_data.gdat_params.cocos = cocos_out; + gdat_data.gdat_params.time = time_eqdsks; + disp(['"time" is expected as an option, choose default time = ' num2str(time_eqdsks)]); end - if equil.cocos ~= cocos_out - [eqdsk_cocosout, eqdsk_cocosout_IpB0pos,cocos_inout]=eqdsk_cocos_transform(eqdskD3D,[equil.cocos cocos_out]); + if time_eqdsks < 10; + % assume given in seconds, d3d time is in ms + time_eqdsks = time_eqdsks * 1e3; + end + gdat_data.gdat_params.time = time_eqdsks; + gdat_data.t = time_eqdsks; + zshift = 0.; + if isfield(gdat_data.gdat_params,'zshift') && ~isempty(gdat_data.gdat_params.zshift) + zshift = gdat_data.gdat_params.zshift; else - eqdsk_cocosout = eqdskD3D; - end - % for several times, use array of structure for eqdsks, - % cannot use it for psi(R,Z) in .data and .x since R, Z might be different at different times, - % so project psi(R,Z) on Rmesh, Zmesh of 1st time - if length(time_eqdsks) > 1 - gdat_data.eqdsk{itime} = write_eqdsk(eqdskD3D.fnamefull,eqdsk_cocosout); - if itime==1 - gdat_data.data(:,:,itime) = gdat_data.eqdsk{itime}.psi; - gdat_data.dim{1} = gdat_data.eqdsk{itime}.rmesh; - gdat_data.dim{2} = gdat_data.eqdsk{itime}.zmesh; + gdat_data.gdat_params.zshift = zshift; + end + gdat_data.gdat_params.zshift = zshift; + params_equil = gdat_data.gdat_params; + params_equil.data_request = 'equil'; + [equil,params_equil,error_status] = gdat_d3d(shot,params_equil); + if error_status>0 + if gdat_params.nverbose>=3; disp(['problems with ' params_equil.data_request]); end + return + end + gdat_data.gdat_params = params_equil; + gdat_data.equil = equil; + for itime=1:length(time_eqdsks) + time_eff = time_eqdsks(itime); + % use read_results updated to effectively obtain an eqdsk with sign correct with COCOS=2 + [eqdskD3D, equil_all_t, equil_t_index]=get_eqdsk_d3d(equil,time_eff,gdat_data.gdat_params.zshift,'source',gdat_data.gdat_params.equil); + eqdskD3D.fnamefull = fullfile(['/tmp/' getenv('USER')],['EQDSK_' num2str(shot) 't' num2str(time_eff,'%.4f')]); + cocos_out = equil.cocos; + if isfield(gdat_data.gdat_params,'cocos') && ~isempty(gdat_data.gdat_params.cocos) + cocos_out = gdat_data.gdat_params.cocos; else - xx=repmat(reshape(gdat_data.dim{1},length(gdat_data.dim{1}),1),1,size(gdat_data.eqdsk{itime}.psi,2)); - yy=repmat(reshape(gdat_data.dim{2},1,length(gdat_data.dim{2})),size(gdat_data.eqdsk{itime}.psi,1),1); - aa = interpos2Dcartesian(gdat_data.eqdsk{itime}.rmesh,gdat_data.eqdsk{itime}.zmesh ... - ,gdat_data.eqdsk{itime}.psi,xx,yy,-1,-1); - gdat_data.data(:,:,itime) = aa; + gdat_data.gdat_params.cocos = cocos_out; + end + if equil.cocos ~= cocos_out + [eqdsk_cocosout, eqdsk_cocosout_IpB0pos,cocos_inout]=eqdsk_cocos_transform(eqdskD3D,[equil.cocos cocos_out]); + else + eqdsk_cocosout = eqdskD3D; + end + % for several times, use array of structure for eqdsks, + % cannot use it for psi(R,Z) in .data and .x since R, Z might be different at different times, + % so project psi(R,Z) on Rmesh, Zmesh of 1st time + if length(time_eqdsks) > 1 + gdat_data.eqdsk{itime} = write_eqdsk(eqdskD3D.fnamefull,eqdsk_cocosout); + if itime==1 + gdat_data.data(:,:,itime) = gdat_data.eqdsk{itime}.psi; + gdat_data.dim{1} = gdat_data.eqdsk{itime}.rmesh; + gdat_data.dim{2} = gdat_data.eqdsk{itime}.zmesh; + else + xx=repmat(reshape(gdat_data.dim{1},length(gdat_data.dim{1}),1),1,size(gdat_data.eqdsk{itime}.psi,2)); + yy=repmat(reshape(gdat_data.dim{2},1,length(gdat_data.dim{2})),size(gdat_data.eqdsk{itime}.psi,1),1); + aa = interpos2Dcartesian(gdat_data.eqdsk{itime}.rmesh,gdat_data.eqdsk{itime}.zmesh ... + ,gdat_data.eqdsk{itime}.psi,xx,yy,-1,-1); + gdat_data.data(:,:,itime) = aa; + end + else + gdat_data.eqdsk = write_eqdsk(eqdskD3D.fnamefull,eqdsk_cocosout); + gdat_data.data = gdat_data.eqdsk.psi; + gdat_data.dim{1} = gdat_data.eqdsk.rmesh; + gdat_data.dim{2} = gdat_data.eqdsk.zmesh; end - else - gdat_data.eqdsk = write_eqdsk(eqdskD3D.fnamefull,eqdsk_cocosout); - gdat_data.data = gdat_data.eqdsk.psi; - gdat_data.dim{1} = gdat_data.eqdsk.rmesh; - gdat_data.dim{2} = gdat_data.eqdsk.zmesh; end - end - gdat_data.dim{3} = gdat_data.t; - gdat_data.x = gdat_data.dim(1:2); - gdat_data.data_fullpath=['psi(R,Z) and eqdsk from geteqdskD3D with ' gdat_data.gdat_params.equil ' ;zshift=' num2str(zshift)]; - gdat_data.units = 'T m^2'; - gdat_data.dimunits = {'m','m','s'}; - gdat_data.request_description = ['data=psi, x=(R,Z), eqdsk contains eqdsk structure with which ' ... + gdat_data.dim{3} = gdat_data.t; + gdat_data.x = gdat_data.dim(1:2); + gdat_data.data_fullpath=['psi(R,Z) and eqdsk from geteqdskD3D with ' gdat_data.gdat_params.equil ' ;zshift=' num2str(zshift)]; + gdat_data.units = 'T m^2'; + gdat_data.dimunits = {'m','m','s'}; + gdat_data.request_description = ['data=psi, x=(R,Z), eqdsk contains eqdsk structure with which ' ... 'plot_eqdsk, write_eqdsk, read_eqdsk can be used']; - %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - case {'equil'} - if ~isfield(gdat_data.gdat_params,'equil') || isempty(gdat_data.gdat_params.equil) || ~ischar(gdat_data.gdat_params.equil) - gdat_data.gdat_params.equil = 'efit03'; - else - end - if exist('read_mds_eq_func')<=0 - if gdat_params.nverbose>=3; disp(['addpath(''/m/GAtools/matlab/efit'',''end'') since needs function read_mds_eq_func']); end - addpath('/m/GAtools/matlab/efit','end'); - end - [equil_all_t,neq,eq,ier]=read_mds_eq_func(shot,gdat_data.gdat_params.equil,'d3d'); - gdat_data.rhovolnorm = eq.results.geqdsk.rhovn; - gdat_data.equil_all_t = equil_all_t; - gdat_data.eq_raw = eq; - % extract main parameters, can add more later - gdat_data.phi = []; - gdat_data.rhotornorm = []; - gdat_data.t = equil_all_t.time; - for it=1:length(equil_all_t.time) - gdat_data.qvalue(:,it) = equil_all_t.gdata(it).qpsi; - gdat_data.psi(:,it) = (equil_all_t.gdata(it).ssibry - equil_all_t.gdata(it).ssimag) ... - .* linspace(0,1,equil_all_t.gdata(it).nw)' + equil_all_t.gdata(it).ssimag; - gdat_data.psi_axis(it)= equil_all_t.gdata(it).ssimag; - gdat_data.psi_lcfs(it)= equil_all_t.gdata(it).ssibry; - gdat_data.rhopolnorm(:,it) = sqrt(abs((gdat_data.psi(:,it)-gdat_data.psi_axis(it)) ./(gdat_data.psi_lcfs(it)-gdat_data.psi_axis(it)))); - gdat_data.rhopolnorm(end,it) = 1.; - gdat_data.vol(:,it)=gdat_data.rhovolnorm(:,it).^2 .* eq.results.aeqdsk.volume(it); - gdat_data.Rmesh(:,it) = eq.results.geqdsk.r; - gdat_data.Zmesh(:,it) = eq.results.geqdsk.z; - gdat_data.psi2D(:,:,it) = equil_all_t.gdata(it).psirz; - gdat_data.pressure(:,it) = equil_all_t.gdata(it).pres; - gdat_data.dpressuredpsi(:,it) = equil_all_t.gdata(it).pprime; % 2nd index are dV/dpsi - gdat_data.ffprime(:,it) = equil_all_t.gdata(it).ffprim; - gdat_data.rwall(:,it) = equil_all_t.gdata(it).xlim; - gdat_data.zwall(:,it) = equil_all_t.gdata(it).ylim; - if equil_all_t.adata(it).rxpt1 < -9.5 - gdat_data.R_Xpoints(:,it,1) = NaN; - else - gdat_data.R_Xpoints(:,it,1) = equil_all_t.adata(it).rxpt1; - end - if equil_all_t.adata(it).rxpt1 < -9.5 - gdat_data.Z_Xpoints(:,it,1) = NaN; + %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + case {'equil'} + if ~isfield(gdat_data.gdat_params,'equil') || isempty(gdat_data.gdat_params.equil) || ~ischar(gdat_data.gdat_params.equil) + gdat_data.gdat_params.equil = 'efit03'; else - gdat_data.Z_Xpoints(:,it,1) = equil_all_t.adata(it).zxpt1; end - if equil_all_t.adata(it).rxpt2 < -9.5 - gdat_data.R_Xpoints(:,it,2) = NaN; - else - gdat_data.R_Xpoints(:,it,2) = equil_all_t.adata(it).rxpt2; + if exist('read_mds_eq_func')<=0 + if gdat_params.nverbose>=3; disp(['addpath(''/m/GAtools/matlab/efit'',''end'') since needs function read_mds_eq_func']); end + addpath('/m/GAtools/matlab/efit','end'); end - if equil_all_t.adata(it).rxpt2 < -9.5 - gdat_data.Z_Xpoints(:,it,2) = NaN; - else - gdat_data.Z_Xpoints(:,it,2) = equil_all_t.adata(it).zxpt2; + [equil_all_t,neq,eq,ier]=read_mds_eq_func(shot,gdat_data.gdat_params.equil,'d3d'); + gdat_data.rhovolnorm = eq.results.geqdsk.rhovn; + gdat_data.equil_all_t = equil_all_t; + gdat_data.eq_raw = eq; + % extract main parameters, can add more later + gdat_data.phi = []; + gdat_data.rhotornorm = []; + gdat_data.t = equil_all_t.time; + for it=1:length(equil_all_t.time) + gdat_data.qvalue(:,it) = equil_all_t.gdata(it).qpsi; + gdat_data.psi(:,it) = (equil_all_t.gdata(it).ssibry - equil_all_t.gdata(it).ssimag) ... + .* linspace(0,1,equil_all_t.gdata(it).nw)' + equil_all_t.gdata(it).ssimag; + gdat_data.psi_axis(it)= equil_all_t.gdata(it).ssimag; + gdat_data.psi_lcfs(it)= equil_all_t.gdata(it).ssibry; + gdat_data.rhopolnorm(:,it) = sqrt(abs((gdat_data.psi(:,it)-gdat_data.psi_axis(it)) ./(gdat_data.psi_lcfs(it)-gdat_data.psi_axis(it)))); + gdat_data.rhopolnorm(end,it) = 1.; + gdat_data.vol(:,it)=gdat_data.rhovolnorm(:,it).^2 .* eq.results.aeqdsk.volume(it); + gdat_data.Rmesh(:,it) = eq.results.geqdsk.r; + gdat_data.Zmesh(:,it) = eq.results.geqdsk.z; + gdat_data.psi2D(:,:,it) = equil_all_t.gdata(it).psirz; + gdat_data.pressure(:,it) = equil_all_t.gdata(it).pres; + gdat_data.dpressuredpsi(:,it) = equil_all_t.gdata(it).pprime; % 2nd index are dV/dpsi + gdat_data.ffprime(:,it) = equil_all_t.gdata(it).ffprim; + gdat_data.rwall(:,it) = equil_all_t.gdata(it).xlim; + gdat_data.zwall(:,it) = equil_all_t.gdata(it).ylim; + if equil_all_t.adata(it).rxpt1 < -9.5 + gdat_data.R_Xpoints(:,it,1) = NaN; + else + gdat_data.R_Xpoints(:,it,1) = equil_all_t.adata(it).rxpt1; + end + if equil_all_t.adata(it).rxpt1 < -9.5 + gdat_data.Z_Xpoints(:,it,1) = NaN; + else + gdat_data.Z_Xpoints(:,it,1) = equil_all_t.adata(it).zxpt1; + end + if equil_all_t.adata(it).rxpt2 < -9.5 + gdat_data.R_Xpoints(:,it,2) = NaN; + else + gdat_data.R_Xpoints(:,it,2) = equil_all_t.adata(it).rxpt2; + end + if equil_all_t.adata(it).rxpt2 < -9.5 + gdat_data.Z_Xpoints(:,it,2) = NaN; + else + gdat_data.Z_Xpoints(:,it,2) = equil_all_t.adata(it).zxpt2; + end + % end + gdat_data.x = gdat_data.rhopolnorm; % - end - gdat_data.x = gdat_data.rhopolnorm; - % - gdat_data.ip = [equil_all_t.gdata(:).cpasma]; - % - gdat_data.data = gdat_data.qvalue; % put q in data - gdat_data.units='q'; % not applicable - gdat_data.data_fullpath = ... - ['q(:,time) in .data, all from [equil_all_t,neq,eq,ier]=read_mds_eq_func(shot,gdat_data.gdat_params.equil,''d3d'');']; - gdat_data.cocos = 2; - gdat_data.dim{1} = gdat_data.x; - gdat_data.dim{2} = gdat_data.t; - gdat_data.dimunits{1} = 'rhopolnorm'; - gdat_data.dimunits{2} = 'time [s]'; + gdat_data.ip = [equil_all_t.gdata(:).cpasma]; + % + gdat_data.data = gdat_data.qvalue; % put q in data + gdat_data.units='q'; % not applicable + gdat_data.data_fullpath = ... + ['q(:,time) in .data, all from [equil_all_t,neq,eq,ier]=read_mds_eq_func(shot,gdat_data.gdat_params.equil,''d3d'');']; + gdat_data.cocos = 2; + gdat_data.dim{1} = gdat_data.x; + gdat_data.dim{2} = gdat_data.t; + gdat_data.dimunits{1} = 'rhopolnorm'; + gdat_data.dimunits{2} = 'time [s]'; - %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - case {'ne','te'} - exp_name_eff = gdat_data.gdat_params.exp_name; - % ne or Te from Thomson data on raw z mesh vs (z,t) - if strcmp(data_request_eff,'te') - node_leaf = 'TEMP'; - else - node_leaf = 'DENSITY'; - end - % core - nodenameeff = ['TS.BLESSED.CORE:' node_leaf]; - a = gdat_d3d(shot,{'electrons',nodenameeff}); - if isempty(a.data) || isempty(a.t) - if gdat_params.nverbose>=3; - a - disp(['with data_request= ' data_request_eff]) + %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + case {'ne','te'} + exp_name_eff = gdat_data.gdat_params.exp_name; + % ne or Te from Thomson data on raw z mesh vs (z,t) + if strcmp(data_request_eff,'te') + node_leaf = 'TEMP'; + else + node_leaf = 'DENSITY'; end - return - end - gdat_data.t = a.t; - gdat_data.x = a.x; - gdat_data.gdat_params.tree = a.gdat_params.tree; - gdat_data.gdat_params.equil = a.gdat_params.equil; - if any(strcmp(fieldnames(a),'units')) - gdat_data.units=a.units; - end - gdat_data.core.data = a.data'; - gdat_data.core.t = a.t; - gdat_data.core.x = a.x; + % core + nodenameeff = ['TS.BLESSED.CORE:' node_leaf]; + a = gdat_d3d(shot,{'electrons',nodenameeff}); + if isempty(a.data) || isempty(a.t) + if gdat_params.nverbose>=3; + a + disp(['with data_request= ' data_request_eff]) + end + return + end + gdat_data.t = a.t; + gdat_data.x = a.x; + gdat_data.gdat_params.tree = a.gdat_params.tree; + gdat_data.gdat_params.equil = a.gdat_params.equil; + if any(strcmp(fieldnames(a),'units')) + gdat_data.units=a.units; + end + gdat_data.core.data = a.data'; + gdat_data.core.t = a.t; + gdat_data.core.x = a.x; % $$$ gdat_data.(lower(node_child_nameeff)).error_bar = max(aup.value-gdat_data.(lower(node_child_nameeff)).data,gdat_data.(lower(node_child_nameeff)).data-alow.value); % $$$ [a,error_status]=rdaD3D_eff(shot,'VTA','R_core',exp_name_eff); % $$$ gdat_data.(lower(node_child_nameeff)).r = repmat(a.data,size(gdat_data.(lower(node_child_nameeff)).data,1),1); % $$$ [a,error_status]=rdaD3D_eff(shot,'VTA','Z_core',exp_name_eff); - gdat_data.z = gdat_data.x; - gdat_data.data_fullpath=[data_request_eff 'from ' nodenameeff]; - nb_core = numel(gdat_data.x); - gdat_data.data = a.data'; % to get time as 2nd dim - % gdat_data.data(1:nb_core,:) = gdat_data.data(1:nb_core,:); - gdat_data.dim=[{gdat_data.z};{gdat_data.t}]; - gdat_data.dimunits=[{'Z [m]'}; {'time [s]'}]; + gdat_data.z = gdat_data.x; + gdat_data.data_fullpath=[data_request_eff 'from ' nodenameeff]; + nb_core = numel(gdat_data.x); + gdat_data.data = a.data'; % to get time as 2nd dim + % gdat_data.data(1:nb_core,:) = gdat_data.data(1:nb_core,:); + gdat_data.dim=[{gdat_data.z};{gdat_data.t}]; + gdat_data.dimunits=[{'Z [m]'}; {'time [s]'}]; % $$$ gdat_data.error_bar(1:nb_core,:) = gdat_data.error_bar(1:nb_core,:); - return - % add edge part - nodenameeff_e = [upper(data_request_eff(1)) 'e_e']; - node_child_nameeff_e = [upper(data_request_eff(1)) 'e_edge']; - [a,error_status]=rdaD3D_eff(shot,'VTA',nodenameeff_e,exp_name_eff); - gdat_data.(lower(node_child_nameeff_e)).data = a.data; - ij_edge_notok = find(a.data>5e21); - gdat_data.(lower(node_child_nameeff_e)).data(ij_edge_notok) = NaN; - gdat_data.(lower(node_child_nameeff_e)).t = a.t; - if ~isempty(a.data) - [a,error_status]=rdaD3D_eff(shot,'VTA','R_edge',exp_name_eff); - gdat_data.(lower(node_child_nameeff_e)).r = repmat(a.data,size(gdat_data.(lower(node_child_nameeff_e)).data,1),1); - [a,error_status]=rdaD3D_eff(shot,'VTA','Z_edge',exp_name_eff); - gdat_data.(lower(node_child_nameeff_e)).z = repmat(a.data',1,size(gdat_data.(lower(node_child_nameeff_e)).data,2)); - nb_edge = size(gdat_data.(lower(node_child_nameeff_e)).z,1); - iaaa=iround_os(gdat_data.(lower(node_child_nameeff_e)).t,gdat_data.(lower(node_child_nameeff)).t); - gdat_data.data(nb_core+1:nb_core+nb_edge,:) = gdat_data.(lower(node_child_nameeff_e)).data(1:nb_edge,iaaa); - gdat_data.dim{1}(nb_core+1:nb_core+nb_edge,:)=gdat_data.(lower(node_child_nameeff_e)).z(1:nb_edge,iaaa); - [alow,e]=rdaD3D_eff(shot,'VTA',[upper(data_request_eff(1)) 'elow_e'],exp_name_eff); - [aup,e]=rdaD3D_eff(shot,'VTA',[upper(data_request_eff(1)) 'eupp_e'],exp_name_eff); - gdat_data.(lower(node_child_nameeff_e)).error_bar = max(aup.value-gdat_data.(lower(node_child_nameeff_e)).data, ... - gdat_data.(lower(node_child_nameeff_e)).data-alow.value); - gdat_data.error_bar(nb_core+1:nb_core+nb_edge,:) = gdat_data.(lower(node_child_nameeff_e)).error_bar(1:nb_edge,iaaa); - else - gdat_data.(lower(node_child_nameeff_e)).data = []; - gdat_data.(lower(node_child_nameeff_e)).t = []; - gdat_data.(lower(node_child_nameeff_e)).error_bar = []; - gdat_data.(lower(node_child_nameeff_e)).r = []; - gdat_data.(lower(node_child_nameeff_e)).z = []; - end - gdat_data.x=gdat_data.dim{1}; - - %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - case {'ne_rho', 'te_rho', 'nete_rho'} - if ~isfield(gdat_data.gdat_params,'fit') || isempty(gdat_data.gdat_params.fit) || ~isnumeric(gdat_data.gdat_params.fit) - gdat_data.gdat_params.fit = 1; % default do fit - end - params_eff = gdat_data.gdat_params; - params_eff.data_request=data_request_eff(1:2); % start with ne if nete_rho - % get raw data - [gdat_data,params_kin,error_status]=gdat_d3d(shot,params_eff); - gdat_data.gdat_params.data_request=data_request_eff; - gdat_data.gdat_request=data_request_eff; - if error_status>0 - if gdat_params.nverbose>=3; disp(['problems with ' params_eff.data_request]); end return - end - % add rho coordinates - params_eff.data_request='equil'; - [equil,params_equil,error_status]=gdat_d3d(shot,params_eff); - if error_status>0 - if gdat_params.nverbose>=3; disp(['problems with ' params_eff.data_request]); end - return - end - gdat_data.gdat_params.equil = params_equil.equil; - %gdat_data.equil = equil; + % add edge part + nodenameeff_e = [upper(data_request_eff(1)) 'e_e']; + node_child_nameeff_e = [upper(data_request_eff(1)) 'e_edge']; + [a,error_status]=rdaD3D_eff(shot,'VTA',nodenameeff_e,exp_name_eff); + gdat_data.(lower(node_child_nameeff_e)).data = a.data; + ij_edge_notok = find(a.data>5e21); + gdat_data.(lower(node_child_nameeff_e)).data(ij_edge_notok) = NaN; + gdat_data.(lower(node_child_nameeff_e)).t = a.t; + if ~isempty(a.data) + [a,error_status]=rdaD3D_eff(shot,'VTA','R_edge',exp_name_eff); + gdat_data.(lower(node_child_nameeff_e)).r = repmat(a.data,size(gdat_data.(lower(node_child_nameeff_e)).data,1),1); + [a,error_status]=rdaD3D_eff(shot,'VTA','Z_edge',exp_name_eff); + gdat_data.(lower(node_child_nameeff_e)).z = repmat(a.data',1,size(gdat_data.(lower(node_child_nameeff_e)).data,2)); + nb_edge = size(gdat_data.(lower(node_child_nameeff_e)).z,1); + iaaa=iround_os(gdat_data.(lower(node_child_nameeff_e)).t,gdat_data.(lower(node_child_nameeff)).t); + gdat_data.data(nb_core+1:nb_core+nb_edge,:) = gdat_data.(lower(node_child_nameeff_e)).data(1:nb_edge,iaaa); + gdat_data.dim{1}(nb_core+1:nb_core+nb_edge,:)=gdat_data.(lower(node_child_nameeff_e)).z(1:nb_edge,iaaa); + [alow,e]=rdaD3D_eff(shot,'VTA',[upper(data_request_eff(1)) 'elow_e'],exp_name_eff); + [aup,e]=rdaD3D_eff(shot,'VTA',[upper(data_request_eff(1)) 'eupp_e'],exp_name_eff); + gdat_data.(lower(node_child_nameeff_e)).error_bar = max(aup.value-gdat_data.(lower(node_child_nameeff_e)).data, ... + gdat_data.(lower(node_child_nameeff_e)).data-alow.value); + gdat_data.error_bar(nb_core+1:nb_core+nb_edge,:) = gdat_data.(lower(node_child_nameeff_e)).error_bar(1:nb_edge,iaaa); + else + gdat_data.(lower(node_child_nameeff_e)).data = []; + gdat_data.(lower(node_child_nameeff_e)).t = []; + gdat_data.(lower(node_child_nameeff_e)).error_bar = []; + gdat_data.(lower(node_child_nameeff_e)).r = []; + gdat_data.(lower(node_child_nameeff_e)).z = []; + end + gdat_data.x=gdat_data.dim{1}; - % core - node_child_nameeff = [upper(data_request_eff(1)) 'e_core']; - inb_chord_core=size(gdat_data.(lower(node_child_nameeff)).r,1); - inb_time_core=size(gdat_data.(lower(node_child_nameeff)).r,2); - psi_out_core = NaN*ones(inb_chord_core,inb_time_core); - rhopolnorm_out_core = NaN*ones(inb_chord_core,inb_time_core); - rhotornorm_out_core = NaN*ones(inb_chord_core,inb_time_core); - rhovolnorm_out_core = NaN*ones(inb_chord_core,inb_time_core); - % edge - node_child_nameeff_e = [upper(data_request_eff(1)) 'e_edge']; - inb_chord_edge=size(gdat_data.(lower(node_child_nameeff_e)).r,1); - inb_time_edge=size(gdat_data.(lower(node_child_nameeff_e)).r,2); - psi_out_edge = NaN*ones(inb_chord_edge,inb_time_edge); - rhopolnorm_out_edge = NaN*ones(inb_chord_edge,inb_time_edge); - rhotornorm_out_edge = NaN*ones(inb_chord_edge,inb_time_edge); - rhovolnorm_out_edge = NaN*ones(inb_chord_edge,inb_time_edge); - % constructs intervals within which a given equil is used: [time_equil(i),time_equil(i+1)] - time_equil=[min(gdat_data.(lower(node_child_nameeff)).t(1)-0.1,equil.t(1)-0.1) 0.5.*(equil.t(1:end-1)+equil.t(2:end)) max(equil.t(end)+0.1,gdat_data.(lower(node_child_nameeff)).t(end)+0.1)]; - for itequil=1:length(time_equil)-1 - rr=equil.Rmesh(:,itequil); - zz=equil.Zmesh(:,itequil); - psirz_in = equil.psi2D(:,:,itequil); - it_core_inequil = find(gdat_data.(lower(node_child_nameeff)).t>time_equil(itequil) & gdat_data.(lower(node_child_nameeff)).t<=time_equil(itequil+1)); - if ~isempty(it_core_inequil) - rout_core=gdat_data.(lower(node_child_nameeff)).r(:,it_core_inequil); - zout_core=gdat_data.(lower(node_child_nameeff)).z(:,it_core_inequil); - psi_at_routzout = interpos2Dcartesian(rr,zz,psirz_in,rout_core,zout_core); - psi_out_core(:,it_core_inequil) = reshape(psi_at_routzout,inb_chord_core,length(it_core_inequil)); - rhopolnorm_out_core(:,it_core_inequil) = sqrt((psi_out_core(:,it_core_inequil)-equil.psi_axis(itequil))./(equil.psi_lcfs(itequil)-equil.psi_axis(itequil))); - for it_cx=1:length(it_core_inequil) - rhotornorm_out_core(:,it_core_inequil(it_cx)) = ... - interpos(equil.rhopolnorm(:,itequil),equil.rhotornorm(:,itequil),rhopolnorm_out_core(:,it_core_inequil(it_cx)),-3,[2 2],[0 1]); - rhovolnorm_out_core(:,it_core_inequil(it_cx)) = ... - interpos(equil.rhopolnorm(:,itequil),equil.rhovolnorm(:,itequil),rhopolnorm_out_core(:,it_core_inequil(it_cx)),-3,[2 2],[0 1]); - end + %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + case {'ne_rho', 'te_rho', 'nete_rho'} + if ~isfield(gdat_data.gdat_params,'fit') || isempty(gdat_data.gdat_params.fit) || ~isnumeric(gdat_data.gdat_params.fit) + gdat_data.gdat_params.fit = 1; % default do fit + end + params_eff = gdat_data.gdat_params; + params_eff.data_request=data_request_eff(1:2); % start with ne if nete_rho + % get raw data + [gdat_data,params_kin,error_status]=gdat_d3d(shot,params_eff); + gdat_data.gdat_params.data_request=data_request_eff; + gdat_data.gdat_request=data_request_eff; + if error_status>0 + if gdat_params.nverbose>=3; disp(['problems with ' params_eff.data_request]); end + return end + % add rho coordinates + params_eff.data_request='equil'; + [equil,params_equil,error_status]=gdat_d3d(shot,params_eff); + if error_status>0 + if gdat_params.nverbose>=3; disp(['problems with ' params_eff.data_request]); end + return + end + gdat_data.gdat_params.equil = params_equil.equil; + %gdat_data.equil = equil; + + % core + node_child_nameeff = [upper(data_request_eff(1)) 'e_core']; + inb_chord_core=size(gdat_data.(lower(node_child_nameeff)).r,1); + inb_time_core=size(gdat_data.(lower(node_child_nameeff)).r,2); + psi_out_core = NaN*ones(inb_chord_core,inb_time_core); + rhopolnorm_out_core = NaN*ones(inb_chord_core,inb_time_core); + rhotornorm_out_core = NaN*ones(inb_chord_core,inb_time_core); + rhovolnorm_out_core = NaN*ones(inb_chord_core,inb_time_core); % edge - it_edge_inequil = find(gdat_data.(lower(node_child_nameeff_e)).t>time_equil(itequil) & gdat_data.(lower(node_child_nameeff_e)).t<=time_equil(itequil+1)); - if ~isempty(it_edge_inequil) - rout_edge=gdat_data.(lower(node_child_nameeff_e)).r(:,it_edge_inequil); - zout_edge=gdat_data.(lower(node_child_nameeff_e)).z(:,it_edge_inequil); - psi_at_routzout = interpos2Dcartesian(rr,zz,psirz_in,rout_edge,zout_edge); - psi_out_edge(:,it_edge_inequil) = reshape(psi_at_routzout,inb_chord_edge,length(it_edge_inequil)); - rhopolnorm_out_edge(:,it_edge_inequil) = sqrt((psi_out_edge(:,it_edge_inequil)-equil.psi_axis(itequil))./(equil.psi_lcfs(itequil)-equil.psi_axis(itequil))); - for it_cx=1:length(it_edge_inequil) - rhotornorm_out_edge(:,it_edge_inequil(it_cx)) = ... - interpos(equil.rhopolnorm(:,itequil),equil.rhotornorm(:,itequil),rhopolnorm_out_edge(:,it_edge_inequil(it_cx)),-3,[2 2],[0 1]); - rhovolnorm_out_edge(:,it_edge_inequil(it_cx)) = ... - interpos(equil.rhopolnorm(:,itequil),equil.rhovolnorm(:,itequil),rhopolnorm_out_edge(:,it_edge_inequil(it_cx)),-3,[2 2],[0 1]); - end + node_child_nameeff_e = [upper(data_request_eff(1)) 'e_edge']; + inb_chord_edge=size(gdat_data.(lower(node_child_nameeff_e)).r,1); + inb_time_edge=size(gdat_data.(lower(node_child_nameeff_e)).r,2); + psi_out_edge = NaN*ones(inb_chord_edge,inb_time_edge); + rhopolnorm_out_edge = NaN*ones(inb_chord_edge,inb_time_edge); + rhotornorm_out_edge = NaN*ones(inb_chord_edge,inb_time_edge); + rhovolnorm_out_edge = NaN*ones(inb_chord_edge,inb_time_edge); + % constructs intervals within which a given equil is used: [time_equil(i),time_equil(i+1)] + time_equil=[min(gdat_data.(lower(node_child_nameeff)).t(1)-0.1,equil.t(1)-0.1) 0.5.*(equil.t(1:end-1)+equil.t(2:end)) max(equil.t(end)+0.1,gdat_data.(lower(node_child_nameeff)).t(end)+0.1)]; + for itequil=1:length(time_equil)-1 + rr=equil.Rmesh(:,itequil); + zz=equil.Zmesh(:,itequil); + psirz_in = equil.psi2D(:,:,itequil); + it_core_inequil = find(gdat_data.(lower(node_child_nameeff)).t>time_equil(itequil) & gdat_data.(lower(node_child_nameeff)).t<=time_equil(itequil+1)); + if ~isempty(it_core_inequil) + rout_core=gdat_data.(lower(node_child_nameeff)).r(:,it_core_inequil); + zout_core=gdat_data.(lower(node_child_nameeff)).z(:,it_core_inequil); + psi_at_routzout = interpos2Dcartesian(rr,zz,psirz_in,rout_core,zout_core); + psi_out_core(:,it_core_inequil) = reshape(psi_at_routzout,inb_chord_core,length(it_core_inequil)); + rhopolnorm_out_core(:,it_core_inequil) = sqrt((psi_out_core(:,it_core_inequil)-equil.psi_axis(itequil))./(equil.psi_lcfs(itequil)-equil.psi_axis(itequil))); + for it_cx=1:length(it_core_inequil) + rhotornorm_out_core(:,it_core_inequil(it_cx)) = ... + interpos(equil.rhopolnorm(:,itequil),equil.rhotornorm(:,itequil),rhopolnorm_out_core(:,it_core_inequil(it_cx)),-3,[2 2],[0 1]); + rhovolnorm_out_core(:,it_core_inequil(it_cx)) = ... + interpos(equil.rhopolnorm(:,itequil),equil.rhovolnorm(:,itequil),rhopolnorm_out_core(:,it_core_inequil(it_cx)),-3,[2 2],[0 1]); + end + end + % edge + it_edge_inequil = find(gdat_data.(lower(node_child_nameeff_e)).t>time_equil(itequil) & gdat_data.(lower(node_child_nameeff_e)).t<=time_equil(itequil+1)); + if ~isempty(it_edge_inequil) + rout_edge=gdat_data.(lower(node_child_nameeff_e)).r(:,it_edge_inequil); + zout_edge=gdat_data.(lower(node_child_nameeff_e)).z(:,it_edge_inequil); + psi_at_routzout = interpos2Dcartesian(rr,zz,psirz_in,rout_edge,zout_edge); + psi_out_edge(:,it_edge_inequil) = reshape(psi_at_routzout,inb_chord_edge,length(it_edge_inequil)); + rhopolnorm_out_edge(:,it_edge_inequil) = sqrt((psi_out_edge(:,it_edge_inequil)-equil.psi_axis(itequil))./(equil.psi_lcfs(itequil)-equil.psi_axis(itequil))); + for it_cx=1:length(it_edge_inequil) + rhotornorm_out_edge(:,it_edge_inequil(it_cx)) = ... + interpos(equil.rhopolnorm(:,itequil),equil.rhotornorm(:,itequil),rhopolnorm_out_edge(:,it_edge_inequil(it_cx)),-3,[2 2],[0 1]); + rhovolnorm_out_edge(:,it_edge_inequil(it_cx)) = ... + interpos(equil.rhopolnorm(:,itequil),equil.rhovolnorm(:,itequil),rhopolnorm_out_edge(:,it_edge_inequil(it_cx)),-3,[2 2],[0 1]); + end + end end - end - gdat_data.(lower(node_child_nameeff)).psi = psi_out_core; - gdat_data.(lower(node_child_nameeff)).rhopolnorm = rhopolnorm_out_core; - gdat_data.(lower(node_child_nameeff)).rhotornorm = rhotornorm_out_core; - gdat_data.(lower(node_child_nameeff)).rhovolnorm = rhovolnorm_out_core; - gdat_data.(lower(node_child_nameeff_e)).psi = psi_out_edge; - gdat_data.(lower(node_child_nameeff_e)).rhopolnorm = rhopolnorm_out_edge; - gdat_data.(lower(node_child_nameeff_e)).rhotornorm = rhotornorm_out_edge; - gdat_data.(lower(node_child_nameeff_e)).rhovolnorm = rhovolnorm_out_edge; - % put values of rhopolnorm for dim{1} by default, all radial mesh for combined core, edge in grids_1d - gdat_data.x = gdat_data.(lower(node_child_nameeff)).rhopolnorm; - iaaa=iround_os(gdat_data.(lower(node_child_nameeff_e)).t,gdat_data.(lower(node_child_nameeff)).t); - gdat_data.x(inb_chord_core+1:inb_chord_core+inb_chord_edge,:) = gdat_data.(lower(node_child_nameeff_e)).rhopolnorm(:,iaaa); - gdat_data.dim{1} = gdat_data.x; - gdat_data.dimunits{1} = 'rhopolnorm'; - gdat_data.grids_1d.rhopolnorm = gdat_data.x; - gdat_data.grids_1d.psi = gdat_data.(lower(node_child_nameeff)).psi; - gdat_data.grids_1d.psi(inb_chord_core+1:inb_chord_core+inb_chord_edge,:) = gdat_data.(lower(node_child_nameeff_e)).psi(:,iaaa); - gdat_data.grids_1d.rhotornorm = gdat_data.(lower(node_child_nameeff)).rhotornorm; - gdat_data.grids_1d.rhotornorm(inb_chord_core+1:inb_chord_core+inb_chord_edge,:) = gdat_data.(lower(node_child_nameeff_e)).rhotornorm(:,iaaa); - gdat_data.grids_1d.rhovolnorm = gdat_data.(lower(node_child_nameeff)).rhovolnorm; - gdat_data.grids_1d.rhovolnorm(inb_chord_core+1:inb_chord_core+inb_chord_edge,:) = gdat_data.(lower(node_child_nameeff_e)).rhovolnorm(:,iaaa); + gdat_data.(lower(node_child_nameeff)).psi = psi_out_core; + gdat_data.(lower(node_child_nameeff)).rhopolnorm = rhopolnorm_out_core; + gdat_data.(lower(node_child_nameeff)).rhotornorm = rhotornorm_out_core; + gdat_data.(lower(node_child_nameeff)).rhovolnorm = rhovolnorm_out_core; + gdat_data.(lower(node_child_nameeff_e)).psi = psi_out_edge; + gdat_data.(lower(node_child_nameeff_e)).rhopolnorm = rhopolnorm_out_edge; + gdat_data.(lower(node_child_nameeff_e)).rhotornorm = rhotornorm_out_edge; + gdat_data.(lower(node_child_nameeff_e)).rhovolnorm = rhovolnorm_out_edge; + % put values of rhopolnorm for dim{1} by default, all radial mesh for combined core, edge in grids_1d + gdat_data.x = gdat_data.(lower(node_child_nameeff)).rhopolnorm; + iaaa=iround_os(gdat_data.(lower(node_child_nameeff_e)).t,gdat_data.(lower(node_child_nameeff)).t); + gdat_data.x(inb_chord_core+1:inb_chord_core+inb_chord_edge,:) = gdat_data.(lower(node_child_nameeff_e)).rhopolnorm(:,iaaa); + gdat_data.dim{1} = gdat_data.x; + gdat_data.dimunits{1} = 'rhopolnorm'; + gdat_data.grids_1d.rhopolnorm = gdat_data.x; + gdat_data.grids_1d.psi = gdat_data.(lower(node_child_nameeff)).psi; + gdat_data.grids_1d.psi(inb_chord_core+1:inb_chord_core+inb_chord_edge,:) = gdat_data.(lower(node_child_nameeff_e)).psi(:,iaaa); + gdat_data.grids_1d.rhotornorm = gdat_data.(lower(node_child_nameeff)).rhotornorm; + gdat_data.grids_1d.rhotornorm(inb_chord_core+1:inb_chord_core+inb_chord_edge,:) = gdat_data.(lower(node_child_nameeff_e)).rhotornorm(:,iaaa); + gdat_data.grids_1d.rhovolnorm = gdat_data.(lower(node_child_nameeff)).rhovolnorm; + gdat_data.grids_1d.rhovolnorm(inb_chord_core+1:inb_chord_core+inb_chord_edge,:) = gdat_data.(lower(node_child_nameeff_e)).rhovolnorm(:,iaaa); - gdat_data.data_fullpath = [gdat_data.data_fullpath ' projected on equilibrium ' gdat_data.gdat_params.equil]; + gdat_data.data_fullpath = [gdat_data.data_fullpath ' projected on equilibrium ' gdat_data.gdat_params.equil]; - % if nete_rho, copy data as .ne, get .te and put pe=e ne Te in data: - gdat_data.(data_request_eff(1:2)).data = gdat_data.data; - gdat_data.(data_request_eff(1:2)).error_bar = gdat_data.error_bar; - gdat_data.(data_request_eff(1:2)).units = gdat_data.units; - gdat_data.(data_request_eff(1:2)).core = gdat_data.([data_request_eff(1:2) '_core']); - gdat_data.(data_request_eff(1:2)).edge = gdat_data.([data_request_eff(1:2) '_edge']); - gdat_data = rmfield(gdat_data,{[data_request_eff(1:2) '_core'],[data_request_eff(1:2) '_edge']}); - if strcmp(data_request_eff(1:4),'nete') - params_eff.data_request=data_request_eff(3:4); - [gdat_data_te,params_kin,error_status]=gdat_d3d(shot,params_eff); - gdat_data.te.data = gdat_data_te.data; - gdat_data.te.error_bar = gdat_data_te.error_bar; - gdat_data.te.units = gdat_data_te.units; - gdat_data.te.core = gdat_data_te.te_core; - gdat_data.te.edge = gdat_data_te.te_edge; - gdat_data.te.error_bar = gdat_data_te.error_bar; - gdat_data.te.core.psi = gdat_data.ne.core.psi; - gdat_data.te.core.rhopolnorm = gdat_data.ne.core.rhopolnorm; - gdat_data.te.core.rhotornorm = gdat_data.ne.core.rhotornorm; - gdat_data.te.core.rhovolnorm = gdat_data.ne.core.rhovolnorm; - gdat_data.te.edge.psi = gdat_data.ne.edge.psi; - gdat_data.te.edge.rhopolnorm = gdat_data.ne.edge.rhopolnorm; - gdat_data.te.edge.rhotornorm = gdat_data.ne.edge.rhotornorm; - gdat_data.te.edge.rhovolnorm = gdat_data.ne.edge.rhovolnorm; - % put pe in main gdat_data - gdat_data.data = 1.6022e-19.*gdat_data.ne.data.*gdat_data.te.data; - gdat_data.error_bar = 1.6022e-19 .* (gdat_data.ne.data .* gdat_data.te.error_bar ... + % if nete_rho, copy data as .ne, get .te and put pe=e ne Te in data: + gdat_data.(data_request_eff(1:2)).data = gdat_data.data; + gdat_data.(data_request_eff(1:2)).error_bar = gdat_data.error_bar; + gdat_data.(data_request_eff(1:2)).units = gdat_data.units; + gdat_data.(data_request_eff(1:2)).core = gdat_data.([data_request_eff(1:2) '_core']); + gdat_data.(data_request_eff(1:2)).edge = gdat_data.([data_request_eff(1:2) '_edge']); + gdat_data = rmfield(gdat_data,{[data_request_eff(1:2) '_core'],[data_request_eff(1:2) '_edge']}); + if strcmp(data_request_eff(1:4),'nete') + params_eff.data_request=data_request_eff(3:4); + [gdat_data_te,params_kin,error_status]=gdat_d3d(shot,params_eff); + gdat_data.te.data = gdat_data_te.data; + gdat_data.te.error_bar = gdat_data_te.error_bar; + gdat_data.te.units = gdat_data_te.units; + gdat_data.te.core = gdat_data_te.te_core; + gdat_data.te.edge = gdat_data_te.te_edge; + gdat_data.te.error_bar = gdat_data_te.error_bar; + gdat_data.te.core.psi = gdat_data.ne.core.psi; + gdat_data.te.core.rhopolnorm = gdat_data.ne.core.rhopolnorm; + gdat_data.te.core.rhotornorm = gdat_data.ne.core.rhotornorm; + gdat_data.te.core.rhovolnorm = gdat_data.ne.core.rhovolnorm; + gdat_data.te.edge.psi = gdat_data.ne.edge.psi; + gdat_data.te.edge.rhopolnorm = gdat_data.ne.edge.rhopolnorm; + gdat_data.te.edge.rhotornorm = gdat_data.ne.edge.rhotornorm; + gdat_data.te.edge.rhovolnorm = gdat_data.ne.edge.rhovolnorm; + % put pe in main gdat_data + gdat_data.data = 1.6022e-19.*gdat_data.ne.data.*gdat_data.te.data; + gdat_data.error_bar = 1.6022e-19 .* (gdat_data.ne.data .* gdat_data.te.error_bar ... + gdat_data.te.data .* gdat_data.ne.error_bar); - gdat_data.units='N/m^2; 1.6022e-19 ne Te'; - gdat_data.data_fullpath=['pe=1.6e-19*ne*Te in data, .ne, .te ' gdat_data.data_fullpath(3:end)]; - gdat_data.label = 'pe'; - end - - % defaults for fits, so user always gets std structure - gdat_data.fit.rhotornorm = []; % same for both ne and te - gdat_data.fit.rhopolnorm = []; - gdat_data.fit.t = []; - gdat_data.fit.te.data = []; - gdat_data.fit.te.drhotornorm = []; - gdat_data.fit.ne.data = []; - gdat_data.fit.ne.drhotornorm = []; - gdat_data.fit.raw.te.data = []; - gdat_data.fit.raw.te.rhotornorm = []; - gdat_data.fit.raw.ne.data = []; - gdat_data.fit.raw.ne.rhotornorm = []; - fit_tension_default = -0.1; - if isfield(gdat_data.gdat_params,'fit_tension') - fit_tension = gdat_data.gdat_params.fit_tension; - else - fit_tension = fit_tension_default; - end - if ~isstruct(fit_tension) - fit_tension_eff.te = fit_tension; - fit_tension_eff.ne = fit_tension; - fit_tension = fit_tension_eff; - else - if ~isfield(fit_tension,'te'); fit_tension.te = fit_tension_default; end - if ~isfield(fit_tension,'ne '); fit_tension.ne = fit_tension_default; end - end - gdat_data.gdat_params.fit_tension = fit_tension; - if isfield(gdat_data.gdat_params,'fit_nb_rho_points') - fit_nb_rho_points = gdat_data.gdat_params.fit_nb_rho_points; - else - fit_nb_rho_points = 201; - end - gdat_data.gdat_params.fit_nb_rho_points = fit_nb_rho_points; - % - if gdat_data.gdat_params.fit==1 - % add fits - gdat_data.fit.t = gdat_data.t; - rhotornormfit = linspace(0,1,fit_nb_rho_points)'; - gdat_data.fit.rhotornorm = rhotornormfit; - gdat_data.fit.rhopolnorm = NaN*ones(length(rhotornormfit),length(gdat_data.fit.t)); - if any(strfind(data_request_eff,'te')) - gdat_data.fit.raw.te.data = NaN*ones(size(gdat_data.te.data)); - gdat_data.fit.raw.te.error_bar = NaN*ones(size(gdat_data.te.data)); - gdat_data.fit.raw.te.rhotornorm = NaN*ones(size(gdat_data.te.data)); - gdat_data.fit.te.data = gdat_data.fit.rhopolnorm; - gdat_data.fit.te.drhotornorm = gdat_data.fit.rhopolnorm; - end - if any(strfind(data_request_eff,'ne')) - gdat_data.fit.raw.ne.data = NaN*ones(size(gdat_data.ne.data)); - gdat_data.fit.raw.ne.error_bar = NaN*ones(size(gdat_data.ne.data)); - gdat_data.fit.raw.ne.rhotornorm = NaN*ones(size(gdat_data.ne.data)); - gdat_data.fit.ne.data =gdat_data.fit.rhopolnorm; - gdat_data.fit.ne.drhotornorm = gdat_data.fit.rhopolnorm; - end - for it=1:length(gdat_data.t) - % make rhotor->rhopol transformation for each time since equilibrium might have changed - irhook=find(gdat_data.grids_1d.rhotornorm(:,it)>0 & gdat_data.grids_1d.rhotornorm(:,it)<1); % no need for ~isnan - [rhoeff isort]=sort(gdat_data.grids_1d.rhotornorm(irhook,it)); - gdat_data.fit.rhopolnorm(:,it)=interpos([0; rhoeff; 1],[0; gdat_data.grids_1d.rhopolnorm(irhook(isort),it); 1],rhotornormfit,-0.1,[2 2],[0 1]); - if any(strfind(data_request_eff,'te')) - idatate = find(gdat_data.te.data(:,it)>0 & gdat_data.grids_1d.rhotornorm(:,it)<=1.05); - if length(idatate)>0 - gdat_data.fit.raw.te.rhotornorm(idatate,it) = gdat_data.grids_1d.rhotornorm(idatate,it); - gdat_data.fit.raw.te.data(idatate,it) = gdat_data.te.data(idatate,it); - gdat_data.fit.raw.te.error_bar(idatate,it) = gdat_data.te.error_bar(idatate,it); - [rhoeff,irhoeff] = sort(gdat_data.grids_1d.rhotornorm(idatate,it)); - rhoeff = [0; rhoeff]; - teeff = gdat_data.te.data(idatate(irhoeff),it); - te_err_eff = gdat_data.te.error_bar(idatate(irhoeff),it); - % they are some strange low error_bars, so remove these by max(Te/error_bar)<=10; and changing it to large error bar - ij=find(teeff./te_err_eff>10.); - if ~isempty(ij); te_err_eff(ij) = teeff(ij)./0.1; end - % - teeff = [teeff(1); teeff]; - te_err_eff = [1e4; te_err_eff]; - [gdat_data.fit.te.data(:,it), gdat_data.fit.te.drhotornorm(:,it)] = interpos(rhoeff,teeff,rhotornormfit,fit_tension.te,[1 0],[0 0],te_err_eff); - end - end - if any(strfind(data_request_eff,'ne')) - idatane = find(gdat_data.ne.data(:,it)>0 & gdat_data.grids_1d.rhotornorm(:,it)<=1.05); - if length(idatane)>0 - gdat_data.fit.raw.ne.rhotornorm(idatane,it) = gdat_data.grids_1d.rhotornorm(idatane,it); - gdat_data.fit.raw.ne.data(idatane,it) = gdat_data.ne.data(idatane,it); - gdat_data.fit.raw.ne.error_bar(idatane,it) = gdat_data.ne.error_bar(idatane,it); - [rhoeff,irhoeff] = sort(gdat_data.grids_1d.rhotornorm(idatane,it)); - rhoeff = [0; rhoeff]; - % they are some strange low error_bars, so remove these by max(Te/error_bar)<=10; and changing it to large error bar - neeff = gdat_data.ne.data(idatane(irhoeff),it); - ne_err_eff = gdat_data.ne.error_bar(idatane(irhoeff),it); - ij=find(neeff./ne_err_eff>10.); - if ~isempty(ij); ne_err_eff(ij) = neeff(ij)./0.1; end - % - neeff = [neeff(1); neeff]; - ne_err_eff = [1e21; ne_err_eff]; - [gdat_data.fit.ne.data(:,it), gdat_data.fit.ne.drhotornorm(:,it)] = interpos(rhoeff,neeff,rhotornormfit,fit_tension.ne,[1 0],[0 0],ne_err_eff); - end - end + gdat_data.units='N/m^2; 1.6022e-19 ne Te'; + gdat_data.data_fullpath=['pe=1.6e-19*ne*Te in data, .ne, .te ' gdat_data.data_fullpath(3:end)]; + gdat_data.label = 'pe'; end - end - - %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - case {'pgyro'} - % LOAD MULTI CHANNEL DATA ECS - % powers, frequencies, etc - params_eff = gdat_data.gdat_params; - params_eff.data_request={'rf' '\echpwrc'}; -% $$$ gyro_names={'leia','luke','scarecrow','tinman','chewbacca','nasa'}; -% $$$ power_names={'ecleifpwrc','eclukfpwrc','ecscafpwrc','ectinfpwrc','ecchefpwrc','ecnasfpwrc'}; - gyro_names={'leia','luke','r2d2','yoda','han'}; - power_names={'ecleifpwrc','eclukfpwrc','ecr2dfpwrc','ecyodfpwrc','echanfpwrc'}; - % pgyro tot in index=length(gyro_names)+1 - try - gdat_data=gdat_d3d(shot,params_eff); - gdat_data.data_request = data_request_eff; - gdat_data.gdat_params.data_request = data_request_eff; - catch - if gdat_params.nverbose>=3; disp(['problems with ' params_eff.data_request]); end - gdat_data.data_request = data_request_eff; - return - end - nb_timepoints = length(gdat_data.t); - pgyro = NaN*ones(nb_timepoints,length(gyro_names)+1); - pgyro(:,length(gyro_names)+1) = reshape(gdat_data.data,nb_timepoints,1); - gdat_data.data = pgyro; - labels{length(gyro_names)+1} = 'ECtot'; - for i=1:length(gyro_names) - % "old" ECRH1 gyrotrons: gyro 1 to 4 in pgyro - params_eff.data_request={'rf',['ech.' gyro_names{i} ':' power_names{i}]}; - gdat_data_i=gdat_d3d(shot,params_eff); - if isempty(gdat_data_i.data) || isempty(gdat_data_i.dim) + % defaults for fits, so user always gets std structure + gdat_data.fit.rhotornorm = []; % same for both ne and te + gdat_data.fit.rhopolnorm = []; + gdat_data.fit.t = []; + gdat_data.fit.te.data = []; + gdat_data.fit.te.drhotornorm = []; + gdat_data.fit.ne.data = []; + gdat_data.fit.ne.drhotornorm = []; + gdat_data.fit.raw.te.data = []; + gdat_data.fit.raw.te.rhotornorm = []; + gdat_data.fit.raw.ne.data = []; + gdat_data.fit.raw.ne.rhotornorm = []; + fit_tension_default = -0.1; + if isfield(gdat_data.gdat_params,'fit_tension') + fit_tension = gdat_data.gdat_params.fit_tension; else - gdat_data.ec{i} = gdat_data_i; - gdat_data.data(:,i) = reshape(gdat_data_i.data,nb_timepoints,1); - gdat_data.dim = [{gdat_data_i.t} {[1:length(gyro_names)+1]}]; - if max(gdat_data_i.data) > 0. - % labels{i} = [gyro_names{i} ':' power_names{i}]; - labels{i} = [gyro_names{i}]; - end - end - try - params_eff.data_request={'rf',['ech.' gyro_names{i} ':ec' gyro_names{i}(1:3) 'polang']}; - a=gdat_d3d(shot,params_eff); - catch - % polang not present - a=[]; + fit_tension = fit_tension_default; end - if isempty(a) + if ~isstruct(fit_tension) + fit_tension_eff.te = fit_tension; + fit_tension_eff.ne = fit_tension; + fit_tension = fit_tension_eff; else - gdat_data.ec{i}.polang_t = a.t; - gdat_data.ec{i}.polang = a.data; - gdat_data.polang_ec{i} = a; + if ~isfield(fit_tension,'te'); fit_tension.te = fit_tension_default; end + if ~isfield(fit_tension,'ne '); fit_tension.ne = fit_tension_default; end end - try - params_eff.data_request={'rf',['ech.' gyro_names{i} ':ec' gyro_names{i}(1:3) 'polcnt']}; - a=gdat_d3d(shot,params_eff); - catch - a=[]; - end - if isempty(a) + gdat_data.gdat_params.fit_tension = fit_tension; + if isfield(gdat_data.gdat_params,'fit_nb_rho_points') + fit_nb_rho_points = gdat_data.gdat_params.fit_nb_rho_points; else - gdat_data.ec{i}.polcnt = a.data; - gdat_data.polcnt_ec{i} = a; + fit_nb_rho_points = 201; + end + gdat_data.gdat_params.fit_nb_rho_points = fit_nb_rho_points; + % + if gdat_data.gdat_params.fit==1 + % add fits + gdat_data.fit.t = gdat_data.t; + rhotornormfit = linspace(0,1,fit_nb_rho_points)'; + gdat_data.fit.rhotornorm = rhotornormfit; + gdat_data.fit.rhopolnorm = NaN*ones(length(rhotornormfit),length(gdat_data.fit.t)); + if any(strfind(data_request_eff,'te')) + gdat_data.fit.raw.te.data = NaN*ones(size(gdat_data.te.data)); + gdat_data.fit.raw.te.error_bar = NaN*ones(size(gdat_data.te.data)); + gdat_data.fit.raw.te.rhotornorm = NaN*ones(size(gdat_data.te.data)); + gdat_data.fit.te.data = gdat_data.fit.rhopolnorm; + gdat_data.fit.te.drhotornorm = gdat_data.fit.rhopolnorm; + end + if any(strfind(data_request_eff,'ne')) + gdat_data.fit.raw.ne.data = NaN*ones(size(gdat_data.ne.data)); + gdat_data.fit.raw.ne.error_bar = NaN*ones(size(gdat_data.ne.data)); + gdat_data.fit.raw.ne.rhotornorm = NaN*ones(size(gdat_data.ne.data)); + gdat_data.fit.ne.data =gdat_data.fit.rhopolnorm; + gdat_data.fit.ne.drhotornorm = gdat_data.fit.rhopolnorm; + end + for it=1:length(gdat_data.t) + % make rhotor->rhopol transformation for each time since equilibrium might have changed + irhook=find(gdat_data.grids_1d.rhotornorm(:,it)>0 & gdat_data.grids_1d.rhotornorm(:,it)<1); % no need for ~isnan + [rhoeff isort]=sort(gdat_data.grids_1d.rhotornorm(irhook,it)); + gdat_data.fit.rhopolnorm(:,it)=interpos([0; rhoeff; 1],[0; gdat_data.grids_1d.rhopolnorm(irhook(isort),it); 1],rhotornormfit,-0.1,[2 2],[0 1]); + if any(strfind(data_request_eff,'te')) + idatate = find(gdat_data.te.data(:,it)>0 & gdat_data.grids_1d.rhotornorm(:,it)<=1.05); + if length(idatate)>0 + gdat_data.fit.raw.te.rhotornorm(idatate,it) = gdat_data.grids_1d.rhotornorm(idatate,it); + gdat_data.fit.raw.te.data(idatate,it) = gdat_data.te.data(idatate,it); + gdat_data.fit.raw.te.error_bar(idatate,it) = gdat_data.te.error_bar(idatate,it); + [rhoeff,irhoeff] = sort(gdat_data.grids_1d.rhotornorm(idatate,it)); + rhoeff = [0; rhoeff]; + teeff = gdat_data.te.data(idatate(irhoeff),it); + te_err_eff = gdat_data.te.error_bar(idatate(irhoeff),it); + % they are some strange low error_bars, so remove these by max(Te/error_bar)<=10; and changing it to large error bar + ij=find(teeff./te_err_eff>10.); + if ~isempty(ij); te_err_eff(ij) = teeff(ij)./0.1; end + % + teeff = [teeff(1); teeff]; + te_err_eff = [1e4; te_err_eff]; + [gdat_data.fit.te.data(:,it), gdat_data.fit.te.drhotornorm(:,it)] = interpos(rhoeff,teeff,rhotornormfit,fit_tension.te,[1 0],[0 0],te_err_eff); + end + end + if any(strfind(data_request_eff,'ne')) + idatane = find(gdat_data.ne.data(:,it)>0 & gdat_data.grids_1d.rhotornorm(:,it)<=1.05); + if length(idatane)>0 + gdat_data.fit.raw.ne.rhotornorm(idatane,it) = gdat_data.grids_1d.rhotornorm(idatane,it); + gdat_data.fit.raw.ne.data(idatane,it) = gdat_data.ne.data(idatane,it); + gdat_data.fit.raw.ne.error_bar(idatane,it) = gdat_data.ne.error_bar(idatane,it); + [rhoeff,irhoeff] = sort(gdat_data.grids_1d.rhotornorm(idatane,it)); + rhoeff = [0; rhoeff]; + % they are some strange low error_bars, so remove these by max(Te/error_bar)<=10; and changing it to large error bar + neeff = gdat_data.ne.data(idatane(irhoeff),it); + ne_err_eff = gdat_data.ne.error_bar(idatane(irhoeff),it); + ij=find(neeff./ne_err_eff>10.); + if ~isempty(ij); ne_err_eff(ij) = neeff(ij)./0.1; end + % + neeff = [neeff(1); neeff]; + ne_err_eff = [1e21; ne_err_eff]; + [gdat_data.fit.ne.data(:,it), gdat_data.fit.ne.drhotornorm(:,it)] = interpos(rhoeff,neeff,rhotornormfit,fit_tension.ne,[1 0],[0 0],ne_err_eff); + end + end + end end + + + %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + case {'pgyro'} + % LOAD MULTI CHANNEL DATA ECS + % powers, frequencies, etc + params_eff = gdat_data.gdat_params; + params_eff.data_request={'rf' '\echpwrc'}; +% $$$ gyro_names={'leia','luke','scarecrow','tinman','chewbacca','nasa'}; +% $$$ power_names={'ecleifpwrc','eclukfpwrc','ecscafpwrc','ectinfpwrc','ecchefpwrc','ecnasfpwrc'}; + gyro_names={'leia','luke','r2d2','yoda','han'}; + power_names={'ecleifpwrc','eclukfpwrc','ecr2dfpwrc','ecyodfpwrc','echanfpwrc'}; + % pgyro tot in index=length(gyro_names)+1 try - params_eff.data_request={'rf',['ech.' gyro_names{i} ':ec' gyro_names{i}(1:3) 'torcnt']}; - a=gdat_d3d(shot,params_eff); + gdat_data=gdat_d3d(shot,params_eff); + gdat_data.data_request = data_request_eff; + gdat_data.gdat_params.data_request = data_request_eff; catch - a=[]; + if gdat_params.nverbose>=3; disp(['problems with ' params_eff.data_request]); end + gdat_data.data_request = data_request_eff; + return end - if isempty(a) + nb_timepoints = length(gdat_data.t); + pgyro = NaN*ones(nb_timepoints,length(gyro_names)+1); + pgyro(:,length(gyro_names)+1) = reshape(gdat_data.data,nb_timepoints,1); + gdat_data.data = pgyro; + labels{length(gyro_names)+1} = 'ECtot'; + for i=1:length(gyro_names) + % "old" ECRH1 gyrotrons: gyro 1 to 4 in pgyro + params_eff.data_request={'rf',['ech.' gyro_names{i} ':' power_names{i}]}; + gdat_data_i=gdat_d3d(shot,params_eff); + if isempty(gdat_data_i.data) || isempty(gdat_data_i.dim) + else + gdat_data.ec{i} = gdat_data_i; + gdat_data.data(:,i) = reshape(gdat_data_i.data,nb_timepoints,1); + gdat_data.dim = [{gdat_data_i.t} {[1:length(gyro_names)+1]}]; + if max(gdat_data_i.data) > 0. + % labels{i} = [gyro_names{i} ':' power_names{i}]; + labels{i} = [gyro_names{i}]; + end + end + try + params_eff.data_request={'rf',['ech.' gyro_names{i} ':ec' gyro_names{i}(1:3) 'polang']}; + a=gdat_d3d(shot,params_eff); + catch + % polang not present + a=[]; + end + if isempty(a) + else + gdat_data.ec{i}.polang_t = a.t; + gdat_data.ec{i}.polang = a.data; + gdat_data.polang_ec{i} = a; + end + try + params_eff.data_request={'rf',['ech.' gyro_names{i} ':ec' gyro_names{i}(1:3) 'polcnt']}; + a=gdat_d3d(shot,params_eff); + catch + a=[]; + end + if isempty(a) + else + gdat_data.ec{i}.polcnt = a.data; + gdat_data.polcnt_ec{i} = a; + end + try + params_eff.data_request={'rf',['ech.' gyro_names{i} ':ec' gyro_names{i}(1:3) 'torcnt']}; + a=gdat_d3d(shot,params_eff); + catch + a=[]; + end + if isempty(a) + else + gdat_data.ec{i}.torcnt = a.data; + gdat_data.torcnt_ec{i} = a; + end + end + gdat_data.gyro_names = gyro_names; + gdat_data.power_names = power_names; + % add ech on time_interval from total power>3% of max; + ij=find(gdat_data.data(:,end)>0.03.*max(gdat_data.data(:,end))); + if ~isempty(ij) + gdat_data.ec_t_on = [gdat_data.t(ij(1)) gdat_data.t(ij(end))]; else - gdat_data.ec{i}.torcnt = a.data; - gdat_data.torcnt_ec{i} = a; + gdat_data.ec_t_on = [0 0]; end - end - gdat_data.gyro_names = gyro_names; - gdat_data.power_names = power_names; - % add ech on time_interval from total power>3% of max; - ij=find(gdat_data.data(:,end)>0.03.*max(gdat_data.data(:,end))); - if ~isempty(ij) - gdat_data.ec_t_on = [gdat_data.t(ij(1)) gdat_data.t(ij(end))]; - else - gdat_data.ec_t_on = [0 0]; - end - if ~isempty(gdat_data.dim) - gdat_data.t = gdat_data.dim{1}; - gdat_data.x = gdat_data.dim{2}; - gdat_data.dimunits=[{'time [ms]'} gyro_names{:} {'ECtot'}]; - gdat_data.units='W'; - gdat_data.data_fullpath=['rf::ech.gyro_names:ec..pwrc']; - icount=0; - for i=1:length(labels) - if ~isempty(labels{i}) - icount=icount+1; - if icount==1 & ~iscell(gdat_data.label) - gdat_data = rmfield(gdat_data,'label'); + if ~isempty(gdat_data.dim) + gdat_data.t = gdat_data.dim{1}; + gdat_data.x = gdat_data.dim{2}; + gdat_data.dimunits=[{'time [ms]'} gyro_names{:} {'ECtot'}]; + gdat_data.units='W'; + gdat_data.data_fullpath=['rf::ech.gyro_names:ec..pwrc']; + icount=0; + for i=1:length(labels) + if ~isempty(labels{i}) + icount=icount+1; + if icount==1 & ~iscell(gdat_data.label) + gdat_data = rmfield(gdat_data,'label'); + end + gdat_data.label{icount} = labels{i}; end - gdat_data.label{icount} = labels{i}; - end + end + else + gdat_data.freq_ech_units =[]'; + gdat_data.ec = []; + gdat_data.polpos_ec = []; + gdat_data.torpos_ec = []; end - else - gdat_data.freq_ech_units =[]'; - gdat_data.ec = []; - gdat_data.polpos_ec = []; - gdat_data.torpos_ec = []; - end - %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - case {'powers'} - sources_avail = {'ohm','ec','nbi','ic'}; % note should allow ech, nbh, ohmic in parameter sources - sources_avail = {'ohm','ec','nbi'}; % note should allow ech, nbh, ohmic in parameter sources - for i=1:length(sources_avail) - gdat_data.(sources_avail{i}).data = []; - gdat_data.(sources_avail{i}).units = []; - gdat_data.(sources_avail{i}).dim=[]; - gdat_data.(sources_avail{i}).dimunits=[]; - gdat_data.(sources_avail{i}).t=[]; - gdat_data.(sources_avail{i}).x=[]; - gdat_data.(sources_avail{i}).data_fullpath=[]; - gdat_data.(sources_avail{i}).label=[]; - end - if ~isfield(gdat_data.gdat_params,'source') || isempty(gdat_data.gdat_params.source) - 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{:})]); + %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + case {'powers'} + sources_avail = {'ohm','ec','nbi','ic'}; % note should allow ech, nbh, ohmic in parameter sources + sources_avail = {'ohm','ec','nbi'}; % note should allow ech, nbh, ohmic in parameter sources + for i=1:length(sources_avail) + gdat_data.(sources_avail{i}).data = []; + gdat_data.(sources_avail{i}).units = []; + gdat_data.(sources_avail{i}).dim=[]; + gdat_data.(sources_avail{i}).dimunits=[]; + gdat_data.(sources_avail{i}).t=[]; + gdat_data.(sources_avail{i}).x=[]; + gdat_data.(sources_avail{i}).data_fullpath=[]; + gdat_data.(sources_avail{i}).label=[]; + end + if ~isfield(gdat_data.gdat_params,'source') || isempty(gdat_data.gdat_params.source) + 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 - return else - gdat_data.gdat_params.source = {gdat_data.gdat_params.source}; + if (gdat_params.nverbose>=1); warning([' source parameter not compatible with: ' sprintf('''%s'' ',sources_avail{:})]); end + return end else - if (gdat_params.nverbose>=1); warning([' source parameter not compatible with: ' sprintf('''%s'' ',sources_avail{:})]); end - return - end - else - for i=1:length(gdat_data.gdat_params.source) - gdat_data.gdat_params.source{i} = lower(gdat_data.gdat_params.source{i}); - 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]) + for i=1:length(gdat_data.gdat_params.source) + gdat_data.gdat_params.source{i} = lower(gdat_data.gdat_params.source{i}); + 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 end end end - end - % always start from ohmic so can use this time as base time since should yield full shot + % always start from ohmic so can use this time as base time since should yield full shot - fields_to_copy = {'data','units','dim','dimunits','t','x','data_fullpath','label','help','gdat_params'}; - fields_to_not_copy = {'shot','gdat_request'}; - % total of each source in .data, but full data in subfield like pgyro in .ec, to check for nbi - params_eff = gdat_data.gdat_params; - % ohmic, use its time-base - params_eff.data_request={'EFIT01','\vloopmhd'}; %poh too noisy even if vloop*ip is not quite correct - try - ohm=gdat_d3d(shot,params_eff); - catch - ohm.data = []; - ohm.dim = []; - end - if ~isempty(ohm.data) && ~isempty(ohm.dim) - ip=gdat_d3d(shot,'ip'); - ip_ohm=interp1(ip.t,ip.data,ohm.t); - ohm.data = ohm.data .* ip_ohm; - for i=1:length(fields_to_copy) - if isfield(ohm,fields_to_copy{i}) - gdat_data.ohm.(fields_to_copy{i}) = ohm.(fields_to_copy{i}); - end - end - gdat_data.ohm.raw_data = gdat_data.ohm.data; - else - if gdat_params.nverbose>=3; disp(['problems with ' params_eff.data_request]); end - return - end - mapping_for_d3d.timedim = 1; mapping_for_d3d.gdat_timedim = 1; - taus = -10; - % - % add each source in main.data, on ohm time array - gdat_data.t = gdat_data.ohm.t; - gdat_data.dim{1} = gdat_data.t; - gdat_data.dimunits{1} = 's'; - gdat_data.ohm.data = interpos(gdat_data.t,gdat_data.ohm.raw_data,5.*taus); - gdat_data.data = reshape(gdat_data.ohm.data,length(gdat_data.t),1); - gdat_data.ohm.tension = 5.*taus; - gdat_data.x =[1]; - gdat_data.label={'P_{ohm}'}; - gdat_data.units = 'W'; - % - if any(strmatch('ec',gdat_data.gdat_params.source)) - % ec - params_eff.data_request='pgyro'; + fields_to_copy = {'data','units','dim','dimunits','t','x','data_fullpath','label','help','gdat_params'}; + fields_to_not_copy = {'shot','gdat_request'}; + % total of each source in .data, but full data in subfield like pgyro in .ec, to check for nbi + params_eff = gdat_data.gdat_params; + % ohmic, use its time-base + params_eff.data_request={'EFIT01','\vloopmhd'}; %poh too noisy even if vloop*ip is not quite correct try - ec=gdat_d3d(shot,params_eff); + ohm=gdat_d3d(shot,params_eff); catch + ohm.data = []; + ohm.dim = []; end - if ~isempty(ec.data) && ~isempty(ec.dim) - for i=1:length(fields_to_copy) - % if has pgyro, use not_copy - if isfield(ec,fields_to_copy{i}) && ~any(strmatch(fields_to_not_copy,fields_to_copy{i})) - gdat_data.ec.(fields_to_copy{i}) = ec.(fields_to_copy{i}); - end - end - gdat_data.data(:,end+1) = interpos(-21,gdat_data.ec.t,gdat_data.ec.data(:,end),gdat_data.t); - gdat_data.x(end+1) =gdat_data.x(end)+1; - gdat_data.label{end+1}='P_{ec}'; - end - end - % - if any(strmatch('nb',gdat_data.gdat_params.source)) - % nbi - params_eff.data_request='nbi'; - try - nbi=gdat_d3d(shot,params_eff); - catch - end - if ~isempty(nbi.data) && ~isempty(nbi.dim) - for i=1:length(fields_to_copy) - if isfield(nbi,fields_to_copy{i}) - gdat_data.nbi.(fields_to_copy{i}) = nbi.(fields_to_copy{i}); - end - end - % add to main with linear interpolation and 0 for extrapolated values - gdat_data.data(:,end+1) = interpos(-21,gdat_data.nbi.t,gdat_data.nbi.data(:,end),gdat_data.t); - gdat_data.x(end+1) =gdat_data.x(end)+1; - gdat_data.label{end+1}='P_{nbi}'; + if ~isempty(ohm.data) && ~isempty(ohm.dim) + ip=gdat_d3d(shot,'ip'); + ip_ohm=interp1(ip.t,ip.data,ohm.t); + ohm.data = ohm.data .* ip_ohm; + for i=1:length(fields_to_copy) + if isfield(ohm,fields_to_copy{i}) + gdat_data.ohm.(fields_to_copy{i}) = ohm.(fields_to_copy{i}); + end + end + gdat_data.ohm.raw_data = gdat_data.ohm.data; + else + if gdat_params.nverbose>=3; disp(['problems with ' params_eff.data_request]); end + return end - end - % - if any(strmatch('ic',gdat_data.gdat_params.source)) - % ic - params_eff.data_request={'ICP','PICRN'}; - try - ic=gdat_d3d(shot,params_eff); - catch + mapping_for_d3d.timedim = 1; mapping_for_d3d.gdat_timedim = 1; + taus = -10; + % + % add each source in main.data, on ohm time array + gdat_data.t = gdat_data.ohm.t; + gdat_data.dim{1} = gdat_data.t; + gdat_data.dimunits{1} = 's'; + gdat_data.ohm.data = interpos(gdat_data.t,gdat_data.ohm.raw_data,5.*taus); + gdat_data.data = reshape(gdat_data.ohm.data,length(gdat_data.t),1); + gdat_data.ohm.tension = 5.*taus; + gdat_data.x =[1]; + gdat_data.label={'P_{ohm}'}; + gdat_data.units = 'W'; + % + if any(strmatch('ec',gdat_data.gdat_params.source)) + % ec + params_eff.data_request='pgyro'; + try + ec=gdat_d3d(shot,params_eff); + catch + end + if ~isempty(ec.data) && ~isempty(ec.dim) + for i=1:length(fields_to_copy) + % if has pgyro, use not_copy + if isfield(ec,fields_to_copy{i}) && ~any(strmatch(fields_to_not_copy,fields_to_copy{i})) + gdat_data.ec.(fields_to_copy{i}) = ec.(fields_to_copy{i}); + end + end + gdat_data.data(:,end+1) = interpos(-21,gdat_data.ec.t,gdat_data.ec.data(:,end),gdat_data.t); + gdat_data.x(end+1) =gdat_data.x(end)+1; + gdat_data.label{end+1}='P_{ec}'; + end end - if ~isempty(ic.data) && ~isempty(ic.dim) - for i=1:length(fields_to_copy) - if isfield(ic,fields_to_copy{i}) - gdat_data.ic.(fields_to_copy{i}) = ic.(fields_to_copy{i}); - end - end - gdat_data.data(:,end+1) = interpos(-21,gdat_data.ic.t,gdat_data.ic.data,gdat_data.t); - gdat_data.x(end+1) =gdat_data.x(end)+1; - gdat_data.label{end+1}='P_{ic}'; + % + if any(strmatch('nb',gdat_data.gdat_params.source)) + % nbi + params_eff.data_request='nbi'; + try + nbi=gdat_d3d(shot,params_eff); + catch + end + if ~isempty(nbi.data) && ~isempty(nbi.dim) + for i=1:length(fields_to_copy) + if isfield(nbi,fields_to_copy{i}) + gdat_data.nbi.(fields_to_copy{i}) = nbi.(fields_to_copy{i}); + end + end + % add to main with linear interpolation and 0 for extrapolated values + gdat_data.data(:,end+1) = interpos(-21,gdat_data.nbi.t,gdat_data.nbi.data(:,end),gdat_data.t); + gdat_data.x(end+1) =gdat_data.x(end)+1; + gdat_data.label{end+1}='P_{nbi}'; + end end - end - % add tot power - gdat_data.data(:,end+1) = sum(gdat_data.data,2); - gdat_data.label{end+1}='P_{tot}'; - gdat_data.x(end+1) =gdat_data.x(end)+1; - gdat_data.dim{2} = gdat_data.x; gdat_data.dimunits{2} = ''; - gdat_data.data_fullpath = 'tot powers from each sources, and total power in .data(:,end)'; - - %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - case {'q_rho'} - [gdat_data,exp_name_eff,DIAG,NTIME_Lpf,NTIME,Lpf1_t,Lpf_SOL] = get_EQ_params(gdat_data); - % since Lpf depends on time, need to load all first and then loop over time for easier mapping - [qpsi,e]=rdaD3D_eff(shot,DIAG,'Qpsi',exp_name_eff); - ndimrho = size(qpsi.data,2); - if ndimrho==NTIME_Lpf - % data seems to be transposed - ndimrho = size(qpsi.data,1); - itotransposeback = 1; % seems x,time inverted so transpose and exchange .x and .t - else - itotransposeback = 0; - end - qpsi=adapt_rda(qpsi,NTIME,ndimrho,itotransposeback); - ijnan=find(isnan(qpsi.value)); - qpsi.value(ijnan)=0; - [psi_tree,e]=rdaD3D_eff(shot,DIAG,'PFL',exp_name_eff); - psi_tree=adapt_rda(psi_tree,NTIME,ndimrho,itotransposeback); - [phi_tree,e]=rdaD3D_eff(shot,DIAG,'TFLx',exp_name_eff); - phi_tree=adapt_rda(phi_tree,NTIME,ndimrho,itotransposeback); - [Vol,e]=rdaD3D_eff(shot,DIAG,'Vol',exp_name_eff); - Vol=adapt_rda(Vol,NTIME,2*ndimrho,itotransposeback); - % seems "LCFS" q-value is far too large, limit to some max (when diverted) - max_qValue = 30.; % Note could just put a NaN on LCFS value since ill-defined when diverted - for it=1:NTIME - Lpf1 = Lpf1_t(it); - % Qpsi and similar data is on (time,radius) with radius being: LCFS..Lpf_points dummy LCFS..SOL part - % change it to (radial,time) and use only Lpf+1 points up to LCFS - ijok=find(qpsi.value(:,1)); % note: eqr fills in only odd points radially - % set NaNs to zeroes - if qpsi.value(ijok(1),1)<0 - gdat_data.qvalue(:,it) = max(qpsi.value(it,Lpf1:-1:1)',-max_qValue); - else - gdat_data.qvalue(:,it) = min(qpsi.value(it,Lpf1:-1:1)',max_qValue); - end - % get x values - psi_it=psi_tree.value(it,Lpf1:-1:1)'; - gdat_data.psi_axis(it)= psi_it(1); - gdat_data.psi_lcfs(it)= psi_it(end); - gdat_data.rhopolnorm(:,it) = sqrt(abs((psi_it-gdat_data.psi_axis(it)) ./(gdat_data.psi_lcfs(it)-gdat_data.psi_axis(it)))); - if strcmp(DIAG,'EQR'); - % q value has only a few values and from center to edge, assume they are from central rhopol values on - % But they are every other point starting from 3rd - ijk=find(gdat_data.qvalue(:,it)~=0); - if length(ijk)>2 - % now shots have non-zero axis values in eqr - rhoeff=gdat_data.rhopolnorm(ijk,it); - qeff=gdat_data.qvalue(ijk,it); % radial order was already inverted above - if ijk(1)>1 - rhoeff = [0.; rhoeff]; - qeff = [qeff(1) ;qeff]; - end - ij_nonan=find(~isnan(gdat_data.rhopolnorm(:,it))); - qfit = zeros(size(gdat_data.rhopolnorm(:,it))); - qfit(ij_nonan)=interpos(rhoeff,qeff,gdat_data.rhopolnorm(ij_nonan,it),-0.01,[1 0],[0 0],[300; ones(size(qeff(1:end-1)))]); - else - qfit = zeros(size(gdat_data.rhopolnorm(:,it))); - end - gdat_data.qvalue(:,it) = qfit; - end - % get rhotor values - phi_it = phi_tree.value(it,Lpf1:-1:1)'; - gdat_data.rhotornorm(:,it) = sqrt(abs(phi_it ./ phi_it(end))); - % get rhovol values - vol_it=Vol.value(it,2*Lpf1-1:-2:1)'; - gdat_data.rhovolnorm(:,it) = sqrt(abs(vol_it ./ vol_it(end))); - % Qpsi and similar data is on (time,radius) with radius being: LCFS..Lpf_points dummy LCFS..SOL part - % change it to (radial,time) and use only Lpf+1 points up to LCFS - ijok=find(qpsi.value(:,1)); % note: eqr fills in only odd points radially - % max value 1e6, change to 2*extrapolation (was max_qValue before) - q_edge=interpos(gdat_data.rhotornorm(1:end-1,it),qpsi.value(it,Lpf1:-1:2),1,-0.1); - gdat_data.qvalue(:,it) = qpsi.value(it,Lpf1:-1:1)'; - if abs(gdat_data.qvalue(end,it)) > 1e3 - % assume diverted - gdat_data.qvalue(end,it) = 2. * q_edge; + % + if any(strmatch('ic',gdat_data.gdat_params.source)) + % ic + params_eff.data_request={'ICP','PICRN'}; + try + ic=gdat_d3d(shot,params_eff); + catch + end + if ~isempty(ic.data) && ~isempty(ic.dim) + for i=1:length(fields_to_copy) + if isfield(ic,fields_to_copy{i}) + gdat_data.ic.(fields_to_copy{i}) = ic.(fields_to_copy{i}); + end + end + gdat_data.data(:,end+1) = interpos(-21,gdat_data.ic.t,gdat_data.ic.data,gdat_data.t); + gdat_data.x(end+1) =gdat_data.x(end)+1; + gdat_data.label{end+1}='P_{ic}'; + end end -% $$$ if qpsi.value(ijok(1),1)<0 -% $$$ gdat_data.qvalue(:,it) = max(qpsi.value(it,Lpf1:-1:1)',-max_qValue); -% $$$ else -% $$$ gdat_data.qvalue(:,it) = min(qpsi.value(it,Lpf1:-1:1)',max_qValue); -% $$$ end - end - gdat_data.x = gdat_data.rhopolnorm; - % get time values - gdat_data.data = gdat_data.qvalue; % put q in data - gdat_data.units=[]; % not applicable - gdat_data.data_fullpath = [DIAG ' from expname: ' gdat_data.gdat_params.exp_name '; q(rhopolnorm,t) in .data(.x,.t)']; - gdat_data.cocos = 17; % should check FPP - gdat_data.dim{1} = gdat_data.x; - gdat_data.dim{2} = gdat_data.t; - gdat_data.dimunits{1} = 'rhopolnorm'; - gdat_data.dimunits{2} = 'time [s]'; + % add tot power + gdat_data.data(:,end+1) = sum(gdat_data.data,2); + gdat_data.label{end+1}='P_{tot}'; + gdat_data.x(end+1) =gdat_data.x(end)+1; + gdat_data.dim{2} = gdat_data.x; gdat_data.dimunits{2} = ''; + gdat_data.data_fullpath = 'tot powers from each sources, and total power in .data(:,end)'; - %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - case {'psi_axis', 'psi_edge'} - if strcmp(upper(gdat_data.gdat_params.equil),'FPG') - gdat_params_prev = gdat_data.gdat_params; gdat_params_eff = gdat_params_prev; - gdat_params_eff.data_request = [{'FPG'},{'fax-bnd'},{'D3DD'}]; - gdat_data = gdat_d3d(gdat_data.shot,gdat_params_eff); - gdat_data.gdat_params = gdat_params_prev; - gdat_data.label = 'psi\_axis-psi\_edge'; - gdat_data.data_fullpath = [gdat_data.data_fullpath ' yields only psi\_axis-psi\_edge from FPG/fax-bnd']; - else + %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + case {'q_rho'} [gdat_data,exp_name_eff,DIAG,NTIME_Lpf,NTIME,Lpf1_t,Lpf_SOL] = get_EQ_params(gdat_data); % since Lpf depends on time, need to load all first and then loop over time for easier mapping - [psi_tree,e]=rdaD3D_eff(shot,DIAG,'PFL',exp_name_eff); - ndimrho = size(psi_tree.data,2); + [qpsi,e]=rdaD3D_eff(shot,DIAG,'Qpsi',exp_name_eff); + ndimrho = size(qpsi.data,2); if ndimrho==NTIME_Lpf - % data seems to be transposed - ndimrho = size(psi_tree.data,1); - itotransposeback = 1; % seems x,time inverted so transpose and exchange .x and .t + % data seems to be transposed + ndimrho = size(qpsi.data,1); + itotransposeback = 1; % seems x,time inverted so transpose and exchange .x and .t else - itotransposeback = 0; + itotransposeback = 0; end + qpsi=adapt_rda(qpsi,NTIME,ndimrho,itotransposeback); + ijnan=find(isnan(qpsi.value)); + qpsi.value(ijnan)=0; + [psi_tree,e]=rdaD3D_eff(shot,DIAG,'PFL',exp_name_eff); psi_tree=adapt_rda(psi_tree,NTIME,ndimrho,itotransposeback); - ijnan=find(isnan(psi_tree.value)); - psi_tree.value(ijnan)=0; - gdat_data.dim{1} = gdat_data.t; - gdat_data.dimunits{1} = 'time [s]'; + [phi_tree,e]=rdaD3D_eff(shot,DIAG,'TFLx',exp_name_eff); + phi_tree=adapt_rda(phi_tree,NTIME,ndimrho,itotransposeback); + [Vol,e]=rdaD3D_eff(shot,DIAG,'Vol',exp_name_eff); + Vol=adapt_rda(Vol,NTIME,2*ndimrho,itotransposeback); + % seems "LCFS" q-value is far too large, limit to some max (when diverted) + max_qValue = 30.; % Note could just put a NaN on LCFS value since ill-defined when diverted for it=1:NTIME - Lpf1 = Lpf1_t(it); - psi_it=psi_tree.value(it,Lpf1:-1:1)'; - if strcmp(data_request_eff,'psi_axis') - gdat_data.data(it)= psi_it(1); - elseif strcmp(data_request_eff,'psi_edge') - gdat_data.data(it)= psi_it(end); - else - end - end - gdat_data.units = psi_tree.units; - gdat_data.data_fullpath = [DIAG '/PFL extract ' data_request_eff]; - end - - %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - case {'rot', 'cerqrot'} - nth_points = 13; - if isfield(gdat_data.gdat_params,'nth_points') && ~isempty(gdat_data.gdat_params.nth_points) - nth_points = gdat_data.gdat_params.nth_points; - else - gdat_data.gdat_params.nth_points = nth_points; - end - channels = -1; - if isfield(gdat_data.gdat_params,'channels') && ~isempty(gdat_data.gdat_params.channels) - channels = gdat_data.gdat_params.channels; - end - diag_name = 'cerqrot'; - if nth_points>=10 - match_rz_to_time = 1; - else - match_rz_to_time = 0; - end - if isfield(gdat_data.gdat_params,'match_rz_to_time') && ~isempty(gdat_data.gdat_params.match_rz_to_time) - match_rz_to_time = gdat_data.gdat_params.match_rz_to_time; - else - gdat_data.gdat_params.match_rz_to_time = match_rz_to_time; - end - time_interval = [-Inf +Inf]; - if isfield(gdat_data.gdat_params,'time_interval') && ~isempty(gdat_data.gdat_params.time_interval) - time_interval = gdat_data.gdat_params.time_interval; - else - gdat_data.gdat_params.time_interval = time_interval; - end - % - if channels(1)<=0 - channels = [1:24]; - end - chanelles=sort(channels); - gdat_data.dim{1} = channels; - gdat_data.gdat_params.channels = channels; - max_points = 0; - for i=channels - aall{i} = gdat_d3d(shot,['\cerqrott' num2str(i)]); - if isnumeric(aall{i}.data) - gdat_data.channels_ok(i) = 1; - if numel(aall{i}.data) > max_points - max_points = numel(aall{i}.data); - gdat_data.t = aall{i}.t; - end - else - gdat_data.channels_ok(i) = 0; - end - end - gdat_data.dim{2} = gdat_data.t; - gdat_data.data = NaN(max(channels),max_points); - for i=channels - if gdat_data.channels_ok(i) - if nth_points>1 - ieff = [1:nth_points:numel(aall{i}.data)]; - iteff = iround_os(gdat_data.t,aall{i}.t(ieff)); - gdat_data.data(i,iteff) = interp1(aall{i}.t,aall{i}.data,gdat_data.t(iteff)); + Lpf1 = Lpf1_t(it); + % Qpsi and similar data is on (time,radius) with radius being: LCFS..Lpf_points dummy LCFS..SOL part + % change it to (radial,time) and use only Lpf+1 points up to LCFS + ijok=find(qpsi.value(:,1)); % note: eqr fills in only odd points radially + % set NaNs to zeroes + if qpsi.value(ijok(1),1)<0 + gdat_data.qvalue(:,it) = max(qpsi.value(it,Lpf1:-1:1)',-max_qValue); else - iteff = iround_os(gdat_data.t,aall{i}.t); - gdat_data.data(i,iteff) = interp1(aall{i}.t,aall{i}.data,gdat_data.t(iteff)); + gdat_data.qvalue(:,it) = min(qpsi.value(it,Lpf1:-1:1)',max_qValue); end + % get x values + psi_it=psi_tree.value(it,Lpf1:-1:1)'; + gdat_data.psi_axis(it)= psi_it(1); + gdat_data.psi_lcfs(it)= psi_it(end); + gdat_data.rhopolnorm(:,it) = sqrt(abs((psi_it-gdat_data.psi_axis(it)) ./(gdat_data.psi_lcfs(it)-gdat_data.psi_axis(it)))); + if strcmp(DIAG,'EQR'); + % q value has only a few values and from center to edge, assume they are from central rhopol values on + % But they are every other point starting from 3rd + ijk=find(gdat_data.qvalue(:,it)~=0); + if length(ijk)>2 + % now shots have non-zero axis values in eqr + rhoeff=gdat_data.rhopolnorm(ijk,it); + qeff=gdat_data.qvalue(ijk,it); % radial order was already inverted above + if ijk(1)>1 + rhoeff = [0.; rhoeff]; + qeff = [qeff(1) ;qeff]; + end + ij_nonan=find(~isnan(gdat_data.rhopolnorm(:,it))); + qfit = zeros(size(gdat_data.rhopolnorm(:,it))); + qfit(ij_nonan)=interpos(rhoeff,qeff,gdat_data.rhopolnorm(ij_nonan,it),-0.01,[1 0],[0 0],[300; ones(size(qeff(1:end-1)))]); + else + qfit = zeros(size(gdat_data.rhopolnorm(:,it))); + end + gdat_data.qvalue(:,it) = qfit; + end + % get rhotor values + phi_it = phi_tree.value(it,Lpf1:-1:1)'; + gdat_data.rhotornorm(:,it) = sqrt(abs(phi_it ./ phi_it(end))); + % get rhovol values + vol_it=Vol.value(it,2*Lpf1-1:-2:1)'; + gdat_data.rhovolnorm(:,it) = sqrt(abs(vol_it ./ vol_it(end))); + % Qpsi and similar data is on (time,radius) with radius being: LCFS..Lpf_points dummy LCFS..SOL part + % change it to (radial,time) and use only Lpf+1 points up to LCFS + ijok=find(qpsi.value(:,1)); % note: eqr fills in only odd points radially + % max value 1e6, change to 2*extrapolation (was max_qValue before) + q_edge=interpos(gdat_data.rhotornorm(1:end-1,it),qpsi.value(it,Lpf1:-1:2),1,-0.1); + gdat_data.qvalue(:,it) = qpsi.value(it,Lpf1:-1:1)'; + if abs(gdat_data.qvalue(end,it)) > 1e3 + % assume diverted + gdat_data.qvalue(end,it) = 2. * q_edge; + end +% $$$ if qpsi.value(ijok(1),1)<0 +% $$$ gdat_data.qvalue(:,it) = max(qpsi.value(it,Lpf1:-1:1)',-max_qValue); +% $$$ else +% $$$ gdat_data.qvalue(:,it) = min(qpsi.value(it,Lpf1:-1:1)',max_qValue); +% $$$ end end - end - gdat_data.x = gdat_data.dim{1}; - gdat_data.dimunits=[{'channels'} ; {'time [s]'}]; - %if any(strcmp(fieldnames(a),'units')); gdat_data.units=a.units; end - gdat_data.data_fullpath = [diag_name '\tcerqrot' num2str(channels(1)) '...' num2str(channels(end))]; - gdat_data.allchannels = aall; - - %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - case {'rhotor', 'rhotor_edge', 'rhotor_norm', 'rhovol', 'volume_rho'} - if strcmp(upper(gdat_data.gdat_params.equil),'FPG') - gdat_params_prev = gdat_data.gdat_params; gdat_params_eff = gdat_params_prev; - gdat_params_eff.data_request = [{'FPG'},{'Vol'},{'D3DD'}]; - gdat_data = gdat_d3d(gdat_data.shot,gdat_params_eff); - gdat_data.gdat_params = gdat_params_prev; - gdat_data.label = 'Vol'; - gdat_data.data_fullpath = [gdat_data.data_fullpath ' yields only edge Volume from FPG/Vol']; - return - end - [gdat_data,exp_name_eff,DIAG,NTIME_Lpf,NTIME,Lpf1_t,Lpf_SOL] = get_EQ_params(gdat_data); - % since Lpf depends on time, need to load all first and then loop over time for easier mapping - [phi_tree,e]=rdaD3D_eff(shot,DIAG,'TFLx',exp_name_eff); - ndimrho = size(phi_tree.data,2); - if ndimrho==NTIME_Lpf - % data seems to be transposed - ndimrho = size(phi_tree.data,1); - itotransposeback = 1; % seems x,time inverted so transpose and exchange .x and .t - else - itotransposeback = 0; - end - phi_tree=adapt_rda(phi_tree,NTIME,ndimrho,itotransposeback); - ijnan=find(isnan(phi_tree.value)); - phi_tree.value(ijnan)=0; - [Vol,e]=rdaD3D_eff(shot,DIAG,'Vol',exp_name_eff); - Vol=adapt_rda(Vol,NTIME,2*ndimrho,itotransposeback); - [psi_tree,e]=rdaD3D_eff(shot,DIAG,'PFL',exp_name_eff); - psi_tree=adapt_rda(psi_tree,NTIME,ndimrho,itotransposeback); - % - switch data_request_eff - case {'volume_rho', 'rhovol'} - for it=1:NTIME - Lpf1 = Lpf1_t(it); - psi_it=psi_tree.value(it,Lpf1:-1:1)'; - psi_axis(it)= psi_it(1); - psi_lcfs(it)= psi_it(end); - gdat_data.x(:,it) = sqrt(abs((psi_it-psi_axis(it)) ./(psi_lcfs(it)-psi_axis(it)))); - gdat_data.vol(:,it)=Vol.value(it,2*Lpf1-1:-2:1)'; - % gdat_data.dvoldpsi(:,it)=Vol.value(it,2*Lpf1:-2:2)'; % 2nd index are dV/dpsi - gdat_data.rhovolnorm(:,it) = sqrt(abs(gdat_data.vol(:,it) ./ gdat_data.vol(end,it))); - end + gdat_data.x = gdat_data.rhopolnorm; + % get time values + gdat_data.data = gdat_data.qvalue; % put q in data + gdat_data.units=[]; % not applicable + gdat_data.data_fullpath = [DIAG ' from expname: ' gdat_data.gdat_params.exp_name '; q(rhopolnorm,t) in .data(.x,.t)']; + gdat_data.cocos = 17; % should check FPP gdat_data.dim{1} = gdat_data.x; gdat_data.dim{2} = gdat_data.t; gdat_data.dimunits{1} = 'rhopolnorm'; gdat_data.dimunits{2} = 'time [s]'; - if strcmp(data_request_eff,'volume_rho') - gdat_data.data = gdat_data.vol; - gdat_data.units = Vol.units; - else strcmp(data_request_eff,'rhovol') - gdat_data.data = gdat_data.rhovolnorm; - gdat_data.units = ' '; - end - case {'rhotor', 'rhotor_edge', 'rhotor_norm'} - b0=gdat(shot,'b0'); - gdat_data.b0 = interpos(b0.t,b0.data,gdat_data.t,-1); - for it=1:NTIME - Lpf1 = Lpf1_t(it); - gdat_data.phi(:,it) = phi_tree.value(it,Lpf1:-1:1)'; - gdat_data.rhotornorm(:,it) = sqrt(abs(gdat_data.phi(:,it) ./ gdat_data.phi(end,it))); - gdat_data.rhotor(:,it) = sqrt(abs(gdat_data.phi(:,it) ./ gdat_data.b0(it) ./ pi)); - psi_it=psi_tree.value(it,Lpf1:-1:1)'; - psi_axis(it)= psi_it(1); - psi_lcfs(it)= psi_it(end); - gdat_data.x(:,it) = sqrt(abs((psi_it-psi_axis(it)) ./(psi_lcfs(it)-psi_axis(it)))); - end - if strcmp(data_request_eff,'rhotor') - gdat_data.data = gdat_data.rhotor; - gdat_data.units = 'm'; - gdat_data.dim{1} = gdat_data.x; - gdat_data.dim{2} = gdat_data.t; - gdat_data.dimunits{1} = 'rhopolnorm'; - gdat_data.dimunits{2} = 'time [s]'; - elseif strcmp(data_request_eff,'rhotor_edge') - gdat_data.data = gdat_data.rhotor(end,:); - gdat_data.units = 'm'; - gdat_data.dim{1} = gdat_data.t; - gdat_data.dimunits{1} = 'time [s]'; - elseif strcmp(data_request_eff,'rhotor_norm') - gdat_data.data = gdat_data.rhotornorm; - gdat_data.units = ' '; - gdat_data.dim{1} = gdat_data.x; - gdat_data.dim{2} = gdat_data.t; - gdat_data.dimunits{1} = 'rhopolnorm'; - gdat_data.dimunits{2} = 'time [s]'; + + %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + case {'psi_axis', 'psi_edge'} + if strcmp(upper(gdat_data.gdat_params.equil),'FPG') + gdat_params_prev = gdat_data.gdat_params; gdat_params_eff = gdat_params_prev; + gdat_params_eff.data_request = [{'FPG'},{'fax-bnd'},{'D3DD'}]; + gdat_data = gdat_d3d(gdat_data.shot,gdat_params_eff); + gdat_data.gdat_params = gdat_params_prev; + gdat_data.label = 'psi\_axis-psi\_edge'; + gdat_data.data_fullpath = [gdat_data.data_fullpath ' yields only psi\_axis-psi\_edge from FPG/fax-bnd']; + else + [gdat_data,exp_name_eff,DIAG,NTIME_Lpf,NTIME,Lpf1_t,Lpf_SOL] = get_EQ_params(gdat_data); + % since Lpf depends on time, need to load all first and then loop over time for easier mapping + [psi_tree,e]=rdaD3D_eff(shot,DIAG,'PFL',exp_name_eff); + ndimrho = size(psi_tree.data,2); + if ndimrho==NTIME_Lpf + % data seems to be transposed + ndimrho = size(psi_tree.data,1); + itotransposeback = 1; % seems x,time inverted so transpose and exchange .x and .t + else + itotransposeback = 0; + end + psi_tree=adapt_rda(psi_tree,NTIME,ndimrho,itotransposeback); + ijnan=find(isnan(psi_tree.value)); + psi_tree.value(ijnan)=0; + gdat_data.dim{1} = gdat_data.t; + gdat_data.dimunits{1} = 'time [s]'; + for it=1:NTIME + Lpf1 = Lpf1_t(it); + psi_it=psi_tree.value(it,Lpf1:-1:1)'; + if strcmp(data_request_eff,'psi_axis') + gdat_data.data(it)= psi_it(1); + elseif strcmp(data_request_eff,'psi_edge') + gdat_data.data(it)= psi_it(end); + else + end + end + gdat_data.units = psi_tree.units; + gdat_data.data_fullpath = [DIAG '/PFL extract ' data_request_eff]; end - end - gdat_data.data_fullpath = [DIAG '/PFL extract in .data: ' data_request_eff]; - %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - case {'sxr'} - % sxr from sx90rm1s by default or else if 'source' is provided - if ~isfield(gdat_data.gdat_params,'freq')|| isempty(gdat_data.gdat_params.freq) - gdat_data.gdat_params.freq = 1; - end - if ~isfield(gdat_data.gdat_params,'source') || isempty(gdat_data.gdat_params.source) - gdat_data.gdat_params.source = 'sx90rm1s'; - end - if ~isfield(gdat_data.gdat_params,'camera') || isempty(gdat_data.gdat_params.camera) - gdat_data.gdat_params.camera = [1:28]; - end - gdat_data.gdat_params.source = upper(gdat_data.gdat_params.source); - % - if ~isfield(gdat_data.gdat_params,'time_interval') - gdat_data.gdat_params.time_interval = []; - end - exp_name_eff = 'D3D'; - icount = 0; - nnth = 1; - if isnumeric(gdat_data.gdat_params.freq) && gdat_data.gdat_params.freq>1; - nnth = floor(gdat_data.gdat_params.freq+0.5); - gdat_data.gdat_params.freq = nnth; - end - for i=1:length(gdat_data.gdat_params.camera) - tree = 'spectroscopy'; - ichord = gdat_data.gdat_params.camera(i); - diagname = ['sxr:' gdat_data.gdat_params.source ':' gdat_data.gdat_params.source num2str(ichord,'%.2d')]; - a = gdat_d3d(shot,{tree,diagname}); - if ~isempty(a.data) - icount = icount + 1; - if icount == 1 - % first time has data - gdat_data.t = a.t(1:nnth:end); - gdat_data.units = a.units; - gdat_data.data = NaN*ones(max(gdat_data.gdat_params.camera),length(gdat_data.t)); - gdat_data.x = [1:max(gdat_data.gdat_params.camera)]; % simpler to have index corresponding to chord number, except for central - gdat_data.dim{1} = gdat_data.x; - gdat_data.dim{2} = gdat_data.t; - gdat_data.dimunits = [{'chord nb'}; {'s'}]; - gdat_data.data_fullpath = ['sxr from source=''' gdat_data.gdat_params.source '''']; - gdat_data.label = ['SXR/' upper(gdat_data.gdat_params.source)]; - end - try - gdat_data.data(ichord,:) = a.data(1:nnth:end); - catch - if (gdat_params.nverbose>=1); disp(['problem with ' gdat_data.gdat_params.source '...' num2str(ichord)]); end - end + %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + case {'rot', 'cerqrot'} + nth_points = 13; + if isfield(gdat_data.gdat_params,'nth_points') && ~isempty(gdat_data.gdat_params.nth_points) + nth_points = gdat_data.gdat_params.nth_points; else - % add fields not yet defined in case all cases have empty data + gdat_data.gdat_params.nth_points = nth_points; end - end - gdat_data.chords = gdat_data.gdat_params.camera; + channels = -1; + if isfield(gdat_data.gdat_params,'channels') && ~isempty(gdat_data.gdat_params.channels) + channels = gdat_data.gdat_params.channels; + end + diag_name = 'cerqrot'; + if nth_points>=10 + match_rz_to_time = 1; + else + match_rz_to_time = 0; + end + if isfield(gdat_data.gdat_params,'match_rz_to_time') && ~isempty(gdat_data.gdat_params.match_rz_to_time) + match_rz_to_time = gdat_data.gdat_params.match_rz_to_time; + else + gdat_data.gdat_params.match_rz_to_time = match_rz_to_time; + end + time_interval = [-Inf +Inf]; + if isfield(gdat_data.gdat_params,'time_interval') && ~isempty(gdat_data.gdat_params.time_interval) + time_interval = gdat_data.gdat_params.time_interval; + else + gdat_data.gdat_params.time_interval = time_interval; + end + % + if channels(1)<=0 + channels = [1:24]; + end + chanelles=sort(channels); + gdat_data.dim{1} = channels; + gdat_data.gdat_params.channels = channels; + max_points = 0; + for i=channels + aall{i} = gdat_d3d(shot,['\cerqrott' num2str(i)]); + if isnumeric(aall{i}.data) + gdat_data.channels_ok(i) = 1; + if numel(aall{i}.data) > max_points + max_points = numel(aall{i}.data); + gdat_data.t = aall{i}.t; + end + else + gdat_data.channels_ok(i) = 0; + end + end + gdat_data.dim{2} = gdat_data.t; + gdat_data.data = NaN(max(channels),max_points); + for i=channels + if gdat_data.channels_ok(i) + if nth_points>1 + ieff = [1:nth_points:numel(aall{i}.data)]; + iteff = iround_os(gdat_data.t,aall{i}.t(ieff)); + gdat_data.data(i,iteff) = interp1(aall{i}.t,aall{i}.data,gdat_data.t(iteff)); + else + iteff = iround_os(gdat_data.t,aall{i}.t); + gdat_data.data(i,iteff) = interp1(aall{i}.t,aall{i}.data,gdat_data.t(iteff)); + end + end + end + gdat_data.x = gdat_data.dim{1}; + gdat_data.dimunits=[{'channels'} ; {'time [s]'}]; + %if any(strcmp(fieldnames(a),'units')); gdat_data.units=a.units; end + gdat_data.data_fullpath = [diag_name '\tcerqrot' num2str(channels(1)) '...' num2str(channels(end))]; + gdat_data.allchannels = aall; - %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - case {'bolo', 'bolom'} - % sxr from sx90rm1s by default or else if 'source' is provided - if ~isfield(gdat_data.gdat_params,'freq')|| isempty(gdat_data.gdat_params.freq) - gdat_data.gdat_params.freq = 1; - end - if ~isfield(gdat_data.gdat_params,'source') || isempty(gdat_data.gdat_params.source) - gdat_data.gdat_params.source = 'BOL_L'; - end - if ~isfield(gdat_data.gdat_params,'camera') || isempty(gdat_data.gdat_params.camera) - gdat_data.gdat_params.camera = [1:24]; - end - gdat_data.gdat_params.source = upper(gdat_data.gdat_params.source); - % - if ~isfield(gdat_data.gdat_params,'time_interval') - gdat_data.gdat_params.time_interval = []; - end - exp_name_eff = 'D3D'; - icount = 0; - nnth = 1; - if isnumeric(gdat_data.gdat_params.freq) && gdat_data.gdat_params.freq>1; - nnth = floor(gdat_data.gdat_params.freq+0.5); - gdat_data.gdat_params.freq = nnth; - end - tree = 'spectroscopy'; - gdat_data.gdat_params.tree = tree; - for i=1:length(gdat_data.gdat_params.camera) - ichord = gdat_data.gdat_params.camera(i); - diagname = ['PRAD.BOLOM.PRAD_01.POWER:' gdat_data.gdat_params.source num2str(ichord,'%.2d') '_P']; - a = gdat_d3d(shot,{tree,diagname}); - if ~isempty(a.data) - icount = icount + 1; - if icount == 1 - % first time has data - gdat_data.t = a.t(1:nnth:end); - gdat_data.units = a.units; - gdat_data.data = NaN*ones(max(gdat_data.gdat_params.camera),length(gdat_data.t)); - gdat_data.x = [1:max(gdat_data.gdat_params.camera)]; % simpler to have index corresponding to chord number, except for central - gdat_data.dim{1} = gdat_data.x; - gdat_data.dim{2} = gdat_data.t; - gdat_data.dimunits = [{'chord nb'}; {'s'}]; - gdat_data.data_fullpath = ['bolo from source=''' gdat_data.gdat_params.source '''']; - gdat_data.label = ['PRAD.BOLOM.PRAD\_01.POWER:' upper(gdat_data.gdat_params.source)]; - end - try - gdat_data.data(ichord,:) = a.data(1:nnth:end); - catch - if (gdat_params.nverbose>=1); disp(['problem with ' gdat_data.gdat_params.source '...' num2str(ichord)]); end - end + %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + case {'rhotor', 'rhotor_edge', 'rhotor_norm', 'rhovol', 'volume_rho'} + if strcmp(upper(gdat_data.gdat_params.equil),'FPG') + gdat_params_prev = gdat_data.gdat_params; gdat_params_eff = gdat_params_prev; + gdat_params_eff.data_request = [{'FPG'},{'Vol'},{'D3DD'}]; + gdat_data = gdat_d3d(gdat_data.shot,gdat_params_eff); + gdat_data.gdat_params = gdat_params_prev; + gdat_data.label = 'Vol'; + gdat_data.data_fullpath = [gdat_data.data_fullpath ' yields only edge Volume from FPG/Vol']; + return + end + [gdat_data,exp_name_eff,DIAG,NTIME_Lpf,NTIME,Lpf1_t,Lpf_SOL] = get_EQ_params(gdat_data); + % since Lpf depends on time, need to load all first and then loop over time for easier mapping + [phi_tree,e]=rdaD3D_eff(shot,DIAG,'TFLx',exp_name_eff); + ndimrho = size(phi_tree.data,2); + if ndimrho==NTIME_Lpf + % data seems to be transposed + ndimrho = size(phi_tree.data,1); + itotransposeback = 1; % seems x,time inverted so transpose and exchange .x and .t else - % add fields not yet defined in case all cases have empty data + itotransposeback = 0; end - end - gdat_data.chords = gdat_data.gdat_params.camera; + phi_tree=adapt_rda(phi_tree,NTIME,ndimrho,itotransposeback); + ijnan=find(isnan(phi_tree.value)); + phi_tree.value(ijnan)=0; + [Vol,e]=rdaD3D_eff(shot,DIAG,'Vol',exp_name_eff); + Vol=adapt_rda(Vol,NTIME,2*ndimrho,itotransposeback); + [psi_tree,e]=rdaD3D_eff(shot,DIAG,'PFL',exp_name_eff); + psi_tree=adapt_rda(psi_tree,NTIME,ndimrho,itotransposeback); + % + switch data_request_eff + case {'volume_rho', 'rhovol'} + for it=1:NTIME + Lpf1 = Lpf1_t(it); + psi_it=psi_tree.value(it,Lpf1:-1:1)'; + psi_axis(it)= psi_it(1); + psi_lcfs(it)= psi_it(end); + gdat_data.x(:,it) = sqrt(abs((psi_it-psi_axis(it)) ./(psi_lcfs(it)-psi_axis(it)))); + gdat_data.vol(:,it)=Vol.value(it,2*Lpf1-1:-2:1)'; + % gdat_data.dvoldpsi(:,it)=Vol.value(it,2*Lpf1:-2:2)'; % 2nd index are dV/dpsi + gdat_data.rhovolnorm(:,it) = sqrt(abs(gdat_data.vol(:,it) ./ gdat_data.vol(end,it))); + end + gdat_data.dim{1} = gdat_data.x; + gdat_data.dim{2} = gdat_data.t; + gdat_data.dimunits{1} = 'rhopolnorm'; + gdat_data.dimunits{2} = 'time [s]'; + if strcmp(data_request_eff,'volume_rho') + gdat_data.data = gdat_data.vol; + gdat_data.units = Vol.units; + else strcmp(data_request_eff,'rhovol') + gdat_data.data = gdat_data.rhovolnorm; + gdat_data.units = ' '; + end + case {'rhotor', 'rhotor_edge', 'rhotor_norm'} + b0=gdat(shot,'b0'); + gdat_data.b0 = interpos(b0.t,b0.data,gdat_data.t,-1); + for it=1:NTIME + Lpf1 = Lpf1_t(it); + gdat_data.phi(:,it) = phi_tree.value(it,Lpf1:-1:1)'; + gdat_data.rhotornorm(:,it) = sqrt(abs(gdat_data.phi(:,it) ./ gdat_data.phi(end,it))); + gdat_data.rhotor(:,it) = sqrt(abs(gdat_data.phi(:,it) ./ gdat_data.b0(it) ./ pi)); + psi_it=psi_tree.value(it,Lpf1:-1:1)'; + psi_axis(it)= psi_it(1); + psi_lcfs(it)= psi_it(end); + gdat_data.x(:,it) = sqrt(abs((psi_it-psi_axis(it)) ./(psi_lcfs(it)-psi_axis(it)))); + end + if strcmp(data_request_eff,'rhotor') + gdat_data.data = gdat_data.rhotor; + gdat_data.units = 'm'; + gdat_data.dim{1} = gdat_data.x; + gdat_data.dim{2} = gdat_data.t; + gdat_data.dimunits{1} = 'rhopolnorm'; + gdat_data.dimunits{2} = 'time [s]'; + elseif strcmp(data_request_eff,'rhotor_edge') + gdat_data.data = gdat_data.rhotor(end,:); + gdat_data.units = 'm'; + gdat_data.dim{1} = gdat_data.t; + gdat_data.dimunits{1} = 'time [s]'; + elseif strcmp(data_request_eff,'rhotor_norm') + gdat_data.data = gdat_data.rhotornorm; + gdat_data.units = ' '; + gdat_data.dim{1} = gdat_data.x; + gdat_data.dim{2} = gdat_data.t; + gdat_data.dimunits{1} = 'rhopolnorm'; + gdat_data.dimunits{2} = 'time [s]'; + end + end + gdat_data.data_fullpath = [DIAG '/PFL extract in .data: ' data_request_eff]; - %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - case {'transp'} - % most of the times the exp for the shotfile should be provided - shotfile_exp_eff = gdat_params.exp_name; - diagname='TRA'; - TRANSP_signals; - for i=1:size(transp_sig,1) - if strcmp(lower(transp_sig{i,2}),'signal') || strcmp(lower(transp_sig{i,2}),'signal-group') - try - eval(['[gdat_data.' transp_sig{i,1} ',e]=rdaD3D_eff(shot,diagname,''' transp_sig{i,1} ''',shotfile_exp_eff);']); - catch - eval(['gdat_data.' transp_sig{i,1} '=[];']); - end - elseif strcmp(lower(transp_sig{i,2}),'area-base') - clear adata_area - try - [adata_area]=sf2ab(diagname,shot,transp_sig{i,1},'-exp',shotfile_exp_eff); - catch - adata_area.value = cell(0); - end - eval(['gdat_data.' transp_sig{i,1} '=adata_area;']); - elseif strcmp(lower(transp_sig{i,2}),'time-base') - clear adata_time - try - [adata_time]=sf2tb(diagname,shot,transp_sig{i,1},'-exp',shotfile_exp_eff); - catch - adata_time.value = cell(0); - end - eval(['gdat_data.' transp_sig{i,1} '=adata_time;']); + %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + case {'sxr'} + % sxr from sx90rm1s by default or else if 'source' is provided + if ~isfield(gdat_data.gdat_params,'freq')|| isempty(gdat_data.gdat_params.freq) + gdat_data.gdat_params.freq = 1; end - end - % copy TIME to .t - if isfield(gdat_data,'TIME') && isfield(gdat_data.TIME,'value') - gdat_data.t = gdat_data.TIME.value; - gdat_data.dim{1} = gdat_data.t, - gdat_data.dimunits{1} = gdat_data.TIME.unit; - end + if ~isfield(gdat_data.gdat_params,'source') || isempty(gdat_data.gdat_params.source) + gdat_data.gdat_params.source = 'sx90rm1s'; + end + if ~isfield(gdat_data.gdat_params,'camera') || isempty(gdat_data.gdat_params.camera) + gdat_data.gdat_params.camera = [1:28]; + end + gdat_data.gdat_params.source = upper(gdat_data.gdat_params.source); + % + if ~isfield(gdat_data.gdat_params,'time_interval') + gdat_data.gdat_params.time_interval = []; + end + exp_name_eff = 'D3D'; + icount = 0; + nnth = 1; + if isnumeric(gdat_data.gdat_params.freq) && gdat_data.gdat_params.freq>1; + nnth = floor(gdat_data.gdat_params.freq+0.5); + gdat_data.gdat_params.freq = nnth; + end + for i=1:length(gdat_data.gdat_params.camera) + tree = 'spectroscopy'; + ichord = gdat_data.gdat_params.camera(i); + diagname = ['sxr:' gdat_data.gdat_params.source ':' gdat_data.gdat_params.source num2str(ichord,'%.2d')]; + a = gdat_d3d(shot,{tree,diagname}); + if ~isempty(a.data) + icount = icount + 1; + if icount == 1 + % first time has data + gdat_data.t = a.t(1:nnth:end); + gdat_data.units = a.units; + gdat_data.data = NaN*ones(max(gdat_data.gdat_params.camera),length(gdat_data.t)); + gdat_data.x = [1:max(gdat_data.gdat_params.camera)]; % simpler to have index corresponding to chord number, except for central + gdat_data.dim{1} = gdat_data.x; + gdat_data.dim{2} = gdat_data.t; + gdat_data.dimunits = [{'chord nb'}; {'s'}]; + gdat_data.data_fullpath = ['sxr from source=''' gdat_data.gdat_params.source '''']; + gdat_data.label = ['SXR/' upper(gdat_data.gdat_params.source)]; + end + try + gdat_data.data(ichord,:) = a.data(1:nnth:end); + catch + if (gdat_params.nverbose>=1); disp(['problem with ' gdat_data.gdat_params.source '...' num2str(ichord)]); end + end + else + % add fields not yet defined in case all cases have empty data + end + end + gdat_data.chords = gdat_data.gdat_params.camera; - %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - case {'zeff_cerq', 'zeff_cer'} - % zeff from specific cer lines, C, N, ... - if ~isfield(gdat_data.gdat_params,'camera') || isempty(gdat_data.gdat_params.camera) - gdat_data.gdat_params.camera = [9 18 20 41]; - end - gdat_data.label = {}; - for i=1:numel(gdat_data.gdat_params.camera) - gdat_data.label{i} = ['cerqzefft' num2str(gdat_data.gdat_params.camera(i))]; - end - % - if ~isfield(gdat_data.gdat_params,'time_interval') - gdat_data.gdat_params.time_interval = []; - end - icount = 0; - for i=1:length(gdat_data.gdat_params.camera) - ichord = gdat_data.gdat_params.camera(i); - diagname = ['\' gdat_data.label{i}]; - a = gdat_d3d(shot,diagname); - if ~isempty(a.data) && isnumeric(a.data) - icount = icount + 1; - if icount == 1 - % first time has data - gdat_data.t = a.t; - gdat_data.units = a.units; - gdat_data.data = NaN*ones(numel(gdat_data.gdat_params.camera),length(gdat_data.t)); - gdat_data.data(icount,:) = a.data; - gdat_data.x = gdat_data.gdat_params.camera; - gdat_data.dim{1} = gdat_data.x; - gdat_data.dim{2} = gdat_data.t; - gdat_data.dimunits = [{'t nb'}; {'s'}]; - gdat_data.data_fullpath = '\cerqzefftii'; + %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + case {'bolo', 'bolom'} + % sxr from sx90rm1s by default or else if 'source' is provided + if ~isfield(gdat_data.gdat_params,'freq')|| isempty(gdat_data.gdat_params.freq) + gdat_data.gdat_params.freq = 1; + end + if ~isfield(gdat_data.gdat_params,'source') || isempty(gdat_data.gdat_params.source) + gdat_data.gdat_params.source = 'BOL_L'; + end + if ~isfield(gdat_data.gdat_params,'camera') || isempty(gdat_data.gdat_params.camera) + gdat_data.gdat_params.camera = [1:24]; + end + gdat_data.gdat_params.source = upper(gdat_data.gdat_params.source); + % + if ~isfield(gdat_data.gdat_params,'time_interval') + gdat_data.gdat_params.time_interval = []; + end + exp_name_eff = 'D3D'; + icount = 0; + nnth = 1; + if isnumeric(gdat_data.gdat_params.freq) && gdat_data.gdat_params.freq>1; + nnth = floor(gdat_data.gdat_params.freq+0.5); + gdat_data.gdat_params.freq = nnth; + end + tree = 'spectroscopy'; + gdat_data.gdat_params.tree = tree; + for i=1:length(gdat_data.gdat_params.camera) + ichord = gdat_data.gdat_params.camera(i); + diagname = ['PRAD.BOLOM.PRAD_01.POWER:' gdat_data.gdat_params.source num2str(ichord,'%.2d') '_P']; + a = gdat_d3d(shot,{tree,diagname}); + if ~isempty(a.data) + icount = icount + 1; + if icount == 1 + % first time has data + gdat_data.t = a.t(1:nnth:end); + gdat_data.units = a.units; + gdat_data.data = NaN*ones(max(gdat_data.gdat_params.camera),length(gdat_data.t)); + gdat_data.x = [1:max(gdat_data.gdat_params.camera)]; % simpler to have index corresponding to chord number, except for central + gdat_data.dim{1} = gdat_data.x; + gdat_data.dim{2} = gdat_data.t; + gdat_data.dimunits = [{'chord nb'}; {'s'}]; + gdat_data.data_fullpath = ['bolo from source=''' gdat_data.gdat_params.source '''']; + gdat_data.label = ['PRAD.BOLOM.PRAD\_01.POWER:' upper(gdat_data.gdat_params.source)]; + end + try + gdat_data.data(ichord,:) = a.data(1:nnth:end); + catch + if (gdat_params.nverbose>=1); disp(['problem with ' gdat_data.gdat_params.source '...' num2str(ichord)]); end + end else + % add fields not yet defined in case all cases have empty data + end + end + gdat_data.chords = gdat_data.gdat_params.camera; + + %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + case {'transp'} + % most of the times the exp for the shotfile should be provided + shotfile_exp_eff = gdat_params.exp_name; + diagname='TRA'; + TRANSP_signals; + for i=1:size(transp_sig,1) + if strcmp(lower(transp_sig{i,2}),'signal') || strcmp(lower(transp_sig{i,2}),'signal-group') try - gdat_data.data(icount,:) = interp1(a.t,a.data,gdat_data.t); + eval(['[gdat_data.' transp_sig{i,1} ',e]=rdaD3D_eff(shot,diagname,''' transp_sig{i,1} ''',shotfile_exp_eff);']); catch - if (gdat_params.nverbose>=1); disp(['problem with ichord = ' num2str(ichord)]); end + eval(['gdat_data.' transp_sig{i,1} '=[];']); end + elseif strcmp(lower(transp_sig{i,2}),'area-base') + clear adata_area + try + [adata_area]=sf2ab(diagname,shot,transp_sig{i,1},'-exp',shotfile_exp_eff); + catch + adata_area.value = cell(0); + end + eval(['gdat_data.' transp_sig{i,1} '=adata_area;']); + elseif strcmp(lower(transp_sig{i,2}),'time-base') + clear adata_time + try + [adata_time]=sf2tb(diagname,shot,transp_sig{i,1},'-exp',shotfile_exp_eff); + catch + adata_time.value = cell(0); + end + eval(['gdat_data.' transp_sig{i,1} '=adata_time;']); end - else - % add fields not yet defined in case all cases have empty data end - end - gdat_data.chords = gdat_data.gdat_params.camera; + % copy TIME to .t + if isfield(gdat_data,'TIME') && isfield(gdat_data.TIME,'value') + gdat_data.t = gdat_data.TIME.value; + gdat_data.dim{1} = gdat_data.t, + gdat_data.dimunits{1} = gdat_data.TIME.unit; + end - otherwise - if (gdat_params.nverbose>=1); warning(['switchcase= ' data_request_eff ' not known in gdat_d3d']); end - error_status=901; - return + %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + case {'zeff_cerq', 'zeff_cer'} + % zeff from specific cer lines, C, N, ... + if ~isfield(gdat_data.gdat_params,'camera') || isempty(gdat_data.gdat_params.camera) + gdat_data.gdat_params.camera = [9 18 20 41]; + end + gdat_data.label = {}; + for i=1:numel(gdat_data.gdat_params.camera) + gdat_data.label{i} = ['cerqzefft' num2str(gdat_data.gdat_params.camera(i))]; + end + % + if ~isfield(gdat_data.gdat_params,'time_interval') + gdat_data.gdat_params.time_interval = []; + end + icount = 0; + for i=1:length(gdat_data.gdat_params.camera) + ichord = gdat_data.gdat_params.camera(i); + diagname = ['\' gdat_data.label{i}]; + a = gdat_d3d(shot,diagname); + if ~isempty(a.data) && isnumeric(a.data) + icount = icount + 1; + if icount == 1 + % first time has data + gdat_data.t = a.t; + gdat_data.units = a.units; + gdat_data.data = NaN*ones(numel(gdat_data.gdat_params.camera),length(gdat_data.t)); + gdat_data.data(icount,:) = a.data; + gdat_data.x = gdat_data.gdat_params.camera; + gdat_data.dim{1} = gdat_data.x; + gdat_data.dim{2} = gdat_data.t; + gdat_data.dimunits = [{'t nb'}; {'s'}]; + gdat_data.data_fullpath = '\cerqzefftii'; + else + try + gdat_data.data(icount,:) = interp1(a.t,a.data,gdat_data.t); + catch + if (gdat_params.nverbose>=1); disp(['problem with ichord = ' num2str(ichord)]); end + end + end + else + % add fields not yet defined in case all cases have empty data + end + end + gdat_data.chords = gdat_data.gdat_params.camera; + + otherwise + if (gdat_params.nverbose>=1); warning(['switchcase= ' data_request_eff ' not known in gdat_d3d']); end + error_status=901; + return end else diff --git a/matlab/IMAS/complete_IDS_CORSICA.m b/matlab/IMAS/complete_IDS_CORSICA.m index f167093c5d619ee5c67213e3657e8a58285efc20..cebd796d5411b084a8c063d77fed1142915804e7 100644 --- a/matlab/IMAS/complete_IDS_CORSICA.m +++ b/matlab/IMAS/complete_IDS_CORSICA.m @@ -55,7 +55,7 @@ for ii = 1:numel(tmp.names) % Remove strange character in coil names IDS_out.pf_active.coil{jj}.name = regexprep(IDS_out.pf_active.coil{jj}.name,'[\n\r]+',''); if strcmp(tmp.names{ii},IDS_out.pf_active.coil{jj}.name) - if isempty(IDS_out.pf_active.coil{jj}.element); IDS_out.pf_active.coil{jj}.element(1) = pf_active_default.coil{1}.element(1); end + if isempty(IDS_out.pf_active.coil{jj}.element); IDS_out.pf_active.coil{jj}.element(1) = pf_active_default.coil{1}.element(1); end IDS_out.pf_active.coil{jj}.element{1}.geometry.geometry_type = 2; % Rectangle description IDS_out.pf_active.coil{jj}.element{1}.geometry.rectangle.r = tmp.R(ii); IDS_out.pf_active.coil{jj}.element{1}.geometry.rectangle.z = tmp.Z(ii); @@ -77,10 +77,10 @@ IDS_out.pf_active.time = []; IDS_out.pf_active.ids_properties.homogeneous_time = 0; if Ncircuit_eff > Ncircuit_in IDS_out.pf_active.circuit(Ncircuit_in+1:Ncircuit_eff,1) = pf_active_default.circuit(1); -end +end if Ncircuit_eff > Nsupply_in IDS_out.pf_active.supply(Nsupply_in+1:Ncircuit_eff,1) = pf_active_default.supply(1); -end +end for ii=1:Ncircuit_eff IDS_out.pf_active.circuit{ii}.name = tmp{ii,1}{1}; IDS_out.pf_active.supply{ii}.name = tmp{ii,1}{1}; @@ -95,16 +95,16 @@ for ii=1:Ncircuit_eff % The coils must share the same current in the circuit so just take the first one. IDS_out.pf_active.circuit{ii}.current.data = IDS_out.pf_active.coil{index_coil(1)}.current.data/IDS_out.pf_active.coil{index_coil(1)}.element{1}.turns_with_sign; IDS_out.pf_active.circuit{ii}.current.time = IDS_out.pf_active.coil{index_coil(1)}.current.time; - + IDS_out.pf_active.circuit{ii}.connections = zeros(2*numel(index_coil) -1 , 2*Ncircuit_eff + 2*Ncoils); for jj = 1:numel(index_coil) IDS_out.pf_active.circuit{ii}.connections( jj , 2*Ncircuit_eff + 2*(index_coil(jj)-1) +1) = 1; IDS_out.pf_active.circuit{ii}.connections( jj +1 , 2*Ncircuit_eff + 2*(index_coil(jj)-1) +2) = 1; end - + % Add the connection to the power supply - IDS_out.pf_active.circuit{ii}.connections(1, 2*ii -1) = 1; - IDS_out.pf_active.circuit{ii}.connections(end, 2*ii ) =1; + IDS_out.pf_active.circuit{ii}.connections(1, 2*ii -1) = 1; + IDS_out.pf_active.circuit{ii}.connections(end, 2*ii ) =1; end %% Limiter description diff --git a/matlab/IMAS/data_limiter.m b/matlab/IMAS/data_limiter.m index 25c05615178e26d33dbd5c6b5314931b9d288fc2..f816c3ecaff935c2272a2aade8e229c298285c43 100644 --- a/matlab/IMAS/data_limiter.m +++ b/matlab/IMAS/data_limiter.m @@ -1,7 +1,7 @@ function data_struct = data_limiter() -% Data from -%Plasma facing line of First Wall and Divertor -%Reference: [2N9J75, v.1.7], [PCR 641, PS4HQW] +% Data from +%Plasma facing line of First Wall and Divertor +%Reference: [2N9J75, v.1.7], [PCR 641, PS4HQW] R = [... 4.1761 diff --git a/matlab/IMAS/data_vessel.m b/matlab/IMAS/data_vessel.m index d2ebe7f592f82567db19690d8486217b87fee47f..9ccdcdebd124f2106c7072e904db5bf9eb5a7d31 100644 --- a/matlab/IMAS/data_vessel.m +++ b/matlab/IMAS/data_vessel.m @@ -1,6 +1,6 @@ function vessel_data = data_vessel() -% Plasma facing line of First Wall and Divertor -%Reference: [2N9J75, v.1.7], [PCR 641, PS4HQW] +% Plasma facing line of First Wall and Divertor +%Reference: [2N9J75, v.1.7], [PCR 641, PS4HQW] rin = [ ... diff --git a/matlab/IMAS/gdat_imas.m b/matlab/IMAS/gdat_imas.m index 24c3e6db505c8a10fe9e28ec27b1a275547e252f..88b72b2f647f2f8ca0bb8b09601439ac62e11e9d 100644 --- a/matlab/IMAS/gdat_imas.m +++ b/matlab/IMAS/gdat_imas.m @@ -211,7 +211,7 @@ if (nargin>=ivarargin_first_char) if mod(nargin-ivarargin_first_char+1,2)==0 for i=1:2:nargin-ivarargin_first_char+1 if ischar(varargin_eff{i}) - gdat_params.(lower(varargin_eff{i})) = varargin_eff{i+1}; % cannot enforce lower(params value) if filename or else are case sensitive + gdat_params.(lower(varargin_eff{i})) = varargin_eff{i+1}; % cannot enforce lower(params value) if filename or else are case sensitive else if gdat_params.nverbose>=1; warning(['input argument nb: ' num2str(i) ' is incorrect, expects a character string']); end error_status=401; @@ -286,7 +286,7 @@ if do_mdsopen_mdsclose end try gdat_data.gdat_params.idx_imas_open_env = imas_open_env('ids', shot, gdat_data.gdat_params.run,gdat_data.gdat_params.database_user, ... - gdat_data.gdat_params.tokamak_name,gdat_data.gdat_params.data_major_version); + gdat_data.gdat_params.tokamak_name,gdat_data.gdat_params.data_major_version); disp('') catch ME warning('could not imas_open_env with following gdat_data.gdat_params:'); @@ -304,16 +304,16 @@ else if isfield(gdat_data.gdat_params,'idx_imas_open_env') if gdat_data.gdat_params.idx_imas_open_env < 0 if gdat_data.gdat_params.nverbose>=1 - warning(['idx < 0, shot/run not opened properly with gdat_data.gdat_params:']); - gdat_data.gdat_params + warning(['idx < 0, shot/run not opened properly with gdat_data.gdat_params:']); + gdat_data.gdat_params end return end else if ~isempty(shot) if gdat_data.gdat_params.nverbose>=1 - warning(['no idx in gdat_params, cannot open shot with gdat_data.gdat_params:']); - gdat_data.gdat_params + warning(['no idx in gdat_params, cannot open shot with gdat_data.gdat_params:']); + gdat_data.gdat_params end return end @@ -389,167 +389,167 @@ elseif strcmp(mapping_for_imas.method,'switchcase') % First the request names valid for "all" machines: % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - case {'ids'} - ids_empty_path = fullfile(fileparts(mfilename('fullpath')),'..','IMAS_IMAS','ids_empty'); + case {'ids'} + ids_empty_path = fullfile(fileparts(mfilename('fullpath')),'..','IMAS_IMAS','ids_empty'); - params_eff = gdat_data.gdat_params; - if isfield(params_eff,'source') && ~isempty(params_eff.source) - ids_top_names = params_eff.source; - if ischar(ids_top_names); ids_top_names = {ids_top_names}; end - else - ids_top_name = []; - warning('gdat:EmptyIDSName','Need an ids name in ''source'' parameter\n check substructure gdat_params.sources_available for an ids list'); - addpath(ids_empty_path); - assert(~~exist('ids_list','file'),'could not find ids_list.m in %s',ids_empty_path); - gdat_data.gdat_params.sources_available = ids_list; - rmpath(ids_empty_path); - return - end - if ~isfield(params_eff,'fix_homogeneous') || isempty(params_eff.fix_homogeneous) - params_eff.fix_homogeneous = 0; - gdat_data.gdat_params.fix_homogeneous = params_eff.fix_homogeneous; - end - ids_gen_ok = ~~exist('ids_gen','file'); - if ~isfield(gdat_data.gdat_params,'error_bar') || isempty(gdat_data.gdat_params.error_bar) - gdat_data.gdat_params.error_bar = 'delta'; - end - if ~isfield(gdat_data.gdat_params,'cocos_in') || isempty(gdat_data.gdat_params.cocos_in) - gdat_data.gdat_params.cocos_in = 11; - end - if ~isfield(gdat_data.gdat_params,'cocos_out') || isempty(gdat_data.gdat_params.cocos_out) - gdat_data.gdat_params.cocos_out = 11; - end - if ~isfield(gdat_data.gdat_params,'ipsign_out') || isempty(gdat_data.gdat_params.ipsign_out) - gdat_data.gdat_params.ipsign_out = 0; - end - if ~isfield(gdat_data.gdat_params,'b0sign_out') || isempty(gdat_data.gdat_params.b0sign_out) - gdat_data.gdat_params.b0sign_out = 0; - end - if ~isfield(gdat_data.gdat_params,'ipsign_in') || isempty(gdat_data.gdat_params.ipsign_in) - if gdat_data.gdat_params.ipsign_out~=0 - gdat_data.gdat_params.ipsign_in = -1; + params_eff = gdat_data.gdat_params; + if isfield(params_eff,'source') && ~isempty(params_eff.source) + ids_top_names = params_eff.source; + if ischar(ids_top_names); ids_top_names = {ids_top_names}; end else - gdat_data.gdat_params.ipsign_in = 0; + ids_top_name = []; + warning('gdat:EmptyIDSName','Need an ids name in ''source'' parameter\n check substructure gdat_params.sources_available for an ids list'); + addpath(ids_empty_path); + assert(~~exist('ids_list','file'),'could not find ids_list.m in %s',ids_empty_path); + gdat_data.gdat_params.sources_available = ids_list; + rmpath(ids_empty_path); + return end - end - if ~isfield(gdat_data.gdat_params,'b0sign_in') || isempty(gdat_data.gdat_params.b0sign_in) - if gdat_data.gdat_params.b0sign_out~=0 - gdat_data.gdat_params.b0sign_in = -1; - else - gdat_data.gdat_params.b0sign_in = 0; + if ~isfield(params_eff,'fix_homogeneous') || isempty(params_eff.fix_homogeneous) + params_eff.fix_homogeneous = 0; + gdat_data.gdat_params.fix_homogeneous = params_eff.fix_homogeneous; end - end - for i=1:length(ids_top_names) - ids_top_name = ids_top_names{i}; - if ids_gen_ok - ids_empty = ids_gen(ids_top_name); % generate ids from 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); - disp(['use structure in .mat file: ' ids_empty_path '/' fname]); - rmpath(ids_empty_path); - catch ME - fprintf('Could not load empty template for %s\n',ids_top_name); - fprintf('Available templates:\n'); - disp(dir(ids_empty_path)); - rmpath(ids_empty_path); - rethrow(ME); - end + ids_gen_ok = ~~exist('ids_gen','file'); + if ~isfield(gdat_data.gdat_params,'error_bar') || isempty(gdat_data.gdat_params.error_bar) + gdat_data.gdat_params.error_bar = 'delta'; end - % load data - try - if isfield(gdat_data.gdat_params,'idx_imas_open_env') && gdat_data.gdat_params.idx_imas_open_env >= 0 - if gdat_data.gdat_params.occurence == 0 - ids_top = ids_get(gdat_data.gdat_params.idx_imas_open_env,ids_top_name); - else - ids_top = ids_get(gdat_data.gdat_params.idx_imas_open_env,[ids_top_name '/' num2str(gdat_data.gdat_params.occurence)]); - end - gdat_data.(ids_top_name) = ids_top; - else - gdat_data.(ids_top_name) = ids_empty; - return - end - catch ME_imas_ids_get - disp(['there is a problem with: imas_get_ids_' ids_top_name ... - ' , 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 '_help']) = getReport(ME_imas_ids_get); - rethrow(ME_imas_ids_get) + if ~isfield(gdat_data.gdat_params,'cocos_in') || isempty(gdat_data.gdat_params.cocos_in) + gdat_data.gdat_params.cocos_in = 11; end - % check homogeneous - switch gdat_data.(ids_top_name).ids_properties.homogeneous_time - case -999999999 - warning([ids_top_name '.ids_properties.homogeneous_time is not defined']); - if isempty(gdat_data.(ids_top_name).time) - if gdat_data.gdat_params.fix_homogeneous - gdat_data.(ids_top_name).ids_properties.homogeneous_time = 0; - warning([ids_top_name '.ids_properties.homogeneous_time set to 0 since .time empty']); - end - elseif isfinite(gdat_data.(ids_top_name).time) - if gdat_data.gdat_params.fix_homogeneous - gdat_data.(ids_top_name).ids_properties.homogeneous_time = 1; - warning([ids_top_name '.ids_properties.homogeneous_time set to 1 since .time finite']); - end - end - case 0 - if ~isempty(gdat_data.(ids_top_name).time) - disp([ids_top_name '.ids_properties.homogeneous_time=0 but .time not empty, to check']) - end - case 1 - if isempty(gdat_data.(ids_top_name).time) - disp([ids_top_name '.ids_properties.homogeneous_time=1 but .time empty, to check']) - end - otherwise - warning([ids_top_name '.ids_properties.homogeneous_time = ' num2str(gdat_data.(ids_top_name).ids_properties.homogeneous_time) ... - ' not sure what to check']) + if ~isfield(gdat_data.gdat_params,'cocos_out') || isempty(gdat_data.gdat_params.cocos_out) + gdat_data.gdat_params.cocos_out = 11; end - % Perform cocos transformation if cocos_out ~= cocos_in - if gdat_data.gdat_params.cocos_in ~= gdat_data.gdat_params.cocos_out - [ids_out,cocoscoeff]=ids_generic_cocos_nodes_transformation_symbolic(gdat_data.(ids_top_name),ids_top_name, ... - gdat_data.gdat_params.cocos_in, gdat_data.gdat_params.cocos_out, gdat_data.gdat_params.ipsign_out,gdat_data.gdat_params.b0sign_out, ... - gdat_data.gdat_params.ipsign_in, gdat_data.gdat_params.b0sign_in); - gdat_data.(ids_top_name) = ids_out; + if ~isfield(gdat_data.gdat_params,'ipsign_out') || isempty(gdat_data.gdat_params.ipsign_out) + gdat_data.gdat_params.ipsign_out = 0; end - end - - %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - case {'eqdsk'} - % add defaults - if ~isfield(gdat_data.gdat_params,'time') - gdat_data.gdat_params.time = 1.; % default time - end - if ~isfield(gdat_data.gdat_params,'write') - gdat_data.gdat_params.write = 1; % default write eqdsk to /tmp/username - end - params_eff = gdat_data.gdat_params; - params_eff = rmfield(params_eff,'time'); - params_eff.data_request = 'ids'; - params_eff.source = 'equilibrium'; - gdat_equil = gdat_imas(shot,params_eff); - params_eff.source = 'wall'; - gdat_wall = gdat_imas(shot,params_eff); - % - eqdsk_filename_suffix = [num2str(gdat_data.shot) '_' num2str(gdat_data.gdat_params.run) 't' num2str(gdat_data.gdat_params.time) ... - gdat_data.gdat_params.tokamak_name '_' gdat_data.gdat_params.database_user]; - [eqdsk_out] = ids2eqdsk(gdat_equil.equilibrium,gdat_wall.wall,gdat_data.gdat_params.time,eqdsk_filename_suffix,gdat_data.gdat_params.write); - gdat_data.equilibrium = gdat_equil.equilibrium; - gdat_data.wall = gdat_wall.wall; - gdat_data.eqdsk = eqdsk_out; - if isfield(gdat_data.gdat_params,'doplot') && gdat_data.gdat_params.doplot == 1 - plot_eqdsk(gdat_data.eqdsk) - end - - %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - otherwise - if (gdat_params.nverbose>=1); warning(['switchcase= ' data_request_eff ' not known in gdat_imas']); end - error_status=901; - return + if ~isfield(gdat_data.gdat_params,'b0sign_out') || isempty(gdat_data.gdat_params.b0sign_out) + gdat_data.gdat_params.b0sign_out = 0; + end + if ~isfield(gdat_data.gdat_params,'ipsign_in') || isempty(gdat_data.gdat_params.ipsign_in) + if gdat_data.gdat_params.ipsign_out~=0 + gdat_data.gdat_params.ipsign_in = -1; + else + gdat_data.gdat_params.ipsign_in = 0; + end + end + if ~isfield(gdat_data.gdat_params,'b0sign_in') || isempty(gdat_data.gdat_params.b0sign_in) + if gdat_data.gdat_params.b0sign_out~=0 + gdat_data.gdat_params.b0sign_in = -1; + else + gdat_data.gdat_params.b0sign_in = 0; + end + end + for i=1:length(ids_top_names) + ids_top_name = ids_top_names{i}; + if ids_gen_ok + ids_empty = ids_gen(ids_top_name); % generate ids from 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); + disp(['use structure in .mat file: ' ids_empty_path '/' fname]); + rmpath(ids_empty_path); + catch ME + fprintf('Could not load empty template for %s\n',ids_top_name); + fprintf('Available templates:\n'); + disp(dir(ids_empty_path)); + rmpath(ids_empty_path); + rethrow(ME); + end + end + % load data + try + if isfield(gdat_data.gdat_params,'idx_imas_open_env') && gdat_data.gdat_params.idx_imas_open_env >= 0 + if gdat_data.gdat_params.occurence == 0 + ids_top = ids_get(gdat_data.gdat_params.idx_imas_open_env,ids_top_name); + else + ids_top = ids_get(gdat_data.gdat_params.idx_imas_open_env,[ids_top_name '/' num2str(gdat_data.gdat_params.occurence)]); + end + gdat_data.(ids_top_name) = ids_top; + else + gdat_data.(ids_top_name) = ids_empty; + return + end + catch ME_imas_ids_get + disp(['there is a problem with: imas_get_ids_' ids_top_name ... + ' , 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 '_help']) = getReport(ME_imas_ids_get); + rethrow(ME_imas_ids_get) + end + % check homogeneous + switch gdat_data.(ids_top_name).ids_properties.homogeneous_time + case -999999999 + warning([ids_top_name '.ids_properties.homogeneous_time is not defined']); + if isempty(gdat_data.(ids_top_name).time) + if gdat_data.gdat_params.fix_homogeneous + gdat_data.(ids_top_name).ids_properties.homogeneous_time = 0; + warning([ids_top_name '.ids_properties.homogeneous_time set to 0 since .time empty']); + end + elseif isfinite(gdat_data.(ids_top_name).time) + if gdat_data.gdat_params.fix_homogeneous + gdat_data.(ids_top_name).ids_properties.homogeneous_time = 1; + warning([ids_top_name '.ids_properties.homogeneous_time set to 1 since .time finite']); + end + end + case 0 + if ~isempty(gdat_data.(ids_top_name).time) + disp([ids_top_name '.ids_properties.homogeneous_time=0 but .time not empty, to check']) + end + case 1 + if isempty(gdat_data.(ids_top_name).time) + disp([ids_top_name '.ids_properties.homogeneous_time=1 but .time empty, to check']) + end + otherwise + warning([ids_top_name '.ids_properties.homogeneous_time = ' num2str(gdat_data.(ids_top_name).ids_properties.homogeneous_time) ... + ' not sure what to check']) + end + % Perform cocos transformation if cocos_out ~= cocos_in + if gdat_data.gdat_params.cocos_in ~= gdat_data.gdat_params.cocos_out + [ids_out,cocoscoeff]=ids_generic_cocos_nodes_transformation_symbolic(gdat_data.(ids_top_name),ids_top_name, ... + gdat_data.gdat_params.cocos_in, gdat_data.gdat_params.cocos_out, gdat_data.gdat_params.ipsign_out,gdat_data.gdat_params.b0sign_out, ... + gdat_data.gdat_params.ipsign_in, gdat_data.gdat_params.b0sign_in); + gdat_data.(ids_top_name) = ids_out; + end + end + + %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + case {'eqdsk'} + % add defaults + if ~isfield(gdat_data.gdat_params,'time') + gdat_data.gdat_params.time = 1.; % default time + end + if ~isfield(gdat_data.gdat_params,'write') + gdat_data.gdat_params.write = 1; % default write eqdsk to /tmp/username + end + params_eff = gdat_data.gdat_params; + params_eff = rmfield(params_eff,'time'); + params_eff.data_request = 'ids'; + params_eff.source = 'equilibrium'; + gdat_equil = gdat_imas(shot,params_eff); + params_eff.source = 'wall'; + gdat_wall = gdat_imas(shot,params_eff); + % + eqdsk_filename_suffix = [num2str(gdat_data.shot) '_' num2str(gdat_data.gdat_params.run) 't' num2str(gdat_data.gdat_params.time) ... + gdat_data.gdat_params.tokamak_name '_' gdat_data.gdat_params.database_user]; + [eqdsk_out] = ids2eqdsk(gdat_equil.equilibrium,gdat_wall.wall,gdat_data.gdat_params.time,eqdsk_filename_suffix,gdat_data.gdat_params.write); + gdat_data.equilibrium = gdat_equil.equilibrium; + gdat_data.wall = gdat_wall.wall; + gdat_data.eqdsk = eqdsk_out; + if isfield(gdat_data.gdat_params,'doplot') && gdat_data.gdat_params.doplot == 1 + plot_eqdsk(gdat_data.eqdsk) + end + + %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + otherwise + if (gdat_params.nverbose>=1); warning(['switchcase= ' data_request_eff ' not known in gdat_imas']); end + error_status=901; + return end else @@ -625,7 +625,7 @@ else end if ~isempty(tracefirrat.data) && ~ischar(tracefirrat.data) && any(isfinite(tracefirrat.data)) ... - && ~isempty(tracefirrat.dim) && ~isempty(tracefirrat.dim{1}) + && ~isempty(tracefirrat.dim) && ~isempty(tracefirrat.dim{1}) firthomratio = interp1(tracefirrat.dim{1},tracefirrat.data,timebase); end diff --git a/matlab/JET/gdat_jet.m b/matlab/JET/gdat_jet.m index 28b88ef5f6820c6173966b4fbf3cdb4b58a47e17..d522d546b81f183e28ccfc711951c545308688c7 100644 --- a/matlab/JET/gdat_jet.m +++ b/matlab/JET/gdat_jet.m @@ -220,8 +220,8 @@ if ~isempty(ij); 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']); + '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 @@ -280,9 +280,9 @@ if strcmp(mapping_for_jet.method,'signal') elseif length(size(aatmp.data))==2 % 2 true dimensions if length(aatmp.t) == size(aatmp.data,1) - mapping_for_jet.timedim = 1; + mapping_for_jet.timedim = 1; else - mapping_for_jet.timedim = 2; + mapping_for_jet.timedim = 2; end else % more than 2 dimensions, find the one with same length to define timedim @@ -304,9 +304,9 @@ if strcmp(mapping_for_jet.method,'signal') nbdims = length(size(gdat_data.data)); for i=1:nbdims if i~=mapping_for_jet.timedim - ieff=i; - if i>mapping_for_jet.timedim; ieff=i-1; end - gdat_data.dim{i} = gdat_data.x{ieff}; + ieff=i; + if i>mapping_for_jet.timedim; ieff=i-1; end + gdat_data.dim{i} = gdat_data.x{ieff}; end end end @@ -401,80 +401,122 @@ elseif strcmp(mapping_for_jet.method,'switchcase') %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - case {'cxrs'} - %not yet finished, just started - % load typical data from cxrs, Ti, ni, vtori and vpoli (if available), as well as zeff from cxrs - % if 'fit' option is added: 'fit',1, then the fitted profiles are returned - % - % sub_nodes names from CXRS_get_profiles function, lower case when used in gdat - sub_nodes = {'Ti','vTor','vPol','nC','Zeff'}; % first node is also copied into data, choose "default' one - sub_nodes_out = lower({'Ti','vTor','vPol','ni','Zeff'}); % - sub_nodes_units = {'eV','m/s','m/s','m^{-3}',''}; % first node is also copied into data, choose "default' one - % use A. Karpushov routine to get profiles and then copy the data or the fitted profiles - aa=CXRS_get_profiles; cxrs_params = aa.param; - cxrs_params.k_plot=0; cxrs_params.k_debug=0; - % add params from gdat call - params_eff = gdat_data.gdat_params; - if isfield(params_eff,'cxrs_plot') && params_eff.cxrs_plot>0 - cxrs_plot = params_eff.cxrs_plot; - else - cxrs_plot = 0; - end - gdat_data.gdat_params.cxrs_plot = cxrs_plot; - if isfield(params_eff,'source') && ~isempty(params_eff.source) - source = params_eff.source; - else - source = [1 2 3]; - end - gdat_data.gdat_params.source = source; - if isfield(params_eff,'time_interval') && ~isempty(params_eff.time_interval) && length(params_eff.time_interval)>=2 - time_interval = params_eff.time_interval; - cxrs_plot=1; - else - time_interval = []; - end - gdat_data.gdat_params.time_interval = time_interval; - gdat_data.gdat_params.cxrs_plot = cxrs_plot; - fit_tension_default = -100.; - if isfield(params_eff,'fit_tension') - fit_tension = params_eff.fit_tension; - else - fit_tension = fit_tension_default; - end - if ~isstruct(fit_tension) - fit_tension_eff.ti = fit_tension; - fit_tension_eff.vi = fit_tension; - fit_tension_eff.ni = fit_tension; - fit_tension_eff.zeff = fit_tension; - fit_tension = fit_tension_eff; - else - if ~isfield(fit_tension,'ti'); fit_tension.ti = fit_tension_default; end - if ~isfield(fit_tension,'vi'); fit_tension.vi = fit_tension_default; end - if ~isfield(fit_tension,'ni') && ~isfield(fit_tension,'nc'); fit_tension.ni = fit_tension_default; end - if ~isfield(fit_tension,'zeff'); fit_tension.zeff = fit_tension_default; end - end - gdat_data.gdat_params.fit_tension = fit_tension; - cxrs_params.prof.Ti.taus = fit_tension.ti; - cxrs_params.prof.vi.taus = fit_tension.vi; - cxrs_params.prof.nc.taus = fit_tension.ni; - cxrs_params.prof.zeff.taus = fit_tension.zeff; - cxrs_params.k_plot = cxrs_plot; - cxrs_profiles = CXRS_get_profiles(shot,source,time_interval,cxrs_params); - inb_times = length(cxrs_profiles.Times); - gdat_data.cxrs_params = cxrs_profiles.param; - if isempty(cxrs_profiles.Times) || ~isfield(cxrs_profiles,'proffit') - if (gdat_params.nverbose>=1); warning(['problems loading data with CXRS_get_profiles for data_request= ' data_request_eff]); end + case {'cxrs'} + %not yet finished, just started + % load typical data from cxrs, Ti, ni, vtori and vpoli (if available), as well as zeff from cxrs + % if 'fit' option is added: 'fit',1, then the fitted profiles are returned + % + % sub_nodes names from CXRS_get_profiles function, lower case when used in gdat + sub_nodes = {'Ti','vTor','vPol','nC','Zeff'}; % first node is also copied into data, choose "default' one + sub_nodes_out = lower({'Ti','vTor','vPol','ni','Zeff'}); % + sub_nodes_units = {'eV','m/s','m/s','m^{-3}',''}; % first node is also copied into data, choose "default' one + % use A. Karpushov routine to get profiles and then copy the data or the fitted profiles + aa=CXRS_get_profiles; cxrs_params = aa.param; + cxrs_params.k_plot=0; cxrs_params.k_debug=0; + % add params from gdat call + params_eff = gdat_data.gdat_params; + if isfield(params_eff,'cxrs_plot') && params_eff.cxrs_plot>0 + cxrs_plot = params_eff.cxrs_plot; + else + cxrs_plot = 0; + end + gdat_data.gdat_params.cxrs_plot = cxrs_plot; + if isfield(params_eff,'source') && ~isempty(params_eff.source) + source = params_eff.source; + else + source = [1 2 3]; + end + gdat_data.gdat_params.source = source; + if isfield(params_eff,'time_interval') && ~isempty(params_eff.time_interval) && length(params_eff.time_interval)>=2 + time_interval = params_eff.time_interval; + cxrs_plot=1; + else + time_interval = []; + end + gdat_data.gdat_params.time_interval = time_interval; + gdat_data.gdat_params.cxrs_plot = cxrs_plot; + fit_tension_default = -100.; + if isfield(params_eff,'fit_tension') + fit_tension = params_eff.fit_tension; + else + fit_tension = fit_tension_default; + end + if ~isstruct(fit_tension) + fit_tension_eff.ti = fit_tension; + fit_tension_eff.vi = fit_tension; + fit_tension_eff.ni = fit_tension; + fit_tension_eff.zeff = fit_tension; + fit_tension = fit_tension_eff; + else + if ~isfield(fit_tension,'ti'); fit_tension.ti = fit_tension_default; end + if ~isfield(fit_tension,'vi'); fit_tension.vi = fit_tension_default; end + if ~isfield(fit_tension,'ni') && ~isfield(fit_tension,'nc'); fit_tension.ni = fit_tension_default; end + if ~isfield(fit_tension,'zeff'); fit_tension.zeff = fit_tension_default; end + end + gdat_data.gdat_params.fit_tension = fit_tension; + cxrs_params.prof.Ti.taus = fit_tension.ti; + cxrs_params.prof.vi.taus = fit_tension.vi; + cxrs_params.prof.nc.taus = fit_tension.ni; + cxrs_params.prof.zeff.taus = fit_tension.zeff; + cxrs_params.k_plot = cxrs_plot; + cxrs_profiles = CXRS_get_profiles(shot,source,time_interval,cxrs_params); + inb_times = length(cxrs_profiles.Times); + gdat_data.cxrs_params = cxrs_profiles.param; + if isempty(cxrs_profiles.Times) || ~isfield(cxrs_profiles,'proffit') + if (gdat_params.nverbose>=1); warning(['problems loading data with CXRS_get_profiles for data_request= ' data_request_eff]); end + for i=1:length(sub_nodes) + sub_eff_out = sub_nodes_out{i}; + gdat_data.(sub_eff_out).fit.data = []; + gdat_data.(sub_eff_out).fit.rho = []; + gdat_data.(sub_eff_out).fit.error_bar = []; + gdat_data.(sub_eff_out).raw.data = []; + gdat_data.(sub_eff_out).raw.rho = []; + gdat_data.(sub_eff_out).raw.error_bar = []; + gdat_data.(sub_eff_out).raw.error_bar_rho = []; + gdat_data.(sub_eff_out).raw.cxrs_system = []; + gdat_data.time_interval = []; + gdat_data.(sub_eff_out).units = sub_nodes_units{i}; + if i==1 + gdat_data.data = gdat_data.(sub_eff_out).fit.data; + gdat_data.x = gdat_data.(sub_eff_out).fit.rho; + gdat_data.error_bar = gdat_data.(sub_eff_out).fit.error_bar; + gdat_data.units = gdat_data.(sub_eff_out).units; + end + end + return + end + inb_channels =120; % need to change if gets bigger!!! but easier to prefill with NaNs and use the "use" part for i=1:length(sub_nodes) + sub_eff = sub_nodes{i}; sub_eff_out = sub_nodes_out{i}; - gdat_data.(sub_eff_out).fit.data = []; - gdat_data.(sub_eff_out).fit.rho = []; - gdat_data.(sub_eff_out).fit.error_bar = []; - gdat_data.(sub_eff_out).raw.data = []; - gdat_data.(sub_eff_out).raw.rho = []; - gdat_data.(sub_eff_out).raw.error_bar = []; - gdat_data.(sub_eff_out).raw.error_bar_rho = []; - gdat_data.(sub_eff_out).raw.cxrs_system = []; + % fits + if isfield(cxrs_profiles.proffit,sub_eff) + gdat_data.(sub_eff_out).fit.data = cxrs_profiles.proffit.(sub_eff); + gdat_data.(sub_eff_out).fit.rho = cxrs_profiles.proffit.([sub_eff '_rho']); + gdat_data.(sub_eff_out).fit.error_bar = cxrs_profiles.proffit.(['d' sub_eff]); + else + gdat_data.(sub_eff_out).fit.data = []; + gdat_data.(sub_eff_out).fit.rho = []; + gdat_data.(sub_eff_out).fit.error_bar = []; + end + % raw data (use all data so keep same size) + gdat_data.(sub_eff_out).raw.data = NaN * ones(inb_channels,inb_times); + gdat_data.(sub_eff_out).raw.rho = NaN * ones(inb_channels,inb_times); + gdat_data.(sub_eff_out).raw.error_bar = NaN * ones(inb_channels,inb_times); + gdat_data.(sub_eff_out).raw.error_bar_rho = NaN * ones(inb_channels,inb_times); + gdat_data.(sub_eff_out).raw.cxrs_system = NaN * ones(inb_channels,inb_times); gdat_data.time_interval = []; + for it=1:inb_times + if isfield(cxrs_profiles,sub_eff) + nb_raw_points = length(cxrs_profiles.(sub_eff){it}.use.y); + gdat_data.(sub_eff_out).raw.data(1:nb_raw_points,it) = cxrs_profiles.(sub_eff){it}.use.y; + gdat_data.(sub_eff_out).raw.rho(1:nb_raw_points,it) = cxrs_profiles.(sub_eff){it}.use.x; + gdat_data.(sub_eff_out).raw.error_bar(1:nb_raw_points,it) = cxrs_profiles.(sub_eff){it}.use.dy; + gdat_data.(sub_eff_out).raw.error_bar_rho(1:nb_raw_points,it) = cxrs_profiles.(sub_eff){it}.use.dx; + gdat_data.(sub_eff_out).raw.cxrs_system(1:nb_raw_points,it) = cxrs_profiles.(sub_eff){it}.use.sys; + gdat_data.time_interval{it} = cxrs_profiles.(sub_eff){it}.t_lim; + end + end gdat_data.(sub_eff_out).units = sub_nodes_units{i}; if i==1 gdat_data.data = gdat_data.(sub_eff_out).fit.data; @@ -483,557 +525,515 @@ elseif strcmp(mapping_for_jet.method,'switchcase') gdat_data.units = gdat_data.(sub_eff_out).units; end end - return - end - inb_channels =120; % need to change if gets bigger!!! but easier to prefill with NaNs and use the "use" part - for i=1:length(sub_nodes) - sub_eff = sub_nodes{i}; - sub_eff_out = sub_nodes_out{i}; - % fits - if isfield(cxrs_profiles.proffit,sub_eff) - gdat_data.(sub_eff_out).fit.data = cxrs_profiles.proffit.(sub_eff); - gdat_data.(sub_eff_out).fit.rho = cxrs_profiles.proffit.([sub_eff '_rho']); - gdat_data.(sub_eff_out).fit.error_bar = cxrs_profiles.proffit.(['d' sub_eff]); + gdat_data.t = cxrs_profiles.proffit.time; + gdat_data.dim = {gdat_data.x; gdat_data.t}; + if isempty(time_interval) + gdat_data.data_fullpath=['CXRS_get_profiles(' num2str(shot) ',[1 2 3],[],cxrs_params); % with cxrs_params']; else - gdat_data.(sub_eff_out).fit.data = []; - gdat_data.(sub_eff_out).fit.rho = []; - gdat_data.(sub_eff_out).fit.error_bar = []; - end - % raw data (use all data so keep same size) - gdat_data.(sub_eff_out).raw.data = NaN * ones(inb_channels,inb_times); - gdat_data.(sub_eff_out).raw.rho = NaN * ones(inb_channels,inb_times); - gdat_data.(sub_eff_out).raw.error_bar = NaN * ones(inb_channels,inb_times); - gdat_data.(sub_eff_out).raw.error_bar_rho = NaN * ones(inb_channels,inb_times); - gdat_data.(sub_eff_out).raw.cxrs_system = NaN * ones(inb_channels,inb_times); - gdat_data.time_interval = []; - for it=1:inb_times - if isfield(cxrs_profiles,sub_eff) - nb_raw_points = length(cxrs_profiles.(sub_eff){it}.use.y); - gdat_data.(sub_eff_out).raw.data(1:nb_raw_points,it) = cxrs_profiles.(sub_eff){it}.use.y; - gdat_data.(sub_eff_out).raw.rho(1:nb_raw_points,it) = cxrs_profiles.(sub_eff){it}.use.x; - gdat_data.(sub_eff_out).raw.error_bar(1:nb_raw_points,it) = cxrs_profiles.(sub_eff){it}.use.dy; - gdat_data.(sub_eff_out).raw.error_bar_rho(1:nb_raw_points,it) = cxrs_profiles.(sub_eff){it}.use.dx; - gdat_data.(sub_eff_out).raw.cxrs_system(1:nb_raw_points,it) = cxrs_profiles.(sub_eff){it}.use.sys; - gdat_data.time_interval{it} = cxrs_profiles.(sub_eff){it}.t_lim; - end + gdat_data.data_fullpath=['CXRS_get_profiles(' num2str(shot) ',[1 2 3],[' num2str(time_interval) '],cxrs_params); % with cxrs_params']; end - gdat_data.(sub_eff_out).units = sub_nodes_units{i}; - if i==1 - gdat_data.data = gdat_data.(sub_eff_out).fit.data; - gdat_data.x = gdat_data.(sub_eff_out).fit.rho; - gdat_data.error_bar = gdat_data.(sub_eff_out).fit.error_bar; - gdat_data.units = gdat_data.(sub_eff_out).units; - end - end - gdat_data.t = cxrs_profiles.proffit.time; - gdat_data.dim = {gdat_data.x; gdat_data.t}; - if isempty(time_interval) - gdat_data.data_fullpath=['CXRS_get_profiles(' num2str(shot) ',[1 2 3],[],cxrs_params); % with cxrs_params']; - else - gdat_data.data_fullpath=['CXRS_get_profiles(' num2str(shot) ',[1 2 3],[' num2str(time_interval) '],cxrs_params); % with cxrs_params']; - end - gdat_data.dimunits{1} = ''; - gdat_data.dimunits{2} = 's'; + gdat_data.dimunits{1} = ''; + gdat_data.dimunits{2} = 's'; - %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - case {'ece', 'eced', 'ece_rho', 'eced_rho'} - params_eff = gdat_data.gdat_params; - channel_index = [1 96]; - if ~isfield(params_eff,'channel_index') || isempty(params_eff.channel_index) - params_eff.channel_index = channel_index; - else - channel_index = params_eff.channel_index; - end - channel_index_list = channel_index; - if numel(channel_index) == 2; channel_index_list=[channel_index(1):channel_index(2)]; end - if isfield(params_eff,'time_interval') && ~isempty(params_eff.time_interval) && length(params_eff.time_interval)>=2 - time_interval = params_eff.time_interval; - else - time_interval = []; - end - gdat_data.gdat_params.time_interval = time_interval; - fit_tension_default = -3.; - if isfield(params_eff,'fit_tension') - fit_tension = params_eff.fit_tension; - else - fit_tension = fit_tension_default; - end - i = channel_index_list(1); - aa.data = []; - for i=channel_index_list(2:end) - if isempty(aa.data) - params_eff.data_request = {'ppf','kk3',num2str(i,'te%.2d')}; - aa = gdat_jet(shot,params_eff); - if ~isempty(aa.data) - aa_data_start(i,:) = reshape(aa.data,1,numel(aa.data)); - aa.data = aa_data_start; - params_eff.data_request = {'ppf','kk3',num2str(i,'rc%.2d')}; - gdat_data.rc = gdat_jet(shot,params_eff); - rc_data(i,:) = reshape(gdat_data.rc.data,1,numel(gdat_data.rc.data)); - gdat_data.rc.data = rc_data; - end + %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + case {'ece', 'eced', 'ece_rho', 'eced_rho'} + params_eff = gdat_data.gdat_params; + channel_index = [1 96]; + if ~isfield(params_eff,'channel_index') || isempty(params_eff.channel_index) + params_eff.channel_index = channel_index; else - % assume same time for all - % mds_dir = '/home/amerle/public/mds-ssh'; - mds_dir = '/home/amerle/public/mds-ssh3'; - if exist(mds_dir,'dir') && ~strcmp(which('mdsipmex'),fullfile(mds_dir,'mdsipmex.mexa64')) - addpath(mds_dir); - end - mdsconnect(['ssh://' gdat_params.jet_user '@mdsplus.jetdata.eu']); - if exist(mds_dir,'dir') && ~strcmp(which('mdsipmex'),fullfile(mds_dir,'mdsipmex.mexa64')) - rmpath(mds_dir); - end - rda_data_request = ['ppf/kk3/' num2str(i,'te%.2d')]; - bb = mdsvalue(['_bb=jet("' rda_data_request '",' num2str(shot) ')']); - if ~isempty(bb) && numel(bb)==size(aa.data,2) - aa.data(i,:) = bb; - end - rda_data_request = ['ppf/kk3/' num2str(i,'rc%.2d')]; - bb = mdsvalue(['_bb=jet("' rda_data_request '",' num2str(shot) ')']); - if ~isempty(bb) && numel(bb)==size(gdat_data.rc.data,2) - gdat_data.rc.data(i,:) = bb; + channel_index = params_eff.channel_index; + end + channel_index_list = channel_index; + if numel(channel_index) == 2; channel_index_list=[channel_index(1):channel_index(2)]; end + if isfield(params_eff,'time_interval') && ~isempty(params_eff.time_interval) && length(params_eff.time_interval)>=2 + time_interval = params_eff.time_interval; + else + time_interval = []; + end + gdat_data.gdat_params.time_interval = time_interval; + fit_tension_default = -3.; + if isfield(params_eff,'fit_tension') + fit_tension = params_eff.fit_tension; + else + fit_tension = fit_tension_default; + end + i = channel_index_list(1); + aa.data = []; + for i=channel_index_list(2:end) + if isempty(aa.data) + params_eff.data_request = {'ppf','kk3',num2str(i,'te%.2d')}; + aa = gdat_jet(shot,params_eff); + if ~isempty(aa.data) + aa_data_start(i,:) = reshape(aa.data,1,numel(aa.data)); + aa.data = aa_data_start; + params_eff.data_request = {'ppf','kk3',num2str(i,'rc%.2d')}; + gdat_data.rc = gdat_jet(shot,params_eff); + rc_data(i,:) = reshape(gdat_data.rc.data,1,numel(gdat_data.rc.data)); + gdat_data.rc.data = rc_data; + end + else + % assume same time for all + % mds_dir = '/home/amerle/public/mds-ssh'; + mds_dir = '/home/amerle/public/mds-ssh3'; + if exist(mds_dir,'dir') && ~strcmp(which('mdsipmex'),fullfile(mds_dir,'mdsipmex.mexa64')) + addpath(mds_dir); + end + mdsconnect(['ssh://' gdat_params.jet_user '@mdsplus.jetdata.eu']); + if exist(mds_dir,'dir') && ~strcmp(which('mdsipmex'),fullfile(mds_dir,'mdsipmex.mexa64')) + rmpath(mds_dir); + end + rda_data_request = ['ppf/kk3/' num2str(i,'te%.2d')]; + bb = mdsvalue(['_bb=jet("' rda_data_request '",' num2str(shot) ')']); + if ~isempty(bb) && numel(bb)==size(aa.data,2) + aa.data(i,:) = bb; + end + rda_data_request = ['ppf/kk3/' num2str(i,'rc%.2d')]; + bb = mdsvalue(['_bb=jet("' rda_data_request '",' num2str(shot) ')']); + if ~isempty(bb) && numel(bb)==size(gdat_data.rc.data,2) + gdat_data.rc.data(i,:) = bb; + end end end - end - gdat_data.data = aa.data; - gdat_data.t = aa.t; - gdat_data.units = 'eV'; - gdat_data.dim{1} = channel_index_list; - gdat_data.dim{2} = gdat_data.t; - gdat_data.x = gdat_data.dim{1}; - gdat_data.dimunits{1} = 'xx'; - gdat_data.dimunits{2} = 's'; - gdat_data.data_fullpath = aa.data_fullpath; - gdat_data.label = aa.label; - gdat_data.help = 'using jet() call for other data channels to avoid loading t many times'; - gdat_data.rc.units = 'm'; - gdat_data.rc.dim{1} = channel_index_list; - gdat_data.rc.dim{2} = gdat_data.rc.t; - gdat_data.rc.x = gdat_data.rc.dim{1}; - gdat_data.rc.dimunits{1} = 'xx'; - gdat_data.rc.dimunits{2} = 's'; + gdat_data.data = aa.data; + gdat_data.t = aa.t; + gdat_data.units = 'eV'; + gdat_data.dim{1} = channel_index_list; + gdat_data.dim{2} = gdat_data.t; + gdat_data.x = gdat_data.dim{1}; + gdat_data.dimunits{1} = 'xx'; + gdat_data.dimunits{2} = 's'; + gdat_data.data_fullpath = aa.data_fullpath; + gdat_data.label = aa.label; + gdat_data.help = 'using jet() call for other data channels to avoid loading t many times'; + gdat_data.rc.units = 'm'; + gdat_data.rc.dim{1} = channel_index_list; + gdat_data.rc.dim{2} = gdat_data.rc.t; + gdat_data.rc.x = gdat_data.rc.dim{1}; + gdat_data.rc.dimunits{1} = 'xx'; + gdat_data.rc.dimunits{2} = 's'; - %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - case {'eqdsk'} - % - time=1.; % default time - if isfield(gdat_data.gdat_params,'time') && ~isempty(gdat_data.gdat_params.time) - time = gdat_data.gdat_params.time; - else + %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + case {'eqdsk'} + % + time=1.; % default time + if isfield(gdat_data.gdat_params,'time') && ~isempty(gdat_data.gdat_params.time) + time = gdat_data.gdat_params.time; + else + gdat_data.gdat_params.time = time; + if (gdat_params.nverbose>=3); disp(['"time" is expected as an option, choose default time = ' num2str(time)]); end + end gdat_data.gdat_params.time = time; - if (gdat_params.nverbose>=3); disp(['"time" is expected as an option, choose default time = ' num2str(time)]); end - end - gdat_data.gdat_params.time = time; - gdat_data.t = time; - zshift = 0.; - if isfield(gdat_data.gdat_params,'zshift') && ~isempty(gdat_data.gdat_params.zshift) - zshift = gdat_data.gdat_params.zshift; - else - gdat_data.gdat_params.zshift = zshift; - end - if abs(zshift-1) <= 1e-6 - zshift_eff = -99; - else - zshift_eff = zshift; - end - if ~isfield(gdat_data.gdat_params,'nr') || isempty(gdat_data.gdat_params.nr) - gdat_data.gdat_params.nr = 129; - end - if ~isfield(gdat_data.gdat_params,'nz') || isempty(gdat_data.gdat_params.nz) - gdat_data.gdat_params.nz = 129; - end - [efitdata,eqd]=geteqdskJET(shot,time,gdat_data.gdat_params.nr,gdat_data.gdat_params.nz,[],zshift_eff,[],[],[],100,[],gdat_data.gdat_params.jet_user); - if length(time) > 1 - gdat_data.eqdsk = eqd; - for itime=1:length(time) - if itime==1 - gdat_data.data(:,:,itime) = gdat_data.eqdsk{itime}.psi; - gdat_data.dim{1} = gdat_data.eqdsk{itime}.rmesh; - gdat_data.dim{2} = gdat_data.eqdsk{itime}.zmesh; - else - % for several times, use array of structure for eqdsks, - % cannot use it for psi(R,Z) in .data and .x since R, Z might be different at different times, - % so project psi(R,Z) on Rmesh, Zmesh of 1st time - xx=repmat(reshape(gdat_data.dim{1},length(gdat_data.dim{1}),1),1,size(gdat_data.eqdsk{itime}.psi,2)); - yy=repmat(reshape(gdat_data.dim{2},1,length(gdat_data.dim{2})),size(gdat_data.eqdsk{itime}.psi,1),1); - aa = interpos2Dcartesian(gdat_data.eqdsk{itime}.rmesh,gdat_data.eqdsk{itime}.zmesh ... - ,gdat_data.eqdsk{itime}.psi,xx,yy,-1,-1); - gdat_data.data(:,:,itime) = aa; + gdat_data.t = time; + zshift = 0.; + if isfield(gdat_data.gdat_params,'zshift') && ~isempty(gdat_data.gdat_params.zshift) + zshift = gdat_data.gdat_params.zshift; + else + gdat_data.gdat_params.zshift = zshift; + end + if abs(zshift-1) <= 1e-6 + zshift_eff = -99; + else + zshift_eff = zshift; + end + if ~isfield(gdat_data.gdat_params,'nr') || isempty(gdat_data.gdat_params.nr) + gdat_data.gdat_params.nr = 129; + end + if ~isfield(gdat_data.gdat_params,'nz') || isempty(gdat_data.gdat_params.nz) + gdat_data.gdat_params.nz = 129; + end + [efitdata,eqd]=geteqdskJET(shot,time,gdat_data.gdat_params.nr,gdat_data.gdat_params.nz,[],zshift_eff,[],[],[],100,[],gdat_data.gdat_params.jet_user); + if length(time) > 1 + gdat_data.eqdsk = eqd; + for itime=1:length(time) + if itime==1 + gdat_data.data(:,:,itime) = gdat_data.eqdsk{itime}.psi; + gdat_data.dim{1} = gdat_data.eqdsk{itime}.rmesh; + gdat_data.dim{2} = gdat_data.eqdsk{itime}.zmesh; + else + % for several times, use array of structure for eqdsks, + % cannot use it for psi(R,Z) in .data and .x since R, Z might be different at different times, + % so project psi(R,Z) on Rmesh, Zmesh of 1st time + xx=repmat(reshape(gdat_data.dim{1},length(gdat_data.dim{1}),1),1,size(gdat_data.eqdsk{itime}.psi,2)); + yy=repmat(reshape(gdat_data.dim{2},1,length(gdat_data.dim{2})),size(gdat_data.eqdsk{itime}.psi,1),1); + aa = interpos2Dcartesian(gdat_data.eqdsk{itime}.rmesh,gdat_data.eqdsk{itime}.zmesh ... + ,gdat_data.eqdsk{itime}.psi,xx,yy,-1,-1); + gdat_data.data(:,:,itime) = aa; + end end + else + gdat_data.eqdsk = eqd{1}; + gdat_data.data = gdat_data.eqdsk.psi; + gdat_data.dim{1} = gdat_data.eqdsk.rmesh; + gdat_data.dim{2} = gdat_data.eqdsk.zmesh; end - else - gdat_data.eqdsk = eqd{1}; - gdat_data.data = gdat_data.eqdsk.psi; - gdat_data.dim{1} = gdat_data.eqdsk.rmesh; - gdat_data.dim{2} = gdat_data.eqdsk.zmesh; - end - gdat_data.dim{3} = gdat_data.t; - gdat_data.x = gdat_data.dim(1:2); - gdat_data.data_fullpath=['psi(R,Z) and eqdsk from geteqdskJET from efit ; zshift=' num2str(zshift)]; - gdat_data.units = 'T m^2'; - gdat_data.dimunits = {'m','m','s'}; - gdat_data.request_description = ['data=psi, x=(R,Z), eqdsk contains eqdsk structure with which ' ... + gdat_data.dim{3} = gdat_data.t; + gdat_data.x = gdat_data.dim(1:2); + gdat_data.data_fullpath=['psi(R,Z) and eqdsk from geteqdskJET from efit ; zshift=' num2str(zshift)]; + gdat_data.units = 'T m^2'; + gdat_data.dimunits = {'m','m','s'}; + gdat_data.request_description = ['data=psi, x=(R,Z), eqdsk contains eqdsk structure with which ' ... 'plot_eqdsk, write_eqdsk, read_eqdsk can be used']; - % data loaded to create eqdsks, can be used in geteqdskJET for other times to avoid to reload all - gdat_data.efitdata = efitdata; + % data loaded to create eqdsks, can be used in geteqdskJET for other times to avoid to reload all + gdat_data.efitdata = efitdata; - %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - case {'mhd'} - params_eff = gdat_data.gdat_params; - if ~isfield(params_eff,'nfft') || isempty(params_eff.nfft) - params_eff.nfft = 4096; - end - gdat_data.gdat_params = params_eff; - params_eff.data_request={'JPF','DA','C1M-H305'}; - gdat_tmp = gdat_jet(shot,params_eff); - gdat_data.sig1.data = reshape(gdat_tmp.data,length(gdat_tmp.data),1 ); - gdat_data.t = gdat_tmp.t; - gdat_data.dim{1} = gdat_data.t; - gdat_data.dim{2} = [1 2]; - gdat_data.dimunits = {'s', 'odd/even'}; - gdat_data.x = gdat_data.dim{2}; - gdat_data.sig1.data_request = params_eff.data_request; - % other coil 180deg apart toroidally - params_eff.data_request = {'JPF','DA','C1M-T009'}; - gdat_tmp=gdat_jet(shot,params_eff); - gdat_data.sig2.data = reshape(gdat_tmp.data,length(gdat_tmp.data),1); - gdat_data.sig2.data_request=params_eff.data_request; - gdat_data.label={'n=odd','n=even'}; - gdat_data.full_path='n=1 in data(:,1) and .sig1; .sig2'; - gdat_data.units = 'T/s'; - gdat_data.label = {'n=odd','n=even'}; % can be used in legend(gdat_data.label) - % - if ~isempty(gdat_data.sig1.data) && ~isempty(gdat_data.sig2.data) - gdat_data.data(:,1) = (gdat_data.sig1.data - gdat_data.sig2.data)./2; - gdat_data.data(:,2) = (gdat_data.sig1.data + gdat_data.sig2.data)./2; - end + %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + case {'mhd'} + params_eff = gdat_data.gdat_params; + if ~isfield(params_eff,'nfft') || isempty(params_eff.nfft) + params_eff.nfft = 4096; + end + gdat_data.gdat_params = params_eff; + params_eff.data_request={'JPF','DA','C1M-H305'}; + gdat_tmp = gdat_jet(shot,params_eff); + gdat_data.sig1.data = reshape(gdat_tmp.data,length(gdat_tmp.data),1 ); + gdat_data.t = gdat_tmp.t; + gdat_data.dim{1} = gdat_data.t; + gdat_data.dim{2} = [1 2]; + gdat_data.dimunits = {'s', 'odd/even'}; + gdat_data.x = gdat_data.dim{2}; + gdat_data.sig1.data_request = params_eff.data_request; + % other coil 180deg apart toroidally + params_eff.data_request = {'JPF','DA','C1M-T009'}; + gdat_tmp=gdat_jet(shot,params_eff); + gdat_data.sig2.data = reshape(gdat_tmp.data,length(gdat_tmp.data),1); + gdat_data.sig2.data_request=params_eff.data_request; + gdat_data.label={'n=odd','n=even'}; + gdat_data.full_path='n=1 in data(:,1) and .sig1; .sig2'; + gdat_data.units = 'T/s'; + gdat_data.label = {'n=odd','n=even'}; % can be used in legend(gdat_data.label) + % + if ~isempty(gdat_data.sig1.data) && ~isempty(gdat_data.sig2.data) + gdat_data.data(:,1) = (gdat_data.sig1.data - gdat_data.sig2.data)./2; + gdat_data.data(:,2) = (gdat_data.sig1.data + gdat_data.sig2.data)./2; + end - %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - case {'ne','te', 'nete'} - nodenameeff_rho = 'rho'; - if ~isfield(gdat_data.gdat_params,'fit') || isempty(gdat_data.gdat_params.fit) || ~isnumeric(gdat_data.gdat_params.fit) - gdat_data.gdat_params.fit = 1; % default do fit - end - if isfield(gdat_data.gdat_params,'source') && ~isempty(gdat_data.gdat_params.source) - if strcmp(lower(gdat_data.gdat_params.source),'chain2') - gdat_data.gdat_params.source = 'hrt2'; + %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + case {'ne','te', 'nete'} + nodenameeff_rho = 'rho'; + if ~isfield(gdat_data.gdat_params,'fit') || isempty(gdat_data.gdat_params.fit) || ~isnumeric(gdat_data.gdat_params.fit) + gdat_data.gdat_params.fit = 1; % default do fit end - if strcmp(lower(gdat_data.gdat_params.source),'hrt2') - nodenameeff_rho = []; % profiles already on rho - gdat_data.gdat_params.fit = 0; % no need, chain2 is already a fit on rhopol + if isfield(gdat_data.gdat_params,'source') && ~isempty(gdat_data.gdat_params.source) + if strcmp(lower(gdat_data.gdat_params.source),'chain2') + gdat_data.gdat_params.source = 'hrt2'; + end + if strcmp(lower(gdat_data.gdat_params.source),'hrt2') + nodenameeff_rho = []; % profiles already on rho + gdat_data.gdat_params.fit = 0; % no need, chain2 is already a fit on rhopol + end + else + gdat_data.gdat_params.source = 'hrts'; end - else - gdat_data.gdat_params.source = 'hrts'; - end - if ~isfield(gdat_data.gdat_params,'fit_ne_edge') || isempty(gdat_data.gdat_params.fit_ne_edge) || ~isnumeric(gdat_data.gdat_params.fit_ne_edge) - gdat_data.gdat_params.fit_ne_edge = 1e18; % default edge ne value (-1 to let free) - end - if ~isfield(gdat_data.gdat_params,'fit_te_edge') || isempty(gdat_data.gdat_params.fit_te_edge) || ~isnumeric(gdat_data.gdat_params.fit_te_edge) - gdat_data.gdat_params.fit_te_edge = 50; % default edge te value (-1 to let free) - end - params_eff = gdat_data.gdat_params; - params_eff.doplot = 0; - % ne and/or Te from Thomson data on raw z mesh vs (z,t) - data_request_effi{1} = data_request_eff; - if strcmp(data_request_eff,'nete') - data_request_effi{1} = 'ne'; % start with ne - data_request_effi{2} = 'te'; - else - data_request_effi{2} = []; - end - params_eff.data_request = {'ppf',params_eff.source,data_request_effi{1}}; - aa = gdat_jet(shot,params_eff); - if isempty(aa.data) || isempty(aa.t) - if gdat_params.nverbose>=3; - aa - disp(['with data_request= ' data_request_eff]) + if ~isfield(gdat_data.gdat_params,'fit_ne_edge') || isempty(gdat_data.gdat_params.fit_ne_edge) || ~isnumeric(gdat_data.gdat_params.fit_ne_edge) + gdat_data.gdat_params.fit_ne_edge = 1e18; % default edge ne value (-1 to let free) end - return - end - gdat_data.data = aa.data; - gdat_data.dim = aa.dim; - gdat_data.t = aa.dim{2}; - gdat_data.x = aa.dim{1}; - gdat_data.dimunits=[{'R [m]'} ; {'time [s]'}]; - gdat_data.data_fullpath=[data_request_eff ' from ' params_eff.source]; - gdat_data.(data_request_effi{1}).data = aa.data; - gdat_data.(data_request_effi{1}).t = aa.t; - gdat_data.(data_request_effi{1}).r = aa.x; - if any(strcmp(fieldnames(aa),'units')) && ~isempty(aa.units) - gdat_data.units=aa.units; - else - if strcmp(data_request_effi{1},'ne') - gdat_data.units = 'm^{-3}'; - elseif strcmp(data_request_effi{1},'te') - gdat_data.units = 'eV'; + if ~isfield(gdat_data.gdat_params,'fit_te_edge') || isempty(gdat_data.gdat_params.fit_te_edge) || ~isnumeric(gdat_data.gdat_params.fit_te_edge) + gdat_data.gdat_params.fit_te_edge = 50; % default edge te value (-1 to let free) end - end - params_eff.data_request = {'ppf',params_eff.source,['d' data_request_effi{1}]}; - aaerr = gdat_jet(shot,params_eff); - gdat_data.error_bar = aaerr.data; - gdat_data.(data_request_effi{1}).error_bar = aaerr.data; - if ~isempty(nodenameeff_rho) - params_eff.data_request = {'ppf',params_eff.source,'rho'}; - aarho = gdat_jet(shot,params_eff); - gdat_data.rhopol = abs(aarho.data); - gdat_data.(data_request_effi{1}).rhopol = abs(aarho.data); % keep rho >0 - gdat_data.(data_request_effi{1}).rhopol_sign = aarho.data; % to be able to distinguish channels - else - gdat_data.rhopol = gdat_data.x; - gdat_data.(data_request_effi{1}).rhopol = gdat_data.x; - gdat_data.dimunits{1} = 'rhopol'; - end - if length(gdat_data.x) == numel(gdat_data.rhopol) - % gdat_data.x is already rhopol and 1D - gdat_data = get_grids_1d(gdat_data,1,1,gdat_params.nverbose); - else - aa=gdat_data; aa.x = aa.rhopol; - gdat_data2 = get_grids_1d(aa,2,1,gdat_params.nverbose); - gdat_data.grids_1d = gdat_data2.grids_1d; - clear aa gdat_data2 - end - % load te if 'nete' was asked - if ~isempty(data_request_effi{2}) - params_eff.data_request = {'ppf',params_eff.source,data_request_effi{2}}; + params_eff = gdat_data.gdat_params; + params_eff.doplot = 0; + % ne and/or Te from Thomson data on raw z mesh vs (z,t) + data_request_effi{1} = data_request_eff; + if strcmp(data_request_eff,'nete') + data_request_effi{1} = 'ne'; % start with ne + data_request_effi{2} = 'te'; + else + data_request_effi{2} = []; + end + params_eff.data_request = {'ppf',params_eff.source,data_request_effi{1}}; aa = gdat_jet(shot,params_eff); if isempty(aa.data) || isempty(aa.t) if gdat_params.nverbose>=3; aa - disp(['with data_request= ' data_request_effi{2}]) + disp(['with data_request= ' data_request_eff]) end return end - gdat_data.(data_request_effi{2}).data = aa.data; - gdat_data.(data_request_effi{2}).t = aa.t; - gdat_data.(data_request_effi{2}).r = aa.x; + gdat_data.data = aa.data; + gdat_data.dim = aa.dim; + gdat_data.t = aa.dim{2}; + gdat_data.x = aa.dim{1}; + gdat_data.dimunits=[{'R [m]'} ; {'time [s]'}]; + gdat_data.data_fullpath=[data_request_eff ' from ' params_eff.source]; + gdat_data.(data_request_effi{1}).data = aa.data; + gdat_data.(data_request_effi{1}).t = aa.t; + gdat_data.(data_request_effi{1}).r = aa.x; if any(strcmp(fieldnames(aa),'units')) && ~isempty(aa.units) - gdat_data.(data_request_effi{2}).units=aa.units; + gdat_data.units=aa.units; else - if strcmp(data_request_effi{2},'ne') - gdat_data.(data_request_effi{2}).units = 'm^{-3}'; - elseif strcmp(data_request_effi{2},'te') - gdat_data.(data_request_effi{2}).units = 'eV'; + if strcmp(data_request_effi{1},'ne') + gdat_data.units = 'm^{-3}'; + elseif strcmp(data_request_effi{1},'te') + gdat_data.units = 'eV'; end end - params_eff.data_request = {'ppf',params_eff.source,['d' data_request_effi{2}]}; + params_eff.data_request = {'ppf',params_eff.source,['d' data_request_effi{1}]}; aaerr = gdat_jet(shot,params_eff); - gdat_data.(data_request_effi{2}).error_bar = aaerr.data; - gdat_data.(data_request_effi{2}).rhopol = gdat_data.(data_request_effi{1}).rhopol; - gdat_data.(data_request_effi{2}).rhopol_sign = gdat_data.(data_request_effi{1}).rhopol_sign; - % construct pressure in .data - gdat_data.data = 1.602e-19.* gdat_data.(data_request_effi{1}).data .* gdat_data.(data_request_effi{2}).data; - end - % defaults for fits, so user always gets std structure - gdat_data.fit.rhotornorm = []; % same for both ne and te - gdat_data.fit.rhopolnorm = []; - gdat_data.fit.t = []; - gdat_data.fit.te.data = []; - gdat_data.fit.te.d_over_drhotornorm = []; - gdat_data.fit.ne.data = []; - gdat_data.fit.ne.d_over_drhotornorm = []; - gdat_data.fit.raw.te.data = []; - gdat_data.fit.raw.te.rhopolnorm = []; - gdat_data.fit.raw.ne.data = []; - gdat_data.fit.raw.ne.rhopolnorm = []; - fit_tension_default = -1; - if isfield(gdat_data.gdat_params,'fit_tension') - fit_tension = gdat_data.gdat_params.fit_tension; - else - fit_tension = fit_tension_default; - end - if ~isstruct(fit_tension) - fit_tension_eff.te = fit_tension; - fit_tension_eff.ne = fit_tension; - fit_tension = fit_tension_eff; - else - if ~isfield(fit_tension,'te'); fit_tension.te = fit_tension_default; end - if ~isfield(fit_tension,'ne '); fit_tension.ne = fit_tension_default; end - end - gdat_data.gdat_params.fit_tension = fit_tension; - if isfield(gdat_data.gdat_params,'fit_nb_rho_points') - fit_nb_rho_points = gdat_data.gdat_params.fit_nb_rho_points; - else - fit_nb_rho_points = 201; - end - gdat_data.gdat_params.fit_nb_rho_points = fit_nb_rho_points; - if isfield(gdat_data.gdat_params,'fit_ne_min') - fit_ne_min = gdat_data.gdat_params.fit_ne_min; - else - fit_ne_min = 1e17; - end - if isfield(gdat_data.gdat_params,'fit_te_min') - fit_te_min = gdat_data.gdat_params.fit_te_min; - else - fit_te_min = 5; - end - gdat_data.gdat_params.fit_te_min = fit_te_min; - fit_mask = -1; % we mask on the indices, thus -1 means no mask - if isfield(gdat_data.gdat_params,'fit_mask') && isnumeric(gdat_data.gdat_params.fit_mask) ... - && ~isempty(gdat_data.gdat_params.fit_mask) - % channel index to mask - fit_mask = gdat_data.gdat_params.fit_mask; - else - fit_mask = fit_mask; - end - gdat_data.gdat_params.fit_mask = fit_mask; - gdat_data.fit.mask = fit_mask; - % - if gdat_data.gdat_params.fit==1 - % add fits - gdat_data.fit.t = gdat_data.t; - rhopolfit = linspace(0,1,fit_nb_rho_points)'; - gdat_data.fit.rhotornorm = NaN*ones(length(rhopolfit),length(gdat_data.fit.t)); - gdat_data.fit.rhopolnorm = rhopolfit; - % common part between ne and te - indices_ok=[1:size(gdat_data.data,1)]'; - indices_ok=setdiff(indices_ok,fit_mask); - for it=1:length(gdat_data.t) - % make rhopol->rhotor transformation for each time since equilibrium might have changed - irhook=find(gdat_data.grids_1d.rhopolnorm(indices_ok,it)>0 & gdat_data.grids_1d.rhopolnorm(indices_ok,it)<1); % no need for ~isnan - [rhoeff isort]=sort(gdat_data.grids_1d.rhopolnorm(indices_ok(irhook),it)); - gdat_data.fit.rhotornorm(:,it)=interpos([0; rhoeff; 1], ... - [0; gdat_data.grids_1d.rhotornorm(indices_ok(irhook(isort)),it); 1],rhopolfit,-0.1,[2 2],[0 1]); + gdat_data.error_bar = aaerr.data; + gdat_data.(data_request_effi{1}).error_bar = aaerr.data; + if ~isempty(nodenameeff_rho) + params_eff.data_request = {'ppf',params_eff.source,'rho'}; + aarho = gdat_jet(shot,params_eff); + gdat_data.rhopol = abs(aarho.data); + gdat_data.(data_request_effi{1}).rhopol = abs(aarho.data); % keep rho >0 + gdat_data.(data_request_effi{1}).rhopol_sign = aarho.data; % to be able to distinguish channels + else + gdat_data.rhopol = gdat_data.x; + gdat_data.(data_request_effi{1}).rhopol = gdat_data.x; + gdat_data.dimunits{1} = 'rhopol'; + end + if length(gdat_data.x) == numel(gdat_data.rhopol) + % gdat_data.x is already rhopol and 1D + gdat_data = get_grids_1d(gdat_data,1,1,gdat_params.nverbose); + else + aa=gdat_data; aa.x = aa.rhopol; + gdat_data2 = get_grids_1d(aa,2,1,gdat_params.nverbose); + gdat_data.grids_1d = gdat_data2.grids_1d; + clear aa gdat_data2 end - for i=1:2 - if strcmp(data_request_effi{i},'te') - gdat_data.fit.raw.te.data = NaN*ones(size(gdat_data.te.data)); - gdat_data.fit.raw.te.error_bar = NaN*ones(size(gdat_data.te.data)); - gdat_data.fit.raw.te.rhopolnorm = NaN*ones(size(gdat_data.te.data)); - gdat_data.fit.te.data = gdat_data.fit.rhotornorm; - gdat_data.fit.te.d_over_drhotornorm = gdat_data.fit.rhotornorm; - elseif strcmp(data_request_effi{i},'ne') - gdat_data.fit.raw.ne.data = NaN*ones(size(gdat_data.ne.data)); - gdat_data.fit.raw.ne.error_bar = NaN*ones(size(gdat_data.ne.data)); - gdat_data.fit.raw.ne.rhopolnorm = NaN*ones(size(gdat_data.ne.data)); - gdat_data.fit.ne.data =gdat_data.fit.rhotornorm; - gdat_data.fit.ne.d_over_drhotornorm = gdat_data.fit.rhotornorm; + % load te if 'nete' was asked + if ~isempty(data_request_effi{2}) + params_eff.data_request = {'ppf',params_eff.source,data_request_effi{2}}; + aa = gdat_jet(shot,params_eff); + if isempty(aa.data) || isempty(aa.t) + if gdat_params.nverbose>=3; + aa + disp(['with data_request= ' data_request_effi{2}]) + end + return + end + gdat_data.(data_request_effi{2}).data = aa.data; + gdat_data.(data_request_effi{2}).t = aa.t; + gdat_data.(data_request_effi{2}).r = aa.x; + if any(strcmp(fieldnames(aa),'units')) && ~isempty(aa.units) + gdat_data.(data_request_effi{2}).units=aa.units; + else + if strcmp(data_request_effi{2},'ne') + gdat_data.(data_request_effi{2}).units = 'm^{-3}'; + elseif strcmp(data_request_effi{2},'te') + gdat_data.(data_request_effi{2}).units = 'eV'; + end end + params_eff.data_request = {'ppf',params_eff.source,['d' data_request_effi{2}]}; + aaerr = gdat_jet(shot,params_eff); + gdat_data.(data_request_effi{2}).error_bar = aaerr.data; + gdat_data.(data_request_effi{2}).rhopol = gdat_data.(data_request_effi{1}).rhopol; + gdat_data.(data_request_effi{2}).rhopol_sign = gdat_data.(data_request_effi{1}).rhopol_sign; + % construct pressure in .data + gdat_data.data = 1.602e-19.* gdat_data.(data_request_effi{1}).data .* gdat_data.(data_request_effi{2}).data; + end + % defaults for fits, so user always gets std structure + gdat_data.fit.rhotornorm = []; % same for both ne and te + gdat_data.fit.rhopolnorm = []; + gdat_data.fit.t = []; + gdat_data.fit.te.data = []; + gdat_data.fit.te.d_over_drhotornorm = []; + gdat_data.fit.ne.data = []; + gdat_data.fit.ne.d_over_drhotornorm = []; + gdat_data.fit.raw.te.data = []; + gdat_data.fit.raw.te.rhopolnorm = []; + gdat_data.fit.raw.ne.data = []; + gdat_data.fit.raw.ne.rhopolnorm = []; + fit_tension_default = -1; + if isfield(gdat_data.gdat_params,'fit_tension') + fit_tension = gdat_data.gdat_params.fit_tension; + else + fit_tension = fit_tension_default; + end + if ~isstruct(fit_tension) + fit_tension_eff.te = fit_tension; + fit_tension_eff.ne = fit_tension; + fit_tension = fit_tension_eff; + else + if ~isfield(fit_tension,'te'); fit_tension.te = fit_tension_default; end + if ~isfield(fit_tension,'ne '); fit_tension.ne = fit_tension_default; end + end + gdat_data.gdat_params.fit_tension = fit_tension; + if isfield(gdat_data.gdat_params,'fit_nb_rho_points') + fit_nb_rho_points = gdat_data.gdat_params.fit_nb_rho_points; + else + fit_nb_rho_points = 201; + end + gdat_data.gdat_params.fit_nb_rho_points = fit_nb_rho_points; + if isfield(gdat_data.gdat_params,'fit_ne_min') + fit_ne_min = gdat_data.gdat_params.fit_ne_min; + else + fit_ne_min = 1e17; + end + if isfield(gdat_data.gdat_params,'fit_te_min') + fit_te_min = gdat_data.gdat_params.fit_te_min; + else + fit_te_min = 5; + end + gdat_data.gdat_params.fit_te_min = fit_te_min; + fit_mask = -1; % we mask on the indices, thus -1 means no mask + if isfield(gdat_data.gdat_params,'fit_mask') && isnumeric(gdat_data.gdat_params.fit_mask) ... + && ~isempty(gdat_data.gdat_params.fit_mask) + % channel index to mask + fit_mask = gdat_data.gdat_params.fit_mask; + else + fit_mask = fit_mask; + end + gdat_data.gdat_params.fit_mask = fit_mask; + gdat_data.fit.mask = fit_mask; + % + if gdat_data.gdat_params.fit==1 + % add fits + gdat_data.fit.t = gdat_data.t; + rhopolfit = linspace(0,1,fit_nb_rho_points)'; + gdat_data.fit.rhotornorm = NaN*ones(length(rhopolfit),length(gdat_data.fit.t)); + gdat_data.fit.rhopolnorm = rhopolfit; + % common part between ne and te + indices_ok=[1:size(gdat_data.data,1)]'; + indices_ok=setdiff(indices_ok,fit_mask); for it=1:length(gdat_data.t) + % make rhopol->rhotor transformation for each time since equilibrium might have changed + irhook=find(gdat_data.grids_1d.rhopolnorm(indices_ok,it)>0 & gdat_data.grids_1d.rhopolnorm(indices_ok,it)<1); % no need for ~isnan + [rhoeff isort]=sort(gdat_data.grids_1d.rhopolnorm(indices_ok(irhook),it)); + gdat_data.fit.rhotornorm(:,it)=interpos([0; rhoeff; 1], ... + [0; gdat_data.grids_1d.rhotornorm(indices_ok(irhook(isort)),it); 1],rhopolfit,-0.1,[2 2],[0 1]); + end + for i=1:2 if strcmp(data_request_effi{i},'te') - idatate = find(gdat_data.te.data(indices_ok,it)>1 & gdat_data.grids_1d.rhopolnorm(indices_ok,it)<=1.05); - idatate = indices_ok(idatate); - if length(idatate)>0 - gdat_data.fit.raw.te.rhopolnorm(idatate,it) = gdat_data.grids_1d.rhopolnorm(idatate,it); - gdat_data.fit.raw.te.data(idatate,it) = gdat_data.te.data(idatate,it); - gdat_data.fit.raw.te.error_bar(idatate,it) = gdat_data.te.error_bar(idatate,it); - [rhoeff,irhoeff] = sort(gdat_data.grids_1d.rhopolnorm(idatate,it)); - rhoeff = [0; rhoeff]; - teeff = gdat_data.te.data(idatate(irhoeff),it); - te_err_eff = gdat_data.te.error_bar(idatate(irhoeff),it); - % they are some strange low error_bars, so remove these by max(Te/error_bar)<=10; and changing it to large error bar - ij=find(teeff./te_err_eff>10.); - if ~isempty(ij); te_err_eff(ij) = teeff(ij)./0.1; end - % - teeff = [teeff(1); teeff]; - te_err_eff = [1e4; te_err_eff]; - if gdat_data.gdat_params.fit_te_edge < 0 - [gdat_data.fit.te.data(:,it), gdat_data.fit.te.d_over_drhopolnorm(:,it)] = ... - interpos(rhoeff,teeff,rhopolfit,fit_tension.te,[1 0],[0 0],te_err_eff); - else - [gdat_data.fit.te.data(:,it), gdat_data.fit.te.d_over_drhopolnorm(:,it)] = ... - interpos(rhoeff,teeff,rhopolfit,fit_tension.te,[1 2],[0 gdat_data.gdat_params.fit_te_edge],te_err_eff); - end - % impose minimum value - ij=find(gdat_data.fit.te.data(:,it)<fit_te_min); - if ~isempty(ij); gdat_data.fit.te.data(ij,it) = fit_te_min; end - end + gdat_data.fit.raw.te.data = NaN*ones(size(gdat_data.te.data)); + gdat_data.fit.raw.te.error_bar = NaN*ones(size(gdat_data.te.data)); + gdat_data.fit.raw.te.rhopolnorm = NaN*ones(size(gdat_data.te.data)); + gdat_data.fit.te.data = gdat_data.fit.rhotornorm; + gdat_data.fit.te.d_over_drhotornorm = gdat_data.fit.rhotornorm; elseif strcmp(data_request_effi{i},'ne') - idatane = find(gdat_data.ne.data(indices_ok,it)>1 & gdat_data.grids_1d.rhopolnorm(indices_ok,it)<=1.05); - idatane = indices_ok(idatane); - if length(idatane)>0 - gdat_data.fit.raw.ne.rhopolnorm(idatane,it) = gdat_data.grids_1d.rhopolnorm(idatane,it); - gdat_data.fit.raw.ne.data(idatane,it) = gdat_data.ne.data(idatane,it); - gdat_data.fit.raw.ne.error_bar(idatane,it) = gdat_data.ne.error_bar(idatane,it); - [rhoeff,irhoeff] = sort(gdat_data.grids_1d.rhopolnorm(idatane,it)); - rhoeff = [0; rhoeff]; - % they are some strange low error_bars, so remove these by max(Te/error_bar)<=10; and changing it to large error bar - neeff = gdat_data.ne.data(idatane(irhoeff),it); - ne_err_eff = gdat_data.ne.error_bar(idatane(irhoeff),it); - ij=find(neeff./ne_err_eff>10.); - if ~isempty(ij); ne_err_eff(ij) = neeff(ij)./0.1; end - % - neeff = [neeff(1); neeff]; - ne_err_eff = [1e21; ne_err_eff]; - if gdat_data.gdat_params.fit_ne_edge < 0 - [gdat_data.fit.ne.data(:,it), gdat_data.fit.ne.d_over_drhopolnorm(:,it)] = interpos(rhoeff,neeff,rhopolfit,fit_tension.ne,[1 0],[0 ... + gdat_data.fit.raw.ne.data = NaN*ones(size(gdat_data.ne.data)); + gdat_data.fit.raw.ne.error_bar = NaN*ones(size(gdat_data.ne.data)); + gdat_data.fit.raw.ne.rhopolnorm = NaN*ones(size(gdat_data.ne.data)); + gdat_data.fit.ne.data =gdat_data.fit.rhotornorm; + gdat_data.fit.ne.d_over_drhotornorm = gdat_data.fit.rhotornorm; + end + for it=1:length(gdat_data.t) + if strcmp(data_request_effi{i},'te') + idatate = find(gdat_data.te.data(indices_ok,it)>1 & gdat_data.grids_1d.rhopolnorm(indices_ok,it)<=1.05); + idatate = indices_ok(idatate); + if length(idatate)>0 + gdat_data.fit.raw.te.rhopolnorm(idatate,it) = gdat_data.grids_1d.rhopolnorm(idatate,it); + gdat_data.fit.raw.te.data(idatate,it) = gdat_data.te.data(idatate,it); + gdat_data.fit.raw.te.error_bar(idatate,it) = gdat_data.te.error_bar(idatate,it); + [rhoeff,irhoeff] = sort(gdat_data.grids_1d.rhopolnorm(idatate,it)); + rhoeff = [0; rhoeff]; + teeff = gdat_data.te.data(idatate(irhoeff),it); + te_err_eff = gdat_data.te.error_bar(idatate(irhoeff),it); + % they are some strange low error_bars, so remove these by max(Te/error_bar)<=10; and changing it to large error bar + ij=find(teeff./te_err_eff>10.); + if ~isempty(ij); te_err_eff(ij) = teeff(ij)./0.1; end + % + teeff = [teeff(1); teeff]; + te_err_eff = [1e4; te_err_eff]; + if gdat_data.gdat_params.fit_te_edge < 0 + [gdat_data.fit.te.data(:,it), gdat_data.fit.te.d_over_drhopolnorm(:,it)] = ... + interpos(rhoeff,teeff,rhopolfit,fit_tension.te,[1 0],[0 0],te_err_eff); + else + [gdat_data.fit.te.data(:,it), gdat_data.fit.te.d_over_drhopolnorm(:,it)] = ... + interpos(rhoeff,teeff,rhopolfit,fit_tension.te,[1 2],[0 gdat_data.gdat_params.fit_te_edge],te_err_eff); + end + % impose minimum value + ij=find(gdat_data.fit.te.data(:,it)<fit_te_min); + if ~isempty(ij); gdat_data.fit.te.data(ij,it) = fit_te_min; end + end + elseif strcmp(data_request_effi{i},'ne') + idatane = find(gdat_data.ne.data(indices_ok,it)>1 & gdat_data.grids_1d.rhopolnorm(indices_ok,it)<=1.05); + idatane = indices_ok(idatane); + if length(idatane)>0 + gdat_data.fit.raw.ne.rhopolnorm(idatane,it) = gdat_data.grids_1d.rhopolnorm(idatane,it); + gdat_data.fit.raw.ne.data(idatane,it) = gdat_data.ne.data(idatane,it); + gdat_data.fit.raw.ne.error_bar(idatane,it) = gdat_data.ne.error_bar(idatane,it); + [rhoeff,irhoeff] = sort(gdat_data.grids_1d.rhopolnorm(idatane,it)); + rhoeff = [0; rhoeff]; + % they are some strange low error_bars, so remove these by max(Te/error_bar)<=10; and changing it to large error bar + neeff = gdat_data.ne.data(idatane(irhoeff),it); + ne_err_eff = gdat_data.ne.error_bar(idatane(irhoeff),it); + ij=find(neeff./ne_err_eff>10.); + if ~isempty(ij); ne_err_eff(ij) = neeff(ij)./0.1; end + % + neeff = [neeff(1); neeff]; + ne_err_eff = [1e21; ne_err_eff]; + if gdat_data.gdat_params.fit_ne_edge < 0 + [gdat_data.fit.ne.data(:,it), gdat_data.fit.ne.d_over_drhopolnorm(:,it)] = interpos(rhoeff,neeff,rhopolfit,fit_tension.ne,[1 0],[0 ... 0],ne_err_eff); - else - ij_in_1 = find(rhoeff<1); - [gdat_data.fit.ne.data(:,it), gdat_data.fit.ne.d_over_drhopolnorm(:,it)] = ... - interpos([rhoeff(ij_in_1); 1.],[neeff(ij_in_1); gdat_data.gdat_params.fit_ne_edge], ... + else + ij_in_1 = find(rhoeff<1); + [gdat_data.fit.ne.data(:,it), gdat_data.fit.ne.d_over_drhopolnorm(:,it)] = ... + interpos([rhoeff(ij_in_1); 1.],[neeff(ij_in_1); gdat_data.gdat_params.fit_ne_edge], ... rhopolfit,fit_tension.ne,[1 2],[0 gdat_data.gdat_params.fit_ne_edge],[ne_err_eff(ij_in_1);ne_err_eff(1)]); + end + % impose minimum value + ij=find(gdat_data.fit.ne.data(:,it)<fit_ne_min); + if ~isempty(ij); gdat_data.fit.ne.data(ij,it) = fit_ne_min; end end - % impose minimum value - ij=find(gdat_data.fit.ne.data(:,it)<fit_ne_min); - if ~isempty(ij); gdat_data.fit.ne.data(ij,it) = fit_ne_min; end end end end end - end - %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - case {'ni','ti'} - nodenameeff_rho = 'rho'; - data_type_eff = data_request_eff; - if strcmp(data_request_eff,'ni'); data_type_eff = 'dd'; end - params_eff = gdat_data.gdat_params; - if isfield(params_eff,'source') && ~isempty(params_eff.source) - if strcmp(lower(params_eff.source),'chain2') - params_eff.source = [data_request_eff(1) 'ion']; + %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + case {'ni','ti'} + nodenameeff_rho = 'rho'; + data_type_eff = data_request_eff; + if strcmp(data_request_eff,'ni'); data_type_eff = 'dd'; end + params_eff = gdat_data.gdat_params; + if isfield(params_eff,'source') && ~isempty(params_eff.source) + if strcmp(lower(params_eff.source),'chain2') + params_eff.source = [data_request_eff(1) 'ion']; + end + if strcmp(lower(params_eff.source(2:end)),'ion') + nodenameeff_rho = []; % profiles already on rho + end + else + params_eff.source = [datar_equest_eff(1) 'ion']; % only chain2 at this stage end - if strcmp(lower(params_eff.source(2:end)),'ion') - nodenameeff_rho = []; % profiles already on rho + gdat_data.gdat_params = params_eff; + params_eff.doplot = 0; + % ne or Te from Thomson data on raw z mesh vs (z,t) + params_eff.data_request = {'ppf',params_eff.source,data_type_eff}; + aa = gdat_jet(shot,params_eff); + if isempty(aa.data) || isempty(aa.t) + if gdat_params.nverbose>=3; + aa + disp(['with data_request= ' data_request_eff]) + end + return end - else - params_eff.source = [datar_equest_eff(1) 'ion']; % only chain2 at this stage - end - gdat_data.gdat_params = params_eff; - params_eff.doplot = 0; - % ne or Te from Thomson data on raw z mesh vs (z,t) - params_eff.data_request = {'ppf',params_eff.source,data_type_eff}; - aa = gdat_jet(shot,params_eff); - if isempty(aa.data) || isempty(aa.t) - if gdat_params.nverbose>=3; - aa - disp(['with data_request= ' data_request_eff]) + gdat_data.data = aa.data; + gdat_data.dim = aa.dim; + gdat_data.t = aa.dim{2}; + gdat_data.x = aa.dim{1}; + gdat_data.dimunits=[{'R [m]'} ; {'time [s]'}]; + gdat_data.data_fullpath=[data_request_eff ' from ' params_eff.source]; + gdat_data.(data_request_eff).data = aa.data; + gdat_data.(data_request_eff).t = aa.t; + gdat_data.(data_request_eff).r = aa.x; + if any(strcmp(fieldnames(aa),'units')) && ~isempty(aa.units) + gdat_data.units=aa.units; + else + if strcmp(data_request_eff,'ni') + gdat_data.units = 'm^{-3}'; + elseif strcmp(data_request_eff,'ti') + gdat_data.units = 'eV'; + end end - return - end - gdat_data.data = aa.data; - gdat_data.dim = aa.dim; - gdat_data.t = aa.dim{2}; - gdat_data.x = aa.dim{1}; - gdat_data.dimunits=[{'R [m]'} ; {'time [s]'}]; - gdat_data.data_fullpath=[data_request_eff ' from ' params_eff.source]; - gdat_data.(data_request_eff).data = aa.data; - gdat_data.(data_request_eff).t = aa.t; - gdat_data.(data_request_eff).r = aa.x; - if any(strcmp(fieldnames(aa),'units')) && ~isempty(aa.units) - gdat_data.units=aa.units; - else - if strcmp(data_request_eff,'ni') - gdat_data.units = 'm^{-3}'; - elseif strcmp(data_request_eff,'ti') - gdat_data.units = 'eV'; + params_eff.data_request = {'ppf',params_eff.source,['e' data_type_eff]}; % not given for dd but ok will be empty + aaerr = gdat_jet(shot,params_eff); + gdat_data.error_bar = aaerr.data; + gdat_data.(data_request_eff).error_bar = aaerr.data; + if ~isempty(nodenameeff_rho) + params_eff.data_request = {'ppf',params_eff.source,'rho'}; + aarho = gdat_jet(shot,params_eff); + gdat_data.rhopol = abs(aarho.data); + gdat_data.(data_request_eff).rhopol = abs(aarho.data); % keep rho >0 + else + gdat_data.rhopol = gdat_data.x; + gdat_data.(data_request_eff).rhopol = gdat_data.x; + gdat_data.dimunits{1} = 'rhopol'; end - end - params_eff.data_request = {'ppf',params_eff.source,['e' data_type_eff]}; % not given for dd but ok will be empty - aaerr = gdat_jet(shot,params_eff); - gdat_data.error_bar = aaerr.data; - gdat_data.(data_request_eff).error_bar = aaerr.data; - if ~isempty(nodenameeff_rho) - params_eff.data_request = {'ppf',params_eff.source,'rho'}; - aarho = gdat_jet(shot,params_eff); - gdat_data.rhopol = abs(aarho.data); - gdat_data.(data_request_eff).rhopol = abs(aarho.data); % keep rho >0 - else - gdat_data.rhopol = gdat_data.x; - gdat_data.(data_request_eff).rhopol = gdat_data.x; - gdat_data.dimunits{1} = 'rhopol'; - end - %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % $$$ case {'ne_rho', 'te_rho', 'nete_rho'} % $$$ % if nete_rho, do first ne, then Te later (so fir stuff already done) % $$$ zshift = 0.; @@ -1282,7 +1282,7 @@ elseif strcmp(mapping_for_jet.method,'switchcase') 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); + 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{:})]); @@ -1325,9 +1325,9 @@ elseif strcmp(mapping_for_jet.method,'switchcase') end if ~isempty(ohm.data) && ~isempty(ohm.dim) for i=1:length(fields_to_copy) - if isfield(ohm,fields_to_copy{i}) - gdat_data.ohm.(fields_to_copy{i}) = ohm.(fields_to_copy{i}); - end + if isfield(ohm,fields_to_copy{i}) + gdat_data.ohm.(fields_to_copy{i}) = ohm.(fields_to_copy{i}); + end end gdat_data.ohm.raw_data = gdat_data.ohm.data; sources_coeff(end+1) = 1; % to be added to sum at end @@ -1353,19 +1353,19 @@ elseif strcmp(mapping_for_jet.method,'switchcase') % nbi params_eff.data_request={'ppf','nbi','ptot'}; try - nbi=gdat_jet(shot,params_eff); + nbi=gdat_jet(shot,params_eff); catch end if ~isempty(nbi.data) && ~isempty(nbi.dim) - for i=1:length(fields_to_copy) - if isfield(nbi,fields_to_copy{i}) - gdat_data.nbi.(fields_to_copy{i}) = nbi.(fields_to_copy{i}); - end - end + for i=1:length(fields_to_copy) + if isfield(nbi,fields_to_copy{i}) + gdat_data.nbi.(fields_to_copy{i}) = nbi.(fields_to_copy{i}); + end + end % add to main with linear interpolation and 0 for extrapolated values - gdat_data.data(:,end+1) = interpos(-21,gdat_data.nbi.t,gdat_data.nbi.data(:,end),gdat_data.t); - gdat_data.x(end+1) =gdat_data.x(end)+1; - gdat_data.label{end+1}='P_{nbi}'; + gdat_data.data(:,end+1) = interpos(-21,gdat_data.nbi.t,gdat_data.nbi.data(:,end),gdat_data.t); + gdat_data.x(end+1) =gdat_data.x(end)+1; + gdat_data.label{end+1}='P_{nbi}'; sources_coeff(end+1) = 1; % to be added to sum at end end end @@ -1374,7 +1374,7 @@ elseif strcmp(mapping_for_jet.method,'switchcase') % ic params_eff.data_request={'ppf','rff','ptot'}; try - ic=gdat_jet(shot,params_eff); + ic=gdat_jet(shot,params_eff); if isempty(ic.data) || isempty(ic.dim) error('Unable to get ppf/rff/ptot'); % Effectively a shortcut to the next catch block end @@ -1386,14 +1386,14 @@ elseif strcmp(mapping_for_jet.method,'switchcase') end end if ~isempty(ic.data) && ~isempty(ic.dim) - for i=1:length(fields_to_copy) - if isfield(ic,fields_to_copy{i}) - gdat_data.ic.(fields_to_copy{i}) = ic.(fields_to_copy{i}); - end - end - gdat_data.data(:,end+1) = interpos(-21,gdat_data.ic.t,gdat_data.ic.data,gdat_data.t); - gdat_data.x(end+1) =gdat_data.x(end)+1; - gdat_data.label{end+1}='P_{ic}'; + for i=1:length(fields_to_copy) + if isfield(ic,fields_to_copy{i}) + gdat_data.ic.(fields_to_copy{i}) = ic.(fields_to_copy{i}); + end + end + gdat_data.data(:,end+1) = interpos(-21,gdat_data.ic.t,gdat_data.ic.data,gdat_data.t); + gdat_data.x(end+1) =gdat_data.x(end)+1; + gdat_data.label{end+1}='P_{ic}'; sources_coeff(end+1) = 1; % to be added to sum at end end end @@ -1401,21 +1401,21 @@ elseif strcmp(mapping_for_jet.method,'switchcase') % radiated power params_eff.data_request='p_rad'; try - rad=gdat_jet(shot,params_eff); + rad=gdat_jet(shot,params_eff); catch rad.data = []; rad.dim = []; end if ~isempty(rad.data) && ~isempty(rad.dim) - for i=1:length(fields_to_copy) - if isfield(rad,fields_to_copy{i}) - gdat_data.rad.(fields_to_copy{i}) = rad.(fields_to_copy{i}); - end - end + for i=1:length(fields_to_copy) + if isfield(rad,fields_to_copy{i}) + gdat_data.rad.(fields_to_copy{i}) = rad.(fields_to_copy{i}); + end + end % add to main with linear interpolation and 0 for extrapolated values - gdat_data.data(:,end+1) = interpos(-21,gdat_data.rad.t,gdat_data.rad.data,gdat_data.t); - gdat_data.x(end+1) =gdat_data.x(end)+1; - gdat_data.label{end+1}='P_{rad}'; + gdat_data.data(:,end+1) = interpos(-21,gdat_data.rad.t,gdat_data.rad.data,gdat_data.t); + gdat_data.x(end+1) =gdat_data.x(end)+1; + gdat_data.label{end+1}='P_{rad}'; sources_coeff(end+1) = 0; % to not be added to sum at end end end diff --git a/matlab/JET/jet_requests_mapping.m b/matlab/JET/jet_requests_mapping.m index 664bf4be1a85890b5eb2aebb0e9b888cb37ad249..c5aa3bd48261e30b9bd3554625a19551a9d51c9a 100644 --- a/matlab/JET/jet_requests_mapping.m +++ b/matlab/JET/jet_requests_mapping.m @@ -5,13 +5,13 @@ function mapping = jet_requests_mapping(data_request) % Defaults mapping = struct(... - 'label', '', ... - 'method', '', ... - 'expression','', ... - 'timedim', -1, ... % dim which is the time is the database, to copy in .t, the other dims are in .x (-1 means last dimension) - 'gdat_timedim',[], ... % if need to reshape data and dim orders to have timedim as gdat_timedim (shifting time to gdat_timedim) - 'min', -inf, ... - 'max', inf); + 'label', '', ... + 'method', '', ... + 'expression','', ... + 'timedim', -1, ... % dim which is the time is the database, to copy in .t, the other dims are in .x (-1 means last dimension) + 'gdat_timedim',[], ... % if need to reshape data and dim orders to have timedim as gdat_timedim (shifting time to gdat_timedim) + 'min', -inf, ... + 'max', inf); % Note that gdat_timedim is set to timedim at end of this function if empty % gdat_timedim should have effective index of the time dimension in gdat @@ -38,384 +38,384 @@ if iscell(data_request) % || (~ischar(data_request) && length(data_request)>1) end switch lower(data_request) - case 'a_minor' - mapping.label = 'a\_minor'; - mapping.timedim = 1; - mapping.method = 'signal'; - mapping.expression = [{'PPF'},{'EFIT'},{'CR0'}]; - case 'b0' - mapping.label = 'B_0'; - mapping.timedim = 1; - mapping.method = 'signal'; - mapping.expression = [{'ppf'},{'MAGN'},{'BVAC'}]; - mapping.method = 'expression'; - mapping.expression = ['params_eff = gdat_data.gdat_params;params_eff.data_request={''ppf'',''MAGN'',''BVAC''}; ' ... + case 'a_minor' + mapping.label = 'a\_minor'; + mapping.timedim = 1; + mapping.method = 'signal'; + mapping.expression = [{'PPF'},{'EFIT'},{'CR0'}]; + case 'b0' + mapping.label = 'B_0'; + mapping.timedim = 1; + mapping.method = 'signal'; + mapping.expression = [{'ppf'},{'MAGN'},{'BVAC'}]; + mapping.method = 'expression'; + mapping.expression = ['params_eff = gdat_data.gdat_params;params_eff.data_request={''ppf'',''MAGN'',''BVAC''}; ' ... 'gdat_tmp=gdat_jet(shot,params_eff);gdat_tmp.r0=2.96;']; - case 'beta' - mapping.label = 'beta\_tor diag [%]'; - mapping.timedim = 1; - mapping.method = 'signal'; - mapping.expression = [{'PPF'},{'EFIT'},{'BTTD'}]; - case 'betan' - mapping.label = '\beta_N'; - mapping.timedim = 1; - mapping.method = 'signal'; - mapping.expression = [{'PPF'},{'EFIT'},{'BTND'}]; - case 'betap' - mapping.label = '\beta_p'; - mapping.timedim = 1; - mapping.method = 'signal'; - mapping.expression = [{'PPF'},{'EFIT'},{'BTPD'}]; - case 'cxrs' - mapping.timedim = 2; - mapping.label = 'cxrs'; - mapping.method = 'switchcase'; - mapping.expression = ''; - case 'delta' - mapping.timedim = 1; - mapping.label = 'delta'; - mapping.method = 'expression'; - mapping.expression = ['params_eff = gdat_data.gdat_params;params_eff.data_request=''delta_bottom''; ' ... + case 'beta' + mapping.label = 'beta\_tor diag [%]'; + mapping.timedim = 1; + mapping.method = 'signal'; + mapping.expression = [{'PPF'},{'EFIT'},{'BTTD'}]; + case 'betan' + mapping.label = '\beta_N'; + mapping.timedim = 1; + mapping.method = 'signal'; + mapping.expression = [{'PPF'},{'EFIT'},{'BTND'}]; + case 'betap' + mapping.label = '\beta_p'; + mapping.timedim = 1; + mapping.method = 'signal'; + mapping.expression = [{'PPF'},{'EFIT'},{'BTPD'}]; + case 'cxrs' + mapping.timedim = 2; + mapping.label = 'cxrs'; + mapping.method = 'switchcase'; + mapping.expression = ''; + case 'delta' + mapping.timedim = 1; + mapping.label = 'delta'; + mapping.method = 'expression'; + mapping.expression = ['params_eff = gdat_data.gdat_params;params_eff.data_request=''delta_bottom''; ' ... 'gdat_tmp=gdat_jet(shot,params_eff);params_eff.data_request=''delta_top'';' ... - 'gdat_tmp2=gdat_jet(shot,params_eff);gdat_tmp.data = 0.5.*(gdat_tmp.data+gdat_tmp2.data);' ... - 'gdat_tmp.label=gdat_data.label; gdat_tmp.gdat_request=gdat_data.gdat_request;']; - case 'delta_top' - mapping.label = 'delta\_top'; - mapping.timedim = 1; - mapping.method = 'signal'; - mapping.expression = [{'ppf'},{'EFIT'},{'TRIU'}]; - case 'delta_bottom' - mapping.label = 'delta\_bottom'; - mapping.timedim = 1; - mapping.method = 'signal'; - mapping.expression = [{'ppf'},{'EFIT'},{'TRIL'}]; - case {'ece', 'eced', 'ece_rho', 'eced_rho'} - mapping.timedim = 2; - mapping.method = 'switchcase'; - mapping.expression = ''; - case 'eqdsk' - mapping.timedim = 2; - mapping.method = 'switchcase'; % could use function make_eqdsk directly? - mapping.expression = ''; - case 'equil' - mapping.gdat_timedim = 2; - mapping.method = 'switchcase'; % could use function make_eqdsk directly? - mapping.expression = ''; - case {'gas','gasm','gash','eler'} - mapping.label = 'eler'; - mapping.timedim = 1; - mapping.method = 'signal'; - mapping.expression = [{'ppf'},{'gash'},{'eler'}]; - case 'halpha' - mapping.label = 'Halpha'; - mapping.timedim = 1; - mapping.method = 'signal'; - mapping.expression = [{'jpf'},{'dd'},{'s3-ad08'}]; - case 'ioh' - mapping.timedim = 1; - mapping.label = 'I ohmic transformer'; - mapping.method = 'signal'; - mapping.expression = []; - case 'ip' - mapping.timedim = 1; - mapping.label = 'Plasma current'; - mapping.method = 'signal'; - mapping.expression = [{'ppf'},{'efit'},{'xip'}]; - mapping.expression = [{'ppf'},{'MAGN'},{'IPLA'}]; - mapping.units = 'A'; - case 'kappa' - mapping.timedim = 1; - mapping.label = '\kappa'; - mapping.method = 'signal'; - mapping.expression = [{'ppf'},{'EHTR'},{'ELON'}]; - mapping.expression = [{'ppf'},{'EFIT'},{'ELON'}]; - case {'li', 'l_i'} - mapping.timedim = 1; - mapping.label = 'l_i_3'; - mapping.method = 'signal'; - mapping.expression = [{'ppf'},{'EFIT'},{'LI3M'}]; - case {'locked', 'locked_mode'} - mapping.timedim = 1; - mapping.label = 'locked mode'; - mapping.method = 'signal'; - mapping.expression = [{'jpf'},{'DA'},{'C2-LOCA'}]; - case 'mhd' - mapping.timedim = 1; - mapping.label = 'n=1 and n=2 amplitude'; - mapping.timedim = 1; - mapping.method = 'switchcase'; + 'gdat_tmp2=gdat_jet(shot,params_eff);gdat_tmp.data = 0.5.*(gdat_tmp.data+gdat_tmp2.data);' ... + 'gdat_tmp.label=gdat_data.label; gdat_tmp.gdat_request=gdat_data.gdat_request;']; + case 'delta_top' + mapping.label = 'delta\_top'; + mapping.timedim = 1; + mapping.method = 'signal'; + mapping.expression = [{'ppf'},{'EFIT'},{'TRIU'}]; + case 'delta_bottom' + mapping.label = 'delta\_bottom'; + mapping.timedim = 1; + mapping.method = 'signal'; + mapping.expression = [{'ppf'},{'EFIT'},{'TRIL'}]; + case {'ece', 'eced', 'ece_rho', 'eced_rho'} + mapping.timedim = 2; + mapping.method = 'switchcase'; + mapping.expression = ''; + case 'eqdsk' + mapping.timedim = 2; + mapping.method = 'switchcase'; % could use function make_eqdsk directly? + mapping.expression = ''; + case 'equil' + mapping.gdat_timedim = 2; + mapping.method = 'switchcase'; % could use function make_eqdsk directly? + mapping.expression = ''; + case {'gas','gasm','gash','eler'} + mapping.label = 'eler'; + mapping.timedim = 1; + mapping.method = 'signal'; + mapping.expression = [{'ppf'},{'gash'},{'eler'}]; + case 'halpha' + mapping.label = 'Halpha'; + mapping.timedim = 1; + mapping.method = 'signal'; + mapping.expression = [{'jpf'},{'dd'},{'s3-ad08'}]; + case 'ioh' + mapping.timedim = 1; + mapping.label = 'I ohmic transformer'; + mapping.method = 'signal'; + mapping.expression = []; + case 'ip' + mapping.timedim = 1; + mapping.label = 'Plasma current'; + mapping.method = 'signal'; + mapping.expression = [{'ppf'},{'efit'},{'xip'}]; + mapping.expression = [{'ppf'},{'MAGN'},{'IPLA'}]; + mapping.units = 'A'; + case 'kappa' + mapping.timedim = 1; + mapping.label = '\kappa'; + mapping.method = 'signal'; + mapping.expression = [{'ppf'},{'EHTR'},{'ELON'}]; + mapping.expression = [{'ppf'},{'EFIT'},{'ELON'}]; + case {'li', 'l_i'} + mapping.timedim = 1; + mapping.label = 'l_i_3'; + mapping.method = 'signal'; + mapping.expression = [{'ppf'},{'EFIT'},{'LI3M'}]; + case {'locked', 'locked_mode'} + mapping.timedim = 1; + mapping.label = 'locked mode'; + mapping.method = 'signal'; + mapping.expression = [{'jpf'},{'DA'},{'C2-LOCA'}]; + case 'mhd' + mapping.timedim = 1; + mapping.label = 'n=1 and n=2 amplitude'; + mapping.timedim = 1; + mapping.method = 'switchcase'; % $$$ mapping.method = 'expression'; % {'JPF','DA','C1M-H306'} {'JPF','DA','C1M-T009'} (big) {'JPF','DA','C1M-MIT27'}{'jpf' 'da' 'c1m-h304'} nfft=1024*3; % $$$ mapping.expression = ['params_eff = gdat_data.gdat_params;params_eff.data_request={''JPF'',''DA'',''C1H-I301''}; ' ... % $$$ 'gdat_tmp=gdat_jet(shot,params_eff);gdat_tmp.data=reshape(gdat_tmp.data,length(gdat_tmp.data),1 );' ... -% $$$ 'gdat_tmp.dim{1}=gdat_tmp.t;gdat_tmp.dim{2}=[1 2];gdat_tmp.x=gdat_tmp.dim{2};' ... -% $$$ 'gdat_tmp.n_1.data = gdat_tmp.data;gdat_tmp.n_1.data_request=params_eff.data_request;' ... -% $$$ 'params_eff.data_request={''JPF'',''DA'',''C1H-I302''};' ... -% $$$ 'gdat_tmp2=gdat_jet(shot,params_eff);gdat_tmp.data(:,2)=reshape(gdat_tmp2.data,length(gdat_tmp2.data),1);' ... -% $$$ 'gdat_tmp.n_2.data = gdat_tmp2.data;gdat_tmp.n_2.data_request=params_eff.data_request;gdat_tmp.label={''n=1'',''n=2''};' ... -% $$$ 'gdat_tmp.full_path=''n=1 in data and .n_1; .n_2'';' ... -% $$$ 'gdat_tmp.gdat_request=''mhd'';gdat_tmp.gdat_params.data_request=gdat_tmp.gdat_request;']; +% $$$ 'gdat_tmp.dim{1}=gdat_tmp.t;gdat_tmp.dim{2}=[1 2];gdat_tmp.x=gdat_tmp.dim{2};' ... +% $$$ 'gdat_tmp.n_1.data = gdat_tmp.data;gdat_tmp.n_1.data_request=params_eff.data_request;' ... +% $$$ 'params_eff.data_request={''JPF'',''DA'',''C1H-I302''};' ... +% $$$ 'gdat_tmp2=gdat_jet(shot,params_eff);gdat_tmp.data(:,2)=reshape(gdat_tmp2.data,length(gdat_tmp2.data),1);' ... +% $$$ 'gdat_tmp.n_2.data = gdat_tmp2.data;gdat_tmp.n_2.data_request=params_eff.data_request;gdat_tmp.label={''n=1'',''n=2''};' ... +% $$$ 'gdat_tmp.full_path=''n=1 in data and .n_1; .n_2'';' ... +% $$$ 'gdat_tmp.gdat_request=''mhd'';gdat_tmp.gdat_params.data_request=gdat_tmp.gdat_request;']; % $$$ mapping.expression = ['params_eff = gdat_data.gdat_params;params_eff.data_request={''JPF'',''DA'',''C1M-T009''}; ' ... % $$$ 'gdat_tmp=gdat_jet(shot,params_eff);gdat_tmp.data=reshape(gdat_tmp.data,length(gdat_tmp.data),1 );' ... -% $$$ 'gdat_tmp.dim{1}=gdat_tmp.t;gdat_tmp.dim{2}=[1 2];gdat_tmp.x=gdat_tmp.dim{2};' ... -% $$$ 'gdat_tmp.n_1.data = gdat_tmp.data;gdat_tmp.n_1.data_request=params_eff.data_request;' ... -% $$$ 'params_eff.data_request={''JPF'',''DA'',''C1M-H305''};' ... -% $$$ 'gdat_tmp2=gdat_jet(shot,params_eff);gdat_tmp.data(:,2)=reshape(gdat_tmp2.data,length(gdat_tmp2.data),1);' ... -% $$$ 'gdat_tmp.n_2.data = gdat_tmp2.data;gdat_tmp.n_2.data_request=params_eff.data_request;gdat_tmp.label={''n=1'',''n=2''};' ... -% $$$ 'gdat_tmp.full_path=''n=1 in data and .n_1; .n_2'';' ... -% $$$ 'gdat_tmp.gdat_request=''mhd'';gdat_tmp.gdat_params.data_request=gdat_tmp.gdat_request;' ... +% $$$ 'gdat_tmp.dim{1}=gdat_tmp.t;gdat_tmp.dim{2}=[1 2];gdat_tmp.x=gdat_tmp.dim{2};' ... +% $$$ 'gdat_tmp.n_1.data = gdat_tmp.data;gdat_tmp.n_1.data_request=params_eff.data_request;' ... +% $$$ 'params_eff.data_request={''JPF'',''DA'',''C1M-H305''};' ... +% $$$ 'gdat_tmp2=gdat_jet(shot,params_eff);gdat_tmp.data(:,2)=reshape(gdat_tmp2.data,length(gdat_tmp2.data),1);' ... +% $$$ 'gdat_tmp.n_2.data = gdat_tmp2.data;gdat_tmp.n_2.data_request=params_eff.data_request;gdat_tmp.label={''n=1'',''n=2''};' ... +% $$$ 'gdat_tmp.full_path=''n=1 in data and .n_1; .n_2'';' ... +% $$$ 'gdat_tmp.gdat_request=''mhd'';gdat_tmp.gdat_params.data_request=gdat_tmp.gdat_request;' ... % $$$ '']; - case 'mhd_ampl' - mapping.timedim = 1; - mapping.label = 'n=1 and n=2 amplitude'; - mapping.method = 'expression'; - mapping.expression = ['params_eff = gdat_data.gdat_params;params_eff.data_request={''JPF'',''DA'',''C1H-G101''}; ' ... + case 'mhd_ampl' + mapping.timedim = 1; + mapping.label = 'n=1 and n=2 amplitude'; + mapping.method = 'expression'; + mapping.expression = ['params_eff = gdat_data.gdat_params;params_eff.data_request={''JPF'',''DA'',''C1H-G101''}; ' ... 'gdat_tmp=gdat_jet(shot,params_eff);gdat_tmp.data=reshape(gdat_tmp.data,length(gdat_tmp.data),1 );' ... - 'gdat_tmp.dim{1}=gdat_tmp.t;gdat_tmp.dim{2}=[1 2];gdat_tmp.x=gdat_tmp.dim{2};' ... - 'gdat_tmp.n_1.data = gdat_tmp.data;gdat_tmp.n_1.data_request=params_eff.data_request;' ... - 'params_eff.data_request={''JPF'',''DA'',''C1H-G102''};' ... - 'gdat_tmp2=gdat_jet(shot,params_eff);gdat_tmp.data(:,2)=reshape(gdat_tmp2.data,length(gdat_tmp2.data),1);' ... - 'gdat_tmp.n_2.data = gdat_tmp2.data;gdat_tmp.n_2.data_request=params_eff.data_request;gdat_tmp.label={''n=1'',''n=2''};' ... - 'gdat_tmp.full_path=''n=1 amplitude in data and .n_1; .n_2'';' ... - 'gdat_tmp.gdat_request=''mhd_ampl'';gdat_tmp.gdat_params.data_request=gdat_tmp.gdat_request;']; - case 'ne' - mapping.timedim = 2; - mapping.method = 'switchcase'; - case 'neint' - mapping.timedim = 1; - mapping.label = 'line integrated el. density'; - mapping.method = 'signal'; - mapping.expression = [{'DCN'},{'H-1'},{'JETD'}]; - case 'nel' - mapping.timedim = 1; - mapping.label = 'nel'; - mapping.method = 'signal'; - mapping.expression = [{'ppf'},{'KG1L'},{'LAD3'}]; - mapping.expression = [{'ppf'},{'HRTX'},{'NELA'}]; - case 'ne_rho' - mapping.timedim = 2; - mapping.label = 'ne'; - mapping.method = 'switchcase'; - case 'nete' - mapping.timedim = 2; - mapping.label = 'ne and Te'; % from chain2 or hrts with interpos fits - mapping.method = 'switchcase'; - case 'nete_rho' - mapping.timedim = 2; - mapping.label = 'ne and Te'; - mapping.method = 'switchcase'; - case {'ng','ngreenwald','n_greenwald'} - mapping.timedim = 1; - 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.dim{1}=gdat_tmp.t;gdat_tmp.dim{2}=[1 2];gdat_tmp.x=gdat_tmp.dim{2};' ... + 'gdat_tmp.n_1.data = gdat_tmp.data;gdat_tmp.n_1.data_request=params_eff.data_request;' ... + 'params_eff.data_request={''JPF'',''DA'',''C1H-G102''};' ... + 'gdat_tmp2=gdat_jet(shot,params_eff);gdat_tmp.data(:,2)=reshape(gdat_tmp2.data,length(gdat_tmp2.data),1);' ... + 'gdat_tmp.n_2.data = gdat_tmp2.data;gdat_tmp.n_2.data_request=params_eff.data_request;gdat_tmp.label={''n=1'',''n=2''};' ... + 'gdat_tmp.full_path=''n=1 amplitude in data and .n_1; .n_2'';' ... + 'gdat_tmp.gdat_request=''mhd_ampl'';gdat_tmp.gdat_params.data_request=gdat_tmp.gdat_request;']; + case 'ne' + mapping.timedim = 2; + mapping.method = 'switchcase'; + case 'neint' + mapping.timedim = 1; + mapping.label = 'line integrated el. density'; + mapping.method = 'signal'; + mapping.expression = [{'DCN'},{'H-1'},{'JETD'}]; + case 'nel' + mapping.timedim = 1; + mapping.label = 'nel'; + mapping.method = 'signal'; + mapping.expression = [{'ppf'},{'KG1L'},{'LAD3'}]; + mapping.expression = [{'ppf'},{'HRTX'},{'NELA'}]; + case 'ne_rho' + mapping.timedim = 2; + mapping.label = 'ne'; + mapping.method = 'switchcase'; + case 'nete' + mapping.timedim = 2; + mapping.label = 'ne and Te'; % from chain2 or hrts with interpos fits + mapping.method = 'switchcase'; + case 'nete_rho' + mapping.timedim = 2; + mapping.label = 'ne and Te'; + mapping.method = 'switchcase'; + case {'ng','ngreenwald','n_greenwald'} + mapping.timedim = 1; + 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);' ... '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);' ... + '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;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_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;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);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);end;']; - case 'ni' - mapping.method = 'switchcase'; % especially since might have option fit, etc - case {'phi_tor', 'phitor', 'toroidal_flux'} - mapping.label = 'toroidal_flux'; - mapping.timedim = 1; - mapping.method = 'signal'; - mapping.expression = [{'PPF'},{'EQUI'},{'PHIT'}]; % note this is only chain2, so should check with efit... - % there is FTOR from EFIT but it's on psinorm - mapping.method = 'expression'; - mapping.expression = ['params_eff = gdat_data.gdat_params;params_eff.data_request=[{''PPF''},{''EFIT''},{''FTOR''}];' ... + '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);end;']; + case 'ni' + mapping.method = 'switchcase'; % especially since might have option fit, etc + case {'phi_tor', 'phitor', 'toroidal_flux'} + mapping.label = 'toroidal_flux'; + mapping.timedim = 1; + mapping.method = 'signal'; + mapping.expression = [{'PPF'},{'EQUI'},{'PHIT'}]; % note this is only chain2, so should check with efit... + % there is FTOR from EFIT but it's on psinorm + mapping.method = 'expression'; + mapping.expression = ['params_eff = gdat_data.gdat_params;params_eff.data_request=[{''PPF''},{''EFIT''},{''FTOR''}];' ... 'gdat_tmp=gdat_jet(shot,params_eff);gdat_tmp.x=sqrt(gdat_tmp.x);gdat_tmp.dim{1}=gdat_tmp.x;']; - case {'p_lh', 'plh'} - mapping.label = 'p\_lh threshold'; - mapping.timedim = 1; - mapping.method = 'expression'; - mapping.expression = ['params_eff = gdat_data.gdat_params;params_eff.data_request=''nel'';' ... + case {'p_lh', 'plh'} + 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);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);' ... - '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.);' ... + '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'';' ... + 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);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.);' ... + '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'';end;']; - case {'p_ohmic', 'p_ohm', 'pohm'} - mapping.label = 'p\_ohmic'; - mapping.timedim = 1; - mapping.method = 'signal'; - mapping.expression = [{'PPF'},{'EFIT'},{'POHM'}]; - case {'p_rad', 'prad'} - mapping.label = 'p\_rad'; - mapping.timedim = 1; + case {'p_ohmic', 'p_ohm', 'pohm'} + mapping.label = 'p\_ohmic'; + mapping.timedim = 1; + mapping.method = 'signal'; + mapping.expression = [{'PPF'},{'EFIT'},{'POHM'}]; + case {'p_rad', 'prad'} + mapping.label = 'p\_rad'; + mapping.timedim = 1; % $$$ mapping.method = 'signal'; % $$$ mapping.expression = [{'PPF'},{'bolo'},{'topi'}]; - mapping.method = 'switchcase'; - case 'powers' - mapping.timedim = 1; - mapping.label = 'various powers'; - mapping.method = 'switchcase'; - case 'psi_axis' - mapping.label = 'psi\_axis'; - mapping.timedim = 1; - mapping.method = 'signal'; - mapping.expression = [{'PPF'},{'EFIT'},{'FAXS'}]; - case 'psi_edge' - mapping.label = 'psi\_edge'; - mapping.timedim = 1; - mapping.method = 'signal'; - mapping.expression = [{'PPF'},{'EFIT'},{'FBND'}]; - case 'q0' - mapping.label = 'q_0'; - mapping.timedim = 1; - mapping.method = 'signal'; - mapping.expression = [{'PPF'},{'EFIT'},{'QAX'}]; - % mapping.expression = [{'PPF'},{'EFIT'},{'QAXM'}]; - case 'q95' - mapping.label = 'q_{95}'; - mapping.timedim = 1; - mapping.method = 'signal'; - mapping.expression = [{'PPF'},{'EFIT'},{'Q95'}]; - case 'q_edge' - mapping.label = 'q_{edge}}'; - mapping.timedim = 1; - mapping.method = 'signal'; - mapping.expression = [{'PPF'},{'EFIT'},{'QWL'}]; - case 'q_rho' - mapping.timedim = 2; - mapping.gdat_timedim = 2; - mapping.label = 'q'; - mapping.method = 'switchcase'; - case 'rgeom' - mapping.label = 'Rgeom'; - mapping.timedim = 1; - mapping.method = 'signal'; - mapping.expression = [{'PPF'},{'EFIT'},{'RGEO'}]; - case 'r_inboard' - mapping.label = 'R\_inboard'; - mapping.timedim = 1; - mapping.method = 'signal'; - mapping.expression = [{'PPF'},{'EFIT'},{'RMJI'}]; - case 'r_outboard' - mapping.label = 'R\_outboard'; - mapping.timedim = 1; - mapping.method = 'signal'; - mapping.expression = [{'PPF'},{'EFIT'},{'RMJO'}]; - case 'rhotor' - mapping.timedim = 2; - mapping.method = 'switchcase'; - mapping.label = 'rhotor'; - case 'rhotor_edge' - mapping.timedim = 1; - mapping.method = 'switchcase'; - mapping.label = 'rhotor\_edge'; - case {'rhotor_norm','rhotornorm'} - mapping.timedim = 2; - mapping.method = 'switchcase'; - mapping.label = 'rhotor\_norm'; - case 'rhovol' - mapping.timedim = 2; - mapping.label = 'rhovol\_norm'; - mapping.method = 'switchcase'; - case 'rmag' - mapping.label = 'R\_magaxis'; - mapping.timedim = 1; - mapping.method = 'signal'; - mapping.expression = [{'PPF'},{'EFIT'},{'RMAG'}]; - case {'rnt', 'neutron_rate'} - mapping.label = 'neutron\_rate'; - mapping.timedim = 1; - mapping.method = 'signal'; - mapping.expression = [{'PPF'},{'TIN'},{'RNT'}]; - case {'sxr', 'sxr_s40', 'sxr_htv'} - mapping.timedim = 1; - mapping.gdat_timedim = 2; - mapping.method = 'switchcase'; - case {'tbeo'} - mapping.label = 'TBEO'; - mapping.timedim = 1; - mapping.method = 'signal'; - mapping.expression = [{'PPF'},{'EDG8'},{'TBEO'}]; - case 'te' - mapping.timedim = 2; - mapping.label = 'Te'; - mapping.method = 'switchcase'; - case 'te_rho' - mapping.timedim = 2; - mapping.label = 'Te'; - mapping.method = 'switchcase'; - case 'ti' - mapping.label = 'Ti'; - mapping.method = 'switchcase'; - case 'vloop' - mapping.label = 'Vloop Upper Restraint Ring Flux Flux Loop, non-integrated'; - mapping.timedim = 1; - mapping.label = 'Vloop'; - mapping.method = 'switchcase'; + mapping.method = 'switchcase'; + case 'powers' + mapping.timedim = 1; + mapping.label = 'various powers'; + mapping.method = 'switchcase'; + case 'psi_axis' + mapping.label = 'psi\_axis'; + mapping.timedim = 1; + mapping.method = 'signal'; + mapping.expression = [{'PPF'},{'EFIT'},{'FAXS'}]; + case 'psi_edge' + mapping.label = 'psi\_edge'; + mapping.timedim = 1; + mapping.method = 'signal'; + mapping.expression = [{'PPF'},{'EFIT'},{'FBND'}]; + case 'q0' + mapping.label = 'q_0'; + mapping.timedim = 1; + mapping.method = 'signal'; + mapping.expression = [{'PPF'},{'EFIT'},{'QAX'}]; + % mapping.expression = [{'PPF'},{'EFIT'},{'QAXM'}]; + case 'q95' + mapping.label = 'q_{95}'; + mapping.timedim = 1; + mapping.method = 'signal'; + mapping.expression = [{'PPF'},{'EFIT'},{'Q95'}]; + case 'q_edge' + mapping.label = 'q_{edge}}'; + mapping.timedim = 1; + mapping.method = 'signal'; + mapping.expression = [{'PPF'},{'EFIT'},{'QWL'}]; + case 'q_rho' + mapping.timedim = 2; + mapping.gdat_timedim = 2; + mapping.label = 'q'; + mapping.method = 'switchcase'; + case 'rgeom' + mapping.label = 'Rgeom'; + mapping.timedim = 1; + mapping.method = 'signal'; + mapping.expression = [{'PPF'},{'EFIT'},{'RGEO'}]; + case 'r_inboard' + mapping.label = 'R\_inboard'; + mapping.timedim = 1; + mapping.method = 'signal'; + mapping.expression = [{'PPF'},{'EFIT'},{'RMJI'}]; + case 'r_outboard' + mapping.label = 'R\_outboard'; + mapping.timedim = 1; + mapping.method = 'signal'; + mapping.expression = [{'PPF'},{'EFIT'},{'RMJO'}]; + case 'rhotor' + mapping.timedim = 2; + mapping.method = 'switchcase'; + mapping.label = 'rhotor'; + case 'rhotor_edge' + mapping.timedim = 1; + mapping.method = 'switchcase'; + mapping.label = 'rhotor\_edge'; + case {'rhotor_norm','rhotornorm'} + mapping.timedim = 2; + mapping.method = 'switchcase'; + mapping.label = 'rhotor\_norm'; + case 'rhovol' + mapping.timedim = 2; + mapping.label = 'rhovol\_norm'; + mapping.method = 'switchcase'; + case 'rmag' + mapping.label = 'R\_magaxis'; + mapping.timedim = 1; + mapping.method = 'signal'; + mapping.expression = [{'PPF'},{'EFIT'},{'RMAG'}]; + case {'rnt', 'neutron_rate'} + mapping.label = 'neutron\_rate'; + mapping.timedim = 1; + mapping.method = 'signal'; + mapping.expression = [{'PPF'},{'TIN'},{'RNT'}]; + case {'sxr', 'sxr_s40', 'sxr_htv'} + mapping.timedim = 1; + mapping.gdat_timedim = 2; + mapping.method = 'switchcase'; + case {'tbeo'} + mapping.label = 'TBEO'; + mapping.timedim = 1; + mapping.method = 'signal'; + mapping.expression = [{'PPF'},{'EDG8'},{'TBEO'}]; + case 'te' + mapping.timedim = 2; + mapping.label = 'Te'; + mapping.method = 'switchcase'; + case 'te_rho' + mapping.timedim = 2; + mapping.label = 'Te'; + mapping.method = 'switchcase'; + case 'ti' + mapping.label = 'Ti'; + mapping.method = 'switchcase'; + case 'vloop' + mapping.label = 'Vloop Upper Restraint Ring Flux Flux Loop, non-integrated'; + mapping.timedim = 1; + mapping.label = 'Vloop'; + mapping.method = 'switchcase'; % $$$ mapping.method = 'signal'; % $$$ mapping.expression = [{'PPF'},{'MAGN'},{'VL'}]; % tension -1e2 (3rd signal good one % $$$ mapping.expression = [{'JPF'},{'DA'},{'C2-VLRRU'}]; % tension -1e4 - case 'volume' - mapping.label = 'Volume'; - mapping.timedim = 1; - mapping.method = 'signal'; - mapping.expression = [{'PPF'},{'EFIT'},{'VOLM'}]; - case 'volume_rho' - mapping.timedim = 2; - mapping.label = 'volume\_norm'; - mapping.method = 'switchcase'; - case {'wmhd', 'w_mhd'} - mapping.label = 'W_mhd'; - mapping.timedim = 1; - mapping.method = 'signal'; - mapping.expression = [{'PPF'},{'EFIT'},{'WP'}]; - case 'zeff' - mapping.label = 'zeff from KS3'; - mapping.timedim = 1; - mapping.method = 'signal'; - mapping.expression = [{'PPF'},{'KS3'},{'ZEFV'}]; - case 'zgeom' - mapping.label = 'Z_{geom}'; - mapping.timedim = 1; - mapping.method = 'signal'; - mapping.expression = [{'PPF'},{'EFIT'},{'ZGEO'}]; - case 'zmag' - mapping.label = 'Z\_magaxis'; - mapping.timedim = 1; - mapping.method = 'signal'; - mapping.expression = [{'PPF'},{'EFIT'},{'ZMAG'}]; - % - % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - % extra JET cases (not necessarily in official data_request name list) - % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - % - case 'transp' - mapping.label = 'transp output'; - mapping.method = 'switchcase'; + case 'volume' + mapping.label = 'Volume'; + mapping.timedim = 1; + mapping.method = 'signal'; + mapping.expression = [{'PPF'},{'EFIT'},{'VOLM'}]; + case 'volume_rho' + mapping.timedim = 2; + mapping.label = 'volume\_norm'; + mapping.method = 'switchcase'; + case {'wmhd', 'w_mhd'} + mapping.label = 'W_mhd'; + mapping.timedim = 1; + mapping.method = 'signal'; + mapping.expression = [{'PPF'},{'EFIT'},{'WP'}]; + case 'zeff' + mapping.label = 'zeff from KS3'; + mapping.timedim = 1; + mapping.method = 'signal'; + mapping.expression = [{'PPF'},{'KS3'},{'ZEFV'}]; + case 'zgeom' + mapping.label = 'Z_{geom}'; + mapping.timedim = 1; + mapping.method = 'signal'; + mapping.expression = [{'PPF'},{'EFIT'},{'ZGEO'}]; + case 'zmag' + mapping.label = 'Z\_magaxis'; + mapping.timedim = 1; + mapping.method = 'signal'; + mapping.expression = [{'PPF'},{'EFIT'},{'ZMAG'}]; + % + % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + % extra JET cases (not necessarily in official data_request name list) + % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + % + case 'transp' + mapping.label = 'transp output'; + mapping.method = 'switchcase'; - otherwise - mapping.label = data_request; - mapping.method = 'signal'; % assume a full tracename is given, so just try with tdi (could check there are some ":", etc...) - mapping.expression = data_request; + otherwise + mapping.label = data_request; + mapping.method = 'signal'; % assume a full tracename is given, so just try with tdi (could check there are some ":", etc...) + mapping.expression = data_request; end diff --git a/matlab/JET/mapflux_fast.m b/matlab/JET/mapflux_fast.m index d7698a5c1bac2950f5beabe892c8f5a2987a4554..177aeb5320bbae56206773fdaefa80389c9cec6a 100644 --- a/matlab/JET/mapflux_fast.m +++ b/matlab/JET/mapflux_fast.m @@ -7,11 +7,11 @@ function flux=mapflux_fast(cij,ri,zi,r,z,varargin) % syntaxe : flux=mapflux(cij,ri,zi,r,z) % % entrees : -% cij : coefficients bspline (efit/sspr(nr+nz+1:nr+nz+nc)) -% ri : points de controle pour r (efit/sspr(1:nr)) -% zi : points de controle pour z (efit/sspr(nr+1:nr+nz)) -% r : grille en r pour la carte de flux (vecteur) -% z : grille en z pour la carte de flux (vecteur) +% cij : coefficients bspline (efit/sspr(nr+nz+1:nr+nz+nc)) +% ri : points de controle pour r (efit/sspr(1:nr)) +% zi : points de controle pour z (efit/sspr(nr+1:nr+nz)) +% r : grille en r pour la carte de flux (vecteur) +% z : grille en z pour la carte de flux (vecteur) % % varargin{1}=1: output as diagonal of flux to get psin on (R,Z) set of points % 0: output full matrix (default) @@ -21,7 +21,7 @@ function flux=mapflux_fast(cij,ri,zi,r,z,varargin) % =0: compute all splines (slightly faster when whole grid needed) % % sortie : -% flux : matrice donnant le flux normalise sur la grille (r,z) +% flux : matrice donnant le flux normalise sur la grille (r,z) %~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ % auteur : patrick maget % date : 13/10/2000 @@ -74,10 +74,10 @@ end % fonction b-spline % bki=bspline(ti,t,k,i) %~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -% auteur : patrick maget +% auteur : patrick maget % date : 14/12/99 %~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -% retourne pour la valeur de i, +% retourne pour la valeur de i, % le vecteur de poids correspondant au vecteur de demande t % seuls les elements de t situes entre ti(i) et ti(i+k+1) ont un poids non nul diff --git a/matlab/JET/psirz.m b/matlab/JET/psirz.m index 72abd3a4cbb9d87a4d425fb5ec624076ee86c6cd..40e26d0615e098edf7516861f12e27538ad2474a 100644 --- a/matlab/JET/psirz.m +++ b/matlab/JET/psirz.m @@ -1,9 +1,9 @@ function [r,z,psinrz,sspr,sspi]=psirz(shot,time,nrg,nzg,efitlab,uid,seqd,varargin); % % psirz : reconstruction des surfaces de flux -% +% % ce programme utilise les donnees de efit ou eftm -% +% % examples: % [r,z,psinrz,sspr,sspi]=psirz(shot,time,nrg,nzg,[efitlab,uid,seq,ncont]); % [r,z,psinrz,sspr,sspi]=psirz(50814,60,65,65,[],[],[],60,sspr,sspi); % to get plot and give sspr,sspi @@ -11,7 +11,7 @@ function [r,z,psinrz,sspr,sspi]=psirz(shot,time,nrg,nzg,efitlab,uid,seqd,varargi % entrees : % shot : numero du choc jet % time : time de l'analyse -% nrg, nzg: nb de points de la grille en r (resp. en z) sur laquelle on fait la +% nrg, nzg: nb de points de la grille en r (resp. en z) sur laquelle on fait la % reconstruction des surfaces de flux. % if nzg is negative, make symmetric box around zero % varargin{1}: plot option: 0: do not plot contours, >0 plot contour with varargin{1} nb of contours (60 is good) @@ -65,7 +65,7 @@ if nargin>=11 & ~isempty(varargin{4}) else deltaz=0; end - + [x,ind]=min(abs(time-tpefit)); sspr_t=ssprs(:,ind); sspi_t=sspis(:,ind); @@ -122,14 +122,14 @@ function flux=mapflux(cij,ri,zi,r,z) % syntaxe : flux=mapflux(cij,ri,zi,r,z) % % entrees : -% cij : coefficients bspline (efit/sspr(nr+nz+1:nr+nz+nc)) -% ri : points de controle pour r (efit/sspr(1:nr)) -% zi : points de controle pour z (efit/sspr(nr+1:nr+nz)) -% r : grille en r pour la carte de flux (vecteur) -% z : grille en z pour la carte de flux (vecteur) +% cij : coefficients bspline (efit/sspr(nr+nz+1:nr+nz+nc)) +% ri : points de controle pour r (efit/sspr(1:nr)) +% zi : points de controle pour z (efit/sspr(nr+1:nr+nz)) +% r : grille en r pour la carte de flux (vecteur) +% z : grille en z pour la carte de flux (vecteur) % % sortie : -% flux : matrice donnant le flux normalise sur la grille (r,z) +% flux : matrice donnant le flux normalise sur la grille (r,z) %~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ % auteur : patrick maget % date : 13/10/2000 @@ -149,10 +149,10 @@ flux=fpq; % fonction b-spline % bki=bspline(ti,t,k,i) %~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -% auteur : patrick maget +% auteur : patrick maget % date : 14/12/99 %~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -% retourne pour la valeur de i, +% retourne pour la valeur de i, % le vecteur de poids correspondant au vecteur de demande t % seuls les elements de t situes entre ti(i) et ti(i+k+1) ont un poids non nul diff --git a/matlab/TCV/gdat_tcv.m b/matlab/TCV/gdat_tcv.m index 5f2b74c2135ad6b6f914daaeca4ba941ae18d908..8b89f6e2a2f98e03c083862b6da6b55461b61c08 100644 --- a/matlab/TCV/gdat_tcv.m +++ b/matlab/TCV/gdat_tcv.m @@ -341,7 +341,7 @@ if (iscell(mapping_for_tcv.expression) || isempty(strfind(mapping_for_tcv.expres % requires FBTE liuqe_version_eff = -1; liuqe_version = -1; - if isempty(findstr(mapping_for_tcv.expression,'tcv_eq')) + if isempty(findstr(mapping_for_tcv.expression,'tcv_eq')) && isempty(findstr(mapping_for_tcv.expression,'\')) % if tcv_eq in expression, liuqe target will be modified to FBTE below with regexprep begstr = 'tcv_eq( "'; substr_liuqe = '", "FBTE" )'; @@ -1740,7 +1740,8 @@ elseif strcmp(mapping_for_tcv.method,'switchcase') gdat_data.ec.ec_data = ec_data; filled_successfully = true; %set flag to true catch ME - warning(ME.identifier,'Problem retrieving TORAY data. \nError message: %s',ME.message); + warning('Problem retrieving TORAY data. \nError message: %s',ME.message); + getReport(ME) % without ; to get output % try to identify cause of the error if ~check_nodes_filled(shot,'toray') if ~any(ec_inputs.launchers_active.data,1) @@ -3315,17 +3316,20 @@ elseif strcmp(mapping_for_tcv.method,'switchcase') %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - case {'sxr', 'mpx'} + case {'sxr', 'mpx', 'radcam'} - if strcmp(data_request_eff,'mpx') - data_request_eff = 'mpx'; % mpx chosen through parameter 'source' within 'sxr' - gdat_data.data_request = data_request_eff; - gdat_data.gdat_params.source = 'mpx'; + if any(contains(data_request_eff,{'mpx','radcam'})) + % effective source chosen through parameter 'source' within 'sxr' + gdat_data.gdat_params.source = data_request_eff; end % sxr from dmpx by default or xtomo if 'camera','xtomo' is provided if ~isfield(gdat_data.gdat_params,'source') || isempty(gdat_data.gdat_params.source) - gdat_data.gdat_params.source = 'mpx'; - elseif ~strcmp(lower(gdat_data.gdat_params.source),'xtomo') && ~strcmp(lower(gdat_data.gdat_params.source),'mpx') + if shot < 70144 + gdat_data.gdat_params.source = 'mpx'; + else + gdat_data.gdat_params.source = 'radcam'; + end + elseif ~any(contains(lower(gdat_data.gdat_params.source),{'xtomo','mpx','radcam'})) if gdat_data.gdat_params.nverbose>=1 warning(['source = ' gdat_data.gdat_params.source ' not expected with data_request= ' data_request_eff]) end @@ -3346,10 +3350,125 @@ elseif strcmp(mapping_for_tcv.method,'switchcase') num2str(time_interval(1)) ',' num2str(time_interval(2)) ']' char(10)]) end end + % at this stage 2 option for freq, raw data (fast, default), 10kHz or similar (slow) + freq_opt = 1; if ~isfield(gdat_data.gdat_params,'freq') - gdat_data.gdat_params.freq = 'slow'; + gdat_data.gdat_params.freq = 'fast'; + end + if strcmp(gdat_data.gdat_params.freq,'slow'); freq_opt = 0; end + % fit_tension for smoothing on slow timescale (radcam for example) + if ~isfield(gdat_data.gdat_params,'fit_tension') || isempty(gdat_data.gdat_params.fit_tension) + gdat_data.gdat_params.fit_tension = -1e2; end switch lower(gdat_data.gdat_params.source) + case {'radcam'} + gdat_data.gdat_params.source = 'radcam'; + gdat_data.camera_list = {'top', 'upper','equatorial','bottom'}; + gdat_data.channel_list = {[1:20],[21:40],[41:80], [81:100]}; + if ~isfield(gdat_data.gdat_params,'camera') || isempty(gdat_data.gdat_params.camera) + gdat_data.gdat_params.camera = {'equatorial'}; % default equatorial + disp(['loads all radcam cameras, each data also in subfield ' gdat_data.gdat_params.camera]) + else + if ischar(gdat_data.gdat_params.camera) || (isstring(gdat_data.gdat_params.camera) && numel(gdat_data.gdat_params.camera)==1) + gdat_data.gdat_params.camera = {char(gdat_data.gdat_params.camera)}; + end + if isnumeric(gdat_data.gdat_params.camera) && (min(gdat_data.gdat_params.camera)<5 && max(gdat_data.gdat_params.camera)>0) + ij = gdat_data.gdat_params.camera([gdat_data.gdat_params.camera>0 & gdat_data.gdat_params.camera<5]); + gdat_data.gdat_params.camera = gdat_data.camera_list(ij); + elseif any(startsWith(gdat_data.gdat_params.camera,gdat_data.camera_list).*endsWith(gdat_data.gdat_params.camera,gdat_data.camera_list)) + ij = startsWith(gdat_data.gdat_params.camera,gdat_data.camera_list).*endsWith(gdat_data.gdat_params.camera,gdat_data.camera_list); + gdat_data.gdat_params.camera = lower(gdat_data.gdat_params.camera(ij>0)); + if any(ij==0) + warning(['camera not defined: ' gdat_data.gdat_params.camera(ij==0)]); + disp(['list of cameras: ' gdat_data.camera_list]) + end + else + error(['camera: ' gdat_data.gdat_params.camera ' not in list: ' gdat_data.camera_list]) + end + end + if ~isfield(gdat_data.gdat_params,'channel') || isempty(gdat_data.gdat_params.channel) + for i=1:numel(gdat_data.gdat_params.camera) + gdat_data.gdat_params.(gdat_data.gdat_params.camera{i}).channel = ... + gdat_data.channel_list{[contains(gdat_data.camera_list,gdat_data.gdat_params.camera{i})]}; + gdat_data.gdat_params.channel{i} = gdat_data.gdat_params.(gdat_data.gdat_params.camera{i}).channel; + end + else + if isnumeric(gdat_data.gdat_params.channel) + gdat_data.gdat_params.channel = {gdat_data.gdat_params.channel}; + end + if numel(gdat_data.gdat_params.camera) ~= numel(gdat_data.gdat_params.channel) + gdat_data.gdat_params + error('expects same number of camera as number of channel group in each cell list') + end + all_channels = []; + for i=1:numel(gdat_data.gdat_params.camera) + all_channels(end+1:end+numel(gdat_data.gdat_params.channel{i})) = gdat_data.gdat_params.channel{i}; + end + % check camera and channel chosen are consistent within camera interval, just redistribute + icount = 0; + for i=1:numel(gdat_data.camera_list) + ij = intersect(gdat_data.channel_list{i},all_channels); + if ~isempty(ij) + icount = icount + 1; + camera{icount} = gdat_data.camera_list{i}; + channel{icount} = ij; + end + end + if ~isequal(sort(camera),sort(gdat_data.gdat_params.camera)) + disp('***************************************************************************') + warning(sprintf('channel nbs and camera did not match, camera chosen adapted: %s %s %s %s',camera{:})); + disp('***************************************************************************') + gdat_data.gdat_params.camera = camera; + end + if ~isequal(sort(cell2mat(channel)),sort(cell2mat(gdat_data.gdat_params.channel))) || ... + numel(gdat_data.gdat_params.channel) ~= numel(channel) + warning(sprintf('channel nbs and channel did not match, channel chosen adapted')); + gdat_data.gdat_params.channel = channel; + end + for i=1:numel(gdat_data.gdat_params.camera) + gdat_data.gdat_params.(gdat_data.gdat_params.camera{i}).channel = gdat_data.gdat_params.channel{i}; + end + end + gdat_data.x = []; + for i=1:numel(gdat_data.gdat_params.camera) + gdat_data.(gdat_data.gdat_params.camera{i}).x = gdat_data.gdat_params.(gdat_data.gdat_params.camera{i}).channel; + gdat_data.x(end+1:end+numel(gdat_data.(gdat_data.gdat_params.camera{i}).x)) = gdat_data.(gdat_data.gdat_params.camera{i}).x; + end + sxr = rc_load_diodes(shot,'diag_name',"sxr",'channels',gdat_data.x); % since all cameras with different channel number + if freq_opt == 1 + gdat_data.data = sxr.data'; + gdat_data.t = sxr.time; + else + gdat_data.t = linspace(sxr.time(1),sxr.time(end),round((sxr.time(end)-sxr.time(1))/1e-4)); + for i=1:size(sxr.data,2) + gdat_data.data(i,:) = interpos(sxr.time,sxr.data(:,i),gdat_data.t,gdat_data.gdat_params.fit_tension); + end + end + gdat_data.r_x = sxr.geometry.xchord(gdat_data.x,:); + gdat_data.z_x = sxr.geometry.ychord(gdat_data.x,:); + gdat_data.r_at_z0 = gdat_data.r_x(:,1) + ... + diff(gdat_data.r_x(:,:)')' .* (0-gdat_data.z_x(:,1))./(gdat_data.z_x(:,2)-gdat_data.z_x(:,1)); + gdat_data.z_at_r09 = gdat_data.z_x(:,1) + ... + diff(gdat_data.z_x(:,:)')' .* (0.9-gdat_data.r_x(:,1))./(gdat_data.r_x(:,2)-gdat_data.r_x(:,1)); + gdat_data.good_channels = sxr.good_channels; + gdat_data.data_fullpath = ['using rc_load_diodes(shot,''diag_name'',"sxr",...) with params in gdat_data.gdat_params']; + gdat_data.units = 'au'; + gdat_data.dim = {gdat_data.x, gdat_data.t}; + gdat_data.dimunits = {'channel', 's'}; + gdat_data.label = strtrim(sprintf('radcam %s %s %s %s %s',gdat_data.gdat_params.camera{:})); + for i=1:numel(gdat_data.gdat_params.camera) + ij = iround_os(sxr.channels,gdat_data.(gdat_data.gdat_params.camera{i}).x); + gdat_data.(gdat_data.gdat_params.camera{i}).data = gdat_data.data(:,ij)'; + gdat_data.(gdat_data.gdat_params.camera{i}).t = gdat_data.t; + gdat_data.(gdat_data.gdat_params.camera{i}).r_x = sxr.geometry.xchord(gdat_data.(gdat_data.gdat_params.camera{i}).x,:); + gdat_data.(gdat_data.gdat_params.camera{i}).z_x = sxr.geometry.ychord(gdat_data.(gdat_data.gdat_params.camera{i}).x,:); + gdat_data.(gdat_data.gdat_params.camera{i}).r_at_z0 = gdat_data.r_at_z0(ij); + gdat_data.(gdat_data.gdat_params.camera{i}).z_at_r09 = gdat_data.z_at_r09(ij); + gdat_data.(gdat_data.gdat_params.camera{i}).good_channels = intersect(gdat_data.(gdat_data.gdat_params.camera{i}).x,sxr.good_channels); + gdat_data.(gdat_data.gdat_params.camera{i}).label = sprintf('radcam %s nb chords: %d', ... + gdat_data.gdat_params.camera{i},numel(gdat_data.(gdat_data.gdat_params.camera{i}).x)); + end + case {'mpx', 'dmpx'} gdat_data.gdat_params.source = 'mpx'; if ~isfield(gdat_data.gdat_params,'camera') || isempty(gdat_data.gdat_params.camera) @@ -3363,8 +3482,6 @@ elseif strcmp(mapping_for_tcv.method,'switchcase') end return end - freq_opt = 0; - if strcmp(gdat_data.gdat_params.freq,'fast'); freq_opt = 1; end t_int = [0 10]; % starts from 0 otherwise mpxdata gives data from t<0 if ~isempty(time_interval); t_int = time_interval; end gdat_data.top.data = []; @@ -3481,7 +3598,6 @@ elseif strcmp(mapping_for_tcv.method,'switchcase') end - %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% case {'transp'} % read transp netcdf output file provided in source parameter and generate substructure with all variables diff --git a/matlab/TCV/get_xtomo_data.m b/matlab/TCV/get_xtomo_data.m index 0c0c69a47c7a4cba4689321d38e8c4ec3d61cfe8..d46922a66aa84dad9372da1acb002307321c1958 100755 --- a/matlab/TCV/get_xtomo_data.m +++ b/matlab/TCV/get_xtomo_data.m @@ -1,26 +1,26 @@ function [sig,t]=get_xtomo_data(shot,t1,t2,dt,fans,angfact,tag); % - -%[sig,t]=get_xtomo_data_m5(shot,t1,t2,dt,fans,angfact,tag); +%[sig,t]=get_xtomo_data_m5(shot,t1,t2,dt,fans,angfact,tag); % -% INPUT: -% shot: TCV shot +% INPUT: +% shot: TCV shot % t1: start time % t2: stop time -% dt: timestep +% dt: timestep % fans: camera switch, e.g. [0 0 0 0 0 0 1 0 1 0]; -% angfact: relative etendue, size: [20 x 10] -% tag 'full' or 'brief', indicates if it is +% angfact: relative etendue, size: [20 x 10] +% tag 'full' or 'brief', indicates if it is % a slow or a fast Pentland acquisition % % OUTPUTS: -% sig: xtomo signals, size: [sum(fans) x length(t)] +% sig: xtomo signals, size: [sum(fans) x length(t)] % t: times -% -% ATTENTION: length(time) may be shorter than foreseen !! +% +% ATTENTION: length(time) may be shorter than foreseen !! % % This routine works on Matlab5. -% Original routine for Matlab4 by Anton Mathias. +% Original routine for Matlab4 by Anton Mathias. % % Last update: 25-08-1999 % @@ -29,468 +29,462 @@ function [sig,t]=get_xtomo_data(shot,t1,t2,dt,fans,angfact,tag); %---- get data and offsets --------------------------------------------------- - % set a flag if flattenign of noise - % for channels with low signal - - - iflat=0; - minsiglevel=0.01; - satlevel=9.9; - - - st1=sprintf('%6.4f',t1); - st2=sprintf('%6.4f',t2); - sdt=num2str(dt); - -% sdt=sprintf('%6.4f',dt); % modified from old version - - - if shot >= 13836 & shot <= 13848 - tstart=-0.02;tstop=-0.01; % this one is to be used only for - else % shot=13836 to shot=13848 - tstart=-0.04;tstop=-0.01; - end - - ststart=num2str(tstart); - ststop=num2str(tstop); - -if nargin <=6 - - shot=mdsopen(shot); - t=mdsdata(['dim_of(\base::xtomo:array_001[',st1,':',st2,':',sdt,',*])']); - S1=[]; - S2=[]; - S3=[]; - S4=[]; - S5=[]; - S6=[]; - S7=[]; - S8=[]; - S9=[]; - S10=[]; - - if isempty(t) - disp('get_xtomo_data: sorry, nothing to be found for this shot ...') - return - else - disp('*-------------------------------------------*') - disp('| get_xtomo_data: getting data from MDS |') - disp('*-------------------------------------------*') - end - - if shot>6768 - - if fans(1) - S=mdsdata(['\base::xtomo:array_001[',st1,':',st2,':',sdt,',0:19]'])'; - offset=mdsdata(['\base::xtomo:array_001[',ststart,':',ststop,',0:19]']); - S1=S-repmat(mean(offset),length(t),1)'; - end - - if fans(2) - S=mdsdata(['\base::xtomo:array_002[',st1,':',st2,':',sdt,',0:19]'])'; - offset=mdsdata(['\base::xtomo:array_002[',ststart,':',ststop,',0:19]']); - S2=S-repmat(mean(offset),length(t),1)'; - end - - if fans(3) - S=mdsdata(['\base::xtomo:array_003[',st1,':',st2,':',sdt,',0:19]'])'; - offset=mdsdata(['\base::xtomo:array_003[',ststart,':',ststop,',0:19]']); - S3=S-repmat(mean(offset),length(t),1)'; - end - - if fans(4) - S=mdsdata(['\base::xtomo:array_004[',st1,':',st2,':',sdt,',0:19]'])'; - offset=mdsdata(['\base::xtomo:array_004[',ststart,':',ststop,',0:19]']); - S4=S-repmat(mean(offset),length(t),1)'; - end - - if fans(5) - S=mdsdata(['\base::xtomo:array_005[',st1,':',st2,':',sdt,',0:19]'])'; - offset=mdsdata(['\base::xtomo:array_005[',ststart,':',ststop,',0:19]']); - S5=S-repmat(mean(offset),length(t),1)'; - end - - if fans(6) - S=mdsdata(['\base::xtomo:array_006[',st1,':',st2,':',sdt,',0:19]'])'; - offset=mdsdata(['\base::xtomo:array_006[',ststart,':',ststop,',0:19]']); - S6=S-repmat(mean(offset),length(t),1)'; - end - - if fans(7) - S=mdsdata(['\base::xtomo:array_007[',st1,':',st2,':',sdt,',0:19]'])'; - offset=mdsdata(['\base::xtomo:array_007[',ststart,':',ststop,',0:19]']); - S7=S-repmat(mean(offset),length(t),1)'; - end - - if fans(8) - S=mdsdata(['\base::xtomo:array_008[',st1,':',st2,':',sdt,',0:19]'])'; - offset=mdsdata(['\base::xtomo:array_008[',ststart,':',ststop,',0:19]']); - S8=S-repmat(mean(offset),length(t),1)'; - end - - if fans(9) - S=mdsdata(['\base::xtomo:array_009[',st1,':',st2,':',sdt,',0:19]'])'; - offset=mdsdata(['\base::xtomo:array_009[',ststart,':',ststop,',0:19]']); - S9=S-repmat(mean(offset),length(t),1)'; - end - - if fans(10) - S=mdsdata(['\base::xtomo:array_010[',st1,':',st2,':',sdt,',0:19]'])'; - offset=mdsdata(['\base::xtomo:array_010[',ststart,':',ststop,',0:19]']); - S10=S-repmat(mean(offset),length(t),1)'; - end - - - sig=-[S1;S2;S3;S4;S5;S6;S7;S8;S9;S10]; - [satrow,satcol]=find(abs(sig)>satlevel); - - if ~isempty(satcol) - i_tlimit=min(satcol(:)); - if i_tlimit>1 - sig=sig(:,1:i_tlimit-1); - t=t(1:i_tlimit-1); - disp(['get_xtomo_data WARNING: some channels saturated',...... - ', t2 changed to ',sprintf('%6.4f',max(t))]); - else - sig=[]; - t=[]; - disp('get_xtomo_data WARNING: saturations, no data returned'); - return - end - end - - - angfact=angfact(:,find(fans)); - angfact=angfact(:); - gains=get_xtomo_gains(shot); - % earlier than shot xxx: - perm=[1:180,[180+[2,1,4,3,6,5,8,7,10,9,12,11,14,13,16,15,18,17,20,19]]]; - gains=gains(perm); - iact=find(fans); - nact=length(iact); - idetec=[]; - for k=1:nact - idetec=[idetec,(iact(k)-1)*20+1:iact(k)*20]; - end - gains=gains(idetec); - gains=gains(:); - fac=ones(size(gains))./gains; - - - sig=-sig.*(repmat(fac,1,length(t))); - - if iflat - for ii=1:length(t) - imini=find( sig(:,ii) < minsiglevel*max(sig(:,ii))); - sig(imini,ii)=zeros(size(imini)); - end - end - - t=t'; - sig=sig.*(repmat(angfact,1,length(t))); - - - else - - if fans(9) - S=mdsdata(['\base::xtomo:array_001[',st1,':',st2,':',sdt,',0:19]'])'; - offset=mdsdata(['\base::xtomo:array_001[',ststart,':',ststop,',0:19]']); - V=S-repmat(mean(offset),length(t),1)'; - end - if fans(7) - S=mdsdata(['\base::xtomo:array_002[',st1,':',st2,':',sdt,',0:19]'])'; - offset=mdsdata(['\base::xtomo:array_002[',ststart,':',ststop,',0:19]']); - H=S-repmat(mean(offset),length(t),1)'; - end - - %---- read gains of the current shot --------------------------------------- - - gains=get_xtomo_gains(shot); - g1=gains(1:20)'; - g2=gains(21:40)'; - - %------ solid angle factors ----------------------- - - aom1=angfact(:,9); - aom2=angfact(:,7); - - - %----- calculate correcting factors --------------------------------------- - - fac1=(aom1./g1); - fac2=(aom2./g2); - - %--- result: offset-, calibration- and angular-factor corrected data ------- - - V=-V.*(repmat(fac1,1,length(t))); % vertical camera: - H=-H.*(repmat(fac2,1,length(t))); % horizontal camera: - - - sig=[H;V]; - - t=t'; - - end +% set a flag if flattenign of noise +% for channels with low signal -else - if (~strcmp(tag,'brief') & ~strcmp(tag,'full')) - disp('Only full or brief accepted as tag') - return - end - - - trace_tree=['\atlas::t_rex3_' tag ':']; - trace=[trace_tree 'signal_inp:p']; - %shot=mdsopen('eltca1::tcv_shot',shot); - shot=mdsopen(shot); - tref=mdsdata(['_tref=dim_of(' trace,'001)']); %trace :p001 - dtref=mdsdata('_dtref = _tref[1]-_tref[0]'); - - - S1=[]; - S2=[]; - S3=[]; - S4=[]; - S5=[]; - S6=[]; - S7=[]; - S8=[]; - S9=[]; - S10=[]; - - t_1=mdsdata('_t = dim_of(\atlas::t_rex3_full:signal_inp:p001)'); - dt1=mdsdata('_dt = _t[1]-_t[0]'); - npts=floor(mdsdata(['_npts=(',ststop,'-(',ststart,'))/_dt'])); - - - -if isempty(t_1) - disp('get_xtomo_data: sorry, nothing to be found for this shot ...') - return - else - disp('*--------------------------------------------*') - disp('| getting Pentland acquisition: getting *') - if strcmp(tag,'brief') - disp('| BRIEF data from MDS *'); - else - disp('| FULL data from MDS *'); - end - disp('*--------------------------------------------*'); - end - - - - if ((dt - dtref) < 1e-7 | floor(dt/dtref) ==0) - step='1'; - else - step =num2str(dt/dtref); - end - - - ind1=find( abs(tref-t1) == min(abs(tref-t1))); - npts1=floor(mdsdata(['_npts1=(',st2,'-(',st1,'))/_dtref'])); - sind1=num2str(ind1); - sind2=num2str(npts1+ind1); - - t=mdsdata(['data(_tref)[',sind1,':',sind2,':', step, ']']); - - - - - if fans(1) - channel=['001';'002';'003';'004';'005';'006';'007';'008';'009';'010';... - '011';'012';'013';'014';'015';'016';'017';'018';'019';'020']; - for i=1:20 -% S(i,:)=mdsdata([trace, channel(i,:),'[',st1,':',st2,':',sdt,']'])'; - - - S(i,:)=mdsdata(['data(',trace,channel(i,:),')[',sind1,':',sind2,':' , step,']'])'; - offset=mdsdata(['data(\atlas::t_rex3_full:signal_inp:p',channel(i,:),')[0:',num2str(npts),']' ]); - S1(i,:)=S(i,:)-repmat(mean(offset),length(t),1)'; - end - end - - - - if fans(2) - channel=['021';'022';'023';'024';'025';'026';'027';'028';'029';'030';... - '031';'032';'033';'034';'035';'036';'037';'038';'039';'040']; - for i=1:20 - -% S(i,:)=mdsdata([trace, channel(i,:),'[',st1,':',st2,':',sdt,']'])'; - - - S(i,:)=mdsdata(['data(',trace,channel(i,:),')[',sind1,':',sind2,':', step, ']'])'; - offset=mdsdata(['data(\atlas::t_rex3_full:signal_inp:p',channel(i,:),')[0:',num2str(npts),']' ]); - S2(i,:)=S(i,:)-repmat(mean(offset),length(t),1)'; - end - end - if fans(3) - - channel=['041';'042';'043';'044';'045';'046';'047';'048';'049';'050';... - '051';'052';'053';'054';'055';'056';'057';'058';'059';'060']; - for i=1:20 -% S(i,:)=mdsdata([trace, channel(i,:),'[',st1,':',st2,':',sdt,']'])'; - - - S(i,:)=mdsdata(['data(',trace,channel(i,:),')[',sind1,':',sind2,':', step, ']'])'; - offset=mdsdata(['data(\atlas::t_rex3_full:signal_inp:p',channel(i,:),')[0:',num2str(npts),']' ]); - S3(i,:)=S(i,:)-repmat(mean(offset),length(t),1)'; - end - end - - if fans(4) - channel=['061';'062';'063';'064';'065';'066';'067';'068';'069';'070';... - '071';'072';'073';'074';'075';'076';'077';'078';'079';'080']; - for i=1:20 -% S(i,:)=mdsdata([trace, channel(i,:),'[',st1,':',st2,':',sdt,']'])'; - - - S(i,:)=mdsdata(['data(',trace,channel(i,:),')[',sind1,':',sind2,':', step, ']'])'; - offset=mdsdata(['data(\atlas::t_rex3_full:signal_inp:p',channel(i,:),')[0:',num2str(npts),']' ]); - S4(i,:)=S(i,:)-repmat(mean(offset),length(t),1)'; - end - end - if fans(5) - channel=['081';'082';'083';'084';'085';'086';'087';'088';'089';'090';... - '091';'092';'093';'094';'095';'096';'097';'098';'099';'100']; - for i=1:20 -% S(i,:)=mdsdata([trace, channel(i,:),'[',st1,':',st2,':',sdt,']'])'; - - - S(i,:)=mdsdata(['data(',trace,channel(i,:),')[',sind1,':',sind2,':',step,']'])'; - offset=mdsdata(['data(\atlas::t_rex3_full:signal_inp:p',channel(i,:),')[0:',num2str(npts),']' ]); - S5(i,:)=S(i,:)-repmat(mean(offset),length(t),1)'; - end - end - - if fans(6) - channel=['101';'102';'103';'104';'105';'106';'107';'108';'109';'110';... - '111';'112';'113';'114';'115';'116';'117';'118';'119';'120']; - for i=1:20 -% S(i,:)=mdsdata([trace,channel(i,:),'[',st1,':',st2,':',sdt,':',step,']'])' - S(i,:)=mdsdata(['data(',trace,channel(i,:),')[',sind1,':',sind2,':', step, ']'])'; - offset=mdsdata(['data(\atlas::t_rex3_full:signal_inp:p',channel(i,:),')[0:',num2str(npts),']' ]); - S6(i,:)=S(i,:)-repmat(mean(offset),length(t),1)'; - end - end - if fans(7) - channel=['121';'122';'123';'124';'125';'126';'127';'128';'129';'130';... - '131';'132';'133';'134';'135';'136';'137';'138';'139';'140']; - for i=1:20 -% S(i,:)=mdsdata([trace, channel(i,:),'[',st1,':',st2,':',sdt,']'])'; - - - S(i,:)=mdsdata(['data(',trace,channel(i,:),')[',sind1,':',sind2,':',step,']'])'; - offset=mdsdata(['data(\atlas::t_rex3_full:signal_inp:p',channel(i,:),')[0:',num2str(npts),']' ]); - S7(i,:)=S(i,:)-repmat(mean(offset),length(t),1)'; - end - end - if fans(8) - channel=['141';'142';'143';'144';'145';'146';'147';'148';'149';'150';... - '151';'152';'153';'154';'155';'156';'157';'158';'159';'160']; - for i=1:20 -% S(i,:)=mdsdata([trace, channel(i,:),'[',st1,':',st2,':',sdt,']'])'; - - - S(i,:)=mdsdata(['data(',trace,channel(i,:),')[',sind1,':',sind2,':', step,']'])'; - offset=mdsdata(['data(\atlas::t_rex3_full:signal_inp:p',channel(i,:),')[0:',num2str(npts),']' ]); - S8(i,:)=S(i,:)-repmat(mean(offset),length(t),1)'; - end - end - if fans(9) - channel=['161';'162';'163';'164';'165';'166';'167';'168';'169';'170';... - '171';'172';'173';'174';'175';'176';'177';'178';'179';'180']; - for i=1:20 -% S(i,:)=mdsdata([trace, channel(i,:),'[',st1,':',st2,':',sdt,']'])'; - - - S(i,:)=mdsdata(['data(',trace,channel(i,:),')[',sind1,':',sind2,':', step,']'])'; - offset=mdsdata(['data(\atlas::t_rex3_full:signal_inp:p',channel(i,:),')[0:',num2str(npts),']' ]); - S9(i,:)=S(i,:)-repmat(mean(offset),length(t),1)'; - end - end - if fans(10) -% channel=['181';'182';'183';'184';'185';'186';'187';'188';'189';'190';... -% '191';'192';'193';'194';'195';'196';'197';'198';'199';'200']; - -% this permutation takes into account some not well defined (not yet) -% hardware corrections. Are the gains to be permutated ? - - - channel=['182';'181';'184';'183';'186';'185';'188';'187';'190';'189';... - '192';'191';'194';'193';'196';'195';'198';'197';'200';'199']; - for i=1:20 -% S(i,:)=mdsdata([trace, channel(i,:),'[',st1,':',st2,':',sdt,']'])'; - - - S(i,:)=mdsdata(['data(',trace,channel(i,:),')[',sind1,':',sind2,':', step,']'])'; - offset=mdsdata(['data(\atlas::t_rex3_full:signal_inp:p',channel(i,:),')[0:',num2str(npts),']' ]); - S10(i,:)=S(i,:)-repmat(mean(offset),length(t),1)'; - end - end - - sig=[S1;S2;S3;S4;S5;S6;S7;S8;S9;S10]; - - - [satrow,satcol]=find(abs(sig)>satlevel); - - if ~isempty(satcol) - i_tlimit=min(satcol(:)); - if i_tlimit>1 - sig=sig(:,1:i_tlimit-1); - t=t(1:i_tlimit-1); - disp(['get_xtomo_data WARNING: some channels saturated',...... - ', t2 changed to ',sprintf('%6.4f',max(t))]); - else - sig=[]; - t=[]; - disp('get_xtomo_data WARNING: saturations, no data returned'); - return - end - end - - - angfact=angfact(:,find(fans)); - angfact=angfact(:); - gains=get_xtomo_gains(shot); - % earlier than shot xxx: - perm=[1:180,[180+[2,1,4,3,6,5,8,7,10,9,12,11,14,13,16,15,18,17,20,19]]]; - gains=gains(perm); - iact=find(fans); - nact=length(iact); - idetec=[]; - for k=1:nact - idetec=[idetec,(iact(k)-1)*20+1:iact(k)*20]; - end - gains=gains(idetec); - gains=gains(:); - fac=ones(size(gains))./gains; - - - sig=sig.*(repmat(fac,1,length(t))); - - if iflat - for ii=1:length(t) - imini=find( sig(:,ii) < minsiglevel*max(sig(:,ii))); - sig(imini,ii)=zeros(size(imini)); - end - end - - t=t'; - sig=sig.*(repmat(angfact,1,length(t))); - +iflat=0; +minsiglevel=0.01; +satlevel=9.9; + + +st1=sprintf('%6.4f',t1); +st2=sprintf('%6.4f',t2); +sdt=num2str(dt); + +% sdt=sprintf('%6.4f',dt); % modified from old version + +if shot >= 13836 & shot <= 13848 + tstart=-0.02;tstop=-0.01; % this one is to be used only for +else % shot=13836 to shot=13848 + tstart=-0.04;tstop=-0.01; end -mdsclose +ststart=num2str(tstart); +ststop=num2str(tstop); + +if nargin <=6 + + shot=mdsopen(shot); + t=mdsdata(['dim_of(\base::xtomo:array_001[',st1,':',st2,':',sdt,',*])']); + S1=[]; + S2=[]; + S3=[]; + S4=[]; + S5=[]; + S6=[]; + S7=[]; + S8=[]; + S9=[]; + S10=[]; + + if isempty(t) + disp('get_xtomo_data: sorry, nothing to be found for this shot ...') + return + else + disp('*-------------------------------------------*') + disp('| get_xtomo_data: getting data from MDS |') + disp('*-------------------------------------------*') + end + + if shot>6768 + + if fans(1) + S=mdsdata(['\base::xtomo:array_001[',st1,':',st2,':',sdt,',0:19]'])'; + offset=mdsdata(['\base::xtomo:array_001[',ststart,':',ststop,',0:19]']); + S1=S-repmat(mean(offset),length(t),1)'; + end + + if fans(2) + S=mdsdata(['\base::xtomo:array_002[',st1,':',st2,':',sdt,',0:19]'])'; + offset=mdsdata(['\base::xtomo:array_002[',ststart,':',ststop,',0:19]']); + S2=S-repmat(mean(offset),length(t),1)'; + end + + if fans(3) + S=mdsdata(['\base::xtomo:array_003[',st1,':',st2,':',sdt,',0:19]'])'; + offset=mdsdata(['\base::xtomo:array_003[',ststart,':',ststop,',0:19]']); + S3=S-repmat(mean(offset),length(t),1)'; + end + + if fans(4) + S=mdsdata(['\base::xtomo:array_004[',st1,':',st2,':',sdt,',0:19]'])'; + offset=mdsdata(['\base::xtomo:array_004[',ststart,':',ststop,',0:19]']); + S4=S-repmat(mean(offset),length(t),1)'; + end + + if fans(5) + S=mdsdata(['\base::xtomo:array_005[',st1,':',st2,':',sdt,',0:19]'])'; + offset=mdsdata(['\base::xtomo:array_005[',ststart,':',ststop,',0:19]']); + S5=S-repmat(mean(offset),length(t),1)'; + end + + if fans(6) + S=mdsdata(['\base::xtomo:array_006[',st1,':',st2,':',sdt,',0:19]'])'; + offset=mdsdata(['\base::xtomo:array_006[',ststart,':',ststop,',0:19]']); + S6=S-repmat(mean(offset),length(t),1)'; + end + + if fans(7) + S=mdsdata(['\base::xtomo:array_007[',st1,':',st2,':',sdt,',0:19]'])'; + offset=mdsdata(['\base::xtomo:array_007[',ststart,':',ststop,',0:19]']); + S7=S-repmat(mean(offset),length(t),1)'; + end + + if fans(8) + S=mdsdata(['\base::xtomo:array_008[',st1,':',st2,':',sdt,',0:19]'])'; + offset=mdsdata(['\base::xtomo:array_008[',ststart,':',ststop,',0:19]']); + S8=S-repmat(mean(offset),length(t),1)'; + end + + if fans(9) + S=mdsdata(['\base::xtomo:array_009[',st1,':',st2,':',sdt,',0:19]'])'; + offset=mdsdata(['\base::xtomo:array_009[',ststart,':',ststop,',0:19]']); + S9=S-repmat(mean(offset),length(t),1)'; + end + + if fans(10) + S=mdsdata(['\base::xtomo:array_010[',st1,':',st2,':',sdt,',0:19]'])'; + offset=mdsdata(['\base::xtomo:array_010[',ststart,':',ststop,',0:19]']); + S10=S-repmat(mean(offset),length(t),1)'; + end + + + sig=-[S1;S2;S3;S4;S5;S6;S7;S8;S9;S10]; + [satrow,satcol]=find(abs(sig)>satlevel); + + if ~isempty(satcol) + i_tlimit=min(satcol(:)); + if i_tlimit>1 + sig=sig(:,1:i_tlimit-1); + t=t(1:i_tlimit-1); + disp(['get_xtomo_data WARNING: some channels saturated',...... + ', t2 changed to ',sprintf('%6.4f',max(t))]); + else + sig=[]; + t=[]; + disp('get_xtomo_data WARNING: saturations, no data returned'); + return + end + end + + + angfact=angfact(:,find(fans)); + angfact=angfact(:); + gains=get_xtomo_gains(shot); + % earlier than shot xxx: + perm=[1:180,[180+[2,1,4,3,6,5,8,7,10,9,12,11,14,13,16,15,18,17,20,19]]]; + gains=gains(perm); + iact=find(fans); + nact=length(iact); + idetec=[]; + for k=1:nact + idetec=[idetec,(iact(k)-1)*20+1:iact(k)*20]; + end + gains=gains(idetec); + gains=gains(:); + fac=ones(size(gains))./gains; + + + sig=-sig.*(repmat(fac,1,length(t))); + + if iflat + for ii=1:length(t) + imini=find( sig(:,ii) < minsiglevel*max(sig(:,ii))); + sig(imini,ii)=zeros(size(imini)); + end + end + + t=t'; + sig=sig.*(repmat(angfact,1,length(t))); + + + else + + if fans(9) + S=mdsdata(['\base::xtomo:array_001[',st1,':',st2,':',sdt,',0:19]'])'; + offset=mdsdata(['\base::xtomo:array_001[',ststart,':',ststop,',0:19]']); + V=S-repmat(mean(offset),length(t),1)'; + end + if fans(7) + S=mdsdata(['\base::xtomo:array_002[',st1,':',st2,':',sdt,',0:19]'])'; + offset=mdsdata(['\base::xtomo:array_002[',ststart,':',ststop,',0:19]']); + H=S-repmat(mean(offset),length(t),1)'; + end + %---- read gains of the current shot --------------------------------------- + + gains=get_xtomo_gains(shot); + g1=gains(1:20)'; + g2=gains(21:40)'; -return + %------ solid angle factors ----------------------- + + aom1=angfact(:,9); + aom2=angfact(:,7); + + + %----- calculate correcting factors --------------------------------------- + + fac1=(aom1./g1); + fac2=(aom2./g2); + + %--- result: offset-, calibration- and angular-factor corrected data ------- + + V=-V.*(repmat(fac1,1,length(t))); % vertical camera: + H=-H.*(repmat(fac2,1,length(t))); % horizontal camera: + + + sig=[H;V]; + + t=t'; + + end + +else + if (~strcmp(tag,'brief') & ~strcmp(tag,'full')) + disp('Only full or brief accepted as tag') + return + end + trace_tree=['\atlas::t_rex3_' tag ':']; + trace=[trace_tree 'signal_inp:p']; + %shot=mdsopen('eltca1::tcv_shot',shot); + shot=mdsopen(shot); + tref=mdsdata(['_tref=dim_of(' trace,'001)']); %trace :p001 + dtref=mdsdata('_dtref = _tref[1]-_tref[0]'); + S1=[]; + S2=[]; + S3=[]; + S4=[]; + S5=[]; + S6=[]; + S7=[]; + S8=[]; + S9=[]; + S10=[]; + t_1=mdsdata('_t = dim_of(\atlas::t_rex3_full:signal_inp:p001)'); + dt1=mdsdata('_dt = _t[1]-_t[0]'); + npts=floor(mdsdata(['_npts=(',ststop,'-(',ststart,'))/_dt'])); + + + + if isempty(t_1) + disp('get_xtomo_data: sorry, nothing to be found for this shot ...') + return + else + disp('*--------------------------------------------*') + disp('| getting Pentland acquisition: getting *') + if strcmp(tag,'brief') + disp('| BRIEF data from MDS *'); + else + disp('| FULL data from MDS *'); + end + disp('*--------------------------------------------*'); + end + + + + if ((dt - dtref) < 1e-7 | floor(dt/dtref) ==0) + step='1'; + else + step =num2str(dt/dtref); + end + + + ind1=find( abs(tref-t1) == min(abs(tref-t1))); + npts1=floor(mdsdata(['_npts1=(',st2,'-(',st1,'))/_dtref'])); + sind1=num2str(ind1); + sind2=num2str(npts1+ind1); + + t=mdsdata(['data(_tref)[',sind1,':',sind2,':', step, ']']); + + + + + if fans(1) + channel=['001';'002';'003';'004';'005';'006';'007';'008';'009';'010';... + '011';'012';'013';'014';'015';'016';'017';'018';'019';'020']; + for i=1:20 + % S(i,:)=mdsdata([trace, channel(i,:),'[',st1,':',st2,':',sdt,']'])'; + + + S(i,:)=mdsdata(['data(',trace,channel(i,:),')[',sind1,':',sind2,':' , step,']'])'; + offset=mdsdata(['data(\atlas::t_rex3_full:signal_inp:p',channel(i,:),')[0:',num2str(npts),']' ]); + S1(i,:)=S(i,:)-repmat(mean(offset),length(t),1)'; + end + end + + + + if fans(2) + channel=['021';'022';'023';'024';'025';'026';'027';'028';'029';'030';... + '031';'032';'033';'034';'035';'036';'037';'038';'039';'040']; + for i=1:20 + + % S(i,:)=mdsdata([trace, channel(i,:),'[',st1,':',st2,':',sdt,']'])'; + + + S(i,:)=mdsdata(['data(',trace,channel(i,:),')[',sind1,':',sind2,':', step, ']'])'; + offset=mdsdata(['data(\atlas::t_rex3_full:signal_inp:p',channel(i,:),')[0:',num2str(npts),']' ]); + S2(i,:)=S(i,:)-repmat(mean(offset),length(t),1)'; + end + end + if fans(3) + + channel=['041';'042';'043';'044';'045';'046';'047';'048';'049';'050';... + '051';'052';'053';'054';'055';'056';'057';'058';'059';'060']; + for i=1:20 + % S(i,:)=mdsdata([trace, channel(i,:),'[',st1,':',st2,':',sdt,']'])'; + + + S(i,:)=mdsdata(['data(',trace,channel(i,:),')[',sind1,':',sind2,':', step, ']'])'; + offset=mdsdata(['data(\atlas::t_rex3_full:signal_inp:p',channel(i,:),')[0:',num2str(npts),']' ]); + S3(i,:)=S(i,:)-repmat(mean(offset),length(t),1)'; + end + end + + if fans(4) + channel=['061';'062';'063';'064';'065';'066';'067';'068';'069';'070';... + '071';'072';'073';'074';'075';'076';'077';'078';'079';'080']; + for i=1:20 + % S(i,:)=mdsdata([trace, channel(i,:),'[',st1,':',st2,':',sdt,']'])'; + + + S(i,:)=mdsdata(['data(',trace,channel(i,:),')[',sind1,':',sind2,':', step, ']'])'; + offset=mdsdata(['data(\atlas::t_rex3_full:signal_inp:p',channel(i,:),')[0:',num2str(npts),']' ]); + S4(i,:)=S(i,:)-repmat(mean(offset),length(t),1)'; + end + end + if fans(5) + channel=['081';'082';'083';'084';'085';'086';'087';'088';'089';'090';... + '091';'092';'093';'094';'095';'096';'097';'098';'099';'100']; + for i=1:20 + % S(i,:)=mdsdata([trace, channel(i,:),'[',st1,':',st2,':',sdt,']'])'; + + + S(i,:)=mdsdata(['data(',trace,channel(i,:),')[',sind1,':',sind2,':',step,']'])'; + offset=mdsdata(['data(\atlas::t_rex3_full:signal_inp:p',channel(i,:),')[0:',num2str(npts),']' ]); + S5(i,:)=S(i,:)-repmat(mean(offset),length(t),1)'; + end + end + + if fans(6) + channel=['101';'102';'103';'104';'105';'106';'107';'108';'109';'110';... + '111';'112';'113';'114';'115';'116';'117';'118';'119';'120']; + for i=1:20 + % S(i,:)=mdsdata([trace,channel(i,:),'[',st1,':',st2,':',sdt,':',step,']'])' + S(i,:)=mdsdata(['data(',trace,channel(i,:),')[',sind1,':',sind2,':', step, ']'])'; + offset=mdsdata(['data(\atlas::t_rex3_full:signal_inp:p',channel(i,:),')[0:',num2str(npts),']' ]); + S6(i,:)=S(i,:)-repmat(mean(offset),length(t),1)'; + end + end + if fans(7) + channel=['121';'122';'123';'124';'125';'126';'127';'128';'129';'130';... + '131';'132';'133';'134';'135';'136';'137';'138';'139';'140']; + for i=1:20 + % S(i,:)=mdsdata([trace, channel(i,:),'[',st1,':',st2,':',sdt,']'])'; + + + S(i,:)=mdsdata(['data(',trace,channel(i,:),')[',sind1,':',sind2,':',step,']'])'; + offset=mdsdata(['data(\atlas::t_rex3_full:signal_inp:p',channel(i,:),')[0:',num2str(npts),']' ]); + S7(i,:)=S(i,:)-repmat(mean(offset),length(t),1)'; + end + end + if fans(8) + channel=['141';'142';'143';'144';'145';'146';'147';'148';'149';'150';... + '151';'152';'153';'154';'155';'156';'157';'158';'159';'160']; + for i=1:20 + % S(i,:)=mdsdata([trace, channel(i,:),'[',st1,':',st2,':',sdt,']'])'; + + + S(i,:)=mdsdata(['data(',trace,channel(i,:),')[',sind1,':',sind2,':', step,']'])'; + offset=mdsdata(['data(\atlas::t_rex3_full:signal_inp:p',channel(i,:),')[0:',num2str(npts),']' ]); + S8(i,:)=S(i,:)-repmat(mean(offset),length(t),1)'; + end + end + if fans(9) + channel=['161';'162';'163';'164';'165';'166';'167';'168';'169';'170';... + '171';'172';'173';'174';'175';'176';'177';'178';'179';'180']; + for i=1:20 + % S(i,:)=mdsdata([trace, channel(i,:),'[',st1,':',st2,':',sdt,']'])'; + + + S(i,:)=mdsdata(['data(',trace,channel(i,:),')[',sind1,':',sind2,':', step,']'])'; + offset=mdsdata(['data(\atlas::t_rex3_full:signal_inp:p',channel(i,:),')[0:',num2str(npts),']' ]); + S9(i,:)=S(i,:)-repmat(mean(offset),length(t),1)'; + end + end + if fans(10) + % channel=['181';'182';'183';'184';'185';'186';'187';'188';'189';'190';... + % '191';'192';'193';'194';'195';'196';'197';'198';'199';'200']; + + % this permutation takes into account some not well defined (not yet) + % hardware corrections. Are the gains to be permutated ? + + + channel=['182';'181';'184';'183';'186';'185';'188';'187';'190';'189';... + '192';'191';'194';'193';'196';'195';'198';'197';'200';'199']; + for i=1:20 + % S(i,:)=mdsdata([trace, channel(i,:),'[',st1,':',st2,':',sdt,']'])'; + + + S(i,:)=mdsdata(['data(',trace,channel(i,:),')[',sind1,':',sind2,':', step,']'])'; + offset=mdsdata(['data(\atlas::t_rex3_full:signal_inp:p',channel(i,:),')[0:',num2str(npts),']' ]); + S10(i,:)=S(i,:)-repmat(mean(offset),length(t),1)'; + end + end + + sig=[S1;S2;S3;S4;S5;S6;S7;S8;S9;S10]; + + + [satrow,satcol]=find(abs(sig)>satlevel); + + if ~isempty(satcol) + i_tlimit=min(satcol(:)); + if i_tlimit>1 + sig=sig(:,1:i_tlimit-1); + t=t(1:i_tlimit-1); + disp(['get_xtomo_data WARNING: some channels saturated',...... + ', t2 changed to ',sprintf('%6.4f',max(t))]); + else + sig=[]; + t=[]; + disp('get_xtomo_data WARNING: saturations, no data returned'); + return + end + end + + + angfact=angfact(:,find(fans)); + angfact=angfact(:); + gains=get_xtomo_gains(shot); + % earlier than shot xxx: + perm=[1:180,[180+[2,1,4,3,6,5,8,7,10,9,12,11,14,13,16,15,18,17,20,19]]]; + gains=gains(perm); + iact=find(fans); + nact=length(iact); + idetec=[]; + for k=1:nact + idetec=[idetec,(iact(k)-1)*20+1:iact(k)*20]; + end + gains=gains(idetec); + gains=gains(:); + fac=ones(size(gains))./gains; + + + sig=sig.*(repmat(fac,1,length(t))); + + if iflat + for ii=1:length(t) + imini=find( sig(:,ii) < minsiglevel*max(sig(:,ii))); + sig(imini,ii)=zeros(size(imini)); + end + end + + t=t'; + sig=sig.*(repmat(angfact,1,length(t))); + + +end + +mdsclose + + +return diff --git a/matlab/TCV/tcv_help_parameters.m b/matlab/TCV/tcv_help_parameters.m index bc9ec8b9a971b945001c46c5f255c3dd232b3019..8734871da0ed2bff8cd6772e8f8a7a653d9a8209 100644 --- a/matlab/TCV/tcv_help_parameters.m +++ b/matlab/TCV/tcv_help_parameters.m @@ -29,7 +29,8 @@ help_struct_all.cxrs_time_interval = ['cxrs: (time_interval can have several nbs ' as well']; help_struct_all.fit_tension = ['smoothing value used in interpos fitting routine, -30 means ''30 times default value'', thus -1 often a' ... ' good value' char(10) ... - 'cxrs: if numeric, default for all cases, if structure, default for non given fields']; + 'cxrs: if numeric, default for all cases, if structure, default for non given fields' char(10) ... + 'radcam: tension for interpos smoothing of data to have lower time samples']; help_struct_all.time = 'eqdsk: time(s) value(s) requested, by default time=1.0s (see time_out for other requests)'; help_struct_all.time_out = ['requested time for output: data points within interval if time_out=[t1 t2], otherwise assumes series of points, uses linear interpolation in that case (default [-Inf Inf])'... char(10) 'for sxr, mpx: only time interval provided in time_out is relevant']; @@ -56,9 +57,13 @@ help_struct_all.error_bar = sprintf('%s\n','for ids: choice of nodes fill in and '''delta'' (default): only upper fill in with the abs(value) to add or subtract to data to get upper and lower values (symmetric)', ... '''delta_with_lower'': same as delta but fill in lower node as well (with delta as well, same as upper)', ... '''added'': add the delta values (old cpo style), so upper=data+error_bar and lower=data+error_bar'); -help_struct_all.camera = ['sxr: for MPX: ''central'', ''top'' (default), ''bottom'' or ''both'' ; ' ... - ' for XTOMO: ''central'' (a central chord only), defaults if empty, [1 3 5] if only camera 1, 3 and 5 are desired']; -help_struct_all.freq = '''slow'', default, lower sampling; ''fast'' full samples for both mpx and xtomo'; +help_struct_all.camera = sprintf('%s\n%s\n%s', ... + 'sxr: for radcam: 1 to 4 or ''top'' (default), ''upper'', ''equatorial'', ''bottom'' array or cell array ok as well;', ... + ' for MPX: ''central'', ''top'' (default), ''bottom'' or ''both'' ;', ... + ' for XTOMO: ''central'' (a central chord only), defaults if empty, [1 3 5] if only camera 1, 3 and 5 are desired'); +help_struct_all.channel = sprintf('%s\n%s\n%s', ... + 'radcam: chord to choose within camera interval, or simply chords, then it is re-distributed to correct camera'); +help_struct_all.freq = '''slow'', default, lower sampling (for radcam smoothing on dt=0.1ms); ''fast'' full samples for radcam, mpx and xtomo'; help_struct_all.max_adcs = 'rtc: source=''adcs'' maximum nb of adc channels loaded for each board in each active node'; help_struct_all.nfft = '512 (default) changes time resolution in spectrogram in gdat_plot for ''mhd'' request'; help_struct_all.map_eqdsk_psirz = 'eqdsk: if time array provided, maps all psi(R,Z,t) on same R,Zmesh in .data (1) or not (0, default)'; @@ -66,8 +71,6 @@ help_struct_all.write = 'eqdsk: write eqdsk while loading data (1, default) or n help_struct_all.rtc = 'load data from mems saved by SCD system (if on for that shot), source defines what to search for'; %help_struct_all. = ''; - - if ~exist('parameter_list') || isempty(parameter_list) help_struct = help_struct_all; return diff --git a/matlab/TCV/tcv_requests_mapping.m b/matlab/TCV/tcv_requests_mapping.m index ad1bc170dab3bea172e5cffe6628196f901c8e63..04dcc1f5c8e483714b1882bb15b8e965bb07ed20 100644 --- a/matlab/TCV/tcv_requests_mapping.m +++ b/matlab/TCV/tcv_requests_mapping.m @@ -458,7 +458,7 @@ switch lower(data_request) mapping.expression = ['params_eff = gdat_data.gdat_params;params_eff.data_request=''tcv_eq("surf","LIUQE.M")'';' ... 'gdat_tmp=gdat_tcv(shot,params_eff); gdat_tmp.dim = {gdat_tmp.t}; gdat_tmp.x=[]; gdat_tmp.data= gdat_tmp.data(end,:);' ... 'gdat_tmp.dimunits{1}=''s'';gdat_tmp.help=''toroidal surface of LCFS'';']; - case 'sxr' + case {'sxr', 'mpx', 'radcam'} mapping.timedim = 1; mapping.gdat_timedim = 2; mapping.method = 'switchcase'; @@ -583,10 +583,6 @@ switch lower(data_request) % $$$ mapping.method = 'tdiliuqe'; % $$$ % mapping.expression = '\results::thomson:psiscatvol:foo'; % $$$ mapping.expression = '\results::thomson:psiscatvol'; - case 'mpx' - mapping.timedim = 1; - mapping.gdat_timedim = 2; - mapping.method = 'switchcase'; case {'profnerho','profterho'} mapping.timedim = 1; mapping.label = data_request; diff --git a/matlab/TCV_IMAS/ids2database.m b/matlab/TCV_IMAS/ids2database.m index 40f83746b8524a2b3f38cf770fcba6147ae7ace2..eb2c2ed7f0275d6700c482f8c6f3a1a4727d2fae 100644 --- a/matlab/TCV_IMAS/ids2database.m +++ b/matlab/TCV_IMAS/ids2database.m @@ -1,4 +1,4 @@ -function [ids_put_status] = ids2database(shot,run,occurence,ids2put,tree_user,tree_tokamak,tree_majorversion,varargin); +function [ids_put_status] = ids2database(shot,run,occurence,ids2put,tree_user,tree_tokamak,tree_majorversion,imas_backend,varargin); % % [ids_put_status] = ids2database(shot,run,occurence,ids2put,varargin); % @@ -7,6 +7,7 @@ function [ids_put_status] = ids2database(shot,run,occurence,ids2put,tree_user,tr % tree_name: getenv('USER') by default, can be 'public' % tree_tokamak: 'tcv' by default % tree_majorversion: '3' by default +% imas_backend: "MDSplus" or "HDF5" % % varargin{1}: tbd % @@ -16,6 +17,7 @@ ids_put_status = 0; tree_user_default = getenv('USER'); tree_tokamak_default = 'tcv'; tree_majorversion_default = '3'; +imas_backend_default = 'MDSplus'; % initialize input parser p = inputParser; @@ -28,6 +30,7 @@ p.addOptional('ids2put', struct([]), @(x) (isstruct(x))); p.addOptional('tree_user', tree_user_default, @(x) (isempty(x) || ischar(x))); p.addOptional('tree_tokamak', tree_tokamak_default, @(x) (isempty(x) || ischar(x))); p.addOptional('tree_majorversion', tree_majorversion_default, @(x) (ischar(x))); +p.addOptional('imas_backend', imas_backend_default, @(x) (isempty(x) || ischar(x))); p.parse; defaults_ids2database = p.Results; % to keep track of defaults @@ -53,8 +56,11 @@ elseif nargin==6 elseif nargin==7 p.parse(shot,run,occurence,ids2put,tree_user,tree_tokamak,tree_majorversion); params = p.Results; -elseif nargin>=8 - p.parse(shot,run,occurence,ids2put,tree_user,tree_tokamak,tree_majorversion,varargin{:}); +elseif nargin==8 + p.parse(shot,run,occurence,ids2put,tree_user,tree_tokamak,tree_majorversion,imas_backend); + params = p.Results; +elseif nargin>=9 + p.parse(shot,run,occurence,ids2put,tree_user,tree_tokamak,tree_majorversion,imas_backend,varargin{:}); params = p.Results; else p.parse; @@ -100,6 +106,19 @@ if isempty(ids_names_ok) return end +if ~ismember(params_ids2database.imas_backend, {'MDSplus', 'HDF5'}) + warning(['Unknown imas_backend: ', imas_backend, ', selecting default: ',imas_backend_default]); + params_ids2database.imas_backend = imas_backend_default; +end + +% Get IMAS backend ID +switch params_ids2database.imas_backend + case "HDF5" + backendid=13; + case "MDSplus" + backendid=12; +end + try %% Initialize the three shot_is_new = 1; % seems only create is ok even if does already exist @@ -109,10 +128,9 @@ try shot_is_new = 0; end if shot_is_new - idx = imas_create_env('ids',shot,run,0,0,params_ids2database.tree_user,params_ids2database.tree_tokamak, ... - params_ids2database.tree_majorversion); % + idx = imas_create_env_backend(shot, run, params_ids2database.tree_user,params_ids2database.tree_tokamak, params_ids2database.tree_majorversion, backendid) else - idx = imas_open_env('ids',shot,run,params_ids2database.tree_user,params_ids2database.tree_tokamak,params_ids2database.tree_majorversion); % + idx = imas_open_env_backend(shot,run,params_ids2database.tree_user,params_ids2database.tree_tokamak,params_ids2database.tree_majorversion,backendid); % end %% Put the field diff --git a/matlab/TCV_IMAS/tcv2ids2database.m b/matlab/TCV_IMAS/tcv2ids2database.m index 9166d42d3cb3b839076f7e15aa0bd33d158735a2..664175a4313b51c1194f1b54980d78155a6777d9 100644 --- a/matlab/TCV_IMAS/tcv2ids2database.m +++ b/matlab/TCV_IMAS/tcv2ids2database.m @@ -10,6 +10,7 @@ function [ids_from_tcv,varargout] = tcv2ids2database(shot,run_out,varargin); % varargin: 'occurence': occurence value % varargin: 'ids_names': cell, ids to load, by default all defined so far (if empty or empty string or not given) % see tcv_available_ids for the list of IDSs available for TCV +% varargin: 'imas_backend': "MDSplus" or "HDF5" % varargin: 'error_bar': type (string) % 'delta' or empty (default): meaning difference in upper is set (standard error_bar % 'added': errorbar is added: upper=data+delta and lower=data-delta @@ -27,6 +28,7 @@ function [ids_from_tcv,varargout] = tcv2ids2database(shot,run_out,varargin); % example: % ids_from_tcv = tcv2ids2database(62745,9999,'ids_names',{'pf_active'},'error_bar','added'); % to test only one ids % ids_from_tcv = tcv2ids2database(62745,9999,'error_bar','added'); % to get all default ids's and old errorbar type +% ids_from_tcv = tcv2ids2database(62745,9999,'ids_names',{'summary'},'imas_backend','HDF5'); % Save data in imas HDF5 backend instead of MDSplus % ids_from_tcv = []; @@ -50,6 +52,7 @@ p.addOptional('run_out', [], @(x) (isnumeric(x) && isscalar(x) && (x == round(x) p.addOptional('occurence', 0, @(x) isempty(x) || (isnumeric(x) && isscalar(x) && (x == round(x)))); % integer ids_names = tcv_available_ids; p.addOptional('ids_names', ids_names, @(x) isempty(x) || iscell(x)); % char or cell array +p.addOptional('imas_backend', 'MDSplus', @(x) isempty(x) || ischar(x)); p.addOptional('error_bar', 'delta', @(x) isempty(x) || ischar(x) ); % char or cell array p.addOptional('tree_user', getenv('USER'), @(x) isempty(x) || ischar(x) ); % char p.addOptional('tree_tokamak', 'tcv', @(x) isempty(x) || ischar(x) ); % char @@ -101,8 +104,9 @@ for i=1:length(params.ids_names) end params.ids_names = ids_names_ok; params_tcv2ids2database = params; -params_not_in_tcv2ids = {'run_out','occurence','tree_user','tree_tokamak','tree_majorversion'}; +params_not_in_tcv2ids = {'run_out','occurence','tree_user','tree_tokamak','tree_majorversion','imas_backend'}; params_tcv2ids = rmfield(params_tcv2ids2database,params_not_in_tcv2ids); + [ids_from_tcv,idsok] = tcv2ids(shot,params_tcv2ids); ids_from_tcv.params_tcv2ids2database = params_tcv2ids2database; @@ -128,7 +132,8 @@ end %% [ids_put_status] = ids2database(shot,run_out,ids_from_tcv.params_tcv2ids2database.occurence,ids_from_tcv, ... - params_tcv2ids2database.tree_user,params_tcv2ids2database.tree_tokamak,params_tcv2ids2database.tree_majorversion); + params_tcv2ids2database.tree_user,params_tcv2ids2database.tree_tokamak,params_tcv2ids2database.tree_majorversion, ... + params_tcv2ids2database.imas_backend); ids_from_tcv.ids_put_status = ids_put_status; diff --git a/matlab/TCV_IMAS/tcv_get_ids_summary.m b/matlab/TCV_IMAS/tcv_get_ids_summary.m index 777eed4318e4fddfd68f5235a3880cf9e34b1d9b..2a720beba4e976d3ab1443119ab95159cb7f7bf3 100644 --- a/matlab/TCV_IMAS/tcv_get_ids_summary.m +++ b/matlab/TCV_IMAS/tcv_get_ids_summary.m @@ -248,7 +248,7 @@ global_quantities_fieldnames = fieldnames(global_quantities); for i=1:numel(global_quantities_fieldnames) if ~any(strcmp(global_quantities_fieldnames{i},special_fields)) if ~isstruct(ids_summary.global_quantities.(global_quantities_fieldnames{i}).value) && ... - ~isempty(global_quantities.(global_quantities_fieldnames{i}).data) + ~isempty(global_quantities.(global_quantities_fieldnames{i}).data) ids_summary.global_quantities.(global_quantities_fieldnames{i}).value = interp1( ... global_quantities.(global_quantities_fieldnames{i}).t,global_quantities.(global_quantities_fieldnames{i}).data, ... ids_summary.time,'linear',NaN); diff --git a/matlab/gdat.m b/matlab/gdat.m index 11efb5931b88064d3e98894b1767e7922d8eb0d0..e21551bfb14986490b743ed75d0a0fe12fa88cdb 100644 --- a/matlab/gdat.m +++ b/matlab/gdat.m @@ -187,10 +187,21 @@ try else args = [{shot,data_request},varargin_eff]; end - [gdat_data,gdat_params,error_status,varargout] = feval(['gdat_' lower(machine_eff)],args{:}); - % because data request can be an actual detailed tree related signal, upper and lower case need to be kept, but other places remain with lower case when case insensitive - % needed since some substructure have machine name like mapping_for - gdat_data.gdat_params.machine = lower(gdat_data.gdat_params.machine); + % treat multiple shot numbers + if nargin > 0 && isnumeric(shot) + args_in = args; + for i=1:numel(shot) + args{1} = shot(i); + [gdat_data_i,gdat_params,error_status(i),varargout] = feval(['gdat_' lower(machine_eff)],args{:}); + gdat_data_i.gdat_params.machine = lower(gdat_data_i.gdat_params.machine); + gdat_data(i) = gdat_data_i; + end + else + [gdat_data,gdat_params,error_status,varargout] = feval(['gdat_' lower(machine_eff)],args{:}); + % because data request can be an actual detailed tree related signal, upper and lower case need to be kept, but other places remain with lower case when case insensitive + % needed since some substructure have machine name like mapping_for + gdat_data.gdat_params.machine = lower(gdat_data.gdat_params.machine); + end catch ME_gdat warning(['problems calling gdat_' lower(machine_eff)]); @@ -204,9 +215,13 @@ catch ME_gdat return end -gdat_data.gdat_call = gdat_call; +if numel(gdat_data) > 0 + for i=1:numel(gdat_data) + gdat_data(i).gdat_call = gdat_call; + end +end -if gdat_data.gdat_params.doplot +if numel(gdat_data) > 0 && gdat_data(1).gdat_params.doplot try % plot gdat_data versus 1st dim by default, if nb_dims<=2, otherwise do not plot hhh = gdat_plot(gdat_data); % return handle to figure diff --git a/matlab/gdat_plot.m b/matlab/gdat_plot.m index ccbf80d03b49bead91fae55fdf1432a7e4941c77..29895699b09e889c7085e485ec014d4c66f645f3 100644 --- a/matlab/gdat_plot.m +++ b/matlab/gdat_plot.m @@ -31,180 +31,189 @@ end doplot=1; if isfield(gdat_plot_params,'doplot') && ~isempty(gdat_plot_params.doplot) doplot = gdat_plot_params.doplot; -elseif isfield(gdat_data,'gdat_params') && isfield(gdat_data.gdat_params,'doplot') && ~isempty(gdat_data.gdat_params.doplot) - if gdat_data.gdat_params.doplot~=0 % assume one does not call gdat_plot not to plot - doplot = gdat_data.gdat_params.doplot; +elseif isfield(gdat_data(1),'gdat_params') && isfield(gdat_data(1).gdat_params,'doplot') && ~isempty(gdat_data(1).gdat_params.doplot) + if gdat_data(1).gdat_params.doplot~=0 % assume one does not call gdat_plot not to plot + doplot = gdat_data(1).gdat_params.doplot; end end if doplot==0; return; end redo_legend_from_Tags = 0; do_legend = 1; -if all(isfield(gdat_data,{'data','t'})) && ~isempty(gdat_data.data) && ~isempty(gdat_data.t) - fighandle = get(0,'CurrentFigure'); - if doplot == 1 - fighandle = figure; - elseif doplot > 1 - fighandle = figure(doplot); - clf; - elseif doplot == -1 - hold all - elseif doplot < -1 - fighandle = figure(abs(doplot)); - hold all - end - if isfield(gdat_data,'gdat_request') && ischar(gdat_data.gdat_request) ... - && strcmp(gdat_data.gdat_request,'eqdsk') - % special case, plot contours of first equil - endstr = ''; - if iscell(gdat_data.eqdsk); endstr = '{1}'; end - eval(['contour(gdat_data.eqdsk' endstr '.rmesh,gdat_data.eqdsk' endstr '.zmesh,gdat_data.eqdsk' endstr '.psi'',100);']) - hold on - eval(['linehandles{end+1} = plot(gdat_data.eqdsk' endstr '.rplas,gdat_data.eqdsk' endstr '.zplas,''k'');']) - eval(['linehandles{end+1} = plot(gdat_data.eqdsk' endstr '.rlim,gdat_data.eqdsk' endstr '.zlim,''k'');']) - axis equal; - title(eval(['gdat_data.eqdsk' endstr '.stitle'])); - do_legend = 0; - elseif any(find(size(gdat_data.data)==length(gdat_data.t))) - try - if length(size(gdat_data.data))<=2 - if isnumeric(gdat_data.t) - linehandles{end+1} = plot(gdat_data.t,gdat_data.data); - elseif iscell(gdat_data.t) - linehandles{end+1} = plot(str2num(cell2mat(gdat_data.t)),gdat_data.data); +nb_linehandles_current = numel(linehandles); +for ishot=1:numel(gdat_data) + nb_linehandles_prev = nb_linehandles_current; + if all(isfield(gdat_data(ishot),{'data','t'})) && ~isempty(gdat_data(ishot).data) && ~isempty(gdat_data(ishot).t) + fighandle = get(0,'CurrentFigure'); + if ishot > 1 && gdat_data(1).gdat_params.doplot==1 + % assume that for a series of shot, need doplot=-1 after 1st plot if doplot was 1 in request + doplot = -1; + end + if doplot == 1 + fighandle = figure; + elseif doplot > 1 + fighandle = figure(doplot); + clf; + elseif doplot == -1 + hold all + elseif doplot < -1 + fighandle = figure(abs(doplot)); + hold all + end + if isfield(gdat_data(ishot),'gdat_request') && ischar(gdat_data(ishot).gdat_request) ... + && strcmp(gdat_data(ishot).gdat_request,'eqdsk') + % special case, plot contours of first equil + endstr = ''; + if iscell(gdat_data(ishot).eqdsk); endstr = '{1}'; end + eval(['contour(gdat_data(ishot).eqdsk' endstr '.rmesh,gdat_data(ishot).eqdsk' endstr '.zmesh,gdat_data(ishot).eqdsk' endstr '.psi'',100);']) + hold on + eval(['linehandles{end+1} = plot(gdat_data(ishot).eqdsk' endstr '.rplas,gdat_data(ishot).eqdsk' endstr '.zplas,''k'');']) + eval(['linehandles{end+1} = plot(gdat_data(ishot).eqdsk' endstr '.rlim,gdat_data(ishot).eqdsk' endstr '.zlim,''k'');']) + axis equal; + title(eval(['gdat_data(ishot).eqdsk' endstr '.stitle'])); + do_legend = 0; + elseif any(find(size(gdat_data(ishot).data)==length(gdat_data(ishot).t))) + try + if length(size(gdat_data(ishot).data))<=2 + if isnumeric(gdat_data(ishot).t) + linehandles{end+1} = plot(gdat_data(ishot).t,gdat_data(ishot).data); + elseif iscell(gdat_data(ishot).t) + linehandles{end+1} = plot(str2num(cell2mat(gdat_data(ishot).t)),gdat_data(ishot).data); + end + else + disp('WARNING') + disp(['size(gdat_data(ishot).data) = ' num2str(size(gdat_data(ishot).data)) ', >2D thus do not try to plot']) + disp(' ') + return + end + catch ME + if exist('ME','var') + disp('Problem in gdat_plot') + rethrow(ME) end - else - disp('WARNING') - disp(['size(gdat_data.data) = ' num2str(size(gdat_data.data)) ', >2D thus do not try to plot']) - disp(' ') return end - catch ME - if exist('ME','var') - disp('Problem in gdat_plot') - rethrow(ME) + if ~isfield(gdat_data(ishot),'shot'); return; end % allows to plot if just .t and .data exist + if doplot < 0 + title([gdat_data(ishot).gdat_params.machine]); + else + title([gdat_data(ishot).gdat_params.machine ' #' num2str(gdat_data(ishot).shot)]); end - return - end - if ~isfield(gdat_data,'shot'); return; end % allows to plot if just .t and .data exist - if doplot < 0 - title([gdat_data.gdat_params.machine]); - else - title([gdat_data.gdat_params.machine ' #' num2str(gdat_data.shot)]); - end - if isfield(gdat_data,'mapping_for') - dimunits_x = gdat_data.dimunits{gdat_data.mapping_for.(gdat_data.gdat_params.machine).gdat_timedim}; - if ischar(dimunits_x) - xlabel(['time [' dimunits_x ']']); + if isfield(gdat_data(ishot),'mapping_for') + dimunits_x = gdat_data(ishot).dimunits{gdat_data(ishot).mapping_for.(gdat_data(ishot).gdat_params.machine).gdat_timedim}; + if ischar(dimunits_x) + xlabel(['time [' dimunits_x ']']); + else + xlabel(['time']); + end else xlabel(['time']); end - else - xlabel(['time']); - end - ylabel_eff = gdat_data.label; - if iscell(gdat_data.label) && length(gdat_data.label)>=2; ylabel_eff = gdat_data.label{end}; end - if ~isempty(gdat_data.units) - hylabel=ylabel([ylabel_eff '[' gdat_data.units ']'],'interpreter','none'); - else - hylabel=ylabel(ylabel_eff,'interpreter','none'); - end - ab=get(gca,'children'); - if iscell(gdat_data.label) && numel(gdat_data.label) > 1; - if numel(ab)==numel(gdat_data.label) || mod(numel(ab),numel(gdat_data.label))==0 - % Assumes a single shot with several lines and labels, if mod==0 then this is a new shot, only Tag present lines - for iab=1:numel(gdat_data.label) - set(ab(iab),'Tag',[num2str(gdat_data.shot) ' ' gdat_data.label{end-iab+1}]); + ylabel_eff = gdat_data(ishot).label; + if iscell(gdat_data(ishot).label) && length(gdat_data(ishot).label)>=2; ylabel_eff = gdat_data(ishot).label{end}; end + if ~isempty(gdat_data(ishot).units) + hylabel=ylabel([ylabel_eff '[' gdat_data(ishot).units ']'],'interpreter','none'); + else + hylabel=ylabel(ylabel_eff,'interpreter','none'); + end + ab=get(gca,'children'); + if iscell(gdat_data(ishot).label) && numel(gdat_data(ishot).label) > 1; + if numel(ab)==numel(gdat_data(ishot).label) || mod(numel(ab),numel(gdat_data(ishot).label))==0 + % Assumes a single shot with several lines and labels, if mod==0 then this is a new shot, only Tag present lines + for iab=1:numel(gdat_data(ishot).label) + set(ab(iab),'Tag',[num2str(gdat_data(ishot).shot) ' ' gdat_data(ishot).label{end-iab+1}]); + end + if numel(ab)>numel(gdat_data(ishot).label), redo_legend_from_Tags = 1; end + end + if iscell(gdat_data(ishot).label) && length(ab) < length(gdat_data(ishot).label) + if length(ab) == 1 + % assume combine label is best + tempaaa = sprintf('%s/',gdat_data(ishot).label{:}); + hhhleg=legend(tempaaa(1:end-1)); + set(ab(1),'Tag',[num2str(gdat_data(ishot).shot) ' ' tempaaa(1:min(10,numel(tempaaa)-1))]); + else + % not sure why would get there + hhhleg=legend(gdat_data(ishot).label{1:length(ab)}); + end + elseif numel(ab)==numel(gdat_data(ishot).label) + hhhleg=legend(gdat_data(ishot).label); + end + if exist('hhhleg','var'), set(hhhleg,'Interpreter','none'); end + else + % assume one line per call + if isempty(gdat_data(ishot).label) + set(ab(1),'Tag',[num2str(gdat_data(ishot).shot)]); + elseif ischar(gdat_data(ishot).label) + % assume one signal, take max 10 chars + set(ab(1),'Tag',[num2str(gdat_data(ishot).shot) ' ' gdat_data(ishot).label(1:min(10,numel(gdat_data(ishot).label)))]); + elseif iscell(gdat_data(ishot).label) && numel(gdat_data(ishot).label) == 1 + if isempty(gdat_data(ishot).label{1}) + set(ab(1),'Tag',[num2str(gdat_data(ishot).shot)]); + else + set(ab(1),'Tag',[num2str(gdat_data(ishot).shot) ' ' gdat_data(ishot).label{1}(1:min(10,numel(gdat_data(ishot).label{1})))]); + end end - if numel(ab)>numel(gdat_data.label), redo_legend_from_Tags = 1; end end - 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)); - set(ab(1),'Tag',[num2str(gdat_data.shot) ' ' tempaaa(1:min(10,numel(tempaaa)-1))]); - else - % not sure why would get there - hhhleg=legend(gdat_data.label{1:length(ab)}); + if redo_legend_from_Tags + for iab=1:numel(ab) + % Use Tag for DisplayName, when overlay plots of multiple data at this stage + set(ab(iab),'DisplayName',strrep(get(ab(iab),'Tag'),'_','\_')); end - elseif numel(ab)==numel(gdat_data.label) - hhhleg=legend(gdat_data.label); end - if exist('hhhleg','var'), set(hhhleg,'Interpreter','none'); end + zoom on; + end + maxnblines = 1; + nb_linehandles_current = numel(linehandles); + if ~exist('ab','var'), ab=get(gca,'children'); end + if do_legend==0 || redo_legend_from_Tags || any(strcmp(gdat_data(ishot).gdat_params.data_request,'powers')) ... + || (numel(ab)==numel(gdat_data(ishot).label) && numel(ab)>1) + % keep legend as is else - % assume one line per call - if isempty(gdat_data.label) - set(ab(1),'Tag',[num2str(gdat_data.shot)]); - elseif ischar(gdat_data.label) - % assume one signal, take max 10 chars - set(ab(1),'Tag',[num2str(gdat_data.shot) ' ' gdat_data.label(1:min(10,numel(gdat_data.label)))]); - elseif iscell(gdat_data.label) && numel(gdat_data.label) == 1 - if isempty(gdat_data.label{1}) - set(ab(1),'Tag',[num2str(gdat_data.shot)]); + for i=nb_linehandles_prev+1:nb_linehandles_current + maxnblines = max(maxnblines,numel(linehandles{i})); + if numel(linehandles{i}) == 1 + set(linehandles{i},'DisplayName',[num2str(gdat_data(ishot).shot)]); else - set(ab(1),'Tag',[num2str(gdat_data.shot) ' ' gdat_data.label{1}(1:min(10,numel(gdat_data.label{1})))]); + for j=1:numel(linehandles{i}) + set(linehandles{i}(j),'DisplayName',[num2str(gdat_data(ishot).shot) ',' num2str(j)]); + end end end end - if redo_legend_from_Tags - for iab=1:numel(ab) - % Use Tag for DisplayName, when overlay plots of multiple data at this stage - set(ab(iab),'DisplayName',strrep(get(ab(iab),'Tag'),'_','\_')); - end - end - zoom on; - end - maxnblines = 1; - if ~exist('ab','var'), ab=get(gca,'children'); end - if do_legend==0 || redo_legend_from_Tags || any(strcmp(gdat_data.gdat_params.data_request,'powers')) ... - || (numel(ab)==numel(gdat_data.label) && numel(ab)>1) - % keep legend as is - else - for i=1:numel(linehandles) - maxnblines = max(maxnblines,numel(linehandles{i})); - if numel(linehandles{i}) == 1 - set(linehandles{i},'DisplayName',[num2str(gdat_data.shot)]); + if do_legend==1 && maxnblines==1; legend show; end + if strcmp(gdat_data(ishot).gdat_request,'mhd') + % special case, add legend instead of ylabel + delete(hylabel); + legend(gdat_data(ishot).label); + % add spectrogram per signal + mhd_sum_data = 0.; + if isfield(gdat_data(ishot).gdat_params,'nfft') && ~isempty(gdat_data(ishot).gdat_params.nfft) + nfft = gdat_data(ishot).gdat_params.nfft; else - for j=1:numel(linehandles{i}) - set(linehandles{i}(j),'DisplayName',[num2str(gdat_data.shot) ',' num2str(j)]); - end + nfft=512; end - end - end - if do_legend==1 && maxnblines==1; legend show; end - if strcmp(gdat_data.gdat_request,'mhd') - % special case, add legend instead of ylabel - delete(hylabel); - legend(gdat_data.label); - % add spectrogram per signal - mhd_sum_data = 0.; - if isfield(gdat_data.gdat_params,'nfft') && ~isempty(gdat_data.gdat_params.nfft) - nfft = gdat_data.gdat_params.nfft; - else - nfft=512; - end - tmhdm=mean(reshape(gdat_data.t(1:nfft*fix(length(gdat_data.t)/nfft)),nfft,fix(length(gdat_data.t)/nfft))); - for i=1:size(gdat_data.data,2) - [B,F,T]=specgram(gdat_data.data(:,i),nfft,1/mean(diff(gdat_data.t)),hanning(nfft),nfft/2); + tmhdm=mean(reshape(gdat_data(ishot).t(1:nfft*fix(length(gdat_data(ishot).t)/nfft)),nfft,fix(length(gdat_data(ishot).t)/nfft))); + for i=1:size(gdat_data(ishot).data,2) + [B,F,T]=specgram(gdat_data(ishot).data(:,i),nfft,1/mean(diff(gdat_data(ishot).t)),hanning(nfft),nfft/2); + figure; + imagesc(T+tmhdm(1),F/1e3,20*log10(abs(B)));axis xy;colormap jet; + ylabel('freq [kHz]') + xlabel(gdat_data(ishot).dimunits{1}) + ylabel_eff = gdat_data(ishot).label; + if iscell(gdat_data(ishot).label) && length(gdat_data(ishot).label)>=i; ylabel_eff = gdat_data(ishot).label{i}; end + title([upper(gdat_data(ishot).gdat_params.machine) '#' num2str(gdat_data(ishot).shot) ' ' ylabel_eff]) + mhd_sum_data = mhd_sum_data + gdat_data(ishot).data(:,i); + end + [B,F,T]=specgram(mhd_sum_data./size(gdat_data(ishot).data,2),nfft,1/mean(diff(gdat_data(ishot).t)),hanning(nfft),nfft/2); figure; imagesc(T+tmhdm(1),F/1e3,20*log10(abs(B)));axis xy;colormap jet; ylabel('freq [kHz]') - xlabel(gdat_data.dimunits{1}) - ylabel_eff = gdat_data.label; - if iscell(gdat_data.label) && length(gdat_data.label)>=i; ylabel_eff = gdat_data.label{i}; end - title([upper(gdat_data.gdat_params.machine) '#' num2str(gdat_data.shot) ' ' ylabel_eff]) - mhd_sum_data = mhd_sum_data + gdat_data.data(:,i); + xlabel(gdat_data(ishot).dimunits{1}) + ylabel_eff = gdat_data(ishot).label; + if iscell(gdat_data(ishot).label); ylabel_eff = sprintf('%s ',gdat_data(ishot).label{:}); end + title([upper(gdat_data(ishot).gdat_params.machine) '#' num2str(gdat_data(ishot).shot) ' sum of ' ylabel_eff]) end - [B,F,T]=specgram(mhd_sum_data./size(gdat_data.data,2),nfft,1/mean(diff(gdat_data.t)),hanning(nfft),nfft/2); - figure; - imagesc(T+tmhdm(1),F/1e3,20*log10(abs(B)));axis xy;colormap jet; - ylabel('freq [kHz]') - xlabel(gdat_data.dimunits{1}) - ylabel_eff = gdat_data.label; - if iscell(gdat_data.label); ylabel_eff = sprintf('%s ',gdat_data.label{:}); end - title([upper(gdat_data.gdat_params.machine) '#' num2str(gdat_data.shot) ' sum of ' ylabel_eff]) + else + disp(['cannot plot gdat_data(' num2str(ishot) '), has empty data or t field']) end -else - disp('cannot plot gdat_data, has empty data or t field') end diff --git a/matlab/generic_fit.m b/matlab/generic_fit.m index 97532229c93b61cf1d84b709170cffdfb7071f82..2ab0d71c87e023edbc83fa404e3ba7ad45003ea3 100644 --- a/matlab/generic_fit.m +++ b/matlab/generic_fit.m @@ -56,12 +56,12 @@ if in_option_eff == 0 disp('no main data') return end - + main_time_base = data_in{1}.t; - + time_interval_in = [main_time_base(1) main_time_base(end)]; ij=find(main_time_base>=time_interval_in(1) & main_time_base<=time_interval_in(2)); - + gen_signals_data.(dataname).combined_data.t = main_time_base(ij); gen_signals_data.(dataname).t = gen_signals_data.(dataname).combined_data.t; for i=1:length(ij) @@ -77,14 +77,14 @@ if in_option_eff == 0 end gen_signals_data.(dataname).combined_data.time_interval(i,1:2) = [t1(i) t2(i)]; end - + for idata=1:length(data_in) gen_signals_data.(dataname).combined_data.rholabel{idata} = data_in{idata}.xname; end for i=1:length(ij) % for each time interval, collect the data - rhotor_data_tofit = []; + rhotor_data_tofit = []; xxdata_tofit = []; xxerr_tofit = []; data_provenance = []; @@ -92,18 +92,18 @@ if in_option_eff == 0 it_data{idata} = find(data_in{idata}.t>=t1(i) & data_in{idata}.t<t2(i)); % construct 1D array with data from data_in{idata} if ~isempty(it_data{idata}) - for it=1:length(it_data{idata}) - jrho_data = find(data_in{idata}.x(:,it_data{idata}(it))>0 & data_in{idata}.x(:,it_data{idata}(it))<1.01 & data_in{idata}.data(:,it_data{idata}(it))>0); - if length(jrho_data)>0 - rhotor_data_tofit(end+1:end+length(jrho_data)) = data_in{idata}.x(jrho_data,it_data{idata}(it)); - xxdata_tofit(end+1:end+length(jrho_data)) = data_in{idata}.data(jrho_data,it_data{idata}(it)); - xxerr_tofit(end+1:end+length(jrho_data)) = data_in{idata}.error_bar(jrho_data,it_data{idata}(it))./coeff_xx_eff(idata); - data_provenance(end+1:end+length(jrho_data)) = idata.*ones(size(jrho_data)); - end - end + for it=1:length(it_data{idata}) + jrho_data = find(data_in{idata}.x(:,it_data{idata}(it))>0 & data_in{idata}.x(:,it_data{idata}(it))<1.01 & data_in{idata}.data(:,it_data{idata}(it))>0); + if length(jrho_data)>0 + rhotor_data_tofit(end+1:end+length(jrho_data)) = data_in{idata}.x(jrho_data,it_data{idata}(it)); + xxdata_tofit(end+1:end+length(jrho_data)) = data_in{idata}.data(jrho_data,it_data{idata}(it)); + xxerr_tofit(end+1:end+length(jrho_data)) = data_in{idata}.error_bar(jrho_data,it_data{idata}(it))./coeff_xx_eff(idata); + data_provenance(end+1:end+length(jrho_data)) = idata.*ones(size(jrho_data)); + end + end end end - + if isempty(xxdata_tofit) disp('xxdata_tofit empty') gen_signals_data.(dataname).combined_data.perDt{i}.rho = []; @@ -158,5 +158,3 @@ gen_signals_data.(dataname).shot = shot; gen_signals_data.(dataname).fit.tension = tension_xx_eff; gen_signals_data.(dataname).fit.coeff_datas = coeff_xx_eff; gen_signals_data.(dataname).fit.rholabel = gen_signals_data.(dataname).combined_data.rholabel{1}; - - diff --git a/matlab/get_data_request_names_from_gdat_xxx.m b/matlab/get_data_request_names_from_gdat_xxx.m index 728e15104fa01f798cd407f731b7715b54e364c4..ae5e9261feb802d5ef2fe9c08cbfcc5ab4571031 100644 --- a/matlab/get_data_request_names_from_gdat_xxx.m +++ b/matlab/get_data_request_names_from_gdat_xxx.m @@ -30,7 +30,7 @@ end fid=fopen([machine_in '_requests_mapping.m'],'r'); nextline=fgetl(fid); while isempty(nextline) || ~isnumeric(nextline) || nextline~=-1 %length(nextline)>2 || ~strcmp(nextline,'-1') - if length(nextline)>7 && strcmp(nextline(1:6),' case ') + if length(nextline)>7 && ~isempty(regexp(nextline,'^ +case ')) ij=find(nextline==['''']); if ~isempty(ij) for i=1:2:length(ij)-1 diff --git a/matlab/get_grids_1d.m b/matlab/get_grids_1d.m index b5822569ef8d33161910c05fbf11127a3d7b0729..b1ff6894b6a31c7913e1aa8b690c2da4469f8557 100644 --- a/matlab/get_grids_1d.m +++ b/matlab/get_grids_1d.m @@ -116,11 +116,11 @@ for it=1:length(gdat_data.t) end end if ~isempty(rhovol.x) && ~isempty(rhovol.data) - if ndim_x_rhovol==1 - gdat_data.grids_1d.rhovolnorm(1:nb_ii,it)=interpos(23,rhovol.x,rhovol.data(:,it_vol_eff),gdat_data.grids_1d.rhopolnorm(ii),tens0); - else - gdat_data.grids_1d.rhovolnorm(1:nb_ii,it)=interpos(23,rhovol.x(:,it_vol_eff),rhovol.data(:,it_vol_eff),gdat_data.grids_1d.rhopolnorm(ii),tens0); - end + if ndim_x_rhovol==1 + gdat_data.grids_1d.rhovolnorm(1:nb_ii,it)=interpos(23,rhovol.x,rhovol.data(:,it_vol_eff),gdat_data.grids_1d.rhopolnorm(ii),tens0); + else + gdat_data.grids_1d.rhovolnorm(1:nb_ii,it)=interpos(23,rhovol.x(:,it_vol_eff),rhovol.data(:,it_vol_eff),gdat_data.grids_1d.rhopolnorm(ii),tens0); + end end end else @@ -135,11 +135,11 @@ for it=1:length(gdat_data.t) end end if ~isempty(rhovol.x) && ~isempty(rhovol.data) - if ndim_x_rhovol==1 - gdat_data.grids_1d.rhovolnorm(1:nb_ii,it)=interpos(23,rhovol.x,rhovol.data(:,it_vol_eff),gdat_data.grids_1d.rhopolnorm(ii,it),tens0); - else - gdat_data.grids_1d.rhovolnorm(1:nb_ii,it)=interpos(23,rhovol.x(:,it_vol_eff),rhovol.data(:,it_vol_eff),gdat_data.grids_1d.rhopolnorm(ii,it),tens0); - end + if ndim_x_rhovol==1 + gdat_data.grids_1d.rhovolnorm(1:nb_ii,it)=interpos(23,rhovol.x,rhovol.data(:,it_vol_eff),gdat_data.grids_1d.rhopolnorm(ii,it),tens0); + else + gdat_data.grids_1d.rhovolnorm(1:nb_ii,it)=interpos(23,rhovol.x(:,it_vol_eff),rhovol.data(:,it_vol_eff),gdat_data.grids_1d.rhopolnorm(ii,it),tens0); + end end end end diff --git a/matlab/get_profiles.m b/matlab/get_profiles.m index 5fbd0cd5ff713fc525a60542e07c3a94629f8ba1..34d4edea3bffe6ff815ebd7b1b0a55c639c04cd8 100644 --- a/matlab/get_profiles.m +++ b/matlab/get_profiles.m @@ -83,15 +83,15 @@ if nargin>=3 end else if get_profiles_params.nverbose>=1; warning(['varargin input argument nb: ' num2str(i) ... - ' (nargin=' num2str(i+2) ') is incorrect, expects a character string']); - end - error_status=-11; - return + ' (nargin=' num2str(i+2) ') is incorrect, expects a character string']); + end + error_status=-11; + return end end else if get_profiles_params.nverbose>=1; ... - warning('number of varargin input arguments incorrect, cannot make pairs of parameters'); + warning('number of varargin input arguments incorrect, cannot make pairs of parameters'); end error_status=-12; return @@ -155,4 +155,3 @@ for i=1:length(profile_struct) end end end - diff --git a/matlab/subcall_all2str.m b/matlab/subcall_all2str.m index 6e5d1ee125d25ccaad650eb1ba91d844a6c8ebd4..8966d184da44bc48e0c6973f93e9f0c7e8742ab0 100644 --- a/matlab/subcall_all2str.m +++ b/matlab/subcall_all2str.m @@ -56,11 +56,7 @@ for i_in=1:length(varargin) elseif ischar(var_to_treat) subcall = [subcall ',''' var_to_treat '''']; elseif iscell(var_to_treat) - subcall = [subcall ',{''' var_to_treat{1} '''']; - for i=2:length(var_to_treat) - subcall = [subcall ',''' var_to_treat{i} '''']; - end - subcall = [subcall '}']; + subcall = [subcall ',' cell2str(var_to_treat,3) '']; else warning('in subcall_all2str: case not foreseen'); end diff --git a/matlab/tests/test_requestnames.m b/matlab/tests/test_requestnames.m index 63595919b38cbbbedf2ad19c8636348badc1df83..557144ccdb55fdc352bb83cf17315892f15429ad 100644 --- a/matlab/tests/test_requestnames.m +++ b/matlab/tests/test_requestnames.m @@ -1,48 +1,63 @@ classdef (SharedTestFixtures={... check_mds,check_gdatpaths}) ... test_requestnames < matlab.unittest.TestCase - + properties (Abstract) Machine; end - + properties(TestParameter,Abstract) % parameters that will vary during tests shot; requests_fast; % placeholders requests_slow; end - + methods(Static) function test_gdat_call(testCase,shot,request) % actual function to test gdat call testCase.assertTrue(isnumeric(str2double(shot))); testCase.assertTrue(ischar(request)); - + % gdat call gdat_call = sprintf(['gdat_' lower(testCase.Machine) '(%s,''%s'')'],shot,request); do_gdat_call = 1; - + switch request case 'eqdsk' % avoid writing files in /tmp, may not be allowed gdat_call = sprintf(['gdat_%s(%s,''%s'',''write'',0)'],lower(testCase.Machine),shot,request); + case 'radcam' + % need a newer shot for tcv radcam + shot = 81102; + gdat_call = sprintf(['gdat_' lower(testCase.Machine) '(%s,''%s'')'],shot,request); end - + % logging fprintf('Testing gdat call: %s\n',gdat_call); - + if do_gdat_call gdat_out = eval(gdat_call); %#ok<NASGU> else gdat_out = struct([]); end - + % in some future: check for warnings %gdat_out = verifyWarningFree(testCase,eval(gdat_call),... % 'Warning issued from gdat call:\n %s\n',gdat_call); - + % (add optional sanity checks of gdat_out here) + gdat_out + switch request + case {'ece', 'expcode', 'ids', 'ni', 'ti', 'transp'} + % tests not yet fully implemented and empty + case 'rtc' + % in this case .data is empty, all in .scd_mems + testCase.assertTrue(isfield(gdat_out,'scd_mems') && isstruct(gdat_out.scd_mems)); + % testCase.assertTrue(isstruct(gdat_out.scd_mems)); + otherwise + testCase.assertTrue(isnumeric(gdat_out.data) & numel(gdat_out.data)>0); + end end end -end \ No newline at end of file +end diff --git a/matlab/tests/test_requestnames_tcv.m b/matlab/tests/test_requestnames_tcv.m index f40ecbfa9348473a86ef5552e37e9ad0340510a7..6941e96ddac1f9ae3cc07d32ee0dc76e58b0c5d5 100644 --- a/matlab/tests/test_requestnames_tcv.m +++ b/matlab/tests/test_requestnames_tcv.m @@ -11,17 +11,17 @@ classdef (TestTags={'tcv'})test_requestnames_tcv < test_requestnames requests_fast = get_all_gdat_requests('TCV','fast'); requests_slow = get_all_gdat_requests('TCV','slow'); end - + methods(Test,TestTags = {'fast'}) function test_gdat_call_fast(testCase,shot,requests_fast) testCase.test_gdat_call(testCase,shot,requests_fast); end end - + methods(Test,TestTags = {'slow'}) function test_gdat_call_slow(testCase,shot,requests_slow) testCase.test_gdat_call(testCase,shot,requests_slow); end end - + end