Commit 36f5fa22 authored by das's avatar das
Browse files

This branch post cruise JR17001 created by DAS 14/8/18 before push to gitlab

On branch JR17001_post_cruise
 Changes to be committed:
	modified:   source/mextras/mcontr_plotlines.m
	modified:   source/mscs/msload.m
	modified:   source/mscs/msposinfo.m
	modified:   source/mscs/mtranslate_varnames.m
	modified:   source/mscs/scs_to_mstar2.m
	modified:   source/msubs/m_add_variable_name.m
	modified:   source/msubs/m_write_variable.m
	modified:   source/unfinished/m_remove_outside_spaces.m
	modified:   source/unfinished/m_verson.m
	modified:   source/unfinished/mavmed.m
	modified:   source/unfinished/mcontr.m
	modified:   source/unfinished/mcontrnew.m
	modified:   source/unfinished/mgetdir.m
	modified:   source/unfinished/mheadr.m
	modified:   source/unfinished/mlisth.m
	modified:   source/unfinished/mplxyed.m
	modified:   source/unfinished/msmoothnav.m

Untracked files:
	source/unfinished/mavmed.m~
parent 0bffbcde
......@@ -42,7 +42,6 @@ while cdim > 0
cdim = size(posall,2);
end
hold on
% keyboard
% plot each contour line
% first switch off lines in base contour plot
set(hplot,'linestyle','none');
......@@ -150,7 +149,6 @@ for kcont = 1:numcontour
end
end
% keyboard
% % % % % % % clabelall = get(hclabel);
% % % % % % % clall = clabelall;
% % % % % % % nstring = length(clabelall);
......
......@@ -58,7 +58,7 @@ nv = length(vars);
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
% keyboard
varnums = m_getvlist(varlist,th);
% time always seems to be last in the scs list; put it first if it is
% in the load list.
......@@ -75,7 +75,6 @@ end
dc1 = nan+ones(nf,1); dc2 = dc1; totdc = 0;
m = 'Counting data cycles';
if ~MEXEC_G.quiet; fprintf(MEXEC_A.Mfidterm,'%s\n',m); end
end
for kf = 1:nf
fn = fnames{kf};
......
......@@ -25,7 +25,7 @@ function [lat lon] = msposinfo(dn1,navstream)
m_common
if ~exist('navstream','var'); navstream = MEXEC_G.uway_default_navstream; end % use default nav stream name
if ~exist('navstream','var'); navstream = MEXEC_G.default_navstream; end % use default nav stream name
instream = navstream; % mexec stream short name
tstream = msresolve_stream(instream);
......
......@@ -34,8 +34,8 @@ tunder(strfind(tunder,'-')) = '_';
tunder(strfind(tunder,'.')) = '_';
root_template = mgetdir('M_TEMPLATES');
fntemplatein = [root_template '/' MEXEC_G.Mshipdatasystem '_' MEXEC_G.MSCRIPT_CRUISE_STRING '_renamelist_' tunder '.csv'];
fntemplateot = [root_template '/' MEXEC_G.Mshipdatasystem '_' MEXEC_G.MSCRIPT_CRUISE_STRING '_renamelist_' tunder '_out.csv'];
fntemplatein = [root_template '/' MEXEC_G.Mshipdatasystem '_renamelist_' tunder '.csv'];
fntemplateot = [root_template '/' MEXEC_G.Mshipdatasystem '_renamelist_' tunder '_out.csv'];
% clean up the translation table if needed. This code was lifted from
% another script but should not be needed for this application.
......@@ -48,6 +48,7 @@ for kline = 1:length(cellall)
snamesin{kline} = m_remove_outside_spaces(cellrow{1});
snamesot{kline} = m_remove_outside_spaces(cellrow{2});
sunits{kline} = m_remove_outside_spaces(cellrow{3});
if length(sunits{kline})==0; sunits{kline} = ' '; end
end
snamesin = snamesin(:);
snamesot = snamesot(:);
......@@ -77,6 +78,7 @@ for k = 1:numvar
end
end
snames_units = snames_units(:);
%--------------------------------
% 2009-01-26 07:48:13
% mheadr
......
function scs_to_mstar2
% function techsas_to_mstar(tstream,dn1,dn2)
% function ncfile = techsas_to_mstar(techsas_in,ncfile,dataname)
% function scs_to_mstar2(tstream,dn1,dn2)
% function ncfile = scs_to_mstar2(scs_in,ncfile,dataname)
% load techsas file into mstar file
% load scs file into mstar file
%
% 8 Sep 2009: SCS version of original techsas script, for JR195
% The searched directory is MEXEC_G.uway_root, which for example can be
......@@ -10,13 +10,14 @@ function scs_to_mstar2
% The var names and units are taken from ascii file
% seatex-gga.TPL
% for example.
%
m_common
m_margslocal
m_varargs
MEXEC_A.Mprog = 'scs_to_mstar2';
m_proghd;
if ~MEXEC_G.quiet; m_proghd; end
instream = m_getinput('Type scs stream name or mexec short name eg gyro_s or gyro : ','s');
......@@ -71,6 +72,7 @@ if isempty(tdata.time) % no data cycles found
end
ncfile.name = mstar_fn;
ncfile = m_openot(ncfile); %check it is not an open mstar file
% techsas_in.name = techsas_fn;
......@@ -127,7 +129,6 @@ m_add_comment(ncfile,tstream);
m_add_comment(ncfile,['at ' nowstring]);
m_add_comment(ncfile,['Time converted from matlab day number to seconds after mstar time origin']);
m_finis(ncfile);
h = m_read_header(ncfile);
......@@ -145,4 +146,5 @@ histin.version = [];
histin.mstar_site = [];
MEXEC_A.Mhistory_in{1} = histin;
m_write_history;
return
......@@ -24,7 +24,6 @@ ncfile.metadata = metadata;
dimnames = m_unpack_dimnames(ncfile);
varnames = m_unpack_varnames(ncfile);
%test to see if a variable already exists with correct dimensions; if not, add it.
kmatch = strmatch(string_var_name,varnames,'exact');
......@@ -76,8 +75,7 @@ if ~isempty(kmatch) % It exists; check dimensions match;
return
end
% Variable doesn't exist so we will add it; First, check each requested dimension exists in file
% Variable doesn't exist so we will add it; First, check each requested dimension exists in file
for k = 1:length(dims_array)
kmatch = strmatch(dims_array{k},dimnames,'exact');
......@@ -106,6 +104,7 @@ end
v.Name = string_var_name;
v.Dimension = dims_array;
v.Nctype = datatype;
%keyboard
nc_addvar(ncfile.name,v);
% % metadata = nc_info(ncfile.name); %refresh metadata
......
......@@ -41,7 +41,6 @@ for k = 1:length(krmatch)
collength(k) = metadata.Dimension(kcmatch(k)).Length;
end
if length(krmatch) ~= length(kcmatch)
error('m_write_variable weird mismatch of dimension names - investigate further')
end
......
......@@ -2,19 +2,24 @@ function sot = m_remove_outside_spaces(sin)
% function sot = m_remove_outside_spaces(sin)
%
% remove any outside spaces from a string
% YLF edit jr17001: unless the string is just a single space
s = [ ' ' sin ' '];
if length(sin)==1 & ~strncmp(sin, ' ', 1)
sot = sin;
else
s = [ ' ' sin ' '];
while strcmp(s(1),' ') == 1
s(1) = [];
if isempty(s); break; end
end
while strcmp(s(1),' ') == 1
s(1) = [];
if isempty(s); break; end
end
s = [s ' '];
while strcmp(s(end),' ') == 1
s(end) = [];
if isempty(s); break; end
end
s = [s ' '];
while strcmp(s(end),' ') == 1
s(end) = [];
if isempty(s); break; end
end
sot = s;
sot = s;
end
return
\ No newline at end of file
......@@ -106,7 +106,6 @@ else
% new_version = increment+max(versions(index),file_version);
new_version = increment+versions(index);
end
% keyboard
versions(index) = new_version;
save(MEXEC.versfile,'datanames','versions');
if ~isnan(Mversionlock) % reset lock file
......
......@@ -78,6 +78,7 @@ while copylistok == 0
fprintf(MEXEC_A.Mfider,'\n%s\n','You must reply r or c : ');
reply = m_getinput(' ','s');
end
rc0 = rc;
end
copylistok = 1;
end
......@@ -149,6 +150,7 @@ step = lims(3);
% do the truncation first.
cvar = nc_varget(ncfile_in.name,h.fldnam{vcontrol});
if ~exist('rc0'); [crows, ccols] = size(cvar); if size(cvar,2)==1; rc = 1; elseif size(cvar,1)==1; rc = 2; end; end %YLF added jr17001 because underway nc file header is incorrect about dims
if rc == 1
x = cvar(:,1);
elseif rc == 2
......@@ -219,8 +221,8 @@ for k = 1:length(kmat)
z = nc_varget(ncfile_in.name,h.fldnam{kmat(k)});
% rearrange data according to sort of control variable
lenav = length(klo);
if rc == 1; zsort = z(ksort,:); zav = nan+zeros(lenav,ncols(kmat(k))); end
if rc == 2; zsort = z(:,ksort); zav = nan+zeros(nrows(kmat(k)),lenav); end
if rc == 1; zsort = z(ksort,:); zav = nan+zeros(lenav,size(z,2)); end
if rc == 2; zsort = z(:,ksort); zav = nan+zeros(size(z,1),lenav); end
if(fullstats == 1)
zn = zav; zstd = zav;
......
......@@ -524,7 +524,6 @@ caxis(ha,colorbar_limits-1e-5)
ca = caxis;
% cdfot.cmap = cmap;
% keyboard
ha = gca;
% set(ha,'position',[.1 .15 .7 .7]);
axis([0 1 0 1]);
......@@ -714,7 +713,6 @@ set(hh,'interpreter','none');
% % % % % set(hh,'HorizontalAlignment','center')
% % % % % set(hh,'VerticalAlignment','top')
% % % % % set(hh,'interpreter','none');
% keyboard
% string for y variable
xlaby = [-t1-tw]; % put first two ylabels at left of axis; remainder below axis
......@@ -745,7 +743,6 @@ set(hh,'interpreter','none');
% need xtick labels
cdfot.mainplot_gca_handle = gca;
% keyboard
%plot colorbar as contourf
pos = get(gca,'position');
......@@ -774,7 +771,6 @@ yc = clev;
[xcg,ycg]= meshgrid(xc,yc);
zc = ycg;
% keyboard
[c2,h2] = contourf(xc,1:length(clev),zc,clev,'k-');
% set(h2,'linestyle','none')
for k = 1:length(clev)
......
......@@ -637,7 +637,6 @@ ca = caxis;
handles = hplot; m_recolor % jc032
% return
% keyboard
ha = gca;
% set(ha,'position',[.1 .15 .7 .7]);
axis([0 1 0 1]);
......@@ -876,8 +875,7 @@ while 1
% % % % % set(hh,'HorizontalAlignment','center')
% % % % % set(hh,'VerticalAlignment','top')
% % % % % set(hh,'interpreter','none');
% keyboard
if isfield(cdfin,'xlabelset')
if isfield(cdfin,'xlabelset')
if ~isempty(cdfin.xlabelset)
cmd = ['set(hh,' cdfin.xlabelset ');']; eval(cmd);
end
......@@ -929,7 +927,6 @@ if isfield(cdfin,'colorbarset')
if strcmp(cdfin.ylabelset,'none'); return; end
end
% keyboard
%plot colorbar as contourf
pos = get(gca,'position');
......@@ -958,7 +955,6 @@ yc = clev;
[xcg,ycg]= meshgrid(xc,yc);
zc = ycg;
% keyboard
[c2,h2] = contourf(xc,1:length(clev),zc,clev,'k-');
handles = h2; m_recolor ; % jc032
......@@ -982,7 +978,6 @@ caxis(gca,ca)
% cdfot.ca = ca; % jc032
cdfot.colorbar_gca_handle = gca;
% keyboard
return
......
......@@ -17,5 +17,6 @@ ii = find(strcmp(M_ABBREV, MEXEC_G.MDIRLIST(:,1)));
if length(ii)==1
mpath = [MEXEC_G.MEXEC_DATA_ROOT '/' MEXEC_G.MDIRLIST{ii,2}];
else
error([M_ABBREV ' set ' num2str(length(ii)) ' times in m_setup'])
warning([M_ABBREV ' set ' num2str(length(ii)) ' times in m_setup'])
mpath = '';
end
......@@ -28,7 +28,6 @@ hist = h;
hist.filename = ncfile.name;
MEXEC_A.Mhistory_in{1} = hist;
% --------------------
% Now do something with the data
h = m_editheader(h,ncfile);
......
......@@ -8,6 +8,6 @@ fn = m_getfilename; % this uses the optional argument if there is one
ncfile.name = fn;
h = m_read_header(ncfile);
if ~MEXEC_G.quiet; m_print_header(h); end
m_print_header(h)
return
\ No newline at end of file
......@@ -207,7 +207,7 @@ if kedit > 0
motsave = MEXEC_A.MARGS_OT;
% cludge MEXEC_A.MARGS_OT to use the write_history feature
nowtime = datestr(now,'yyyymmdd_HHMMSS');
editfn = ['mplxyed_' nowtime '_' h.dataname];
editfn = [mgetdir('M_CTD') '/mplxyed_' nowtime '_' h.dataname];
% bak jc069 put more detailed information about source and output files in edit record file
mess_4 = ['ot_file : ' hist.filename];
mess_5 = ['ot_dataname : ' hist.dataname];
......
......@@ -151,7 +151,7 @@ cvar = nc_varget(ncfile_in.name,h.fldnam{vcontrol});
if rc == 1
x = cvar(:,1);
elseif rc == 2
x = cvar(1,:);
x = cvar(1,:)';
end
if trunc == 2 | trunc == 4
......@@ -219,7 +219,7 @@ for k = 1:length(kmat)
% rearrange data according to sort of control variable
lenav = length(klo);
if rc == 1; zsort = z(ksort,:); zav = nan+zeros(lenav,ncols(kmat(k))); end
if rc == 2; zsort = z(:,ksort); zav = nan+zeros(nrows(kmat(k)),lenav); end
if rc == 2; zsort = z(:,ksort)'; zav = nan+zeros(lenav,nrows(kmat(k))); end
if(fullstats == 1)
zn = zav; zstd = zav;
......@@ -227,49 +227,35 @@ for k = 1:length(kmat)
for k2 = 1:lenav
if ~isnan(klo(k2)) & ~isnan(khi(k2))
if rc == 1;
m = 'This code branch not operational yet';
fprintf(MEXEC_A.Mfider,'%s\n',m);
error('exiting');
return
zsub = zsort(klo(k2):khi(k2),:);
zav(k2,:) = m_nanmean(zsub,rc); % average in direction controlled by rc
if fullstats == 1
ok = isfinite(zsub);
zn(k2,:) = sum(ok,rc);
zstd(k2,:) = m_nanstd(zsub,rc);
end
else
zsub = zsort(:,klo(k2):khi(k2));
xsub = xsort(:,klo(k2):khi(k2));
xsub = xsub';
zsub = zsub';
% keyboard
for ky = 1:size(zsub,2);
y = zsub(:,ky);
kok = find(~isnan(xsub+y));
% keyboard
if length(kok) > 1
xoff = xsub(kok(1));
p = polyfit(xsub(kok)-xoff,y(kok),1);
zav(1,k2) = polyval(p,xc(k2)-xoff);
end
end
xsub = xsub';
zsub = zsub';
% zav(1,k2) = interp1(xsub,zsub,xc(k2));
% zav(:,k2) = m_nanmean(zsub,rc); % average in direction controlled by rc
if fullstats == 1
ok = isfinite(zsub);
zn(:,k2) = sum(ok,rc);
zstd(:,k2) = m_nanstd(zsub,rc);
zsub = zsort(klo(k2):khi(k2),:);
xsub = xsort(klo(k2):khi(k2));
for ky = 1:size(zsub,2);
y = zsub(:,ky);
kok = find(~isnan(xsub+y));
if length(kok) > 1
xoff = xsub(kok(1));
p = polyfit(xsub(kok)-xoff,y(kok),1);
zav(k2,:) = polyval(p,xc(k2)-xoff);
end
end
if fullstats == 1
ok = isfinite(zsub);
zn(k2,:) = sum(ok,rc);
zstd(k2,:) = m_nanstd(zsub);
end
end
end
if rc==2
zav = zav';
if fullstats
zn = zn';
zstd = zstd';
end
end
vname = h.fldnam{kmat(k)};
vname1 = vname;
if kmat(k) == vcontrol; vname1 = [vname1 '_bin_average']; end
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment