/[MITgcm]/MITgcm_contrib/gael/bulkMatlab/core_load_fields.m
ViewVC logotype

Annotation of /MITgcm_contrib/gael/bulkMatlab/core_load_fields.m

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


Revision 1.1 - (hide annotations) (download)
Tue Feb 19 21:28:58 2008 UTC (17 years, 5 months ago) by gforget
Branch: MAIN
CVS Tags: HEAD
matlab script to compute bulk formulae forcing etc.

1 gforget 1.1 function [mystruct_out]=core_load_fields(ycur,hcur);
2     %loads the fields and does the interpolation to the 1x1 ECCO grid
3     domaine_global_def;
4    
5     mask=squeeze(tmask3D(:,:,1));
6    
7     rep_in='/net/ross/raid0/gforget/DATAbin/forcing/CORE/fromWebDec07/interannual_data/';
8    
9     files_core=strvcat('q_10.','t_10.','u_10.','v_10.','slp.','ncar_rad.','ncar_precip.');
10     nbfields_core=[1460*ones(1,5) 365 12];
11    
12    
13     ncload /net/ross/raid0/gforget/DATAbin/forcing/CORE/fromWebDec07/main_data/t_10.2004_08_30.nc LON LAT; lon2D_g=LON*ones(1,94); lat2D_g=ones(192,1)*LAT';
14     [x1,y1] = meshgrid([-1.875 lon2D_g(:,1)' 360 361.875],lat2D_g(1,:));
15     [x2,y2] = meshgrid(lon2D_t(:,1),lat2D_t(1,:));
16    
17    
18     for fcur=1:7
19    
20     switch fcur
21     case 1; var_core=strvcat('Q_10_MOD'); var_ecco='aqh';
22     case 2; var_core=strvcat('T_10_MOD'); var_ecco='atemp';
23     case 3; var_core=strvcat('U_10_MOD'); var_ecco='uwind';
24     case 4; var_core=strvcat('V_10_MOD'); var_ecco='vwind';
25     case 5; var_core=strvcat('SLP'); var_ecco='slp';
26     case 6; var_core=strvcat('SWDN_MOD','LWDN_MOD'); var_ecco=strvcat('swdn','lwdn');
27     case 7; var_core=strvcat('RAIN','SNOW'); var_ecco=strvcat('rain','snow');
28     end
29    
30     for ecur=1:size(var_core,1)
31    
32     if nbfields_core(fcur)==1460;
33     %load the 6 hourly field:
34     if ycur<2001; suff_file='2004_08_03'; else; suff_file='2006_04_06'; end;
35     nc = netcdf([rep_in deblank(files_core(fcur,:)) num2str(ycur) '.' suff_file '.nc'], 'nowrite');
36     field_cur=nc{deblank(var_core(ecur,:))}(hcur,:,:); nc = close(nc);
37     elseif nbfields_core(fcur)==365;
38     %load the daily field:
39     if ycur<2001; suff_file='2004_08_03'; else; suff_file='2006_04_06'; end;
40     nc = netcdf([rep_in deblank(files_core(fcur,:)) num2str(ycur) '.' suff_file '.nc'], 'nowrite');
41     field_cur=nc{deblank(var_core(ecur,:))}(ceil(hcur/4),:,:); nc = close(nc);
42     else
43     %interpolate from the monthly field:
44     % coeffs etc:
45     dcur=ceil((hcur)/4); [mcur,mcurW]=coeff_MonthlyAtlasInterp(dcur);
46     ycur2=[ycur ycur];
47     if ~isempty(find(mcur==1))&dcur>300; ycur2(find(mcur==1))=ycur+1; end;
48     if ~isempty(find(mcur==12))&dcur<100; ycur2(find(mcur==12))=ycur-1; end;
49     tmp1=find(ycur2==1991); ycur2(tmp1)=1992; mcur(tmp1)=1;
50     tmp1=find(ycur2==2005); ycur2(tmp1)=2004; mcur(tmp1)=12;
51     % load the two fields:
52     if ycur2(1)<2001; suff_file='2004_08_03'; else; suff_file='2006_04_06'; end;
53     nc2 = netcdf([rep_in deblank(files_core(fcur,:)) num2str(ycur2(1)) '.' suff_file '.nc'], 'nowrite');
54     field1=nc2{deblank(var_core(ecur,:))}(mcur(1),:,:); nc2 = close(nc2);
55     if ycur2(2)<2001; suff_file='2004_08_03'; else; suff_file='2006_04_06'; end;
56     nc2 = netcdf([rep_in deblank(files_core(fcur,:)) num2str(ycur2(2)) '.' suff_file '.nc'], 'nowrite');
57     field2=nc2{deblank(var_core(ecur,:))}(mcur(2),:,:); nc2 = close(nc2);
58     % weighted average -> time interpolation
59     field_cur=(1-mcurW)*field1+mcurW*field2;
60     end
61    
62     %spatial interpolation:
63     field_cur=field_cur';
64     tmp1=[field_cur(end,:);field_cur;field_cur(1,:);field_cur(2,:)]';
65     field_cur=interp2(x1,y1,tmp1,x2,y2)';
66    
67     eval([deblank(var_ecco(ecur,:)) '=field_cur.*mask;']);
68    
69     end
70    
71     end%for fcur=1:7
72    
73     rhoConstFresh=999.8;
74     slp=slp/100; %in pascal -> /100 => mbar
75     precip=(rain+snow)/1000*rhoConstFresh; %mm/s->m/s->kg/m^2/s
76    
77     mystruct_out=struct('aqh',aqh,'atemp',atemp,'uwind',uwind,'vwind',vwind,'swdn',swdn,'lwdn',lwdn,'precip',precip,'slp',slp);
78    

  ViewVC Help
Powered by ViewVC 1.1.22