Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
locupe
mexec
Commits
ae63b40b
Commit
ae63b40b
authored
5 years ago
by
Yvonne Firing
Browse files
Options
Download
Email Patches
Plain Diff
end of jr18002
parent
07f3b52f
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
20 additions
and
121 deletions
+20
-121
source/mscs/msload.m
source/mscs/msload.m
+3
-5
source/mscs/msnames.m
source/mscs/msnames.m
+3
-1
source/mscs/scs_to_mstar2.m
source/mscs/scs_to_mstar2.m
+14
-5
source/mtechsas/mtload.m~
source/mtechsas/mtload.m~
+0
-110
No files found.
source/mscs/msload.m
View file @
ae63b40b
...
...
@@ -88,6 +88,7 @@ if ~MEXEC_G.quiet; fprintf(MEXEC_A.Mfidterm,'%s\n',m); end
% now load data
vdata
=
struct
;
vunits
=
struct
;
for
kv
=
varnums
% make empty space so file doesn't grow in loop
vuse
=
nan
+
ones
(
1
,
totdc
);
...
...
@@ -121,9 +122,6 @@ for kv = varnums
loadvarname
=
vars
{
kv
};
loadvarname
(
strfind
(
loadvarname
,
'-'
))
=
'_'
;
% remove minus in var name
loadvarname
(
strfind
(
loadvarname
,
'/'
))
=
'_'
;
% remove slash in var name
% cmd = ['vdata.' vars{kv} ' = vuse(:)'';']; eval(cmd);
% cmd = ['vunits.' vars{kv} ' = units{kv};']; eval(cmd);
cmd
=
[
'vdata.'
loadvarname
' = vuse(:)
''
;'
];
eval
(
cmd
);
cmd
=
[
'vunits.'
loadvarname
' = units{kv};'
];
eval
(
cmd
);
vdata
=
setfield
(
vdata
,
loadvarname
,
vuse
(:)
'
);
vunits
=
setfield
(
vunits
,
loadvarname
,
units
{
kv
});
end
This diff is collapsed.
Click to expand it.
source/mscs/msnames.m
View file @
ae63b40b
...
...
@@ -36,8 +36,10 @@ matlist = {
'tsshrp'
' '
'tsshrp'
'netmonitor'
' '
'netmonitor'
'anemometer'
' '
'anemometer'
% 'surfmet' ' ' 'anemometer'
'dopplerlog'
' '
'dopplerlog'
'ea600m'
' '
'ea600'
% 'ea600m' ' ' 'ea600'
'ea600'
' '
'ea600'
% 'em120' ' ' 'em120'
'em122'
' '
'em122'
% bak on jr281, em122 instead of em120
'emlog_vhw'
' '
'emlog-vhw'
...
...
This diff is collapsed.
Click to expand it.
source/mscs/scs_to_mstar2.m
View file @
ae63b40b
...
...
@@ -67,8 +67,12 @@ instrument = ' '; % null for the time being
% bak for jr195 2009-sep-17
% load data before creating mstar file in case no data cycles found
[
tdata
tunits
]
=
msload
(
tstream
,
dn1
,
dn2
,
loadvlist
);
if
isempty
(
tdata
.
time
)
% no data cycles found
return
if
isempty
(
tdata
.
time
)
% if isfield(MEXEC_G, 'uway_writeempty') & MEXEC_G.uway_writeempty % no data cycles found
% warning(['no data for ' tstream ' between ' dn1 ' and ' dn2])
% else
return
% end
end
ncfile
.
name
=
mstar_fn
;
...
...
@@ -85,7 +89,7 @@ nc_attput(ncfile.name,nc_global,'platform_number',MEXEC_G.PLATFORM_NUMBER); %eg
% [tdata tunits] = msload(tstream,dn1,dn2,loadvlist);
% techsas_names = m_unpack_varnames(techsas_in);
%
/local/users/pstar/jr18002/mcruise/data/nav/seatex/seatex_gll_jr18002_d322_raw.nc
techsas_names = m_unpack_varnames(techsas_in);
techsas_names
=
fieldnames
(
tdata
);
% techsas_time_dim = nc_getdiminfo(techsas_in.name,'time'); % bak jc032 need to know present number of records in growing techsas file
...
...
@@ -102,8 +106,8 @@ for k = 1:length(techsas_names)
clear
techsas_data
techsas_units
v
% techsas_data = nc_varget(techsas_in.name,techsas_names{k},0,techsas_time_length);
% techsas_units = nc_attget(techsas_in.name,techsas_names{k},'units');
cmd
=
[
'
techsas_data = tdata
.'
techsas_names
{
k
}
';'
];
eval
(
cmd
);
cmd
=
[
'
techsas_units = tunits
.'
techsas_names
{
k
}
';'
];
eval
(
cmd
);
techsas_data
=
getfield
(
tdata
,
techsas_names
{
k
});
techsas_units
=
getfield
(
tunits
,
techsas_names
{
k
});
% adjust time to a more conventional mstar time
if
strcmp
(
techsas_names
{
k
},
'time'
)
...
...
@@ -111,6 +115,11 @@ for k = 1:length(techsas_names)
techsas_units
=
'seconds'
;
end
v
.
name
=
techsas_names
{
k
};
v
.
data
=
techsas_data
;
v
.
units
=
techsas_units
;
%if length(v.data)==0
% if strcmp(v.name, 'time'); v.data = [dn1 dn2];
% else; v.data = [NaN NaN]; end
% warning('filling with NaNs')
%end
m_write_variable
(
ncfile
,
v
);
end
...
...
This diff is collapsed.
Click to expand it.
source/mtechsas/mtload.m~
deleted
100755 → 0
View file @
07f3b52f
function [vdata vunits] = mtload(instream,dn1,dn2,varlist,mode)
% function [vdata vunits] = mtload(instream,dn1,dn2,varlist)
%
% USE, eg
% mtload('winch',[2009 4 4],[2009 5 4 12 0 0])
% mtload('winch',now-0.1,now)
% mtload('winch',now-0.1)
% mtload winch now-0.1
% mtload winch '[2009 4 9 12 0 0]' now
% mtload winch '2009 4 9 12 0 0' now 'time cableout rate'
%
% mtload(instream,dn1,dn2,varlist) or
% mtload instream dn1 dn2 varlist
%
% load techsas data into Matlab
% source stream is instream; can be techsas name or mexec short name.
% dn1 and dn2 are matlab datenums or datevecs that define the required
% data period
% note silent mode; use 'q' to suppress output to the screen;
% Data are loaded from all relevant techsas files with matching stream
% name, and appended.
% varlist is a single character string and can use either variable names or
% numbers, eg '/' '1~4' 'time lat long' 'time 2~4' 'time 2 4 6'
% Use mtvars to find the variable names in a stream.
%
% YLF modified Feb 2017 (JC145) for case where no files are found
% GDM modified Mar 2017 (JC145) reinstated the 'q'mode
m_common
tstream = mtresolve_stream(instream);
[mt1 mt2] = mtgetdfinfo(tstream,'f'); % get time limits in case they are required for default
if ~exist('dn1','var'); dn1 = mt1; end
if isempty(dn1); dn1 = mt1; end
if ischar(dn1); cmd =['dn1 = [' dn1 '];']; eval(cmd); end % if the arg has come in as a string, convert from char to number
if ~exist('dn2','var'); dn2 = now; end
if isempty(dn2); dn2 = now; end
if ischar(dn2); cmd =['dn2 = [' dn2 '];']; eval(cmd); end
% convert datevecs to nums; if the arguments are datenums nothing is
% changed
dn1 = datenum(dn1);
dn2 = datenum(dn2);
% get file names
fnames = mtchoosefiles(tstream,dn1,dn2);
nf = length(fnames);
if nf==0; vdata = []; vunits = []; else %YLF added JC145
% get var list
[vars units] = mtgetvars(tstream);
nv = length(vars);
% sort out the var list
if ~exist('varlist','var'); varlist = '/'; end
th.fldnam = vars;
th.noflds = nv; % create a structure equivalent to the mstar headers to parse for var names
varnums = m_getvlist(varlist,th);
% time always seems to be last in the techsas list; put it first if it is
% in the load list.
loadvarnames = vars(varnums);
ktime = strmatch('time',loadvarnames);
if ~isempty(ktime)
timevarnum = varnums(ktime);
varnums(ktime) = [];
varnums = [timevarnum varnums];
end
% identify parts of files to load
dc1 = nan+ones(nf,1); dc2 = dc1; totdc = 0;
m = 'Counting data cycles';
if ~MEXEC_G.quiet|~strncmp(mode,'q',1); fprintf(MEXEC_A.Mfidterm,'%s\n',m); end
for kf = 1:nf
fn = fnames{kf};
fullfn = [MEXEC_G.uway_root '/' fn];
[dc1(kf) dc2(kf)] = mtgetdcrange(fn,dn1,dn2);
totdc = totdc + dc2(kf)-dc1(kf)+1;
end
m = [sprintf('%d',totdc) ' data cycles and ' sprintf('%d',nv) ' vars found in ' sprintf('%d',nf) ' files'];
if ~MEXEC_G.quiet|~strncmp(mode,'q',1); fprintf(MEXEC_A.Mfidterm,'%s\n',m); end
% now load data
for kv = varnums
% make empty space so file doesn't grow in loop
vuse = nan+ones(1,totdc);
kount = 0;
m = ['loading variable ' vars{kv}];
if ~MEXEC_G.quiet|~strncmp(mode,'q',1); fprintf(MEXEC_A.Mfidterm,'%s\n',m); end
for kf = 1:nf
fn = fnames{kf};
fullfn = [MEXEC_G.uway_root '/' fn];
nk = dc2(kf)-dc1(kf)+1; % load this many data cycles on this operation
vin = nc_varget(fullfn,vars{kv},dc1(kf)-1,nk);
vuse(kount+1:kount+nk) = vin;
kount = kount+nk;
end
cmd = ['vdata.' vars{kv} ' = vuse(:)'';']; eval(cmd);
cmd = ['vunits.' vars{kv} ' = units{kv};']; eval(cmd);
end
end
\ No newline at end of file
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment