Skip to content

Commit

Permalink
Move all matlab files to repository
Browse files Browse the repository at this point in the history
  • Loading branch information
thesser1 committed Mar 15, 2013
1 parent 1c4a0e9 commit 0ab8487
Show file tree
Hide file tree
Showing 954 changed files with 112,351 additions and 0 deletions.
Binary file not shown.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
9,889 changes: 9,889 additions & 0 deletions 1990-12/1990-12/level1/Max-mean-ww3.dat

Large diffs are not rendered by default.

Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
25 changes: 25 additions & 0 deletions ARGUS_merged/getdata.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
test=ftp('cil-ftp.oce.orst.edu','ftp','[email protected]');

nowtime=now;
stime=datestr(nowtime);
month=stime(4:6);
[yr,mn,dayofmonth]=datevec(nowtime);
dayofyear=nowtime-datenum(yr,0,0);

if yr==2013
cd(test,'pub/argus02a/2013/cx')
else
cd(test,'pub/argus02a/2012/cx')
end

foldername=[sprintf('%.0f',dayofyear-1) '_' month '.' sprintf('%02.0f',dayofmonth)];
fprintf('%s\n',foldername);
mkdir(foldername);

cd(test,foldername)
mget(test,'*.var.merge.png',foldername)
mget(test,'*.timex.merge.png',foldername)
mget(test,'*.bright.merge.png',foldername)
mget(test,'*.dark.merge.png',foldername)

close(test)
25 changes: 25 additions & 0 deletions ARGUS_merged/test/getdata.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
test=ftp('cil-ftp.oce.orst.edu','ftp','[email protected]');

nowtime=now;
stime=datestr(nowtime);
month=stime(4:6);
[yr,mn,dayofmonth]=datevec(nowtime);
dayofyear=nowtime-datenum(yr,0,0);

if yr==2013
cd(test,'pub/argus02a/2013/cx')
else
cd(test,'pub/argus02a/2012/cx')
end

foldername=[sprintf('%.0f',dayofyear-1) '_' month '.' sprintf('%02.0f',dayofmonth)];
fprintf('%s\n',foldername);
mkdir(foldername);

cd(test,foldername)
mget(test,'*.var.merge.png',foldername)
mget(test,'*.timex.merge.png',foldername)
mget(test,'*.bright.merge.png',foldername)
mget(test,'*.dark.merge.png',foldername)

close(test)
32 changes: 32 additions & 0 deletions Altimeter/alt_WAM_stat1.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
function [mod_out,mod_bias,mod_rmse,alt_out,blah,yearmon] = alt_WAM_stat1( ...
alt_data)

fname = ls('*_Hst.tgz');
untar(fname)
yearmon = fname(end-13:end-8);
bbop = dir('c*0');

for zz = 1:size(bbop,1) - 1
fid = fopen(bbop(zz).name);

for jj = 257:-1:1
data = fscanf(fid,'%10f',381);
hs(:,jj) = data;
end
fclose(fid);
hs2 = hs';
mod_out(:,:,zz) = hs2;%*0.01;
for qq = 1:size(alt_data,2)
mod_bias{qq}(:,:,zz) = hs2 - alt_data(qq).alt_data(zz).Hs_grid;
alt_out{qq}(:,:,zz) = alt_data(qq).alt_data(zz).Hs_grid;
mod_rmse{qq}(:,:,zz) = (mod_out(:,:,zz) - alt_out{qq}(:,:,zz)).^2;
blah{qq}(zz) = max(max(alt_out{qq}(:,:,zz)));
for jj = 1:size(alt_out{qq},2)
pp = (alt_data(qq).alt_data(zz).Hs_grid(:,jj) == -999 | hs2(:,jj) == -999);
mod_bias{qq}(pp,jj,zz) = NaN;
alt_out{qq}(pp,jj,zz) = NaN;
mod_rmse{qq}(pp,jj,zz) = NaN;
clear pp
end
end
end
35 changes: 35 additions & 0 deletions Altimeter/alt_stat1.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
function [mod_out,mod_bias,mod_rmse,alt_out,blah,yearmon] = alt_stat1(alt_data,nlon,nlat)

fname = ls('*-hss.tgz');
untar(fname)
yearmon = fname(1:6);
bbop = dir('*.hs');

% mod_bias = cell(bbop-1);alt_out = cell(bbop-1); mod_rmse =cell(bbop-1);
% blah = cell(bbop-1);
for zz = 1:size(bbop,1)-1
fid = fopen(bbop(zz).name);
data = fgetl(fid);

for jj = 1:nlat
data = fscanf(fid,'%f',nlon);
hs(jj,:) = data;
end
fclose(fid);

mod_out(:,:,zz) = hs*0.01;
for qq = 1:size(alt_data,2)
alt_out{qq}(:,:,zz) = alt_data(qq).alt_data(zz).Hs_grid;
%mod_bias{qq}(:,:,zz) = hs*0.01 - alt_data(qq).alt_data(zz).Hs_grid;
mod_bias{qq}(:,:,zz) = mod_out(:,:,zz) - alt_out{qq}(:,:,zz);
mod_rmse{qq}(:,:,zz) = (mod_out(:,:,zz) - alt_out{qq}(:,:,zz)).^2;
blah{qq}(zz) = max(max(alt_out{qq}(:,:,zz)));
for jj = 1:size(alt_out{qq},2)
pp = (isnan(alt_data(qq).alt_data(zz).Hs_grid(:,jj)) | hs(:,jj) == -999);
mod_bias{qq}(pp,jj,zz) = NaN;
alt_out{qq}(pp,jj,zz) = NaN;
mod_rmse{qq}(pp,jj,zz) = NaN;
clear pp
end
end
end
34 changes: 34 additions & 0 deletions Altimeter/alt_stat2.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
function [mod_bias3,mod_rmse3,alt_out3,mod_si] = alt_stat2(mod_bias, ...
mod_rmse,alt_out)

mod_bias2 = zeros(size(mod_bias,1),size(mod_bias,2),25);
mod_bias3 = zeros(size(mod_bias,1),size(mod_bias,2));
mod_rmse2 = zeros(size(mod_rmse,1),size(mod_rmse,2),25);
mod_rmse3 = zeros(size(mod_rmse,1),size(mod_rmse,2));
alt_out2 = zeros(size(alt_out,1),size(alt_out,2),25);
alt_out3 = zeros(size(alt_out,1),size(alt_out,2));
mod_si = zeros(size(mod_rmse,1),size(mod_rmse,2));
%
for jj = 3:size(alt_out,2)-2
for ii = 3:size(alt_out,1)-2
% ppx = [ii-1,ii,ii+1,ii-1,ii,ii+1,ii-1,ii,ii+1];
% ppy = [jj+1,jj+1,jj+1,jj,jj,jj,jj-1,jj-1,jj-1];
ppx = [ii-2,ii-1,ii,ii+1,ii+2,ii-2,ii-1,ii,ii+1,ii+2,ii-2,ii-1,ii, ...
ii+1,ii+2,ii-2,ii-1,ii,ii+1,ii+2,ii-2,ii-1,ii,ii+1,ii+2];
ppy = [jj+2,jj+2,jj+2,jj+2,jj+2,jj+1,jj+1,jj+1,jj+1,jj+1,jj,jj,jj, ...
jj,jj,jj-1,jj-1,jj-1,jj-1,jj-1,jj-2,jj-2,jj-2,jj-2,jj-2];
for zz = 1:25
qq = ~isnan(alt_out(ppx(zz),ppy(zz),:));
mod_bias2(ii,jj,zz) = mean(mod_bias(ppx(zz),ppy(zz),qq));
alt_out2(ii,jj,zz) = mean(alt_out(ppx(zz),ppy(zz),qq));
mod_rmse2(ii,jj,zz) = mean(mod_rmse(ppx(zz),ppy(zz),qq));
end
clear qq
qq = ~isnan(alt_out2(ii,jj,:));
alt_out3(ii,jj) = mean(alt_out2(ii,jj,qq));
mod_bias3(ii,jj) = mean(mod_bias2(ii,jj,qq));
mod_rmse3(ii,jj) = sqrt(sum(mod_rmse2(ii,jj,qq))/length(qq));
mod_si(ii,jj) = mod_rmse3(ii,jj)./alt_out3(ii,jj).*100;
clear qq
end
end
45 changes: 45 additions & 0 deletions Altimeter/alt_time_con.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
function [time_mat]=alt_time_con(year,time)

%% constant days associated with leap year
daylp = [0,31,60,91,121,152,182,213,244,274,305,335];
daynlp = [0,31,59,90,120,151,181,212,243,273,304,334];

yy = 1985:1:year-1;
ht = find(mod(yy,4) == 0);
tts = length(yy)*365*24*3600 + length(ht)*24*3600;
tty = time - repmat(tts,size(time));

%% find day number
tt1 = tty./(24*3600);
ttm = ceil(tt1);
ttsm = (ttm-1)*24*3600;

% find month including leap years
if leapyear(year) == 1
mon = find(daylp <= ttm(1), 1, 'last' );
day = ttm - repmat(daylp(mon),size(ttm));
else
mon = find(daynlp <= ttm(1), 1, 'last' );
day = ttm - repmat(daynlp(mon),size(ttm));
end

%% use day month to find hr min
tt2 = tty - ttsm;
tt3 = tt2/3600;
tth = floor(tt3);
ttsh = tth*3600;

%% find minutes
tt4 = tty - ttsm - ttsh;
tt5 = tt4/60;
ttm = floor(tt5);
ttsmin = ttm*60;

%% find seconds
tts = floor(tty-ttsm-ttsh-ttsmin);

time_mat = datenum(year,mon,day,tth,ttm,tts);




112 changes: 112 additions & 0 deletions Altimeter/bin2mat.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
function ZG = bin2mat(x,y,z,XI,YI,varargin)
% BIN2MAT - create a matrix from scattered data without interpolation
%
% ZG = BIN2MAT(X,Y,Z,XI,YI) - creates a grid from the data
% in the (usually) nonuniformily-spaced vectors (x,y,z)
% using grid-cell averaging (no interpolation). The grid
% dimensions are specified by the uniformily spaced vectors
% XI and YI (as produced by meshgrid).
%
% ZG = BIN2MAT(...,@FUN) - evaluates the function FUN for each
% cell in the specified grid (rather than using the default
% function, mean). If the function FUN returns non-scalar output,
% the output ZG will be a cell array.
%
% ZG = BIN2MAT(...,@FUN,ARG1,ARG2,...) provides aditional
% arguments which are passed to the function FUN.
%
% EXAMPLE
%
% %generate some scattered data
% [x,y,z]=peaks(150);
% ind=(rand(size(x))>0.9);
% xs=x(ind); ys=y(ind); zs=z(ind);
%
% %create a grid, use lower resolution if
% %no gaps are desired
% xi=min(xs):0.25:max(xs);
% yi=min(ys):0.25:max(ys);
% [XI,YI]=meshgrid(xi,yi);
%
% %calculate the mean and standard deviation
% %for each grid-cell using bin2mat
% Zm=bin2mat(xs,ys,zs,XI,YI); %mean
% Zs=bin2mat(xs,ys,zs,XI,YI,@std); %std
%
% %plot the results
% figure
% subplot(1,3,1);
% scatter(xs,ys,10,zs,'filled')
% axis image
% title('Scatter Data')
%
% subplot(1,3,2);
% pcolor(XI,YI,Zm)
% shading flat
% axis image
% title('Grid-cell Average')
%
% subplot(1,3,3);
% pcolor(XI,YI,Zs)
% shading flat
% axis image
% title('Grid-cell Std. Dev.')
%
% SEE also RESHAPE ACCUMARRAY FEVAL

% A. Stevens 3/10/2009
% [email protected]

%check inputs
error(nargchk(5,inf,nargin,'struct'));

%make sure the vectors are column vectors
x = x(:);
y = y(:);
z = z(:);

if all(any(diff(cellfun(@length,{x,y,z}))));
error('Inputs x, y, and z must be the same size');
end

%process optional input
fun=@mean;
test=1;
if ~isempty(varargin)
fun=varargin{1};
if ~isa(fun,'function_handle');
fun=str2func(fun);
end

%test the function for non-scalar output
test = feval(fun,rand(5,1),varargin{2:end});

end

%grid nodes
xi=XI(1,:);
yi=YI(:,1);
[m,n]=size(XI);

%limit values to those within the specified grid
xmin=min(xi);
xmax=max(xi);
ymin=min(yi);
ymax=max(yi);

gind =(x>=xmin & x<=xmax & ...
y>=ymin & y<=ymax);

%find the indices for each x and y in the grid
[junk,xind] = histc(x(gind),xi);
[junk,yind] = histc(y(gind),yi);

%break the data into a cell for each grid node
blc_ind=accumarray([yind xind],z(gind),[m n],@(x){x},{NaN});

%evaluate the data in each grid using FUN
if numel(test)>1
ZG=cellfun(@(x)(feval(fun,x,varargin{2:end})),blc_ind,'uni',0);
else
ZG=cellfun(@(x)(feval(fun,x,varargin{2:end})),blc_ind);
end
Loading

0 comments on commit 0ab8487

Please sign in to comment.