-
Notifications
You must be signed in to change notification settings - Fork 2
/
write_list_point_4_spectral.m
175 lines (131 loc) · 5.27 KB
/
write_list_point_4_spectral.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
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
clear
close all
time=round(now)-4; % look for files generated 4 days ago
time=datenum(2021,1,1,0,0,0);
%Loading OBS %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
path='/scale_wlg_persistent/filesets/project/niwa03150/santanarc/';
path_obs=[path,'data/obs/'];
file='SteepHead_SP_FullRecord_QC';
file_obs=file;
display(['Loading: ',path,file,'.mat']);
%load([path_obs,file,'.mat'])%,'time','obs')
tstation={'Sinclair Head','Ohau Head','Mana Island','Makara' ,'Karori Rock','Wairewa Lake Forsyth','Taumutu'};
stations={'sinclair_head','ohau_head','mana_island','makara' ,'karori_rock','wairewa_lake_forsyth','Taumutu'};
lat_obss=[-41.366885 ,-42.256063 ,-41.083327 ,-41.203393, -41.344623 ,-43.84110,-43.866527];
lon_obss=[174.716761 , 173.853341,174.763960 ,174.702391, 174.650430 ,172.71835,172.381380];
stations={stations{end}};
scase='dixon-anderson';
[tstation,lat_obss,lon_obss]=read_wave_stations(scase);
%tstation={tstation{14}};
%lon_obss= lon_obss(14);
%lat_obss= lat_obss(14);
lon_obs=lon_obss; lat_obs=lat_obss;
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
path='/scale_wlg_devoper/filesets/archive/ecoconnect/EFS/';
%path='/scale_wlg_nobackup/filesets/nobackup/niwa03150/WAVE/hindcast/';
ptime=datestr(time,'/YYYY/mm/DD/HH/');
ftime=datestr(time,'YYYYmmDDHH');
grids={'GLOBALWAVE','NZWAVE','NZWAVE-HR','TONGAWAVE'};
gnames={'globalwave+globalum','nzwave+nzlam','nzwave_hr+nzcsm','tongawave+globalum'};
% Loading GRIDS %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
scrsz=[1 1 1366 768];
scrsz=[1 1 1920 1080];
scrsz=[1 1 1910 990];
scrsz=[2 42 958 953];
%scrsz=get(0,'screensize');
figure('position',scrsz,'color',[1 1 1],'visible','on')
hold on
set(gca,'fontsize',12,'fontweight','bold')
colors={'b','r','r','k'};
gsel=3;
for i=gsel
pname=[path,grids{i},ptime];
%if i==3;
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_mod=double(ncread(fname,'lon'));
lat_mod=double(ncread(fname,'lat'));
[lonm,latm]=meshgrid(lon_mod,lat_mod);
if i==gsel;
pcolor(lon_mod,lat_mod,depth')
contour(lon_mod,lat_mod,depth',[30 40 50],'k')
colormap(cmocean('deep'))
shading flat;
cb=colorbar;
set(get(cb,'ylabel'),'string','Depth (m)','fontsize',12,'fontweight','bold');
else;
%grid contour
min_lon=min(lon_mod(:)); max_lon=max(lon_mod(:));
min_lat=min(lat_mod(:)); max_lat=max(lat_mod(:));
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
plot_ww3p=0;
if plot_ww3p==1;
fname=[pname,'ww3p_',ftime,'-utc_',gnames{i},'.nc'];
lon=ncread(fname,'lon');
lat=ncread(fname,'lat');
plot(lon,lat,'.','color',colors{i},'markersize',8)
end
plot_obs=0;
if plot_obs==1;
for i=1:length(lon_obss)
[dif ilon]=nanmin(abs(lon_mod-lon_obs(i)));
[dif ilat]=nanmin(abs(lat_mod-lat_obs(i)));
plot(lon_mod(ilon),lat_mod(ilat),'s','color','b','markersize',4)
plot(lon_obss(i),lat_obss(i) ,'.','color','r','markersize',4)
text(lon_obss(i)+.05,lat_obss(i),[tstation{i},' ',num2str(depth(ilon,ilat),'%.2f'),' m'],'fontsize',12,'color','k')%,'markersize',4)
end
end
end
%xlim([170 185]); ylim([-60 -15]) % North Island
%xlim([160 183]); ylim([-55 -25]) % NZ
%xlim([140 185]); ylim([-60 -15]) % NZ and AUS
%xlim([min(lon_obss)-.9 max(lon_obss)+.9]); ylim([min(lat_obss)-.9 max(lat_obss)+.9]); % NZ and AUS
%xlim([140 210]); ylim([-60 10]) % GLOBAL and TONGA
%xlim([184.1 186.5]); ylim([-22 -15]) % GLOBAL and TONGA
%caxis([0 1000])
plot_aus=0;
if plot_aus==1;
fname=['~/ww3/grids/ww3.acs.g3.201612.2017','.nc'];
lon_aus=ncread(fname,'longitude');
lat_aus=ncread(fname,'latitude');
plot(lon_aus,lat_aus,'.','color','m','markersize',4)
end
%title('Bathymetry = GLOBALWAVE, Red = NZWAVE, and Black = NZWAVE-HR. Points are from p files')
%return
title('Location of analysis and model bathymetry')
ylabel('Latitude')
xlabel('Longitude')
save_fig=0;
if save_fig==1;
path_fig=['/scale_wlg_nobackup/filesets/nobackup/niwa03150/santanarc/figures/']; % GLOBALWAVE/'];%2018/01/05/00'];
display(['Saving: ',path_fig,scase]);
export_fig(gcf,[path_fig,scase],'-png','-r150');
saveas(gcf,[path_fig,scase],'fig');
end
depth=depth';
ic=find(depth>=0 & depth<=50);
[lon_modm,lat_modm]=meshgrid(lon_mod,lat_mod);
%plot(lon_modm(ic),lat_modm(ic),'.b')
% list of obs
list_of_obs=1;
if list_of_obs==1
file_obsn='/scale_wlg_persistent/filesets/project/niwa03150/santanarc/Control/nzwave-2/outsite.csv';
display(['Processing: ',file_obsn]);
ob=importdata([file_obsn]);
lstation=ob.textdata;
lon_obsl(:,1)=ob.data(:,1);
lat_obsl(:,1)=ob.data(:,2);
for i=1:length(lon_obsl)
%[dif ilon]=nanmin(abs(lon_mod-lon_obs(i)));
%[dif ilat]=nanmin(abs(lat_mod-lat_obs(i)));
plot(lon_obsl(i),lat_obsl(i) ,'.','color','r','markersize',4)
text(lon_obsl(i)+.05,lat_obsl(i),[lstation{i}],'fontsize',12,'color','k')%,'markersize',4)
end
end