-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsampling_ports.m
More file actions
156 lines (133 loc) · 4.97 KB
/
sampling_ports.m
File metadata and controls
156 lines (133 loc) · 4.97 KB
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
clear all; close all; clc;
cd /Users/dlizarbe/Documents/DANIEL/2001_2010
[mask,LON,LAT,path1]=lets_get_started;
%%
cd /Volumes/BM_2022_x/Hindcast_1990_2010/inout;
load('/Volumes/BM_2022_x/Hindcast_1990_2010/means/Wc_mean_wstrss.mat'); %Wc
load('Ekman_pump.mat');
load('EKMAN_pump_April.mat')
%load('Ekman_We_wind.mat');%WSCD
load('/Users/dlizarbe/Documents/DANIEL/depths/MLD_W_1990_2010.mat'); % CROCO
Humboldt_ports;
W_MLD=mean(Wmld,3,'omitnan');
%W_analytical = Mean_We + Wc_mean; %m/s
W_analytical = LTM_ekpump + Wc_mean;
%W_a = WcMean + Ekman_We;
W_a = WcMean + EK_pump;
W_amean=nanmean(W_a,3);
%load('MLD_W');
Wmld_mean=mean(Wmld,3,'omitnan').*86400;
%Wmld_mean=mean(Wmld,3,'omitnan');
%wind_mean=mean(wind,3,'omitnan');
%load('Mean_199709_2010_chlor')
%load('/Users/dlizarbe/Documents/DANIEL/winds/Ekman_winds.mat')
load('Z_2002_2010.mat')
%WE_mean=W_amean.*86400;
WE_mean = LTM_ekpump.*86400;
%[LONi,LATi]=meshgrid(loni,lati);
Humboldt_ports
long_degrees=5;%around 500km
%%
dark_green_rgb = [0, 0.5, 0];
figure
P=get(gcf,'position');
P(3)=P(3)*1.2;
P(4)=P(4)*2.5;
set(gcf,'position',P);
set(gcf,'PaperPositionMode','auto');
%[c,h]=contourf(LON',LAT',Wmld_mean.*mask',[-3:0.2:3]);colorbar;
[c,h]=contourf(LON,LAT,WE_mean,[-3:0.2:3]);colorbar;
set(h,'LineColor','none');
title('Long-term mean of ocean (1990-2010) W velocity at MLD','fontsize',20);
cmocean('balance',13);
caxis([-1.6 1.6]);
hold on
qp=quiversc(LON,LAT,U,V,'k');hold on;
[c,h]=contour(lon,lat,chloro',[0.5 2 5 10],'Color',dark_green_rgb,'linewidth',3);
clabel(c,h);
borders('countries','facecolor','white');
axis([-90 -70 -33 10]);
ax = gca;
ax.FontSize = 16;
c=colorbar;
c.Label.String='m/day';
hold on
for i = 1:length(Puertos)
key = Puertos{i,1}; % Get port name
x = Puertos{i,2}(2); % Get longitude
y = Puertos{i,2}(1); % Get latitude
plot(x,y,'ko--','markerfacecolor','m');
text(x+0.2, y, key, 'FontSize', 16); % Plot text
xx=[floor(x)-long_degrees,x];
yy=[y-0.2, y+0.2];
hold on
plot_square(xx(1),xx(2)-0.2,yy(1),yy(2));
xsq{i,1}=xx; ysq{i,1}=yy;
distance_km(i,1) = calculate_longitudinal_distance(Puertos{i,2}(1),long_degrees);%lat, long_degrees
end
%% %% let's create a struct
port_names = Puertos(:, 1);
num_ports = numel(port_names);
ports = struct; % Initialize empty struct
for i = 1:num_ports
port_name = port_names{i};
ports.(port_name) = struct; % Create empty struct with port name as field
end
%% lets extract the variables 400km from the coast
%[xi,yi]=create_square(xsq{ii,1}(1), xsq{ii,1}(2),ysq{ii,1}(1), ysq{ii,1}(2));
for ii=1:1:numel(port_names)
%---- find the area W_mld
indxlon_wmld=find(LON(:,1)>=xsq{ii,1}(1) & LON(:,1)<=xsq{ii,1}(2));%
indxlat_wmld=find(LAT(1,:)>=ysq{ii,1}(1) & LAT(1,:)<=ysq{ii,1}(2));
%Winds
indxloni=find(LON(:,1)>=xsq{ii,1}(1) & LON(:,1)<=xsq{ii,1}(2));%
indxlati=find(LAT(1,:)>=ysq{ii,1}(1) & LAT(1,:)<=ysq{ii,1}(2));
%chlor
indxlon=find(lon>=xsq{ii,1}(1) & lon<=xsq{ii,1}(2));%
indxlat=find(lat>=ysq{ii,1}(1) & lat<=ysq{ii,1}(2));
%Ekman upwelling velocity
indxlon_wE=find(LON(:,1)>=xsq{ii,1}(1) & LON(:,1)<=xsq{ii,1}(2));%
indxlat_wE=find(LAT(1,:)>=ysq{ii,1}(1) & LAT(1,:)<=ysq{ii,1}(2));
%cut the variable
Wmld_port=mean(Wmld_mean(indxlat_wmld,indxlon_wmld),1,'omitnan'); %W_mld
V_port=V(indxloni,indxlati);%v wind
chlor_port=mean(chloro(indxlon,indxlat),2,'omitnan');%chlor
WE_port=mean(WE_mean(indxlon_wE,indxlat_wE),2,'omitnan')';%ekman
%z
cut_z=Z_mean(indxlat_wmld,indxlon_wmld,:);
Z_port=mean(squeeze(mean(cut_z,1,'omitnan')),2); %W_mld
%distance to coast
dist_wmld=flip(linspace(0,distance_km(ii),length(Wmld_port)));
dist_wind=flip(linspace(0,distance_km(ii),length(V_port)));
dist_chlor=flip(linspace(0,distance_km(ii),length(chlor_port)));
dist_ekman=flip(linspace(0,distance_km(ii),length(WE_port)));
dist_Z=flip(linspace(0,distance_km(ii),length(Z_port)));
% depth
% plot(dist,Wmld_port);
% set(gca, 'XDir','reverse'); xlim([0 400]);
%fieldnames
fieldName1 = 'Wmld';
fieldName2 = 'Vwind';
fieldName3 = 'chlor';
fieldName4 = 'wE';
fieldName5 = 'dist_wmld';
fieldName6 = 'dist_wind';
fieldName7 = 'dist_chlor';
fieldName8 = 'dist_ekman';
fieldName9 = 'Z';
fieldName10 = 'dist_Z';
%struct
ports.(port_names{ii, 1}).(fieldName1)=Wmld_port;
ports.(port_names{ii, 1}).(fieldName2)=V_port;
ports.(port_names{ii, 1}).(fieldName3)=chlor_port;
ports.(port_names{ii, 1}).(fieldName4)=WE_port;
ports.(port_names{ii, 1}).(fieldName5)=dist_wmld;
ports.(port_names{ii, 1}).(fieldName6)=dist_wind;
ports.(port_names{ii, 1}).(fieldName7)=dist_chlor;
ports.(port_names{ii, 1}).(fieldName8)=dist_ekman;
ports.(port_names{ii, 1}).(fieldName9)=Z_port;
ports.(port_names{ii, 1}).(fieldName10)=dist_Z;
end
%%
%pcolor(LON(indxWmld_lon,1),LAT(1,indxWmld_lat),Wmld_mean(indxWmld_lat,indxWmld_lon)); shading flat;
save('ports_Bordbar_onlyPump.mat','ports');