Skip to content

Commit

Permalink
- capitalize section titles (diags_driver_tex.m)
Browse files Browse the repository at this point in the history
- add skipTH, skipSLT, and skipGM switches (diags_set_A.m)
- add 'diags_trsp/' to subdirectory list (listSubdirs)
- add filesep after dirTex (write2tex.m)
  • Loading branch information
gaelforget committed May 27, 2018
1 parent a8d5673 commit 2f97542
Show file tree
Hide file tree
Showing 5 changed files with 69 additions and 48 deletions.
35 changes: 19 additions & 16 deletions gcmfaces_diags/diags_driver_tex.m
Original file line number Diff line number Diff line change
Expand Up @@ -165,17 +165,17 @@

elseif strcmp(setDiags{ii},'profiles');
%in situ profiles fit
write2tex(fileTex,1,'fit to data',1);
write2tex(fileTex,1,'fit to in situ data',2);
write2tex(fileTex,1,'Fit To Data',1);
write2tex(fileTex,1,'Fit To In Situ Data',2);
insitu_diags(dirMat,0,dirTex,nameTex);

elseif strcmp(setDiags{ii},'cost');
if isempty(find(strcmp(setDiags,'profiles')));
write2tex(fileTex,1,'fit to data',1);
write2tex(fileTex,1,'Fit To Data',1);
end;
%altimeter fit
if ~isempty(dir([dirMat 'cost/cost_altimeter_mod.mat']))
write2tex(fileTex,1,'fit to altimeter data (RADS)',2);
write2tex(fileTex,1,'Fit To Altimeter Data (RADS)',2);
cost_altimeter_disp(dirMat,0,'etaglo',dirTex,nameTex);
cost_altimeter_disp(dirMat,2,'modMobs',dirTex,nameTex);
cost_altimeter_disp(dirMat,1,'modMobs',dirTex,nameTex);
Expand All @@ -184,21 +184,21 @@
cost_altimeter_disp(dirMat,1,'mod',dirTex,nameTex);
end;
%other cost terms
write2tex(fileTex,1,'fit to sst data',2);
write2tex(fileTex,1,'Fit To SST Data',2);
cost_sst('',dirMat,0,dirTex,nameTex);
write2tex(fileTex,1,'fit to seaice data',2);
write2tex(fileTex,1,'Fit To Seaice Data',2);
cost_seaicearea('',dirMat,0,dirTex,nameTex);

elseif strcmp(setDiags{ii},'A');
write2tex(fileTex,1,'volume, heat and salt transports',1);
write2tex(fileTex,1,'Volume, Heat, And Salt Transports',1);
diags_display({dirMat,dirMatRef},'A',dirTex,nameTex);

elseif strcmp(setDiags{ii},'B');
write2tex(fileTex,1,'mean and variance maps',1);
write2tex(fileTex,1,'Mean And Variance Maps',1);
diags_display({dirMat,dirMatRef},'B',dirTex,nameTex);

elseif strcmp(setDiags{ii},'C');
write2tex(fileTex,1,'global, zonal, regional averages',1);
write2tex(fileTex,1,'Global, Zonal, Regional Averages',1);
diags_display({dirMat,dirMatRef},'C',dirTex,nameTex);

elseif strcmp(setDiags{ii},'D');
Expand All @@ -208,26 +208,29 @@
end;
for kk=budget_list;
if kk==1;
tmp1='(top to bottom)';
tmp1='(Top To Bottom)';
else;
tmp1=sprintf('(%im to bottom)',round(-mygrid.RF(kk)));
tmp1=sprintf('(%im To Bottom)',round(-mygrid.RF(kk)));
end;
write2tex(fileTex,1,['budgets : volume, heat and salt ' tmp1],1);
write2tex(fileTex,1,['Budgets : Volume, Heat, And Salt ' tmp1],1);
diags_display({dirMat,dirMatRef},{'D',kk},dirTex,nameTex);
end;

elseif strcmp(setDiags{ii},'MLD');
write2tex(fileTex,1,'mixed layer depth fields',1);
write2tex(fileTex,1,'Mixed Layer Depth Fields',1);
diags_display({dirMat,dirMatRef},'MLD',dirTex,nameTex);
elseif strcmp(setDiags{ii},'SEAICE');
write2tex(fileTex,1,'seaice and snow fields',1);
write2tex(fileTex,1,'Seaice And Snow Fields',1);
diags_display({dirMat,dirMatRef},'SEAICE',dirTex,nameTex);
elseif strcmp(setDiags{ii},'gudA');
write2tex(fileTex,1,'Primary Production And Related Fields',1);
diags_display({dirMat,dirMatRef},'gudA',dirTex,nameTex);
elseif strcmp(setDiags{ii},'drwn3');
write2tex(fileTex,1,'Plankton and related fields',1);
write2tex(fileTex,1,'Plankton Biomass And Related Fields',1);
diags_display({dirMat,dirMatRef},'drwn3',dirTex,nameTex);
elseif strcmp(setDiags{ii},'controls');
%controls
write2tex(fileTex,1,'controls',1);
write2tex(fileTex,1,'Control Parameters',1);
cost_xx('',dirMat,0,dirTex,nameTex);

else;
Expand Down
68 changes: 42 additions & 26 deletions gcmfaces_diags/diags_set_A.m
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@

skipTH=0; skipSLT=0;

if userStep==1;%diags to be computed
listDiags='fldBAR fldTRANSPORTS gloOV gloOVbolus gloOVres gloMT_H gloMT_FW gloMT_SLT';
listBasins=1;
Expand All @@ -17,22 +19,38 @@
listFlds={listFlds{:},'ADVx_SLT','ADVy_SLT','DFxE_SLT','DFyE_SLT'};
listFldsNames=deblank(listFlds);
listFiles={'trsp_3d_set1','trsp_2d_set1','trsp_3d_set2'};
listSubdirs={[dirModel 'diags/TRSP/'],[dirModel 'diags/']};
listSubdirs={[dirModel 'diags_trsp/'],[dirModel 'diags/TRSP/'],[dirModel 'diags/']};
elseif userStep==3;%computational part;

skipTH=~isa(ADVx_TH,'gcmfaces');
skipSLT=~isa(ADVx_SLT,'gcmfaces');
skipGM=~isa(GM_PsiX,'gcmfaces');
if skipTH|skipSLT|skipGM;
skTH=num2str(skipTH); skSLT=num2str(skipSLT); skGM=num2str(skipGM);
fprintf(['Skipping TH(' skTH ') or SLT(' skSLT ') or GM(' skGM ')\n']);
end;

%mask fields:
fldU=UVELMASS.*mygrid.mskW; fldV=VVELMASS.*mygrid.mskS;
if ~isempty(whos('ADVx_TH'));%for backward compatibility
if ~skipTH;
if size(ADVx_TH{1},3)>1; %assume full 3D fields
mskW=mygrid.mskW; mskS=mygrid.mskS;
else; %assume vertically integrated (2D fields)
mskW=mygrid.mskW(:,:,1); mskS=mygrid.mskS(:,:,1);
end;
ADVx_TH=ADVx_TH.*mskW; ADVy_TH=ADVy_TH.*mskS;
ADVx_SLT=ADVx_SLT.*mskW; ADVy_SLT=ADVy_SLT.*mskS;
DFxE_TH=DFxE_TH.*mskW; DFyE_TH=DFyE_TH.*mskS;
end;
if ~skipSLT;
if size(ADVx_SLT{1},3)>1; %assume full 3D fields
mskW=mygrid.mskW; mskS=mygrid.mskS;
else; %assume vertically integrated (2D fields)
mskW=mygrid.mskW(:,:,1); mskS=mygrid.mskS(:,:,1);
end;
ADVx_SLT=ADVx_SLT.*mskW; ADVy_SLT=ADVy_SLT.*mskS;
DFxE_SLT=DFxE_SLT.*mskW; DFyE_SLT=DFyE_SLT.*mskS;
end;
if ~isempty(whos('GM_PsiX'));%for backward compatibility
if ~skipGM;
[fldUbolus,fldVbolus,fldWbolus]=calc_bolus(GM_PsiX,GM_PsiY);
fldUbolus=fldUbolus.*mygrid.mskW; fldVbolus=fldVbolus.*mygrid.mskS;
fldUres=fldU+fldUbolus; fldVres=fldV+fldVbolus;
Expand All @@ -53,32 +71,30 @@
%note: while mskC is a basin mask for tracer points, it can be applied to U/V below
%compute overturning: eulerian contribution
[fldOV]=calc_overturn(fldU.*mskC,fldV.*mskC);
if ~isempty(whos('GM_PsiX'));%for backward compatibility
fldOVbolus=NaN*fldOV; fldOVres=NaN*fldOV;
if ~skipGM;
%compute overturning: eddy contribution
[fldOVbolus]=calc_overturn(fldUbolus.*mskC,fldVbolus.*mskC);
%compute overturning: residual overturn
[fldOVres]=calc_overturn(fldUres.*mskC,fldVres.*mskC);
else;
fldOVbolus=NaN*fldOV; fldOVres=NaN*fldOV;
end;

if ~isempty(whos('ADVx_TH'));%for backward compatibility

[fldMT_FW]=1e-6*calc_MeridionalTransport(fldU.*mskC,fldV.*mskC,1);
fldMT_H=NaN*mygrid.LATS; fldMT_SLT=NaN*mygrid.LATS;
if ~skipTH;
%compute meridional heat transports:
tmpU=(ADVx_TH+DFxE_TH).*mskC(:,:,1:size(ADVx_TH{1},3));
tmpV=(ADVy_TH+DFyE_TH).*mskC(:,:,1:size(ADVx_TH{1},3));
[fldMT_H]=1e-15*4e6*calc_MeridionalTransport(tmpU,tmpV,0);
%compute meridional fresh water transports:
%... using the virtual salt flux formula:
%[fldMT_FW]=1e-6/35*calc_MeridionalTransport(ADVx_SLT+DFxE_SLT,ADVy_SLT+DFyE_SLT,0);
%[fldMT_FW]=1e-6/35*calc_MeridionalTransport(ADVx_SLT,ADVy_SLT,0);
%... using the real freshwater flux formula:
[fldMT_FW]=1e-6*calc_MeridionalTransport(fldU.*mskC,fldV.*mskC,1);
end;
if ~skipSLT;
%compute meridional salt transports:
tmpU=(ADVx_SLT+DFxE_SLT).*mskC(:,:,1:size(ADVx_TH{1},3));
tmpV=(ADVy_SLT+DFyE_SLT).*mskC(:,:,1:size(ADVx_TH{1},3));
[fldMT_SLT]=1e-6*calc_MeridionalTransport(tmpU,tmpV,0);
else;
fldMT_H=NaN*mygrid.LATS; fldMT_FW=NaN*mygrid.LATS; fldMT_SLT=NaN*mygrid.LATS;
%compute meridional seawater transports using the virtual salt flux formula:
%[fldMT_FW]=1e-6/35*calc_MeridionalTransport(ADVx_SLT+DFxE_SLT,ADVy_SLT+DFyE_SLT,0);
%[fldMT_FW]=1e-6/35*calc_MeridionalTransport(ADVx_SLT,ADVy_SLT,0);
end;

%store to global, atlantic or Pac+Ind arrays:
Expand Down Expand Up @@ -285,9 +301,9 @@

if sum(strcmp(choicePlot,'all'))|sum(strcmp(choicePlot,'mfwt'));

if addToTex; write2tex(fileTex,1,'meridional freshwater transport',2); end;
if addToTex; write2tex(fileTex,1,'meridional seawater transport',2); end;

%meridional freshwater transport
%meridional seawater transport
figureL;
fld=mean(alldiag.gloMT_FW(:,tt),2);
plot(mygrid.LATS,fld,'LineWidth',2);
Expand All @@ -299,8 +315,8 @@
end;
set(gca,'FontSize',14); grid on; axis([-90 90 -1.5 2.0]);
if doAnomalies; aa=axis; aa(3:4)=scaleAnom*[-1 1]*0.1; axis(aa); end;
title('Meridional Freshwater Transport (in Sv)');
myCaption={myYmeanTxt,'mean -- meridional freshwater transport (Sv)'};
title('Meridional seawater transport (in Sv)');
myCaption={myYmeanTxt,'mean -- meridional seawater transport (Sv)'};
if addToTex; write2tex(fileTex,2,myCaption,gcf); end;

%and the corresponding standard deviation:
Expand All @@ -316,8 +332,8 @@
end;
set(gca,'FontSize',14); grid on; axis([-90 90 0 2]);
if doAnomalies; aa=axis; aa(3:4)=scaleAnom*[0 1]*0.2; axis(aa); end;
title('Meridional Freshwater Transport (in Sv)');
myCaption={myYmeanTxt,' standard deviation -- meridional freshwater transport (Sv)'};
title('Meridional seawater transport (in Sv)');
myCaption={myYmeanTxt,' standard deviation -- meridional seawater transport (Sv)'};
if addToTex; write2tex(fileTex,2,myCaption,gcf); end;
end;

Expand Down Expand Up @@ -378,15 +394,15 @@
myCaption={'meridional heat transport (PW, annual mean)'};
if addToTex; write2tex(fileTex,2,myCaption,gcf); end;

%meridional freshwater transport
%meridional seawater transport
fld=squeeze(alldiag.gloMT_FW(:,tt))';
x=TT*ones(1,length(mygrid.LATS)); y=ones(nt,1)*mygrid.LATS';
fld=runmean(fld,myNmean,1);
cc=[[-250:50:-100] [-75 -50] [-35:10:35] [50 75] [100:50:250]]/100;
if doAnomalies; cc=scaleAnom*[-1:0.1:1]*0.05; end;
figureL; pcolor(x,y,fld); shading flat; axis([TT(1) TT(end) -90 90]);
gcmfaces_cmap_cbar(cc); title('Meridional Freshwater Transport (in Sv)');
myCaption={'meridional freshwater transport (Sv, annual mean)'};
gcmfaces_cmap_cbar(cc); title('Meridional seawater transport (in Sv)');
myCaption={'meridional seawater transport (Sv, annual mean)'};
if addToTex; write2tex(fileTex,2,myCaption,gcf); end;

%meridional salt transport
Expand Down
3 changes: 2 additions & 1 deletion gcmfaces_diags/diags_set_B.m
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@
end;
listFldsNames=deblank(listFlds);
listFiles={'state_3d_set1','trsp_3d_set1','state_2d_set1','other_2d_set1'};
listSubdirs={[dirModel 'diags/OTHER/' ],[dirModel 'diags/STATE/' ],[dirModel 'diags/TRSP/' ],[dirModel 'diags/']};
listSubdirs={[dirModel 'diags/OTHER/' ],[dirModel 'diags/STATE/' ],[dirModel 'diags/TRSP/' ],...
[dirModel 'diags_trsp/' ],[dirModel 'diags/']};

elseif userStep==3;%computation
%mask fields:
Expand Down
3 changes: 2 additions & 1 deletion gcmfaces_diags/diags_set_C.m
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@
listFlds={ 'THETA','SALT','ETAN','SIarea','SIheff','SIhsnow','sIceLoad','MXLDEPTH','UVELMASS','VVELMASS'};
listFldsNames=deblank(listFlds);
listFiles={'state_2d_set1','other_2d_set1','state_3d_set1','trsp_3d_set1'};
listSubdirs={[dirModel 'diags/OTHER/' ],[dirModel 'diags/STATE/' ],[dirModel 'diags/TRSP/'],[dirModel 'diags/']};
listSubdirs={[dirModel 'diags/OTHER/' ],[dirModel 'diags/STATE/' ],[dirModel 'diags/TRSP/' ],...
[dirModel 'diags_trsp/'],[dirModel 'diags/']};
elseif userStep==3;%computational part;
%mask and re-arrange fields:
fldT=THETA.*mygrid.mskC; fldS=SALT.*mygrid.mskC;
Expand Down
8 changes: 4 additions & 4 deletions gcmfaces_misc/write2tex.m
Original file line number Diff line number Diff line change
Expand Up @@ -123,16 +123,16 @@
[dirTex,fileTex,EXT] = fileparts(myFile);
%print figure
if strcmp(frmt,'eps');
print(myFig,'-depsc',[dirTex fileTex '_fig' num2str(myFigNumTex) '.eps']);
print(myFig,'-depsc',[dirTex filesep fileTex '_fig' num2str(myFigNumTex) '.eps']);
elseif strcmp(frmt,'jpg');
print(myFig,'-djpeg90',[dirTex fileTex '_fig' num2str(myFigNumTex) '.jpg']);
print(myFig,'-djpeg90',[dirTex filesep fileTex '_fig' num2str(myFigNumTex) '.jpg']);
elseif strcmp(frmt,'png');
print(myFig,'-dpng',[dirTex fileTex '_fig' num2str(myFigNumTex) '.png']);
print(myFig,'-dpng',[dirTex filesep fileTex '_fig' num2str(myFigNumTex) '.png']);
end
%save figure (with visible caption)
set(captionHandle,'Visible','on');
set(get(captionHandle,'Children'),'Visible','on');
saveas(myFig,[dirTex fileTex '_fig' num2str(myFigNumTex)],'fig');
saveas(myFig,[dirTex filesep fileTex '_fig' num2str(myFigNumTex)],'fig');
%close figure
close;
%add figure to text file
Expand Down

0 comments on commit 2f97542

Please sign in to comment.