function [mystruct_out]=core_load_fields(ycur,hcur); %loads the fields and does the interpolation to the 1x1 ECCO grid domaine_global_def; mask=squeeze(tmask3D(:,:,1)); rep_in='/net/ross/raid0/gforget/DATAbin/forcing/CORE/fromWebDec07/interannual_data/'; files_core=strvcat('q_10.','t_10.','u_10.','v_10.','slp.','ncar_rad.','ncar_precip.'); nbfields_core=[1460*ones(1,5) 365 12]; 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'; [x1,y1] = meshgrid([-1.875 lon2D_g(:,1)' 360 361.875],lat2D_g(1,:)); [x2,y2] = meshgrid(lon2D_t(:,1),lat2D_t(1,:)); for fcur=1:7 switch fcur case 1; var_core=strvcat('Q_10_MOD'); var_ecco='aqh'; case 2; var_core=strvcat('T_10_MOD'); var_ecco='atemp'; case 3; var_core=strvcat('U_10_MOD'); var_ecco='uwind'; case 4; var_core=strvcat('V_10_MOD'); var_ecco='vwind'; case 5; var_core=strvcat('SLP'); var_ecco='slp'; case 6; var_core=strvcat('SWDN_MOD','LWDN_MOD'); var_ecco=strvcat('swdn','lwdn'); case 7; var_core=strvcat('RAIN','SNOW'); var_ecco=strvcat('rain','snow'); end for ecur=1:size(var_core,1) if nbfields_core(fcur)==1460; %load the 6 hourly field: if ycur<2001; suff_file='2004_08_03'; else; suff_file='2006_04_06'; end; nc = netcdf([rep_in deblank(files_core(fcur,:)) num2str(ycur) '.' suff_file '.nc'], 'nowrite'); field_cur=nc{deblank(var_core(ecur,:))}(hcur,:,:); nc = close(nc); elseif nbfields_core(fcur)==365; %load the daily field: if ycur<2001; suff_file='2004_08_03'; else; suff_file='2006_04_06'; end; nc = netcdf([rep_in deblank(files_core(fcur,:)) num2str(ycur) '.' suff_file '.nc'], 'nowrite'); field_cur=nc{deblank(var_core(ecur,:))}(ceil(hcur/4),:,:); nc = close(nc); else %interpolate from the monthly field: % coeffs etc: dcur=ceil((hcur)/4); [mcur,mcurW]=coeff_MonthlyAtlasInterp(dcur); ycur2=[ycur ycur]; if ~isempty(find(mcur==1))&dcur>300; ycur2(find(mcur==1))=ycur+1; end; if ~isempty(find(mcur==12))&dcur<100; ycur2(find(mcur==12))=ycur-1; end; tmp1=find(ycur2==1991); ycur2(tmp1)=1992; mcur(tmp1)=1; tmp1=find(ycur2==2005); ycur2(tmp1)=2004; mcur(tmp1)=12; % load the two fields: if ycur2(1)<2001; suff_file='2004_08_03'; else; suff_file='2006_04_06'; end; nc2 = netcdf([rep_in deblank(files_core(fcur,:)) num2str(ycur2(1)) '.' suff_file '.nc'], 'nowrite'); field1=nc2{deblank(var_core(ecur,:))}(mcur(1),:,:); nc2 = close(nc2); if ycur2(2)<2001; suff_file='2004_08_03'; else; suff_file='2006_04_06'; end; nc2 = netcdf([rep_in deblank(files_core(fcur,:)) num2str(ycur2(2)) '.' suff_file '.nc'], 'nowrite'); field2=nc2{deblank(var_core(ecur,:))}(mcur(2),:,:); nc2 = close(nc2); % weighted average -> time interpolation field_cur=(1-mcurW)*field1+mcurW*field2; end %spatial interpolation: field_cur=field_cur'; tmp1=[field_cur(end,:);field_cur;field_cur(1,:);field_cur(2,:)]'; field_cur=interp2(x1,y1,tmp1,x2,y2)'; eval([deblank(var_ecco(ecur,:)) '=field_cur.*mask;']); end end%for fcur=1:7 rhoConstFresh=999.8; slp=slp/100; %in pascal -> /100 => mbar precip=(rain+snow)/1000*rhoConstFresh; %mm/s->m/s->kg/m^2/s mystruct_out=struct('aqh',aqh,'atemp',atemp,'uwind',uwind,'vwind',vwind,'swdn',swdn,'lwdn',lwdn,'precip',precip,'slp',slp);