% 
% script to get TCV data as ids and then write them on the database
%

shot=40000;
shot=62745;
run_out=999;
occurence=0;

ids2get = {'equilibrium', 'magnetics', 'pf_active','wall'}; % default will load all defined so far
[ids_from_tcv,idsok] = tcv2ids(shot,ids2get);

%% can plot with: [plotids_H] = plotids([],idsok.ids{1},idsok.ids{2});
if isfield(ids_from_tcv,'tf')
  % avoid present problem of not saving data if ids_from_tcv.tf.field_map{1}.time is not set
  if length(ids_from_tcv.tf.field_map)>0 && abs(ids_from_tcv.tf.field_map{1}.time+9.e40)<1e-5
    ids_from_tcv.tf.field_map{1}.time = -8.9000e+40;
    disp(['WARNING: ids_from_tcv.tf.field_map{1}.time changed to ' num2str(ids_from_tcv.tf.field_map{1}.time) ' to avoid writing error']);
  end
end
%%
[ids_put_status] = ids2database(shot,run_out,occurence,ids_from_tcv);


% [plotids_H] = plotids([],idsok.ids);

% tic;[TTTe,idse]=evalc('ids_get(expIdx, ''equilibrium'')');toc
% tic;[TTTm,idsm]=evalc('ids_get(expIdx, ''magnetics'')');toc
% tic;[TTTp,idsp]=evalc('ids_get(expIdx, ''pf_active'')');toc
% tic;[TTTt,idst]=evalc('ids_get(expIdx, ''tf'')');toc
% tic;[TTTw,idsw]=evalc('ids_get(expIdx, ''wall'')');toc
