-
Notifications
You must be signed in to change notification settings - Fork 2
/
write_nzwave_lonlat.m
113 lines (78 loc) · 2.96 KB
/
write_nzwave_lonlat.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
clear
close all
time=round(now)-4; % look for files from 4 days in the past
% datenum(2023,7,18,0,0,0);
path='/scale_wlg_devoper/filesets/archive/ecoconnect/EFS/';
ptime=datestr(time,'/YYYY/mm/DD/HH/');
ftime=datestr(time,'YYYYmmDDHH');
grids={'GLOBALWAVE','NZWAVE','NZWAVE-HR'};
gnames={'globalwave+globalum','nzwave+nzlam','nzwave_hr+nzcsm'};
%ww3g_2023071800-utc_globalwave+globalum.nc
%ww3g_2023071800-utc_nzwave+nzlam.nc
%ww3g_2023071800-utc_nzwave_hr+nzcsm.nc
scrsz=[1 1 1366 768];
%scrsz=get(0,'screensize');
%figure('position',scrsz,'color',[1 1 1],'visible','on')
%hold on
%set(gca,'fontsize',12,'fontweight','bold')
colors={'b','r','k'};
for i=3
pname=[path,grids{i},ptime]
if i==1;
fname=[pname,'ww3g_',ftime,'-utc_',gnames{i},'.nc'];
depth=ncread(fname,'depth',[1 1 1],[Inf Inf 1]);
else;
fname=[pname,'ww3g_',ftime,'-utc_',gnames{i},'.nc'];
end
lon=ncread(fname,'lon');
lat=ncread(fname,'lat');
hs=squeeze(double(ncread(fname,'hsig', [1 1 1],[Inf Inf 1])));
tp=squeeze(double(ncread(fname,'tpeak', [1 1 1],[Inf Inf 1])));
pd=squeeze(double(ncread(fname,'peak_direction',[1 1 1],[Inf Inf 1])));
depth=squeeze(double(ncread(fname,'depth',[1 1 1],[Inf Inf Inf])));
depth=nanmean(depth,3);
fda=['WW3_grid_',grids{i},'.nc'];
fda=['nzwave-hr-lon-lat-depth','.nc'];
if exist(fda)==2
system(['rm -rf ',fda]);
end
display(['Writing: lonlat ',fda])
% creating nc and variables
nccreate(fda,'lon','Dimensions', {'lon', length(lon)});
nccreate(fda,'lat','Dimensions', {'lat', length(lat)});
%nccreate(fda,'hs','Dimensions', {'lon', length(lon),'lat', length(lat)});
%nccreate(fda,'tp','Dimensions', {'lon', length(lon),'lat', length(lat)});
%nccreate(fda,'pd','Dimensions', {'lon', length(lon),'lat', length(lat)});
nccreate(fda,'depth','Dimensions', {'lon', length(lon),'lat', length(lat)});
ncwrite(fda,'lon',lon)
ncwrite(fda,'lat',lat)
%ncwrite(fda,'hs',hs)
%ncwrite(fda,'tp',tp)
%ncwrite(fda,'pd',pd)
ncwrite(fda,'depth',depth)
close all
if i==3; return; end
if i==1;
pcolor(lon,lat,depth')
colormap(cmocean('deep'))
shading flat;
colorbar
xlim([140 185])
ylim([-60 -15])
else;
%grid contour
min_lon=min(lon(:)); max_lon=max(lon(:));
min_lat=min(lat(:)); max_lat=max(lat(:));
plot([min_lon min_lon],[min_lat max_lat],'color',colors{i},'linewidth',2)
plot([max_lon max_lon],[min_lat max_lat],'color',colors{i},'linewidth',2)
plot([min_lon max_lon],[min_lat min_lat],'color',colors{i},'linewidth',2)
plot([min_lon max_lon],[max_lat max_lat],'color',colors{i},'linewidth',2)
end
fname=[pname,'ww3p_',ftime,'-utc_',gnames{i},'.nc'];
lon=ncread(fname,'lon');
lat=ncread(fname,'lat');
plot(lon,lat,'.','color',colors{i},'markersize',4)
end
return
title('Bathymetry = GLOBALWAVE, Black = NZWAVE, and Red = NZWAVE-HR. Points are from p files')
export_fig(gcf,'ww3_2023_grids','-png','-r150');