-
Notifications
You must be signed in to change notification settings - Fork 1
/
saveEfield.m
39 lines (35 loc) · 1.1 KB
/
saveEfield.m
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
function fname = saveEfield( ef , varargin )
%
% saveEfield( ef , ...)
%
% Save the electric field and ion velocity data to file with an
% automatically generated file name. Also a plot of the electric
% field is created.
%
% INPUT:
% ef an output list from fitEfVi
% ... other parameters as name-value pairs + other parameters
% passed to plotEfield
% the only parameter effective in saveEfield is 'path', it
% must be a path to an existing directory, where the results
% are saved. default '.'
%
% OUTPUT:
% none
%
% IV 2018
%
% parse the inputs
p = inputParser;
p.KeepUnmatched=true;
defaultSavepath = '.';
checkSavepath = @(x) exist(x,'dir');
addRequired(p,'ef',@isstruct);
addParameter(p,'path',defaultSavepath,checkSavepath);
parse(p,ef,varargin{:})
% the file name
fname = fullfile(p.Results.path,[datestr(datetime(round(min(ef.time)),'ConvertFrom','posixtime'),'yyyymmddTHHMMss'),'-',datestr(datetime(round(max(ef.time)),'ConvertFrom','posixtime'),'yyyymmddTHHMMss'),'_Efield']);
save([fname,'_Vi.mat'],'ef');
% plot
plotEfield( ef , varargin{:} );
print([fname,'.png'],'-dpng');