/[MITgcm]/MITgcm_contrib/gael/profilesMatlabProcessing/profiles_misc/model_load.m
ViewVC logotype

Contents of /MITgcm_contrib/gael/profilesMatlabProcessing/profiles_misc/model_load.m

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph


Revision 1.3 - (show annotations) (download)
Mon May 5 13:00:40 2014 UTC (11 years, 2 months ago) by gforget
Branch: MAIN
CVS Tags: checkpoint65x, checkpoint65r, checkpoint65p, checkpoint65q, checkpoint65v, checkpoint65w, checkpoint65t, checkpoint65u, checkpoint66f, checkpoint66e, checkpoint66d, checkpoint66c, checkpoint66b, checkpoint66a, checkpoint66o, HEAD
Changes since 1.2: +3 -3 lines
- update calls to v4_read_bin (now read_bin.m)

1 function [grid,atlas]=model_load(model,varargin);
2 % [grid,atlas]=model_load(model,[reload]);
3 %
4 % model is a string used to select the model to be loaded
5 % 'OCCA' : ECCOv4 grid + OCCA atlas
6 % 'SOSE59' : SOSE59 grid + atlas
7 %
8 % if reload=0 (default), variables are loaded from .mat files
9 % if reload=1 , variables are loaded from original files, and saved in
10 % the matlab form.
11 %
12 % - grid ("model"_grid.mat)
13 % mygrid : structure containing XC, YC, RAC and RC
14 % mytri : information used for delaunay triangulation
15 % MYBASININDEX : basin index
16 %
17 % - state/variance reference climatologies ("model"_atlas.mat)
18 % atlas : T/S atlas in a structure format
19 % atlas.T, atlas.S are cells of 4-dim arrays with monthly values
20 %
21 % gcmfaces toolbox must be working
22 %
23
24 % process arguments
25 reload=0;
26 if nargin>1,
27 reload=varargin{1};
28 end
29
30 % directory where .mat model files are stored
31 dir_model='/Users/roquet/Documents/MATLAB/MITprof/model_database/';
32
33
34 % try to load .mat files
35 if reload==0 & exist([dir_model model '_grid.mat'],'file') & exist([dir_model model '_atlas.mat'],'file')
36 % load grid and atlas
37 load([dir_model model '_grid.mat']);
38 load([dir_model model '_atlas.mat']);
39 return
40
41 end
42
43
44 % if reload~=0 or fields are not found, generation of .mat files
45
46 % protect global grid variables
47 global mygrid mytri MYBASININDEX
48 mygrid1=mygrid; mytri1=mytri; MYBASININDEX1=MYBASININDEX;
49
50 switch model
51 case 'OCCA',
52 % atlas made combining OCCA, PHC in arctic and WOA in marginal seas
53 % using the grid ECCOv4, monthly values
54
55 % set directories:
56 dir_in='/Users/roquet/Documents/MATLAB/MITprof/climatology/';
57 dirGrid=[dir_in 'GRIDv4/'];
58 fileBasin=[dir_in 'basin_masks_eccollc_90x50.bin'];
59 fileT=[dir_in 'T_OWPv1_M_eccollc_90x50.bin'];
60 fileS=[dir_in 'S_OWPv1_M_eccollc_90x50.bin'];
61
62 %load and save grid :
63 grid_load(dirGrid,5,'compact'); gcmfaces_bindata;
64 mygrid=rmfield(mygrid,{'XG','YG','RAC','RAZ','DXC','DYC','DXG','DYG'});
65 mygrid=rmfield(mygrid,{'hFacC','hFacW','hFacS','Depth','AngleCS','AngleSN'});
66 mygrid=rmfield(mygrid,{'hFacCsurf','mskW','mskS','DRC','DRF','RF'});
67 % list_param={'XC','YC','RAC','RC'};
68 % grid_load(dirGrid,5,list_param);
69 % gcmfaces_bindata;
70 MYBASININDEX=convert2array(read_bin(fileBasin,1,0));
71 grid.name=model;
72 grid.mygrid=mygrid;
73 grid.mytri=mytri;
74 grid.MYBASININDEX=MYBASININDEX;
75
76 % read T/S Atlas
77 fldT=mygrid.mskC; fldT(:)=0; fldS=fldT;
78 for tt=1:12;
79 fldT(:,:,:,tt)=read_bin(fileT,tt).*mygrid.mskC;
80 fldS(:,:,:,tt)=read_bin(fileS,tt).*mygrid.mskC;
81 end;
82 atlas.name=model;
83 atlas.T={convert2array(fldT)}; atlas.S={convert2array(fldS)};
84
85 case 'SOSE59',
86 % 59th iteration of SOSE, annual climatology
87
88 % set directories:
89 dir_in='/Users/roquet/Documents/donnees/MODEL/SOSE59/';
90 dirGrid=[dir_in 'grid/'];
91
92 %load grid :
93 grid_load(dirGrid,1,'straight'); gcmfaces_bindata;
94 mygrid=rmfield(mygrid,{'XG','YG','RAC','RAZ','DXC','DYC','DXG','DYG'});
95 mygrid=rmfield(mygrid,{'hFacC','hFacW','hFacS','Depth','AngleCS','AngleSN'});
96 mygrid=rmfield(mygrid,{'hFacCsurf','mskW','mskS','DRC','DRF','RF'});
97 % list_param={'XC','YC','RAC','RC'};
98 % grid_load(dirGrid,1,list_param);
99 % gcmfaces_bindata;
100
101 MYBASININDEX=convert2array(mygrid.mskC(:,:,1));
102 MYBASININDEX(isnan(MYBASININDEX))=0;
103
104 grid.name=model;
105 grid.mygrid=mygrid;
106 grid.mytri=mytri;
107 grid.MYBASININDEX=MYBASININDEX;
108
109 % load atlas
110 atlas_file=[dir_in 'SOSE59_TS.mat'];
111 load(atlas_file);
112 atlas.name=model;
113 atlas.T={THETA_SOSE59};
114 atlas.S={SALT_SOSE59};
115
116 otherwise
117 error('not a valid model string');
118 end
119
120 % save .mat files
121 save([dir_model model '_grid.mat'],'grid');
122 save([dir_model model '_atlas.mat'],'atlas');
123
124 % reload global grid variables
125 mygrid=mygrid1; mytri=mytri1; MYBASININDEX=MYBASININDEX1;
126
127

  ViewVC Help
Powered by ViewVC 1.1.22