User Guides
Beyond Albedo

Outputting values other than albedo

Albedo predictions are the most common use case for biosnicar. However, the model can return a wide range of different values. This already happens in the downloaded version of biosnicar - you don't have to do anything to enable it. The outputs from the radiative transfer solver, either adding-doubling or Toon, comes in the form of an instance of an Outputs class. This object has the following fields:

  • albedo: Spectral albedo
  • BBA: Broadband albedo calculated from albedo
  • BBAVIS: Broadband albedo in the visible wavelengths only
  • BBANIR: Broadband albedo in the near-infrared wavelengths only
  • total_insolation: Total energy received at the surface in W/m^2
  • abs_slr_btm: Spectrally-integrated absorption by underlying surface
  • abs_vis_btm: Spectrally-integrated absorption by underlying surface in the visible wavelengths only
  • abs_nir_btm: Spectrally-integrated absorption by underlying surface in the near infrared wavelengths only
  • abs_slr_tot: Spectrally-integrated VIS and NIR total column absorption
  • abs_vis_tot: Spectrally-integrated VIS and NIR total column absorption in the visible wavelengths only
  • abs_nir_tot: Spectrally-integrated VIS and NIR total column absorption in the near infrared wavelengths only
  • absorbed_flux_per_layer: energy absorbed in each vertical layer
  • heat_rt: Radiative heating rate in K/hr

It is also possible to extend the scope of Outputs to include some more values that are currently treated as intermediates in the radiative transfer model. For example, upwards and downward fluxes in each layer (output from the calculate_fluxes() function in each solver but not propagated to Outputs).

Note that if you are using the convenience wrapper, get_albedo(), you only have access to the albedo data. This is because the albedo data is extracted from Outputs inside get_albedo() and returned on its own. You can either make a very simple update to get_albedo() by swapping the return value from outputs.albedo to simply outputs, or you can run the individual biosnicar functions without the get_albedo() wrapper. In the latter case, the radiative transfer solvers already return the full set of output values.

Here's how you would update get_albedo to return all the outputs:

# ORIGINAL
  ...
    display_out_data(outputs)
    return outputs.albedo
 
# UPDATED
  ...
    display_out_data(outputs)
    return outputs

And then you could access each output value as follows:

outputs = get_albedo("adding-doubling", plot=False, validate-True)
print(outputs.albedo) # print the albedo
print(outputs.BBA) # print the broadband albedo
# ...etc
 

Here's how you can run the functions individually, without using the get_albedo() wrapper:

from pathlib import Path
from biosnicar.adding_doubling_solver import adding_doubling_solver
from biosnicar.column_OPs import get_layer_OPs, mix_in_impurities
from biosnicar.display import display_out_data, plot_albedo
from biosnicar.setup_snicar import setup_snicar
from biosnicar.toon_rt_solver import toon_solver
from biosnicar.validate_inputs import validate_inputs
 
(
    ice,
    illumination,
    rt_config,
    model_config,
    plot_config,
    impurities,
) = setup_snicar()
 
# now get the optical properties of the ice column
ssa_snw, g_snw, mac_snw = get_layer_OPs(ice, model_config)
tau, ssa, g, L_snw = mix_in_impurities(
    ssa_snw, g_snw, mac_snw, ice, impurities, model_config
)
# now run one or both of the radiative transfer solvers
outputs = adding_doubling_solver(tau, ssa, g, L_snw, ice, illumination, model_config)
 
# now you have access to all the output values. You can access them for plotting or 
# printing, or using in some other way.
 
plot_albedo(plot_config, model_config, outputs.albedo) # plot albedo
print(outputs.BBA) # print broadband albedo