Skip to content

Commit

Permalink
updating files
Browse files Browse the repository at this point in the history
  • Loading branch information
thesser1 committed May 22, 2013
1 parent 75d679d commit 9e6d04b
Show file tree
Hide file tree
Showing 12 changed files with 491 additions and 26 deletions.
2 changes: 1 addition & 1 deletion Altimeter/read_alt.m
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
dird = 'H:\GlobWave';
cd(dird);
else
dird = 'E:\GlobWave\Altimeter';
dird = '/media/Expansion Drive_/GlobWave/Altimeter';
cd(dird);
end
sats = dir('*');
Expand Down
19 changes: 15 additions & 4 deletions Buoy_analysis/adjust_canada_spec.m
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
function aa = adjust_canada_spec(bb)

ii = bb.hsb > 0.5;
aa.stnum = bb.stnum;
aa.lat = bb.lat;
aa.lon = bb.lon;
aa.dep = bb.dep;

ii = bb.hsb > 0.25;
aa.date = bb.date(ii,:);
aa.timemat = bb.timemat(ii,:);
aa.ef = bb.ef(:,ii);
Expand Down Expand Up @@ -36,9 +41,15 @@
ip = ip(2);
end
end
% if ip < 12
% ip = 12;
% end
if bb.stnum >= 45000 & bb.stnum < 46000
if ip < 17
ip = 17;
end
else
if ip < 15
ip = 15;
end
end

aa.tp(ii) = 1.0/aa.freq(ip,ii);
end
Expand Down
24 changes: 17 additions & 7 deletions Buoy_analysis/canada_2_onlns.m
Original file line number Diff line number Diff line change
@@ -1,7 +1,13 @@
function canada_2_onlns(canada,year)

ndbc = canada;
cdir = 'X:\CANADIAN_BUOY_ATL\';
if isunix
cdir = '/mnt/CHL_WIS_1/CANADIAN_BUOY_GRLAKES/';
slash = '/';
else
cdir = 'X:\CANADIAN_BUOY_GRLAKES\';
slash = '\';
end
if ischar(canada)
canadac = canada;
else
Expand All @@ -23,12 +29,13 @@ function canada_2_onlns(canada,year)
end
mont = ['jan';'feb';'mar';'apr';'may';'jun';'jul';'aug';'sep';'oct'; ...
'nov';'dec'];
cdiry = [cdir,canadac,'\'];
cdiry = [cdir,canadac,slash];
if exist(cdiry,'dir')
[aa,status] = read_canada_sp(cdiry,yearc);
if status == 0
return
end
aa = adjust_canada_spec(aa);
else
return
end
Expand All @@ -48,9 +55,12 @@ function canada_2_onlns(canada,year)
monc = mont(mon,:);
end


ndbcd = ['X:\NDBC_CANADA\'];
ndbct = [ndbcd,yearc,'\',monc,'\'];
if isunix
ndbcd = ['/mnt/CHL_WIS_1/NDBC_CANADA/'];
else
ndbcd = ['X:\NDBC_CANADA\'];
end
ndbct = [ndbcd,yearc,slash,monc,slash];

nfile = [ndbct,'n',ndbcc,'_',yearc,'_',monnc,'.onlns'];
if exist(nfile,'file')
Expand All @@ -69,8 +79,8 @@ function canada_2_onlns(canada,year)
bb1(:,3) = str2num(time(ii,7:8));
bb1(:,4) = str2num(time(ii,9:10));
bb1(:,5) = str2num(time(ii,11:12));
[latd,latm,lats] = deg2dms(aa.lat);
[lond,lonm,lons] = deg2dms(aa.lon);
[latd,latm,lats] = ddeg2dms(aa.lat);
[lond,lonm,lons] = ddeg2dms(aa.lon);
loc = [latd,abs(latm),round(abs(lats)),lond,abs(lonm),round(abs(lons))];
bb1(:,6:11) = repmat(loc,size(bb1,1),1);
bb1(:,12) = aa.dep;
Expand Down
104 changes: 104 additions & 0 deletions Buoy_analysis/canada_2_onlns.m~
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
function canada_2_onlns(canada,year)

ndbc = canada;
if isunix
cdir = '/mnt/CHL_WIS_1/CANADIAN_BUOY_GRLAKES/';
slash = '/';
else
cdir = 'X:\CANADIAN_BUOY_GRLAKES\';
slash = '\';
end
if ischar(canada)
canadac = canada;
else
if canada < 100
canadac = ['0',num2str(canada)];
else
canadac = num2str(canada);
end
end
if ischar(ndbc)
ndbcc = ndbc;
else
ndbcc = num2str(ndbc);
end
if ischar(year)
yearc = year;
else
yearc = num2str(year);
end
mont = ['jan';'feb';'mar';'apr';'may';'jun';'jul';'aug';'sep';'oct'; ...
'nov';'dec'];
cdiry = [cdir,canadac,slash];
if exist(cdiry,'dir')
[aa,status] = read_canada_sp(cdiry,yearc);
if status == 0
return
end
aa = adjust_canada_spec(aa);
else
return
end
time = aa.date;
tt = str2num(time(:,1:6));
for mon = 1:12
if ischar(mon)
monnc = mon;
monn = str2num(mon);
monc = mont(monn,:);
else
if mon < 10
monnc = ['0',num2str(mon)];
else
monnc = num2str(mon);
end
monc = mont(mon,:);
end

if isunix
ndbcd = ['/mnt/CHL_WIS_1/NDBC_CANADA/'];
else
ndbcd = ['X:\NDBC_CANADA\'];
end
ndbct = [ndbcd,yearc,slash,monc,slash];

nfile = [ndbct,'n',ndbcc,'_',yearc,'_',monnc,'.onlns'];
if exist(nfile,'file')
continue
end


% if status == 0
% return
% end
yrmon = [yearc,monnc];
ii = str2num(yrmon) == tt;
if any(ii)
bb1(:,1) = str2num(time(ii,1:4));
bb1(:,2) = str2num(time(ii,5:6));
bb1(:,3) = str2num(time(ii,7:8));
bb1(:,4) = str2num(time(ii,9:10));
bb1(:,5) = str2num(time(ii,11:12));
[latd,latm,lats] = ddeg2dms(aa.lat);
[lond,lonm,lons] = ddeg2dms(aa.lon);
loc = [latd,abs(latm),round(abs(lats)),lond,abs(lonm),round(abs(lons))];
bb1(:,6:11) = repmat(loc,size(bb1,1),1);
bb1(:,12) = aa.dep;
bb1(:,13:15) = -99.99;
bb1(:,16) = -999.9;
bb1(:,17:18) = -99.99;
bb1(:,19) = -999.9;

ab.c11 = aa.ef(:,ii);
if any(strcmp('a1',fieldnames(aa)))
ab.a1=aa.a1;ab.a2=aa.a2;
ab.b1 = aa.b1;ab.b2 = aa.b2;
end
ab.df = aa.bw(:,1);
ab.freq = aa.freq(:,1);ab.dep = aa.dep;
bb2 = convert_2_onlns(ab);
bb = horzcat(bb1,bb2);
create_onlns(ndbcc,yearc,monnc,bb,ndbct);
end
clear bb1 bb2 ab bb
end
42 changes: 34 additions & 8 deletions Buoy_analysis/cdip_2_onlns.m
Original file line number Diff line number Diff line change
@@ -1,11 +1,27 @@
function cdip_2_onlns(cdip,ndbc,year,mon)
%
% converts cdip spectral file to WIS onlns
% created 05/14/2013 by TJ Hesser
%
% INPUT:
% cdip NUM/STR : CDIP ID ex (071)
% ndbc NUM/STR : NDBC ID ex (46001)
% year NUM/STR : year for evaluation (YYYY)
% mon NUM/STR : month for evaluation (MM)
%
% OUTPUT:
% writes *.onlns file to raid NDBC_CDIP as described in file
%
% ----------------------------------------------------------

% sets input directory (set to raid CDIP directory)
if isunix
%cdir = '/mnt/CHL_WIS_1/CDIP/';
cdir = '/home/thesser1/NODC/';
cdir = '/mnt/CHL_WIS_1/CDIP/';
%cdir = '/home/thesser1/NODC/';
else
cdir = 'X:\CDIP\';
end
% converts cdip to string if given in numeric form
if ischar(cdip)
cdipc = cdip;
else
Expand All @@ -15,18 +31,21 @@ function cdip_2_onlns(cdip,ndbc,year,mon)
cdipc = num2str(cdip);
end
end
% converts ndbc to string if given in numeric format
if ischar(ndbc)
ndbcc = ndbc;
else
ndbcc = num2str(ndbc);
end
% converts year to string if given in nummeric
if ischar(year)
yearc = year;
else
yearc = num2str(year);
end
mont = ['jan';'feb';'mar';'apr';'may';'jun';'jul';'aug';'sep';'oct'; ...
'nov';'dec'];
% converts mon to string and character form
if ischar(mon)
monnc = mon;
monn = str2num(mon);
Expand All @@ -39,31 +58,35 @@ function cdip_2_onlns(cdip,ndbc,year,mon)
end
monc = mont(mon,:);
end
% finds full directory listing with year, month
if isunix
cdiry = [cdir,'spc_',yearc,'/',cdipc,'/',monc,'/01/'];
else
cdiry = [cdir,'spc_',yearc,'\',cdipc,'\',monc,'\01\'];
end
% looks for output directory to determin if it exists
if exist(cdiry,'dir')
if isunix
%ndbcd = ['/mnt/CHL_WIS_1/NDBC_CDIP'];
ndbcd = ['/home/thesser1/NDBC/'];
ndbcd = ['/mnt/CHL_WIS_1/NDBC_CDIP'];
%ndbcd = ['/home/thesser1/NDBC/'];
ndbct = [ndbcd,yearc,'/',monc,'/'];
else
ndbcd = ['X:\NDBC_CDIP\'];
ndbct = [ndbcd,yearc,'\',monc,'\'];
end


% name of WIS onlns file for output
nfile = [ndbct,'n',ndbcc,'_',yearc,'_',monnc,'.onlns'];
if exist(nfile,'file')
return
end
% if exist(nfile,'file')
% return
% end

% read cdip spectral files
[aa,status]= read_cdip_sp(cdiry);
if status == 0
return
end
% set all the array parametersf from aa sturct
time = num2str(aa.date');
bb1(:,1) = str2num(time(:,1:4));
bb1(:,2) = str2num(time(:,5:6));
Expand All @@ -88,7 +111,10 @@ function cdip_2_onlns(cdip,ndbc,year,mon)
end
ab.df = aa.bw(:,1);
ab.freq = aa.freq(:,1);ab.dep = aa.dep;
% converts to onlns included MEM generation
bb2 = convert_2_onlns(ab);
% concatinates two arrays
bb = horzcat(bb1,bb2);
% writes out the onlns file
create_onlns(ndbcc,yearc,monnc,bb,ndbct);
end
8 changes: 7 additions & 1 deletion Buoy_analysis/convert_2_onlns.m
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
function bb = convert_2_onlns(aa)

%
% convert a structured array to onlns array format
% created 05/15/2013 TJ Hesser
%
% INPUT:
% aa. STRUCT : structured array with wave parameters
%
for zz = 1:size(aa.c11,2)
hmo = 4.0*sqrt(sum(aa.c11(:,zz).*aa.df));
[fpp,fm,fp,mp] = periods(aa.c11(:,zz),aa.freq,aa.df);
Expand Down
12 changes: 8 additions & 4 deletions Buoy_analysis/read_canada_sp.m
Original file line number Diff line number Diff line change
Expand Up @@ -37,16 +37,19 @@
%clear all
fname = dir([fdir,'*',year,'.fb']);
if isempty(fname)
fnamezip = ls([fdir,'*',year,'.zip']);
if isempty(fnamezip)
fnamezip = dir([fdir,'*',year,'.zip']);
if size(fnamezip,1) == 0
status = 0;aa = 0;
return
end
for zz = 1:size(fnamezip,1)
cd(fdir)
unzip(fnamezip(zz,:));
unzip(fnamezip(zz).name);
end
fname = dir([fdir,'*',year,'.fb']);
if isempty(fname)
fname = dir([fdir,'*',year,'.FB']);
end
fname = ls([fdir,'*',year,'.fb']);
end
dfold = 0;zf = 0;status = 1;
for zfile = 1:size(fname,1)
Expand Down Expand Up @@ -133,6 +136,7 @@
data = fgetl(fid);data = fgetl(fid);
clear freq df ef
end
delete([fdir,fname(zfile).name])
end
fclose(fid);
%delete(fname);
Expand Down
Loading

0 comments on commit 9e6d04b

Please sign in to comment.