function [ids_saved,varargout] = tcv2ids(shot,run,varargin);
%
%   [ids_saved,varargout] = TCV2ids(shot,run,varargin);
%
% Assumes you have done: 
% >> addpath ~g2osaute/public/matlab9_11_2016 (on the gateway)
% >> mdsconnect('localhost:5555') % using the tunnel made in another session like: ssh -L 5555:tcvdata:8000 username@lac911.epfl.ch

% in another window do the tunnel: ssh -L 5555:tcvdata:8000 username@lac911.epfl.ch
% addpath ~g2osaute/public/matlab9_11_2016
% mdsconnect('localhost:5555')

equil_empty=ids_gen('equilibrium');
[ids_equilibrium,ids_equilibrium_description]=tcv_get_ids_equilibrium(shot,equil_empty);
ids_saved.equilibrium = ids_equilibrium;
ids_saved.equilibrium_description = ids_equilibrium_description;

% now write to ids tree
shot_is_new = 1; % seems only create is ok even if does already exist
if shot_is_new
  idx  = imas_create('ids',shot,run,run,run); % 
else
  idx  = imas_open('ids',shot,run); % 
end

ids_put(idx,'equilibrium',ids_equilibrium);
imas_close(idx)
