1- function bin_to_csv(fnames , n_col , ns , options , SoilLayer , GroundwaterSettings )
1+ function bin_to_csv(fnames , n_col , ns , options , SoilLayer , GroundwaterSettings , FullCSVfiles )
22 %% flu
33 flu_names = {' simulation_number' , ' nu_iterations' , ' year' , ' DoY' , ...
44 ' Rntot' , ' lEtot' , ' Htot' , ...
@@ -91,60 +91,6 @@ function bin_to_csv(fnames, n_col, ns, options, SoilLayer, GroundwaterSettings)
9191 Sim_qtot_units = repelem({' cm s-1' }, length(depth ));
9292 write_output(Sim_qtot_names , Sim_qtot_units , fnames .Sim_qtot_file , n_col .Sim_qtot , ns , true );
9393
94- %% Spectrum (added on 19 September 2008)
95- spectrum_hemis_optical_names = {' hemispherically integrated radiation spectrum' };
96- spectrum_hemis_optical_units = {' W m-2 um-1' };
97- write_output(spectrum_hemis_optical_names , spectrum_hemis_optical_units , fnames .spectrum_hemis_optical_file , n_col .spectrum_hemis_optical , ns , true );
98-
99- spectrum_obsdir_optical_names = {' radiance spectrum in observation direction' };
100- spectrum_obsdir_optical_units = {' W m-2 sr-1 um-1' };
101- write_output(spectrum_obsdir_optical_names , spectrum_obsdir_optical_units , fnames .spectrum_obsdir_optical_file , n_col .spectrum_obsdir_optical , ns , true );
102-
103- if options .calc_ebal
104- write_output({' thermal BlackBody emission spectrum in observation direction' }, {' W m-2 sr-1 um-1' }, ...
105- fnames .spectrum_obsdir_BlackBody_file , n_col .spectrum_obsdir_BlackBody , ns , true );
106- if options .calc_planck
107- write_output({' thermal emission spectrum in hemispherical direction' }, {' W m-2 sr-1 um-1' }, ...
108- fnames .spectrum_hemis_thermal_file , n_col .spectrum_hemis_thermal , ns , true );
109- write_output({' thermal emission spectrum in observation direction' }, {' W m-2 sr-1 um-1' }, ...
110- fnames .spectrum_obsdir_thermal_file , n_col .spectrum_obsdir_thermal , ns , true );
111- end
112- end
113- write_output({' irradiance' }, {' W m-2 um-1' }, ...
114- fnames .irradiance_spectra_file , n_col .irradiance_spectra , ns , true );
115- write_output({' reflectance' }, {' fraction of radiation in observation direction *pi / irradiance' }, ...
116- fnames .reflectance_file , n_col .reflectance , ns , true );
117- %% input and parameter values (added June 2012)
118- % write_output(fnames.pars_and_input_file, true)
119- % write_output(fnames.pars_and_input_short_file, true)
120- %% Optional Output
121- if options .calc_vert_profiles
122- write_output({' Fraction leaves in the sun, fraction of observed, fraction of observed&visible per layer' }, {' rows: simulations or time steps, columns: layer numbers' }, ...
123- fnames .gap_file , n_col .gap , ns , true );
124- write_output({' aPAR per leaf layer' }, {' umol m-2 s-1' }, ...
125- fnames .layer_aPAR_file , n_col .layer_aPAR , ns , true );
126- write_output({' aPAR by Cab per leaf layer' }, {' umol m-2 s-1' }, ...
127- fnames .layer_aPAR_Cab_file , n_col .layer_aPAR_Cab , ns , true );
128- if options .calc_ebal
129- write_output({' leaf temperature of sunlit leaves, shaded leaves, and weighted average leaf temperature per layer' }, {' ^oC ^oC ^oC' }, ...
130- fnames .leaftemp_file , n_col .leaftemp , ns , true );
131- write_output({' sensible heat flux per layer' }, {' W m-2' }, ...
132- fnames .layer_H_file , n_col .layer_H , ns , true );
133- write_output({' latent heat flux per layer' }, {' W m-2' }, ...
134- fnames .layer_LE_file , n_col .layer_LE , ns , true );
135- write_output({' photosynthesis per layer' }, {' umol m-2 s-1' }, ...
136- fnames .layer_A_file , n_col .layer_A , ns , true );
137- write_output({' average NPQ = 1-(fm-fo)/(fm0-fo0), per layer' }, {' ' }, ...
138- fnames .layer_NPQ_file , n_col .layer_NPQ , ns , true );
139- write_output({' net radiation per leaf layer' }, {' W m-2' }, ...
140- fnames .layer_Rn_file , n_col .layer_Rn , ns , true );
141- end
142- if options .calc_fluor
143- fluorescence_names = {' supward fluorescence per layer' };
144- fluorescence_units = {' W m-2' };
145- write_output(fluorescence_names , fluorescence_units , fnames .layer_fluorescence_file , n_col .layer_fluorescence , ns , true );
146- end
147- end
14894 if options .calc_fluor
14995 write_output({' fluorescence per simulation for wavelengths of 640 to 850 nm, with 1 nm resolution' }, {' W m-2 um-1 sr-1' }, ...
15096 fnames .fluorescence_file , n_col .fluorescence , ns , true );
@@ -154,21 +100,83 @@ function bin_to_csv(fnames, n_col, ns, options, SoilLayer, GroundwaterSettings)
154100 write_output({' fluorescence per simulation for wavelengths of 640 to 850 nm, with 1 nm resolution, for PSII only' }, {' W m-2 um-1 sr-1' }, ...
155101 fnames .fluorescencePSII_file , n_col .fluorescencePSII , ns , true );
156102 end
157- write_output({' hemispherically integrated fluorescence per simulation for wavelengths of 640 to 850 nm, with 1 nm resolution' }, {' W m-2 um-1' }, ...
158- fnames .fluorescence_hemis_file , n_col .fluorescence_hemis , ns , true );
159- write_output({' total emitted fluorescence by all leaves for wavelengths of 640 to 850 nm, with 1 nm resolution' }, {' W m-2 um-1' }, ...
160- fnames .fluorescence_emitted_by_all_leaves_file , n_col .fluorescence_emitted_by_all_leaves , ns , true );
161- write_output({' total emitted fluorescence by all photosystems for wavelengths of 640 to 850 nm, with 1 nm resolution' }, {' W m-2 um-1' }, ...
162- fnames .fluorescence_emitted_by_all_photosystems_file , n_col .fluorescence_emitted_by_all_photosystems , ns , true );
163- write_output({' TOC fluorescence contribution from sunlit leaves for wavelengths of 640 to 850 nm, with 1 nm resolution' }, {' W m-2 um-1 sr-1' }, ...
164- fnames .fluorescence_sunlit_file , n_col .fluorescence_sunlit , ns , true );
165- write_output({' TOC fluorescence contribution from shaded leaves for wavelengths of 640 to 850 nm, with 1 nm resolution' }, {' W m-2 um-1 sr-1' }, ...
166- fnames .fluorescence_shaded_file , n_col .fluorescence_shaded , ns , true );
167- write_output({' TOC fluorescence contribution from from leaves and soil after scattering for wavelenghts of 640 to 850 nm, with 1 nm resolution' }, {' W m-2 um-1 sr-1' }, ...
168- fnames .fluorescence_scattered_file , n_col .fluorescence_scattered , ns , true );
169103 end
170- write_output({' Bottom of canopy irradiance in the shaded fraction, and average BOC irradiance' }, {' First 2162 columns: shaded fraction. Last 2162 columns: average BOC irradiance. Unit: Wm-2 um-1' }, ...
171- fnames .BOC_irradiance_file , n_col .BOC_irradiance , ns , true );
104+
105+ % Optional for large output files
106+ if FullCSVfiles
107+ %% Spectrum (added on 19 September 2008)
108+ spectrum_hemis_optical_names = {' hemispherically integrated radiation spectrum' };
109+ spectrum_hemis_optical_units = {' W m-2 um-1' };
110+ write_output(spectrum_hemis_optical_names , spectrum_hemis_optical_units , fnames .spectrum_hemis_optical_file , n_col .spectrum_hemis_optical , ns , true );
111+
112+ spectrum_obsdir_optical_names = {' radiance spectrum in observation direction' };
113+ spectrum_obsdir_optical_units = {' W m-2 sr-1 um-1' };
114+ write_output(spectrum_obsdir_optical_names , spectrum_obsdir_optical_units , fnames .spectrum_obsdir_optical_file , n_col .spectrum_obsdir_optical , ns , true );
115+
116+ if options .calc_ebal
117+ write_output({' thermal BlackBody emission spectrum in observation direction' }, {' W m-2 sr-1 um-1' }, ...
118+ fnames .spectrum_obsdir_BlackBody_file , n_col .spectrum_obsdir_BlackBody , ns , true );
119+ if options .calc_planck
120+ write_output({' thermal emission spectrum in hemispherical direction' }, {' W m-2 sr-1 um-1' }, ...
121+ fnames .spectrum_hemis_thermal_file , n_col .spectrum_hemis_thermal , ns , true );
122+ write_output({' thermal emission spectrum in observation direction' }, {' W m-2 sr-1 um-1' }, ...
123+ fnames .spectrum_obsdir_thermal_file , n_col .spectrum_obsdir_thermal , ns , true );
124+ end
125+ end
126+ write_output({' irradiance' }, {' W m-2 um-1' }, ...
127+ fnames .irradiance_spectra_file , n_col .irradiance_spectra , ns , true );
128+ write_output({' reflectance' }, {' fraction of radiation in observation direction *pi / irradiance' }, ...
129+ fnames .reflectance_file , n_col .reflectance , ns , true );
130+
131+ %% input and parameter values (added June 2012)
132+ % write_output(fnames.pars_and_input_file, true)
133+ % write_output(fnames.pars_and_input_short_file, true)
134+
135+ %% Optional Output
136+ if options .calc_vert_profiles
137+ write_output({' Fraction leaves in the sun, fraction of observed, fraction of observed&visible per layer' }, {' rows: simulations or time steps, columns: layer numbers' }, ...
138+ fnames .gap_file , n_col .gap , ns , true );
139+ write_output({' aPAR per leaf layer' }, {' umol m-2 s-1' }, ...
140+ fnames .layer_aPAR_file , n_col .layer_aPAR , ns , true );
141+ write_output({' aPAR by Cab per leaf layer' }, {' umol m-2 s-1' }, ...
142+ fnames .layer_aPAR_Cab_file , n_col .layer_aPAR_Cab , ns , true );
143+ if options .calc_ebal
144+ write_output({' leaf temperature of sunlit leaves, shaded leaves, and weighted average leaf temperature per layer' }, {' ^oC ^oC ^oC' }, ...
145+ fnames .leaftemp_file , n_col .leaftemp , ns , true );
146+ write_output({' sensible heat flux per layer' }, {' W m-2' }, ...
147+ fnames .layer_H_file , n_col .layer_H , ns , true );
148+ write_output({' latent heat flux per layer' }, {' W m-2' }, ...
149+ fnames .layer_LE_file , n_col .layer_LE , ns , true );
150+ write_output({' photosynthesis per layer' }, {' umol m-2 s-1' }, ...
151+ fnames .layer_A_file , n_col .layer_A , ns , true );
152+ write_output({' average NPQ = 1-(fm-fo)/(fm0-fo0), per layer' }, {' ' }, ...
153+ fnames .layer_NPQ_file , n_col .layer_NPQ , ns , true );
154+ write_output({' net radiation per leaf layer' }, {' W m-2' }, ...
155+ fnames .layer_Rn_file , n_col .layer_Rn , ns , true );
156+ end
157+ if options .calc_fluor
158+ fluorescence_names = {' supward fluorescence per layer' };
159+ fluorescence_units = {' W m-2' };
160+ write_output(fluorescence_names , fluorescence_units , fnames .layer_fluorescence_file , n_col .layer_fluorescence , ns , true );
161+ end
162+ end
163+ if options .calc_fluor
164+ write_output({' hemispherically integrated fluorescence per simulation for wavelengths of 640 to 850 nm, with 1 nm resolution' }, {' W m-2 um-1' }, ...
165+ fnames .fluorescence_hemis_file , n_col .fluorescence_hemis , ns , true );
166+ write_output({' total emitted fluorescence by all leaves for wavelengths of 640 to 850 nm, with 1 nm resolution' }, {' W m-2 um-1' }, ...
167+ fnames .fluorescence_emitted_by_all_leaves_file , n_col .fluorescence_emitted_by_all_leaves , ns , true );
168+ write_output({' total emitted fluorescence by all photosystems for wavelengths of 640 to 850 nm, with 1 nm resolution' }, {' W m-2 um-1' }, ...
169+ fnames .fluorescence_emitted_by_all_photosystems_file , n_col .fluorescence_emitted_by_all_photosystems , ns , true );
170+ write_output({' TOC fluorescence contribution from sunlit leaves for wavelengths of 640 to 850 nm, with 1 nm resolution' }, {' W m-2 um-1 sr-1' }, ...
171+ fnames .fluorescence_sunlit_file , n_col .fluorescence_sunlit , ns , true );
172+ write_output({' TOC fluorescence contribution from shaded leaves for wavelengths of 640 to 850 nm, with 1 nm resolution' }, {' W m-2 um-1 sr-1' }, ...
173+ fnames .fluorescence_shaded_file , n_col .fluorescence_shaded , ns , true );
174+ write_output({' TOC fluorescence contribution from from leaves and soil after scattering for wavelenghts of 640 to 850 nm, with 1 nm resolution' }, {' W m-2 um-1 sr-1' }, ...
175+ fnames .fluorescence_scattered_file , n_col .fluorescence_scattered , ns , true );
176+ end
177+ write_output({' Bottom of canopy irradiance in the shaded fraction, and average BOC irradiance' }, {' First 2162 columns: shaded fraction. Last 2162 columns: average BOC irradiance. Unit: Wm-2 um-1' }, ...
178+ fnames .BOC_irradiance_file , n_col .BOC_irradiance , ns , true );
179+ end
172180
173181 fclose(' all' );
174182
@@ -177,7 +185,6 @@ function bin_to_csv(fnames, n_col, ns, options, SoilLayer, GroundwaterSettings)
177185 for k = 1 : numel(fn )
178186 delete(fnames.(fn{k }));
179187 end
180-
181188end
182189
183190function write_output(header , units , bin_path , f_n_col , ns , not_header )
0 commit comments