Newer
Older

Olivier Sauter
committed
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
function [gdat_data,gdat_params,error_status,varargout] = gdat_jet(shot,data_request,varargin)
%
% function [gdat_data,gdat_params,error_status,varargout] = gdat(shot,data_request,varargin)
%
% Aim: get data from a given machine using full path or keywords.
% data_request are and should be case independent (transformed in lower case in the function and outputs)
%
% If no inputs are provided, return the list of available pre-defined data_request in gdat_data and default parameters gdat_params
%
% Inputs:
%
% no inputs: return default parameters in a structure form in gdat_params
% shot: shot number
% data_request: keyword (like 'ip') or trace name or structure containing all parameters but shot number
% varargin{i},varargin{i+1},i=1:nargin-2: additional optional parameters given in pairs: param_name, param_value
% The optional parameters list might depend on the data_request
% examples of optional parameters:
% 'plot',1 (plot is set by default to 0)
% 'machine','JET' (the default machine is the local machine)
%
%
% Outputs:
%
% gdat_data: structure containing the data, the time trace if known and other useful information
% gdat_data.t : time trace
% gdat_data.data: requested data values
% gdat_data.dim : values of the various coordinates related to the dimensions of .data(:,:,...)
% note that one of the dim is the time, replicated in .t for clarity
% gdat_data.dimunits : units of the various dimensions, 'dimensionless' if dimensionless
% gdat_data.error_bar : if provided
% gdat_data.gdat_call : list of parameters provided in the gdat call (so can be reproduced)
% gdat_data.shot: shot number
% gdat_data.machine: machine providing the data
% gdat_data.gdat_request: keyword for gdat if relevant
% gdat_data.data_fullpath: full path to the data node if known and relevant, or relevant expression called if relevant
% gdat_data.gdat_params: copy gdat_params for completeness (gdat_params contains a .help structure detailing each parameter)
% gdat_data.xxx: any other relevant information
%
% gdat_params contains the options relevant for the called data_request. It also contains a help structure for each option
% eg.: param1 in gdat_params.param1 and help in gdat_params.help.param1
%
% Examples:
% (should add working examples for various machines (provides working shot numbers for each machine...))
%
% [a1,a2]=gdat;
% a2.data_request = 'Ip';
% a3=gdat(51994,a2); % gives input parameters as a structure, allows to call the same for many shots
% a4=gdat('opt1',123,'opt2',[1 2 3],'shot',55379,'data_request','Ip','opt3','aAdB'); % all in pairs
% a5=gdat(51994,'ip'); % standard call
% a6=gdat(51994,'ip','Opt1',123,'Doplot',1,'opt2','Abc'); % standard call with a few options (note all lowercase in output)
%
% For JET, the specific trace can be given as:
% aa==gdat(51994,[{'ppf'},{'efit'},{'xip'}],'machine','jet','doplot',1);
%
% Comments for local developer:
% This gdat is just a "header routine" calling the gdat for the specific machine gdat_`machine`.m which can be called
% directly, thus which should be able to treat the same type of input arguments
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Prepare some variables, etc
varargout{1}=cell(1,1);
error_status=1;
% construct main default parameters structure
gdat_params.data_request = '';
default_machine = 'jet';
gdat_params.machine=default_machine;
gdat_params.doplot = 0;
gdat_params.nverbose = 1;
% construct list of keywords from global set of keywords and specific JET set
% get data_request names from centralized table

Olivier Sauter
committed
%%% data_request_names = get_data_request_names; % do not use xlsx anymore but scan respective machine_requests_mapping.m files
data_request_names = get_data_request_names_from_gdat_xxx(default_machine);

Olivier Sauter
committed
% add JET specific to all:
if ~isempty(data_request_names.jet)
jet_names = fieldnames(data_request_names.jet);
for i=1:length(jet_names)
data_request_names.all.(jet_names{i}) = data_request_names.jet.(jet_names{i});
end
end
data_request_names_all = sort(fieldnames(data_request_names.all));

Olivier Sauter
committed
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
% construct default output structure
gdat_data.data = [];
gdat_data.units = [];
gdat_data.dim = [];
gdat_data.dimunits = [];
gdat_data.t = [];
gdat_data.x = [];
gdat_data.shot = [];
gdat_data.gdat_request = [];
gdat_data.gdat_params = gdat_params;
gdat_data.data_fullpath = [];
gdat_data.help = [];
% Treat inputs:
ivarargin_first_char = 3;
data_request_eff = '';
if nargin>=2 && ischar(data_request); data_request = lower(data_request); end
gdat_data.gdat_request = data_request_names_all; % so if return early gives list of possible request names
gdat_data.gdat_params.help = jet_help_parameters(fieldnames(gdat_data.gdat_params));
gdat_params = gdat_data.gdat_params;
% no inputs
if nargin==0
% return defaults and list of keywords
return
end
do_mdsopen_mdsclose = 1;
% treat 1st arg
if nargin>=1
if isempty(shot)
% means mdsopen(shot) already performed
shot=-999; % means not defined
do_mdsopen_mdsclose = 0;
elseif isnumeric(shot)
gdat_data.shot = shot;
elseif ischar(shot)
ivarargin_first_char = 1;
else
if gdat_params.nverbose>=1; warning('type of 1st argument unexpected, should be numeric or char'); end
error_status=2;
return
end
if nargin==1
% Only shot number given. If there is a default data_request set it and continue, otherwise return
return
end
end
% 2nd input argument if not part of pairs
if nargin>=2 && ivarargin_first_char~=1
if isempty(data_request)
return
end
% 2nd arg can be a structure with all options except shot_number, or a string for the pathname or keyword, or the start of pairs string/value for the parameters
if isstruct(data_request)
if ~isfield(data_request,'data_request')
if gdat_params.nverbose>=1; warning('expects field data_request in input parameters structure'); end
error_status=3;
return
end
data_request.data_request = lower(data_request.data_request);
data_request_eff = data_request.data_request;
gdat_params = data_request;
else
% since data_request is char check from nb of args if it is data_request or a start of pairs
if mod(nargin-1,2)==0
ivarargin_first_char = 2;
else
ivarargin_first_char = 3;
data_request_eff = data_request;
end
end
end
if ~isstruct(data_request)
gdat_params.data_request = data_request_eff;
end
% if start pairs from shot or data_request, shift varargin
if ivarargin_first_char==1
varargin_eff{1} = shot;
varargin_eff{2} = data_request;
varargin_eff(3:nargin) = varargin(:);
elseif ivarargin_first_char==2
varargin_eff{1} = data_request;
varargin_eff(2:nargin-1) = varargin(:);
else
varargin_eff(1:nargin-2) = varargin(:);
end
% extract parameters from pairs of varargin:
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})
% enforce lower case for any character driven input
if ischar(varargin_eff{i+1})
gdat_params.(lower(varargin_eff{i})) = lower(varargin_eff{i+1});
else
gdat_params.(lower(varargin_eff{i})) = varargin_eff{i+1};
end
else
if gdat_params.nverbose>=1; warning(['input argument nb: ' num2str(i) ' is incorrect, expects a character string']); end
error_status=401;
return
end
end
else
if gdat_params.nverbose>=1; warning('number of input arguments incorrect, cannot make pairs of parameters'); end
error_status=402;
return
end
end
data_request_eff = gdat_params.data_request; % in case was defined in pairs
% if it is a request_keyword copy it:
if ischar(data_request_eff) || length(data_request_eff)==1
ij=strmatch(data_request_eff,data_request_names_all,'exact');
else
ij=[];
end
if ~isempty(ij);
gdat_data.gdat_request = data_request_names_all{ij};
if isfield(data_request_names.all.(data_request_names_all{ij}),'description') && ~isempty(data_request_names.all.(data_request_names_all{ij}).description)
% copy description of keyword
gdat_data.request_description = data_request_names.all.(data_request_names_all{ij}).description;
end
end
% special treatment if shot and data_request given within pairs
if isfield(gdat_params,'shot')
shot = gdat_params.shot; % should use only gdat_params.shot but change shot to make sure
gdat_data.shot = gdat_params.shot;
gdat_params=rmfield(gdat_params,'shot');
end
if ~isfield(gdat_params,'data_request') || isempty(gdat_params.data_request)
% warning('input for ''data_request'' missing from input arguments') % might be correct, asking for list of requests
error_status=5;
return
end
gdat_data.gdat_params = gdat_params;
% re-assign main variables to make sure use the one in gdat_data structure
shot = gdat_data.shot;
data_request_eff = gdat_data.gdat_params.data_request;
error_status = 6; % at least reached this level
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Specifications on how to get the data provided in jet_requests_mapping
mapping_for_jet = jet_requests_mapping(data_request_eff);
gdat_data.label = mapping_for_jet.label;
% fill again at end to have full case, but here to have present status in case of early return
gdat_data.gdat_params.help = jet_help_parameters(fieldnames(gdat_data.gdat_params));
gdat_data.mapping_for.jet = mapping_for_jet;
gdat_params = gdat_data.gdat_params;
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% 1st treat the simplest method: "signal"
if strcmp(mapping_for_jet.method,'signal')
ppftype = mapping_for_jet.expression{1};
tracename = [mapping_for_jet.expression{2} '/' mapping_for_jet.expression{3}];
[a,x,t,d,e]=rda_jet(shot,ppftype,tracename);
if e==0
if gdat_params.nverbose>=3; disp(['error after rda_jet in signal with data_request_eff= ' data_request_eff]); end
return
end
aatmp.data = a; aatmp.t = t; aatmp.x = x;
gdat_data.data = aatmp.data;
gdat_data.t = aatmp.t;
gdat_data.x = aatmp.x;
if isempty(gdat_data.data)
return
end
if mapping_for_jet.timedim<=0
% need to guess timedim
if prod(size(aatmp.data)) == length(aatmp.data)
mapping_for_jet.timedim = 1;
elseif length(size(aatmp.data))==2
% 2 true dimensions
if length(aatmp.t) == size(aatmp.data,1)
mapping_for_jet.timedim = 1;
else
mapping_for_jet.timedim = 2;
end
else
% more than 2 dimensions, find the one with same length to define timedim
mapping_for_jet.timedim = find(size(aatmp.data)==length(aatmp.t));
if length(mapping_for_jet.timedim); mapping_for_jet.timedim = mapping_for_jet.timedim(1); end
end
mapping_for_jet.gdat_timedim = mapping_for_jet.timedim;
end
if length(size(aatmp.data))==1 | (length(size(aatmp.data))==2 & size(aatmp.data,2)==1)
gdat_data.dim=[{aatmp.t}];
gdat_data.dimunits={'time [s]'};
elseif length(size(aatmp.data))==2
gdat_data.dim{mapping_for_jet.timedim} = gdat_data.t;
gdat_data.dimunits{mapping_for_jet.timedim} = 'time [s]';
gdat_data.dim{setdiff([1:2],mapping_for_jet.timedim)} = gdat_data.x;
else
gdat_data.dim{mapping_for_jet.timedim} = gdat_data.t;
gdat_data.dimunits{mapping_for_jet.timedim} = 'time [s]';
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};
end
end
end
nbdims = length(gdat_data.dim);
if isfield(aatmp,'units')
gdat_data.units = aatmp.units;
elseif isfield(mapping_for_jet,'units')
gdat_data.units =mapping_for_jet.units;
end

Olivier Sauter
committed
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
if mapping_for_jet.gdat_timedim>0 && mapping_for_jet.gdat_timedim ~= mapping_for_jet.timedim
% shift timedim to gdat_timedim data(i,j,...itime,k,...) -> data(i,inewtime,j,...,k,...)
% note that this means that gdat_data.x and gdat_data.t are same and correct,
% only .data, .dim and .dimunits need to be changed
iprev=[1:nbdims];
ij=find(dim_nontim>mapping_for_jet.gdat_timedim-1);
inew=[1:mapping_for_jet.gdat_timedim-1 mapping_for_jet.timedim dim_nontim(ij)];
data_sizes = size(aatmp.data);
gdat_data.data = NaN*ones(data_sizes(inew));
abcol=ones(1,nbdims)*double(':'); abcomma=ones(1,nbdims)*double(',');
dimstr_prev=['(' repmat(':,',1,mapping_for_jet.timedim-1) 'it,' ...
repmat(':,',1,nbdims-mapping_for_jet.timedim-1) ':)'];
dimstr_new=['(' repmat(':,',1,mapping_for_jet.gdat_timedim-1) 'it,' ...
repmat(':,',1,nbdims-mapping_for_jet.gdat_timedim-1) ':)'];
% eval gdat_data.data(;,:,...,it,...) = aatmp.data(:,:,:,it,...);
for it=1:size(aatmp.data,mapping_for_jet.timedim)
shift_eval = ['gdat_data.data' dimstr_new ' = aatmp.data' dimstr_prev ';'];
eval(shift_eval);
end
gdat_data.dim = aatmp.dim(inew);
% gdat_data.dimunits = aatmp.dimunits(inew);
else
mapping_for_jet.gdat_timedim = mapping_for_jet.timedim;
end
gdat_data.data_fullpath=mapping_for_jet.expression;
% end of method "signal"
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
elseif strcmp(mapping_for_jet.method,'expression')
% 2nd: method="expression"
% assume expression contains an expression to evaluate and which creates a local structure into variable gdat_tmp
% we copy the structure, to make sure default nodes are defined and to avoid if return is an closed object like tdi
% eval_expr = [mapping_for_jet.expression ';'];
eval([mapping_for_jet.expression ';']);
if isempty(gdat_tmp) || (~isstruct(gdat_tmp) & ~isobject(gdat_tmp))
if (gdat_params.nverbose>=1); warning(['expression does not create a gdat_tmp structure: ' mapping_for_jet.expression]); end
error_status=801;
return
end
tmp_fieldnames = fieldnames(gdat_tmp);
if sum(strcmp(tmp_fieldnames,'data'))==0 % note: cannot do isfield since gdat_tmp might be an object
if (gdat_params.nverbose>=1); warning(['expression does not return a child name ''data'' for ' data_request_eff]); end
end
for i=1:length(tmp_fieldnames)
gdat_data.(tmp_fieldnames{i}) = gdat_tmp.(tmp_fieldnames{i});
end
% add .t and .x in case only dim is provided
% do not allow shifting of timedim since should be treated in the relevant expression
ijdim=find(strcmp(tmp_fieldnames,'dim')==1);
if ~isempty(ijdim)
nbdims = length(gdat_data.dim);
if mapping_for_jet.timedim==-1;
mapping_for_jet.timedim = nbdims;
if (size(gdat_data.data,nbdims)==1 && nbdims>1); mapping_for_jet.timedim = nbdims-1; end
end
dim_nontim = setdiff([1:nbdims],mapping_for_jet.timedim);
ijt=find(strcmp(tmp_fieldnames,'t')==1);
if isempty(ijt)
gdat_data.t = gdat_data.dim{mapping_for_jet.timedim};
end
ijx=find(strcmp(tmp_fieldnames,'x')==1);
if isempty(ijx)
if ~isempty(dim_nontim)
% since most cases have at most 2d, copy as array if data is 2D and as cell if 3D or more
if length(dim_nontim)==1
gdat_data.x = gdat_data.dim{dim_nontim(1)};
else
gdat_data.x = gdat_data.dim(dim_nontim);
end
end
end
gdat_data.data_fullpath=mapping_for_jet.expression;
end
% end of method "expression"
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
elseif strcmp(mapping_for_jet.method,'switchcase')
switch data_request_eff % not lower(...) since data_request_eff should be lower case already at this stage
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% First the request names valid for "all" machines:
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
case {'a_minor','rgeom'}
% compute average minor or major radius (on z=zaxis normally)
nodenameeff=['\results::r_max_psi' substr_liuqe];
rmaxpsi=tdi(nodenameeff);
ijnan = find(isnan(rmaxpsi.data));
if isempty(rmaxpsi.data) || isempty(rmaxpsi.dim) || ischar(rmaxpsi.data) || ...
( ~isempty(ijnan) && prod(size(ijnan))==prod(size(rmaxpsi.data)) )
if (gdat_params.nverbose>=1); warning(['problems loading data for ' nodenameeff ' for data_request= ' data_request_eff]); end
if (gdat_params.nverbose>=3); disp(['rerun LIUQE?']); end
return
end
nodenameeff2=['\results::r_min_psi' substr_liuqe];
rminpsi=tdi(nodenameeff2);
ijnan = find(isnan(rminpsi.data));
if isempty(rminpsi.data) || isempty(rminpsi.dim) || ...
( ~isempty(ijnan) && prod(size(ijnan))==prod(size(rminpsi.data)) )
if (gdat_params.nverbose>=1); warning(['problems loading data for ' nodenameeff2 ' for data_request= ' data_request_eff]); end
if (gdat_params.nverbose>=3); disp(['rerun LIUQE?']); end
return
end
ij=find(rmaxpsi.data<0.5 | rmaxpsi.data>1.2);
if ~isempty(ij); rmaxpsi.data(ij)=NaN; end
ij=find(rminpsi.data<0.5 | rminpsi.data>1.2);
if ~isempty(ij); rminpsi.data(ij)=NaN; end
if strcmp(data_request_eff,'a_minor')
gdat_data.data=0.5.*(rmaxpsi.data(end,:) - rminpsi.data(end,:));
gdat_data.data_fullpath=[nodenameeff ' - ' nodenameeff2 ' /2'];
elseif strcmp(data_request_eff,'rgeom')
gdat_data.data=0.5.*(rmaxpsi.data(end,:) + rminpsi.data(end,:));
gdat_data.data_fullpath=[nodenameeff ' + ' nodenameeff2 ' /2'];
else
if (gdat_params.nverbose>=1); warning(['should not be in this case with data_request_eff = ' data_request_eff]); end
return
end
gdat_data.dim = rmaxpsi.dim(2);
gdat_data.t = gdat_data.dim{1};
if any(strcmp(fieldnames(rmaxpsi),'units'))
gdat_data.units = rmaxpsi.units;
end
gdat_data.dimunits = rmaxpsi.dimunits(2);
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
case {'zgeom'}
% compute average minor or major radius (on z=zaxis normally)
nodenameeff=['\results::z_contour' substr_liuqe];
zcontour=tdi(nodenameeff);
if isempty(zcontour.data) || isempty(zcontour.dim) % || ischar(zcontour.data) (to add?)
if (gdat_params.nverbose>=1); warning(['problems loading data for ' nodenameeff ' for data_request= ' data_request_eff]); end
if (gdat_params.nverbose>=3); disp(['rerun LIUQE?']); end
return
end
if strcmp(data_request_eff,'zgeom')
gdat_data.data=0.5.*(max(zcontour.data,[],1) + min(zcontour.data,[],1));
gdat_data.data_fullpath=['(max+min)/2 of ' nodenameeff];
gdat_data.dim{1} = zcontour.dim{2};
gdat_data.dimunits{1} = zcontour.dimunits{2};
else
if (gdat_params.nverbose>=1); warning(['should not be in this case with data_request_eff = ' data_request_eff]); end
return
end
gdat_data.t = gdat_data.dim{mapping_for_jet.gdat_timedim};
if any(strcmp(fieldnames(zcontour),'units'))
gdat_data.units = zcontour.units;
end
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
case {'b0'}
% B0 at R0=0.88
R0EXP=0.88;
if liuqe_version==-1
nodenameeff = 'jet_eq("BZERO","FBTE")';
tracetdi=tdi(nodenameeff);
gdat_data.data = tracetdi.data;
else
nodenameeff=['\magnetics::iphi'];
tracetdi=tdi(nodenameeff);
gdat_data.data=192.E-07 * 0.996 *tracetdi.data/R0EXP;
end
if isempty(tracetdi.data) || isempty(tracetdi.dim) % || ischar(tracetdi.data) (to add?)
if (gdat_params.nverbose>=1); warning(['problems loading data for ' nodenameeff ' for data_request= ' data_request_eff]); end
return
end
gdat_data.data_fullpath=[nodenameeff];
gdat_data.dim = tracetdi.dim;
gdat_data.t = gdat_data.dim{1};
if any(strcmp(fieldnames(tracetdi),'units'))
gdat_data.units = tracetdi.units;
end
gdat_data.dimunits = tracetdi.dimunits;
gdat_data.request_description = ['vacuum magnetic field at R0=' num2str(R0EXP) 'm; COCOS=17'];
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
case {'betan'}
% 100*beta / |Ip[MA] * B0[T]| * a[m]
% get B0 from gdat_jet, without re-opening the shot and using the same parameters except data_request
% easily done thanks to structure call for options
params_eff = gdat_data.gdat_params;
params_eff.data_request='b0';
b0=gdat_jet([],params_eff); % note: no need to set .doplot=0 since gdat_jet does not call gdat_plot in any case
params_eff.data_request='ip';
ip=gdat_jet([],params_eff);
params_eff.data_request='beta';
beta=gdat_jet([],params_eff);
params_eff.data_request='a_minor';
a_minor=gdat_jet([],params_eff);
% use beta as time base
if isempty(b0.data) || isempty(b0.dim) || isempty(ip.data) || isempty(ip.dim) || isempty(a_minor.data) || isempty(a_minor.dim) || isempty(beta.data) || isempty(beta.dim)
if (gdat_params.nverbose>=1); warning(['problems loading data for data_request= ' data_request_eff]); end
return
end
gdat_data.dim = beta.dim;
gdat_data.t = beta.dim{1};
gdat_data.data = beta.data;
ij=find(~isnan(ip.data));
ip_t = interp1(ip.dim{1}(ij),ip.data(ij),gdat_data.t);
ij=find(~isnan(b0.data));
b0_t = interp1(b0.dim{1}(ij),b0.data(ij),gdat_data.t);
ij=find(~isnan(a_minor.data));
a_minor_t = interp1(a_minor.dim{1}(ij),a_minor.data(ij),gdat_data.t);
gdat_data.data = 100.*beta.data ./ abs(ip_t).*1.e6 .* abs(b0_t) .* a_minor_t;
gdat_data.data_fullpath='100*beta/ip*1e6*b0*a_minor, each from gdat_jet';
gdat_data.units = '';
gdat_data.dimunits{1} = 's';
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
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};
% 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;
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';
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
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;
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
gdat_data.gdat_params.zshift = zshift;
for itime=1:length(time)
time_eff = time(itime);
% use read_results updated to effectively obtain an eqdsk with sign correct with COCOS=2
[fnames_readresults]=read_results_for_chease(shot,time_eff,liuqe_version,3,[],[],[],zshift,0,1);
if isempty(fnames_readresults)
if gdat_params.nverbose>=1;
warning(['could not create eqdsk file from read_results_for_chease with data_request= ' data_request_eff]);
end
return
end
eqdskval=read_eqdsk(fnames_readresults{4},7,0,[],[],1); % LIUQE is 17 but read_results divided psi by 2pi thus 7
for i=1:length(fnames_readresults)
unix(['rm ' fnames_readresults{i}]);
end
% transform to cocos=2 since read_results originally assumed it was cocos=2
cocos_in = 2;
[eqdsk_cocos_in, eqdsk_cocosout_IpB0pos,cocos_inout]=eqdsk_cocos_transform(eqdskval,[7 cocos_in]);
fnamefull = fullfile(['/tmp/' getenv('USER')],['EQDSK_' num2str(shot) 't' num2str(time_eff,'%.4f')]);
% We still write COCOS=2 case, since closer to standard (in /tmp)
write_eqdsk(fnamefull,eqdsk_cocos_in,cocos_in,[],[],[],1);
% Now gdat_jet should return the convention from LIUQE which is COCOS=17, except if specified in option
% create standard filename name from shot, time_eff (cocos will be added by write_eqdsk)
cocos_out = 17;
if isfield(gdat_data.gdat_params,'cocos') && ~isempty(gdat_data.gdat_params.cocos)
cocos_out = gdat_data.gdat_params.cocos;
else
gdat_data.gdat_params.cocos = cocos_out;
end
[eqdsk_cocosout, eqdsk_cocosout_IpB0pos,cocos_inout]=eqdsk_cocos_transform(eqdsk_cocos_in,[cocos_in cocos_out]);
% 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) > 1
gdat_data.eqdsk{itime} = write_eqdsk(fnamefull,eqdsk_cocosout,cocos_out);
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(fnamefull,eqdsk_cocosout,cocos_out);
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 read_eqdsk from LIUQE' num2str(liuqe_version) ';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 {'mhd'}
% load n=1, 2 and 3 Bdot from magnetic measurements
if shot< 50926
n1=tdi('abs(mhdmode("LFS",1,1))');
n2=tdi('abs(mhdmode("LFS",2,1))');
n3=tdi('abs(mhdmode("LFS",3,1))');
gdat_data.data_fullpath='abs(mhdmode("LFS",n,1));% for 1, 2, 3';
else
if isfield(gdat_data.gdat_params,'source') && ~isempty(gdat_data.gdat_params.source)
% gdat_data.gdat_params.source;
else
gdat_data.gdat_params.source = '23';
end
if length(gdat_data.gdat_params.source)>=2 && strcmp(gdat_data.gdat_params.source(1:2),'23')
aaLFSz23_sect3=tdi('\atlas::DT196_MHD_001:channel_067');
aaLFSz23_sect11=tdi('\atlas::DT196_MHD_001:channel_075');
n1 = aaLFSz23_sect3;
n1.data = aaLFSz23_sect3.data - aaLFSz23_sect11.data;
n2 = aaLFSz23_sect3;
n2.data = aaLFSz23_sect3.data + aaLFSz23_sect11.data;
n3=n1;
gdat_data.data_fullpath='\atlas::DT196_MHD_001:channel_067 -+ \atlas::DT196_MHD_001:channel_075 for n=1,2, LFS_sect_3/11, z=23cm';
if strcmp(gdat_data.gdat_params.source,'23full')
% HFS from sec 3 and 11
aaHFSz23_sect3=tdi('\atlas::DT196_MHD_002:channel_018');
aaHFSz23_sect11=tdi('\atlas::DT196_MHD_002:channel_022');
gdat_data.n1_HFS=aaHFSz23_sect3;
gdat_data.n1_HFS.data = gdat_data.n1_HFS.data - aaHFSz23_sect11.data;
gdat_data.n2_HFS=aaHFSz23_sect3;
gdat_data.n2_HFS.data = gdat_data.n2_HFS.data + aaHFSz23_sect11.data;
gdat_data.data_fullpath=['\atlas::DT196_MHD_001:channel_067 -+ \atlas::DT196_MHD_001:channel_075 for n=1,2, LFS_sect_3/11, z=23cm; _HFS' ...
' same for sector HFS: MHD_002:channel_018-+MHD_002:channel_022'];
end
elseif strcmp(gdat_data.gdat_params.source(1),'0')
aaLFSz0_sect3=tdi('\atlas::DT196_MHD_001:channel_083');
aaLFSz0_sect11=tdi('\atlas::DT196_MHD_001:channel_091');
n1 = aaLFSz0_sect3;
n1.data = aaLFSz0_sect3.data - aaLFSz0_sect11.data;
n2 = aaLFSz0_sect3;
n2.data = aaLFSz0_sect3.data + aaLFSz0_sect11.data;
n3=n1;
gdat_data.data_fullpath='\atlas::DT196_MHD_001:channel_083 -+ \atlas::DT196_MHD_001:channel_091 for n=1,2, LFS_sect_3/11, z=0cm';
if strcmp(gdat_data.gdat_params.source,'0full')
% sect 11 180deg from sec 3
aaHFSz0_sect3=tdi('\atlas::DT196_MHD_002:channel_034');
aaHFSz0_sect11=tdi('\atlas::DT196_MHD_002:channel_038');
gdat_data.n1_HFS=aaHFSz0_sect11;
gdat_data.n1_HFS.data = gdat_data.n1_HFS.data - aaHFSz0_sect11.data;
gdat_data.n2_HFS=aaHFSz0_sect11;
gdat_data.n2_HFS.data = gdat_data.n2_HFS.data + aaHFSz0_sect11.data;
gdat_data.data_fullpath=['\atlas::DT196_MHD_001:channel_083 -+ \atlas::DT196_MHD_001:channel_091 for n=1,2, LFS_sect3/11, z=0cm; _HFS' ...
' same for HFS: MHD_002:channel_034-+MHD_002:channel_038'];
end
else
disp('should not be here in ''mhd'', ask O. Sauter')
return
end
end
if ~isempty(n1.data)
gdat_data.data(:,1) = reshape(n1.data,length(n1.data),1);
if length(n2.data)==length(n1.data); gdat_data.data(:,2) = reshape(n2.data,length(n2.data),1); end
if length(n3.data)==length(n1.data); gdat_data.data(:,3) = reshape(n3.data,length(n3.data),1); end
gdat_data.dim{1} = n1.dim{1};
gdat_data.t = gdat_data.dim{1};
gdat_data.dim{2} = [1; 2; 3];
gdat_data.dimunits{1} = n1.dimunits{1};
gdat_data.dimunits{2} = 'n number';
gdat_data.units = 'T/s';
gdat_data.request_description = 'delta_Bdot from magnetic probes to get n=1, 2 and 3';
gdat_data.label = {'n=1','n=2','n=3'}; % can be used in legend(gdat_data.label)
end
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
case {'ne','te'}
% ne or Te from Thomson data on raw z mesh vs (z,t)
if ~(isfield(gdat_data.gdat_params,'edge') && ~isempty(gdat_data.gdat_params.edge) && ...
gdat_data.gdat_params.edge>0)
gdat_data.gdat_params.edge = 0;
end
[gdat_data] = get_thomson_raw_data(shot,data_request_eff,gdat_data,gdat_data.gdat_params.edge,gdat_params.nverbose);
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
case {'ne_rho', 'te_rho', 'nete_rho'}
% if nete_rho, do first ne, then Te later (so fir stuff already done)
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 ~(isfield(gdat_data.gdat_params,'edge') && ~isempty(gdat_data.gdat_params.edge) && ...
gdat_data.gdat_params.edge>0)
gdat_data.gdat_params.edge = 0;
end
[gdat_data] = get_thomson_raw_data(shot,data_request_eff,gdat_data,gdat_data.gdat_params.edge,gdat_params.nverbose);
% construct rho mesh
edge_str_ = '';
edge_str_dot = '';
if gdat_data.gdat_params.edge
edge_str_ = '_edge';
edge_str_dot = '.edge';
end
psi_max=gdat([],['\results::thomson' edge_str_dot ':psi_max' substr_liuqe]);
psiscatvol=gdat([],['\results::thomson' edge_str_dot ':psiscatvol' substr_liuqe]);
if abs(zshift)>1e-5
% calculate new psiscatvol
psitdi=tdi(['\results::psi' substr_liuqe]);
rmesh=psitdi.dim{1};
zmesh=psitdi.dim{2};
zthom=mdsdata('dim_of(\thomson:te,1)');
zeffshift=zshift;
% set zeffshift time array same as psitdi
switch length(zeffshift)
case 1
zeffshift=zeffshift * ones(size(psitdi.dim{3}));
case length(psitdi.dim{3})
% ok
case length(psiscatvol.dim{1})
zeffshift=interp1(psiscatvol.dim{1},zeffshift,psitdi.dim{3});
otherwise
if (gdat_params.nverbose>=1);
disp(' bad time dimension for zshift')
disp(['it should be 1 or ' num2str(length(psiscatvol.dim{1})) ' or ' num2str(length(psitdi.dim{3}))])
end
end
for it=1:length(psiscatvol.dim{1})
itpsitdi=iround(psitdi.dim{3},psiscatvol.dim{1}(it));
psirz=psitdi.data(:,:,itpsitdi);
psiscatvol0=griddata(rmesh,zmesh,psirz',0.9*ones(size(zthom)),zthom-zeffshift(itpsitdi));
psiscatvol.data(it,:)=psiscatvol0;
end
end
if ~isempty(psiscatvol.data) && ~ischar(psiscatvol.data) && ~isempty(psi_max.data) && ~ischar(psi_max.data)
for ir=1:length(psiscatvol.dim{2})
rho(ir,:)= sqrt(1.-psiscatvol.data(:,ir)./psi_max.data(:))';
end
else
if gdat_params.nverbose>=1; warning(['psiscatvol empty?, no rho calculated for data_request = ' data_request_eff]); end
rho=[];
end
gdat_data.dim{1}=rho;
gdat_data.dimunits=[{'sqrt(psi_norm)'} ; {'time [s]'}];
gdat_data.x=rho;
%%%%%%%%%%%
% if nete_rho, copy data as .ne, get .te and put pe=e ne Te in data:
if strcmp(data_request_eff(1:4),'nete')
% note, now has ne.data_raw for density without fir_to_thomson_ratio
gdat_data.ne.data = gdat_data.data;
gdat_data.ne.data_raw = gdat_data.data_raw;
gdat_data.ne.error_bar = gdat_data.error_bar;
gdat_data.ne.error_bar_raw = gdat_data.error_bar_raw;
gdat_data.ne.firrat=gdat_data.firrat;
gdat_data.ne.units = 'm^{-3}';
gdat_data = rmfield(gdat_data,{'firrat','data_raw','error_bar_raw'});
%
nodenameeff=['\results::thomson' edge_str_dot ':te'];
tracetdi=tdi(nodenameeff);
nodenameeff=['\results::thomson' edge_str_dot ':te; error_bar'];
tracestd=tdi(['\results::thomson' edge_str_dot ':te:error_bar']);
gdat_data.te.data=tracetdi.data';
gdat_data.te.error_bar=tracestd.data';
gdat_data.te.units = tracetdi.units;
gdat_data.data_fullpath=['pe=1.6e-19*ne*Te in data, .ne, .te from \results::thomson' ...
edge_str_dot ':ne and te and projected on rhopol\_norm'];
gdat_data.units='N/m^2; 1.6022e-19 ne Te';
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);
end
%%%%%%%%%%% add fitted profiles if 'fit'>=1
default_fit_type = 'conf';
if ~isfield(gdat_data.gdat_params,'fit') || isempty(gdat_data.gdat_params.fit)
gdat_data.gdat_params.fit = 1;
end
% add empty structure for fit so results is always the same with or without call to fit=1 or 0
gdat_data.fit.data = [];
gdat_data.fit.x = [];
gdat_data.fit.t = [];
gdat_data.fit.units = [];
gdat_data.fit.data_fullpath = [];
if strcmp(data_request_eff(1:4),'nete')
% note gdat_data.fit.data level is for pe
gdat_data.fit.ne.data = [];
gdat_data.fit.ne.x = [];
gdat_data.fit.ne.t = [];
gdat_data.fit.ne.units = [];
gdat_data.fit.ne.data_fullpath = [];
gdat_data.fit.te.data = [];
gdat_data.fit.te.x = [];
gdat_data.fit.te.t = [];
gdat_data.fit.te.units = [];
gdat_data.fit.te.data_fullpath = [];
end
if gdat_data.gdat_params.fit>0
% default is from proffit:avg_time
if ~(isfield(gdat_data.gdat_params,'fit_type') && ~isempty(gdat_data.gdat_params.fit_type)) || ~any(strcmp(gdat_data.gdat_params.fit_type,{'local', 'avg', 'conf'}))
gdat_data.gdat_params.fit_type = default_fit_type;
end
switch gdat_data.gdat_params.fit_type
case 'avg'
def_proffit = '\results::proffit.avg_time:';
case 'local'
def_proffit = '\results::proffit.local_time:';
case 'conf'
def_proffit = '\results::conf:';
otherwise
if (gdat_params.nverbose>=1);
disp('should not be in switch gdat_data.gdat_params.fit_type')
disp('ask olivier.sauter@epfl.ch')
end
return
end
if strcmp(gdat_data.gdat_params.fit_type,'conf')
nodenameeff = [def_proffit data_request_eff(1:2)];
else
if strcmp(data_request_eff(1:2),'ne')
nodenameeff = [def_proffit 'neft_abs']; % do first ne if nete asked for
elseif strcmp(data_request_eff(1:2),'te')
nodenameeff = [def_proffit 'teft'];
else
if (gdat_params.nverbose>=1);
disp(['should not be here: data_request_eff, data_request_eff(1:2)= ',data_request_eff, data_request_eff(1:2)]);
end
end
end
if isfield(gdat_data.gdat_params,'trialindx') && ~isempty(gdat_data.gdat_params.trialindx) && ...
gdat_data.gdat_params.trialindx>=0
nodenameeff=[nodenameeff ':trial'];
trialindx = gdat_data.gdat_params.trialindx;
else
gdat_data.gdat_params.trialindx = [];
trialindx = [];
end
tracetdi=tdi(nodenameeff);
if isempty(trialindx)
if ~isempty(tracetdi.data) && ~isempty(tracetdi.dim) && ~ischar(tracetdi.data)
gdat_data.fit.data = tracetdi.data;
else
if gdat_params.nverbose>=1
disp([nodenameeff ' is empty, thus no fits, check hldsi(shot) and may need to run anaprofs?'])
end
if strcmp(data_request_eff(1:4),'nete')
gdat_data.fit.ne.data_fullpath = [nodenameeff ' is empty'];
gdat_data.fit.te.data_fullpath = [nodenameeff ' is empty'];
else
gdat_data.fit.data_fullpath = [nodenameeff ' is empty'];
end
return
end
else
if ~isempty(tracetdi.data) && size(tracetdi.data,3)>=trialindx+1
gdat_data.fit.data = tracetdi.data(:,:,trialindx+1);
else
if gdat_params.nverbose>=1
disp([nodenameeff ' with trialindx=' num2str(trialindx) ' is empty, thus no fits, check hldsi(shot) and may need to run anaprofs?'])
end
gdat_data.fit.data_fullpath = [nodenameeff ' with trialindx=' num2str(trialindx) ' is empty'];
return
end
end
gdat_data.fit.x=tracetdi.dim{1};
gdat_data.fit.t=tracetdi.dim{2};
if mapping_for_jet.timedim~=2 | mapping_for_jet.gdat_timedim~=2
if (gdat_params.nverbose>=1);
disp(['unexpected timedim in fit: data_request_eff= ' data_request_eff ...
', mapping_for_jet.timedim= ' mapping_for_jet.timedim ...
', mapping_for_jet.gdat_timedim= ' mapping_for_jet.gdat_timedim]);
end
end