SNOWPACK 20241226.26c8720
Programming with libsnowpack

Snowpack is now distributed as a very simple application that delegates most of the work to a library, libsnowpack. This C++ library can easily be integrated in other models/applications. In order to do so, the following header have to be included:

#include <meteoio/MeteoIO.h>

Usually, MeteoIO is used to get the meteorological data and the meteoio meteo data class (mio::MeteoData) is converted to Snowpack meteo data class (CurrentMeteo). The Snowpack specific configuration options are stored in a SnowpackConfig class that is passed to the various other objects.

The main computation is performed by the Snowpack class that needs the following data for its Snowpack::runSnowpackModel call:

  • the meteo data for the current timestamp as a CurrentMeteo object;
  • the information about the specific location where the snowpack is simulated contained in a SnowStation object;
  • the boundary conditions in a BoundCond object;
  • the surface fluxes in a SurfaceFluxes object.

In order to initialize some of these objects from data stored in files, a helper class has been designed: SnowpackIO. Of interest are the following calls: SnowpackIO::readSnowCover, SnowpackIO::writeSnowCover, SnowpackIO::writeProfile, SnowpackIO::writeTimeSeries. Please keep in mind that the Snowpack parameters are internally always given perpendicularly to the ground.

In order to compute hazard relevant data, the Hazard class has been designed. The stability data is computed by the Stability class. Some information has to be exchanged between the SnowpackIO object and the Hazard and/or Stability objects. This is handled by the SN_SNOWSOIL_DATA and ZwischenData classes.

In order to ease debugging, these classes redefine the "<<" operator to show in a compact way their relevant content. For example,

SnowStation station;
std::cout << station;
Definition: DataClasses.h:604

shows the relevant parameters of "station":

<station>
<Coords>
Altitude -999
Lat/Long (-999°0'0.000000" , -999°0'0.000000")
Lat/Long (-999 , -999)
X/Y_coords (-999 , -999)
I/J_indices (-999 , -999)
Projection NULL NULL
EPSG -1
</Coords>
ID: MST96
Name: MST96
Slope: -999 bearing: -999
</station>
0 element(s) and 0 node(s). Soil=false canopy=false
Soil: SoilNode=0 depth=0 BareSoil_z0=0
Albedo: mAlbedo=0 cAlbedo=0 SoilAlb=0
Snow: Measured HS=0 Calculated HS=0 New snow=0 of density=0
Energy: ColdContent=0 dIntEnergy=0 SubSurfaceMelt=x SubSurfaceFrze=x
Snowdrift: windward=0 ErosionLevel=0 ErosionMass=0
Stability: S_d(0)=0 S_n(0)=0 S_s(0)=0 S_1=0 S_2=0 S_4(0)=0 S_5(0)=0
Kt= 0
</SnowStation>