Commit b85b16f5 authored by Jérémy Baudry's avatar Jérémy Baudry
Browse files

clean for winter school

parent d6594dfd
......@@ -11,8 +11,20 @@
! q0 : internal nutrient subsistence quota (for bio_model=2) [mol N/mol C]
! mortality : mortality rate [s-1]
! Kn : Half saturation constant [mol N/m3]
! Vmax : maximum nutrient uptake rate [molP/molC/s-1]
! Nutrient_0 : Initial Nutrient concentration [mol N/m3]
! Vmax : maximum nutrient uptake rate [molP/molC/s]
!
! nut_profile : initial nutrient profile
! 1: uniform in the watercolumn (mixed conditions)
! 2: two layers (stratified conditions)
!
! nut_layer : Depth of the bottom layer (for nut_profile=2) [m]
! Nutrient_0 : Initial Nutrient concentration (for nut_profile=1) [mol N/m3]
! Nutrient_1 : Initial nutrient concentration in the surface layer [mol N/m3]
! Nutrient_2 : Initial nutrient concentration in the bottom layer [mol N/m3]
! bottom_flux : Nutrient replenishment at the bottom [mol N/m3/s]
! nut_relax : Relax nutrient profile to initial profile
! 0: false
! 1: True
! w_s : Plankton settling velocity [m/s]
! part_management : algorithm management number particles
! mu_r : Respiration rate constant [s-1]
......@@ -25,17 +37,23 @@
bio_calc = 1
bio_model = 2
mu_max = 2.3148e-5
q0 = 5e-02
mu_max = 2.8935e-5
q0 = 0.05
mortality = 0
Kn = 9.3870e-6
Kn = 2.14e-4
Vmax = 9.3870e-6
Nutrient_0 = 5e-3
nut_profile = 1
nut_layer = 15
Nutrient_0 = 5e-4
Nutrient_1 = 1e-6
Nutrient_2 = 5e-3
bottom_flux = 0
nut_relax = 0
w_s = 0
part_management = 1
part_management = 0
mu_r = 1.1574e-06
kw = 0
q_max = 0.25
q_max = 0.5
m0 = 1e-12
/
......@@ -32,17 +32,17 @@
!------------------------------------------------------------------------------------------
&model_parameter_nml
name_exp ='1depth200'
depth = 200
name_exp ='exp3'
depth = 40
dz = 0.5
K_value = 1e-6
time_step = 60
ndays = 2
output_time = 2
ndays = 10
output_time = 10
mix_state = 1
particle_distribution = 2
nbpart = 5000
z_0 = 10
nbpart = 20000
z_0 = 5
day_length = 16
rad_max = 600
k_bg = 0.4
......
function PHLAG
evalin('base','clear all')
evalin('base','close all')
main_window=figure('Name','PHLAG','position',[40 40 894 435],'CloseRequestFcn',@my_closereq,'Numbertitle','off','menubar','none');
wallpaper=imshow('phyto.jpg','border','tight');
set(main_window,'color',[0 0 0])
load_button= uicontrol('Style', 'pushbutton', 'String', 'load file',...
'Position', [20 250 200 100],...
'Callback', @loadfun,'BackgroundColor',[.2 .2 .2],...
'ForegroundColor','w','fontsize',12);
select_button= uicontrol('Style', 'pushbutton', 'String', 'Draw',...
'Position', [20 120 200 100],...
'Callback', @drawfun,'BackgroundColor',[.2 .2 .2],...
'ForegroundColor','w','fontsize',12);
txt_intro='Visualize PHLAG2014 outputs';
uicontrol('Style','text',...
'Position',[250 200 500 100],...
'String',txt_intro,'fontsize',30,'BackgroundColor',[0 0 0],'ForegroundColor','w');
function my_closereq(source,event)
selection = questdlg('Are you sure you want to close?',...
'Close Request Function',...
'Yes','No','Yes');
switch selection,
case 'Yes',
delete(gcf)
evalin('base','clear all')
case 'No'
return
end
end
function closebio(source,event)
ise = evalin( 'base', 'exist(''linebio'') == 1' );
if ise
evalin('base','clear linebio')
evalin('base','clear linebio2')
end
ise = evalin( 'base', 'exist(''linenut'') == 1' );
if ise
evalin('base','clear linenut')
evalin('base','clear linenut2')
end
delete(gcf)
end
function loadfun(source,event)
evalin('base','clear all')
directory= uigetdir('.');
popup =msgbox('Importing files...');
eulbio_path=[directory,'/EULER_BIOMASS.dat'];
eulbio=load(eulbio_path);
assignin('base', 'eulbio', eulbio)
lagbio_path=[directory,'/LAGRANGE_BIOMASS.dat'];
lagbio=load(lagbio_path);
assignin('base', 'lagbio', lagbio)
eulnut_path=[directory,'/EULER_NUTRIENTS.dat'];
eulnut=load(eulnut_path);
assignin('base', 'eulnut', eulnut)
lagnut_path=[directory,'/LAGRANGE_NUTRIENTS.dat'];
lagnut=load(lagnut_path);
assignin('base', 'lagnut', lagnut)
time_path=[directory,'/TIME.dat'];
time=load(time_path);
assignin('base', 'time', time)
depth_path=[directory,'/DEPTH.dat'];
depth=load(depth_path);
assignin('base', 'depth', depth)
eulQ_path=[directory,'/EULER_CELL_QUOTA.dat'];
eulQ=load(eulQ_path);
assignin('base', 'eulQ', eulQ)
lagQ_path=[directory,'/LAGRANGE_CELL_QUOTA.dat'];
lagQ=load(lagQ_path);
assignin('base', 'lagQ', lagQ)
Qdistrib_path=[directory,'/out.nc'];
Qdistrib=ncread(Qdistrib_path,'cell quota');
assignin('base', 'Qdistrib', Qdistrib)
diffusivity_path=[directory,'/DIFFUSIVITY.dat'];
diffusivity=load(diffusivity_path);
assignin('base', 'diffusivity', diffusivity)
light_path=[directory,'/LIGHT_PROFILE.dat'];
light=load(light_path);
assignin('base', 'light', light)
growtheul_path=[directory,'/EULER_GROWTHRATE.dat'];
eulgrowth=load(growtheul_path);
assignin('base', 'eulgrowth', eulgrowth)
growthlag_path=[directory,'/LAGRANGE_GROWTHRATE.dat'];
laggrowth=load(growthlag_path);
assignin('base', 'laggrowth', laggrowth)
growthdistrib_path=[directory,'/out.nc'];
growthdistrib=ncread(growthdistrib_path,'growth_rate');
assignin('base', 'growthdistrib', growthdistrib)
growthcat=ncread(Qdistrib_path,'growthcat');
assignin('base', 'growthcat', growthcat)
Qcat=ncread(Qdistrib_path,'Qcat');
assignin('base', 'Qcat', Qcat)
close(popup)
row1=['loaded directory: ',directory];
uicontrol('Style','text',...
'Position',[250 160 500 20],...
'String',char({row1}),'BackgroundColor',[.8 .8 .8]);
end
function drawfun(source,event)
eulbio=evalin('base','eulbio');
lagbio=evalin('base','lagbio');
eulnut=evalin('base','eulnut');
lagnut=evalin('base','lagnut');
time=evalin('base','time');
depth=evalin('base','depth');
eulgrowth=evalin('base','eulgrowth');
laggrowth=evalin('base','laggrowth');
eulQ=evalin('base','eulQ');
lagQ=evalin('base','lagQ');
cm=colormap('jet');
cm1(1,:)=[0 0 0];
for i=2:10
cm1(i,:)=[0 0.05*i 0.1*i];
end
cmap(1:10,:)=cm1;
cmap(11:59,:)=cm(16:end,:);
[s,v] = listdlg('PromptString','Type of selection',...
'SelectionMode','single',...
'ListString',char({'Biomass';'Growth rate';'Cell quota';'External nutrients';'Light';'Diffusivity'}));
if s==1
figbio=figure('Name','BIOMASS','position',[200 200 1100 550],'Numbertitle','off','menubar','none','CloseRequestFcn',@closebio);
set(figbio,'color',[0.2 0.2 0.2])
assignin('base','figbio',figbio)
biotot_button= uicontrol('Style', 'pushbutton', 'String', 'Total Biomass',...
'Position', [20,250,200,40],...
'Callback', @calc_biotot,'BackgroundColor',[.2 .2 .2],...
'ForegroundColor','w','fontsize',12);
bio1=subplot(2,2,1);
pcolor(time,depth,lagbio')
shading interp
c1=colorbar;
xlabel('Time [Days]')
ylabel('Depth [m]')
title('LAGRANGIAN')
ax=gca;
ax.XAxis.Color='w';
ax.YAxis.Color='w';
set(ax,'yticklabel',flipud(get(ax,'yticklabel')))
set(c1,'color','w')
ylabel(c1,'Biomas [mol C/m^3]')
hold on
bio2=subplot(2,2,3);
pcolor(time,depth,eulbio')
shading interp
c2=colorbar;
colormap(cmap)
hold on
ylabel(c2,'Biomas [mol C/m^3]')
xlabel('Time [Days]')
ylabel('Depth [m]')
ax=gca;
ax.XAxis.Color='w';
ax.YAxis.Color='w';
set(c2,'color','w')
set(ax,'yticklabel',flipud(get(ax,'yticklabel')))
title('EULERIAN')
assignin('base', 'bio1', bio1)
assignin('base', 'bio2', bio2)
uicontrol('Parent',figbio,'Style','slider','Position',[320,250,200,20],...
'value',0.5, 'min',0, 'max',1,'callback',@colorscale);
uicontrol('Style','text',...
'Position',[320,270,200,20],...
'String','color scale','backgroundColor',get(figbio,'color'),'ForegroundColor','w');
set(bio1,'units','pixel')
set(bio2,'units','pixel')
set(bio2,'Position',[60 50 420 180])
set(bio1,'Position',[60 330 420 180])
set(bio1,'fontsize',12)
set(bio2,'fontsize',12)
curs=datacursormode(figbio);
set(curs,'enable','on');
set(curs,'UpdateFcn', @plotbiomass )
%
elseif s==4
fignut=figure('Name','Nutrients','position',[200 200 1100 550],'Numbertitle','off','menubar','none','CloseRequestFcn',@closebio);
set(fignut,'color',[0.2 0.2 0.2])
assignin('base','fignut',fignut)
nut1=subplot(2,2,1);
pcolor(time,depth,lagnut')
shading interp
c1=colorbar;
ylabel(c1,'Nutrients [mol N/m^3]')
xlabel('Time [Days]')
ylabel('Depth [m]')
ax=gca;
ax.XAxis.Color='w';
ax.YAxis.Color='w';
set(c1,'color','w')
set(ax,'yticklabel',flipud(get(ax,'yticklabel')))
title('LAGRANGIAN')
hold on
nut2=subplot(2,2,3);
pcolor(time,depth,eulnut')
shading interp
c2=colorbar;
ylabel(c2,'Nutrients [mol N/m^3]')
colormap(cmap)
hold on
xlabel('Time [Days]')
ylabel('Depth [m]')
ax=gca;
ax.XAxis.Color='w';
ax.YAxis.Color='w';
set(c2,'color','w')
set(ax,'yticklabel',flipud(get(ax,'yticklabel')))
title('EULERIAN')
assignin('base', 'nut1', nut1)
assignin('base', 'nut2', nut2)
uicontrol('Parent',fignut,'Style','slider','Position',[320,250,200,20],...
'value',0.5, 'min',0, 'max',1,'callback',@colorscalenut);
uicontrol('Style','text',...
'Position',[320,270,200,20],...
'String','color scale','backgroundColor',get(fignut,'color'),'ForegroundColor','w');
set(nut1,'units','pixel')
set(nut2,'units','pixel')
set(nut2,'Position',[60 50 420 180])
set(nut1,'Position',[60 330 420 180])
set(nut1,'fontsize',12)
set(nut2,'fontsize',12)
curs=datacursormode(fignut);
set(curs,'enable','on');
set(curs,'UpdateFcn', @plotnut )
elseif s==2
figgrowth=figure('Name','GROWTH RATE','position',[200 200 1100 550],'Numbertitle','off','menubar','none');
set(figgrowth,'color',[0.2 0.2 0.2])
assignin('base','figgrowth',figgrowth)
growth1=subplot(2,2,1);
assignin('base','growth1',growth1)
pcolor(time,depth,laggrowth')
shading interp
c1=colorbar;
ylabel(c1,'Growth rate [/s]')
xlabel('Time [Days]')
ylabel('Depth [m]')
ax=gca;
ax.XAxis.Color='w';
ax.YAxis.Color='w';
set(c1,'color','w')
set(ax,'yticklabel',flipud(get(ax,'yticklabel')))
title('LAGRANGIAN')
growth2=subplot(2,2,3);
pcolor(time,depth,eulgrowth')
shading interp
c2=colorbar;
ylabel(c2,'Growth rate [/s]')
colormap(cmap)
xlabel('Time [Days]')
ylabel('Depth [m]')
ax=gca;
ax.XAxis.Color='w';
ax.YAxis.Color='w';
set(c2,'color','w')
title('EULERIAN')
set(ax,'yticklabel',flipud(get(ax,'yticklabel')))
assignin('base', 'growth1', growth1)
assignin('base', 'growth2', growth2)
uicontrol('Parent',figgrowth,'Style','slider','Position',[320,250,200,20],...
'value',0.5, 'min',0, 'max',1,'callback',@colorscalegrowth);
uicontrol('Style','text',...
'Position',[320,270,200,20],...
'String','color scale','backgroundColor',get(figgrowth,'color'),'ForegroundColor','w');
set(growth1,'units','pixel')
set(growth2,'units','pixel')
set(growth2,'Position',[60 50 420 180])
set(growth1,'Position',[60 330 420 180])
set(growth1,'fontsize',12)
set(growth2,'fontsize',12)
curs=datacursormode(figgrowth);
set(curs,'enable','on');
set(curs,'UpdateFcn', @plotgrowthdistrib )
elseif s==3
figQ=figure('Name','NUTRIENT CELL QUOTA','position',[200 200 1100 550],'Numbertitle','off','menubar','none');
set(figQ,'color',[0.2 0.2 0.2])
assignin('base','figQ',figQ)
Q1=subplot(2,2,1);
assignin('base','Q1',Q1)
pcolor(time,depth,lagQ')
shading interp
c1=colorbar;
xlabel('Time [Days]')
ylabel('Depth [m]')
ax=gca;
ax.XAxis.Color='w';
ax.YAxis.Color='w';
set(c1,'color','w')
title('LAGRANGIAN')
ylabel(c1,'Cell quota [mol N/mol C]')
Q2=subplot(2,2,3);
pcolor(time,depth,eulQ')
shading interp
c2=colorbar;
set(c2,'color','w')
ylabel(c2,'Cell quota [mol N/mol C]')
colormap(cmap)
xlabel('Time [Days]')
ylabel('Depth [m]')
ax=gca;
ax.XAxis.Color='w';
ax.YAxis.Color='w';
assignin('base', 'Q1', Q1)
assignin('base', 'Q2', Q2)
title('EULERIAN')
uicontrol('Parent',figQ,'Style','slider','Position',[320,250,200,20],...
'value',0.5, 'min',0, 'max',1,'callback',@colorscaleQ);
uicontrol('Style','text',...
'Position',[320,270,200,20],...
'String','color scale','backgroundColor',get(figQ,'color'),'ForegroundColor','w');
set(Q1,'units','pixel')
set(Q2,'units','pixel')
set(Q2,'Position',[60 50 420 180])
set(Q1,'Position',[60 330 420 180])
set(Q1,'fontsize',12)
set(Q2,'fontsize',12)
curs=datacursormode(figQ);
set(curs,'enable','on');
set(curs,'UpdateFcn', @plotQdistrib )
elseif s==5
light=evalin('base','light');
figlight=figure('Name','INCIDENT LIGHT','position',[200 200 800 300],'Numbertitle','off','menubar','none');
set(figlight,'color',[0.2 0.2 0.2])
assignin('base','figlight',figlight)
plot(time(2:end),light,'linewidth',1.5,'color','y')
xlabel('Time [Days]')
ylabel('Incident light')
set(gca,'color','none')
ax=gca;
ax.XAxis.Color='w';
ax.YAxis.Color='w';
grid on
elseif s==6
diffusivity=evalin('base','diffusivity');
figdif=figure('Name','DIFFUSIVITY','position',[200 200 800 350],'Numbertitle','off','menubar','none');
assignin('base','figdif',figdif)
pcolor(time,depth,diffusivity(:,1:end-1)')
shading interp
colorbar
colormap(cmap)
xlabel('Time [Days]')
ylabel('Depth [m]')
set(gca,'color','none')
ax=gca;
ax.XAxis.Color='w';
ax.YAxis.Color='w';
end
end
function colorscale(source,event)
bio1=evalin('base','bio1');
bio2= evalin( 'base','bio2');
up=get(source,'value');
current_cax=caxis(bio1);
caxis(bio1,[0 up])
caxis(bio2,[0 up])
end
function colorscaleQ(source,event)
Q1=evalin('base','Q1');
Q2= evalin( 'base','Q2');
up=get(source,'value');
current_cax=caxis(Q1);
caxis(Q1,[0 up])
caxis(Q2,[0 up])
end
function colorscalegrowth(source,event)
growth1=evalin('base','growth1');
growth2= evalin( 'base','growth2');
up=get(source,'value');
current_cax=caxis(growth1);
caxis(growth1,[0 up])
caxis(growth2,[0 up])
end
function colorscalenut(source,event)
nut1=evalin('base','nut1');
nut2= evalin( 'base','nut2');
up=get(source,'value');
current_cax=caxis(nut1);
caxis(nut1,[0 up])
caxis(nut2,[0 up])
end
function calc_biotot(source,event)
figbiotot=figure('Name',' TOTAL BIOMASS','position',[200 200 500 500],'Numbertitle','off','menubar','none');
set(figbiotot,'color',[0.2 0.2 0.2])
eulbio=evalin('base','eulbio');
lagbio=evalin('base','lagbio');
depth=evalin('base','depth');
time=evalin('base','time');
dz=diff(depth);
dz=dz(1);
biototeul=sum(eulbio,2)*dz;
biototlag=sum(lagbio,2)*dz;
plot(time,biototlag,'color','r','linewidth',1.5)
hold on
plot(time,biototeul,'linewidth',1.5,'color','b')
hold off
ylabel('total biomass [mol]')
xlabel('Time [Days]')
l=legend('LAGRANGIAN','EULERIAN');
set(l,'box','off')
set(gca,'color','none')
ax=gca;
ax.XAxis.Color='w';
ax.YAxis.Color='w';
grid on
end
function txt = plotQdistrib(source,event)
Q1=evalin('base','Q1');
figQ=evalin('base','figQ');
set(figQ,'color',[0.2 0.2 0.2])
Qdistrib=evalin('base','Qdistrib');
time=evalin('base','time');
depth=evalin('base','depth');
Qcat=evalin('base','Qcat');
eulQ=evalin('base','eulQ');
lagQ=evalin('base','lagQ');
posQ = get(event,'Position');
txt = {['Time: ',num2str(posQ(1))],...
['Depth: ',num2str(posQ(2))]};
if (gca==Q1)
Q3= subplot(2,2,[2 4]) ;
set(gca,'color','none')
ax=gca;
ax.XAxis.Color='w';
ax.YAxis.Color='w';
set(Q3,'units','pixel')
set(Q3,'fontsize',12)
set(Q3,'Position',[680 50 400 480])
[~,posQx]=min(abs(time-posQ(1)));
[~,posQy]=min(abs(depth-posQ(2)));
areaQ=area(Qcat,Qdistrib(round(posQy),:,round(posQx)));