0001 function [polcoms]=get_polcoms_timeseriesv1(rootfname,ts_controlfile,Mobj,inputConf,tseries_dir,mm,polcoms)
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012 nvars2 = 9;
0013 var_names2 = {'u','v','temp','sal','aa','ak','qsq','al','iop'};
0014
0015
0016 fid = fopen(ts_controlfile);
0017 nstations = textscan(fid, '%u',1);
0018 C= textscan(fid, '%u%u%f%f',nstations{1});
0019 fclose(fid);
0020 [lat,lon]=deal(C{3},C{4});
0021 [polcoms_i,polcoms_j]=deal(C{1},C{2});
0022 clear C
0023
0024
0025 tmpZone = regexpi(inputConf.utmZone,'\ ','split');
0026 [tseries.x, tseries.y] = wgs2utm(lat(:), lon(:), str2double(char(tmpZone{1}(1))), 'N');
0027
0028
0029
0030 distance = abs(complex(tseries.x,tseries.y)-complex(nanmean(Mobj.x),nanmean(Mobj.y)));
0031 dist_lim = mode(distance);
0032 igood=find(distance < dist_lim*5);
0033
0034
0035
0036
0037
0038 inputConf.zetUVfile=fullfile(tseries_dir,['zet_UBVB.',rootfname,'.',num2str(inputConf.modelYear),'.',num2str(mm,'%02d')]);
0039 inputConf.PolcomsPoints=[polcoms_i(igood),polcoms_j(igood)];
0040
0041
0042
0043
0044
0045 polcoms.bcidx=sub2ind(size(polcoms.latb),inputConf.PolcomsPoints(:,1),inputConf.PolcomsPoints(:,2));
0046 latb=polcoms.latb(polcoms.bcidx);
0047 lonb=polcoms.lonb(polcoms.bcidx);
0048 [polcoms.bcxb, polcoms.bcyb] = wgs2utm(latb(:), lonb(:), str2double(char(tmpZone{1}(1))), 'N');
0049 latu=polcoms.latu(polcoms.bcidx);
0050 lonu=polcoms.lonu(polcoms.bcidx);
0051 [polcoms.bcxu, polcoms.bcyu] = wgs2utm(latu(:), lonu(:), str2double(char(tmpZone{1}(1))), 'N');
0052
0053
0054
0055
0056 [polcoms.xb, polcoms.yb] = wgs2utm(polcoms.latb(:), polcoms.lonb(:), str2double(char(tmpZone{1}(1))), 'N');
0057 [polcoms.xu, polcoms.yu] = wgs2utm(polcoms.latu(:), polcoms.lonu(:), str2double(char(tmpZone{1}(1))), 'N');
0058
0059 fdb = TriScatteredInterp(polcoms.xb(:), polcoms.yb(:), polcoms.bathy(:), 'natural');
0060
0061 polcoms.bchb=fdb(polcoms.bcxb,polcoms.bcyb);
0062 polcoms.bchu=fdb(polcoms.bcxu, polcoms.bcyu);
0063
0064
0065
0066 polcoms.igood=igood;
0067
0068
0069
0070
0071 for ff=1:length(igood)
0072 fname =fullfile(tseries_dir,['physseries.',num2str(igood(ff)),'.',rootfname,'.',num2str(inputConf.modelYear),'.',num2str(mm,'%02d')]);
0073 cleanfile =fullfile(tseries_dir,'cleanfile');
0074 clean_statement=['sed ''s/^\**/0/g'' ' , fname,' > ',cleanfile];
0075 system(clean_statement);
0076 data = load(cleanfile);
0077 jday = data(:,1);data(:,1)=[];
0078 jday = reshape(jday,nvars2,[]);
0079 [~,ntimes]=size(jday);
0080 [~,ndepths]=size(data);
0081
0082 jday = jday(1,:);jday = repmat(jday,[ndepths 1]);
0083 for nn=1:length(var_names2)
0084 polcoms.(var_names2{nn})(ff,:,:) = data(nn:length(var_names2):end,:)'./1000;
0085 end
0086 polcoms.jday(ff,:,:) = jday/24;
0087
0088 end
0089
0090 polcoms.time=datenum(inputConf.modelYear,mm,1):1/24:(size(polcoms.jday,3)-1)/24+datenum(inputConf.modelYear,mm,1);
0091 inputConf.PolcomsLevs=ndepths;
0092
0093
0094 [dumpstruct]=readzetUBVB(inputConf,ntimes);
0095 polcoms=catstruct(dumpstruct,polcoms);
0096 polcoms.ndepths=ndepths;
0097 polcoms.ntimes=ntimes;
0098 return
0099
0100
0101
0102
0103
0104
0105
0106