forked from MITgcm/gcmfaces
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathexample_MITprof.m
151 lines (117 loc) · 4.52 KB
/
example_MITprof.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
function []=example_MITprof();
% EXAMPLE_MITPROF illustrates the use of MITprof datasets by computing
% Argo stats over a regional domain that includes the ACC core
gcmfaces_global;
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
if myenv.verbose>0;
gcmfaces_msg('===============================================');
gcmfaces_msg(['*** entering example_MITprof: illustrate ' ...
'the use of MITprof datasets by computing Argo ACC stats'],'');
end;
%%%%%%%%%%%%%%%%%
%load grid and setup test case:
%%%%%%%%%%%%%%%%%
if isempty(mygrid);
grid_load;
end;
myenv.nctilesdir=fullfile('release2_climatology',filesep,'nctiles_climatology',filesep);
myenv.mitprofdir=fullfile('release2_climatology',filesep,'profiles',filesep);
if ~isdir(myenv.nctilesdir);
diags=[];
help gcmfaces_demo;
warning(['skipping example_MITprof (missing ' myenv.nctilesdir ')']);
return;
end;
if ~isdir(myenv.mitprofdir);
diags=[];
help gcmfaces_demo;
warning(['skipping example_MITprof (missing ' myenv.mitprofdir ')']);
return;
end;
%%%%%%%%%%%%%%%%%%%%%%%
%define regional mask
if myenv.verbose>0;
gcmfaces_msg('* call calc_barostream and define regional mask accordingly');
end;
%compute mean streamfunction to define mask:
fldU=mygrid.mskW.*mean(read_nctiles([myenv.nctilesdir 'UVELMASS/UVELMASS']),4);
fldV=mygrid.mskS.*mean(read_nctiles([myenv.nctilesdir 'VVELMASS/VVELMASS']),4);
[fldBAR]=calc_barostream(fldU,fldV);
%define 2D mask:
msk2D=fldBAR;
msk2D(fldBAR>100)=0; msk2D(fldBAR<30)=0; msk2D(mygrid.YC>0)=0;
msk2D(msk2D>0)=1; msk2D=msk2D.*mygrid.mskC(:,:,1);
%max climatological MLD could aternatively be used to define mask:
% maxMLD=mygrid.mskC(:,:,1).*max(read_nctiles('release2_climatology/nctiles_climatology/MXLDEPTH/MXLDEPTH'),[],3);
%define 3D mask:
msk3D=repmat(msk2D,[1 1 50]).*mygrid.mskC;
msk3D(:,:,26:50)=0.*msk3D(:,:,26:50);
%%%%%%%%%%%%%%%%%%%%%%%
%read in MITprof data sets and matching climatology profiles
if myenv.verbose>0;
gcmfaces_msg('* read-in and select Argo profiles');
end;
listData={'MITprof_mar2016_argo9506*','MITprof_mar2016_argo0708*','MITprof_mar2016_argo0910*',...
'MITprof_mar2016_argo1112*','MITprof_mar2016_argo1314*','MITprof_mar2016_argo1515*'};
listVar={'prof_T'}; listV={'T'};
for vv=1:length(listVar);
tmpprof=MITprof_stats_load(myenv.mitprofdir,listData,listV{vv},listVar{vv});
%
loc_tile=gcmfaces_loc_tile(90,90,tmpprof.prof_lon,tmpprof.prof_lat);
tmpprof.prof_msk=convert2array(msk2D);
tmpprof.prof_msk=tmpprof.prof_msk(loc_tile.point);
tmpprof=MITprof_subset(tmpprof,'msk',1);
%
if vv==1; myprof=tmpprof; end;
myprof.(listVar{vv})=tmpprof.prof;
%
clear tmpprof;
end;
myprof=rmfield(myprof,{'prof','prof_msk'});
if myenv.verbose>0;
gcmfaces_msg('* subsample monthly climatology to profile locations');
end;
fldIn.fil=fullfile(myenv.nctilesdir,filesep,'THETA');
fldIn.tim='monclim'; fldIn.name='prof_Tclim';
myprof=MITprof_resample(myprof,fldIn);
%%%%%%%%%%%%%%%%%%%%%%%
%compute monthly averages
if myenv.verbose>0;
gcmfaces_msg('* call MITprof_wrapper to compute monthly climatology');
end;
%specify operation to compute via MITprof_wrapper
myop=[];
%myop.op_name='mean';
myop.op_name='cycle'; myop.op_tim=[0:7:365];
myop.op_vars={'prof_T','prof_Tclim'};
%compute cycle via MITprof_wrapper
[cy_T,cy_Tclim]=MITprof_wrapper(myprof,myop);
if myenv.verbose>0;
gcmfaces_msg('* call MITprof_wrapper via bootstrp to compute std');
end;
%store myprof and myop into global variable
global myprofmyop; myprofmyop=myprof;
for ii=fieldnames(myop)'; myprofmyop.(ii{1})=myop.(ii{1}); end;
%store mask since it could be useful for plotting or other purposes
myprofmyop.msk2D=msk2D;
myprofmyop.msk3D=msk3D;
%compute boostrap samples using MITprof_wrapper
K=[1:myprofmyop.np]; N=100;
myout = bootstrp(N, @MITprof_wrapper,K);
%compute standard deviation
bo_cy_T=reshape(cell2mat(myout(:,1)'),[size(cy_T) N]);
bo_cy_Tclim=reshape(cell2mat(myout(:,2)'),[size(cy_T) N]);
std_cy_T=std(bo_cy_T,[],3);
std_cy_Tclim=std(bo_cy_Tclim,[],3);
%%%%%%%%%%%%%%%%%%%%%%%
%display results
figure;
subplot(2,2,1); imagescnan(cy_T'); colorbar; title('mean using Argo');
subplot(2,2,2); imagescnan(cy_Tclim'); colorbar; title('mean using climatology');
subplot(2,2,3); imagescnan(std_cy_T'); colorbar; title('std using Argo');
subplot(2,2,4); imagescnan(std_cy_Tclim'); colorbar; title('std using climatology');
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
if myenv.verbose>0;
gcmfaces_msg('*** leaving example_MITprof');
gcmfaces_msg('===============================================');
end;