-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathbuild_target_hirataANNmon.m
79 lines (61 loc) · 2.34 KB
/
build_target_hirataANNmon.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
function build_target_hirataANNmon
% Assemble PFT time series from Taka Hirata's algorithm for the phytoANN. Take all 6 phyto-PFTs.
% by apalacz@dtu-aqua
% last modified: 12 Apr 2013
%% Clear WorkSpace and CommandWindow
clear all
close all
clc
cd(pwd)
%% Choose time and space
[ Params.Geo ] = ask_domain_ANN ( ' target' ) ;
[ Params.Time, time ] = ask_time_ANN ( ' target' ) ;
%% Set up the directories
datarootdir = '/media/aqua-H/arpa/Data/Satellite';
outdir = [datarootdir,'/TS_targets/'];
pftdir = '/Hirata_pfts/monthly/';
source = 'hirata';
XYres = '1deg';
Ndims = 'TS'; % Area-averaged Time Series
Tres = 'mon';
%% Load
% % Confine to domain:
% if Params.Geo.Area == 2 || Params.Geo.Area == 3 ;
% i = 1 ;
% j = 'NEAtlantic' ;
% else
% i = Params.Geo.Area ;
% j = Params.Geo.Basin ;
% end;
load ([datarootdir,pftdir,'PFTs_1997-2004.mat'],[Params.Geo.Basin,'_diat'],[Params.Geo.Basin,'_coco'],...
[Params.Geo.Basin,'_chlo'],[Params.Geo.Basin,'_cyan'],[Params.Geo.Basin,'_pEuk'],...
[Params.Geo.Basin,'_prok'],'coord');
pfts = cat(4, eval([Params.Geo.Basin,'_diat']), eval([Params.Geo.Basin,'_coco']), ...
eval([Params.Geo.Basin,'_cyan']), eval([Params.Geo.Basin,'_chlo']), ...
eval([Params.Geo.Basin,'_pEuk']), eval([Params.Geo.Basin,'_prok']) ) ;
f1 = (coord(Params.Geo.Area).lat >= Params.Geo.Domain(1) & coord(Params.Geo.Area).lat <= Params.Geo.Domain(2))==1; % find the indices matching desired lat range
f2 = (coord(Params.Geo.Area).lon >= Params.Geo.Domain(3) & coord(Params.Geo.Area).lon <= Params.Geo.Domain(4))==1; % find the indices matching desired lat range
pfts = pfts ( :, f2==1, f1==1, :) ;
sz = size(pfts);
targets = zeros(sz(1),sz(4));
for n = 1:sz(4);
for t = 1:sz(1);
dum = squeeze ( pfts(t,:,:,n) ) ;
targets (t,n) = nanmean ( dum(:) ) ;
end;
end;
% clr = {'r','b','c','g'};
% figure(1)
% for n = 1 : sz(4);
% plot(time,targets(:,n),clr{n});
% hold on;
% end;
% datetick ( 'x', 'keeplimits' ) ;
%% Save the array
clear OutFile;
OutFile = strcat ( outdir,'TAR_',source,'X_',XYres,'_',Ndims,...
'_',Params.Geo.Basin,'_',Tres,'_',...
'YY' ,Params.Time.TyStart,'-',Params.Time.TyEnd,...
'.mat');
save ( OutFile, 'targets' );
end