This header file contains the definition of the structures required to handle I/O. More...
#include <snowpack/DataClasses.h>#include <cstdarg>#include <string>#include <cstring>#include <vector>Go to the source code of this file.
Namespaces | |
| namespace | snowpack |
| Return the library version. | |
Macros | |
Conversion macros | |
| #define | M_TO_CM(l) ( (l) * 100. ) |
| For lengths. More... | |
| #define | M_TO_MM(l) ( (l) * 1000. ) |
| #define | CM_TO_M(l) ( (l) / 100. ) |
| #define | MM_TO_M(l) ( (l) / 1000. ) |
| #define | MM_TO_CM(l) ( (l) / 10. ) |
| #define | D_TO_H(t) ( (t) * 24. ) |
| For time. More... | |
| #define | D_TO_M(t) ( (t) * 1440. ) |
| #define | D_TO_S(t) ( (t) * 86400. ) |
| #define | H_TO_D(t) ( (t) / 24.0 ) |
| #define | H_TO_M(t) ( (t) * 60. ) |
| #define | H_TO_S(t) ( (t) * 3600. ) |
| #define | M_TO_D(t) ( (t) / 1440. ) |
| #define | M_TO_H(t) ( (t) / 60. ) |
| #define | M_TO_S(t) ( (t) * 60. ) |
| #define | S_TO_D(t) ( (t) / 86400. ) |
| #define | S_TO_H(t) ( (t) / 3600. ) |
| #define | S_TO_M(t) ( (t) / 60. ) |
Functions | |
| std::string | snowpack::getLibVersion () |
| void | prn_msg (const char *fileAndPath, const int theLine, const char *msg_type, const mio::Date &date_in, const char *format,...) |
| Print a message to screen (see p.351-352[,469] in C: The Complete Reference) If date_in is Date(), no running date will be written, otherwise write date_in to (<t>) The output format depends on message type: More... | |
| bool | booleanTime (const double &JulianDate, double days_between, const double &start, const double &calculation_step_length) |
| Determines whether a certain time has been reached (e.g. to dump output) The function returns TRUE whenever JulianDate >= start && JulianDate == start + n*days_between, n=0,1,2,... More... | |
| void | deleteOldOutputFiles (const std::string &outdir, const std::string &experiment, const std::string &stationID, const unsigned int &nSlopes, const std::vector< std::string > &vecExtensions) |
| Delete old output files (*.sno, *.ini) from outdir. More... | |
| void | averageFluxTimeSeries (const size_t &n_steps, const bool &useCanopyModel, SurfaceFluxes &Sdata, SnowStation &Xdata) |
| Averages energy fluxes. More... | |
| void | typeToCode (int *F1, int *F2, int *F3, int type) |
| Decompose type in its constituents At present decomposition into Swiss numerical code TODO Adapt to new international code. More... | |
| double | unitConversion (const double val, char *unitIn, char *unitOut) |
| Performs simple unit conversion (supports temperature, prefixes and exponents) More... | |
| bool | massBalanceCheck (const SnowStation &Xdata, const SurfaceFluxes &Sdata, double &tot_mass_in) |
| Performs mass balance check either before or after a calculation time step. More... | |
| size_t | findUpperNode (const double &z, const std::vector< NodeData > &Ndata, const size_t &nN) |
| Returns number of lowest node above a given position z perpendicular to slope (m) . More... | |
| double | forcedErosion (const double hs, SnowStation &Xdata) |
| Forced erosion of a missed event. More... | |
| void | deflateInflate (const CurrentMeteo &Mdata, SnowStation &Xdata, double &dhs_corr, double &mass_corr, const bool &prn_check) |
| Deflates or inflates the snowpack for warning service purposes. More... | |
| double | logisticFunction (const double input, const double threshold, const double width) |
| Logistic function. More... | |
| void | cumulate (double &accu, const double value) |
| Cumulate if and only if value is defined. More... | |
| void | checkOldOutputFiles (const mio::Date &i_date, const std::string &stationID) |
| double | getPerpSensorPosition (const bool &useSoilLayers, const double &z_vert, const double &hs_ref, const double &Ground, const double &SlopeAngle) |
| Returns sensor position perpendicular to slope (m). Negative vertical height indicates depth from either snow or ground surface (depending on useSoilLayers). For example, a sensor at -0.1 when useSoilLayers=false means a snow temperature at 10cm below the surface; a sensor at -0.2 when useSoilLayers=true means a soil temperature 20cm deep in the ground. NOTE: Depth from snow surface cannot be used with SNP_SOIL set. More... | |
This header file contains the definition of the structures required to handle I/O.
| #define CM_TO_M | ( | l | ) | ( (l) / 100. ) |
| #define D_TO_H | ( | t | ) | ( (t) * 24. ) |
For time.
| #define D_TO_M | ( | t | ) | ( (t) * 1440. ) |
| #define D_TO_S | ( | t | ) | ( (t) * 86400. ) |
| #define H_TO_D | ( | t | ) | ( (t) / 24.0 ) |
| #define H_TO_M | ( | t | ) | ( (t) * 60. ) |
| #define H_TO_S | ( | t | ) | ( (t) * 3600. ) |
| #define M_TO_CM | ( | l | ) | ( (l) * 100. ) |
For lengths.
| #define M_TO_D | ( | t | ) | ( (t) / 1440. ) |
| #define M_TO_H | ( | t | ) | ( (t) / 60. ) |
| #define M_TO_MM | ( | l | ) | ( (l) * 1000. ) |
| #define M_TO_S | ( | t | ) | ( (t) * 60. ) |
| #define MM_TO_CM | ( | l | ) | ( (l) / 10. ) |
| #define MM_TO_M | ( | l | ) | ( (l) / 1000. ) |
| #define S_TO_D | ( | t | ) | ( (t) / 86400. ) |
| #define S_TO_H | ( | t | ) | ( (t) / 3600. ) |
| #define S_TO_M | ( | t | ) | ( (t) / 60. ) |
| void averageFluxTimeSeries | ( | const size_t & | n_steps, |
| const bool & | useCanopyModel, | ||
| SurfaceFluxes & | Sdata, | ||
| SnowStation & | Xdata | ||
| ) |
Averages energy fluxes.
| n_steps | Number of calculation time steps since last output |
| useCanopyModel | |
| Sdata | |
| Xdata |
| bool booleanTime | ( | const double & | JulianDate, |
| double | days_between, | ||
| const double & | start, | ||
| const double & | calculation_step_length | ||
| ) |
Determines whether a certain time has been reached (e.g. to dump output) The function returns TRUE whenever JulianDate >= start && JulianDate == start + n*days_between, n=0,1,2,...
| JulianDate | Julian Date |
| days_between | number of days between two outputs |
| start | start date as Julian Date |
| calculation_step_length | (min) //HACK: it should be in SI!! |
| void checkOldOutputFiles | ( | const mio::Date & | i_date, |
| const std::string & | stationID | ||
| ) |
| void cumulate | ( | double & | accu, |
| const double | value | ||
| ) |
Cumulate if and only if value is defined.
| accu | cumulator |
| value | to be added to accu |
| void deflateInflate | ( | const CurrentMeteo & | Mdata, |
| SnowStation & | Xdata, | ||
| double & | dhs_corr, | ||
| double & | mass_corr, | ||
| const bool & | prn_check | ||
| ) |
Deflates or inflates the snowpack for warning service purposes.
| Mdata | |
| Xdata | |
| dhs_corr | Correction on calculated snow depth (m) |
| mass_corr | Mass correction (kg m-2) |
| prn_check | If set to true, output an information message when correcting for a missed erosion event or wrong settling |
| void deleteOldOutputFiles | ( | const std::string & | outdir, |
| const std::string & | experiment, | ||
| const std::string & | stationID, | ||
| const unsigned int & | nSlopes, | ||
| const std::vector< std::string > & | vecExtension | ||
| ) |
Delete old output files (*.sno, *.ini) from outdir.
| outdir | Output dir |
| experiment | Name of ongoing experiment |
| stationID | |
| nSlopes | Number of slopes treated |
| vecExtension | file extensions that have to be removed |
| size_t findUpperNode | ( | const double & | z, |
| const vector< NodeData > & | Ndata, | ||
| const size_t & | nN | ||
| ) |
Returns number of lowest node above a given position z perpendicular to slope (m)
.
| z | Position perpendicular to slope (m) |
| Ndata | |
| nN | Number of nodes |
| double forcedErosion | ( | const double | hs, |
| SnowStation & | Xdata | ||
| ) |
Forced erosion of a missed event.
| hs | Snow depth to assimilate |
| Xdata |
| double getPerpSensorPosition | ( | const bool & | useSoilLayers, |
| const double & | z_vert, | ||
| const double & | hs_ref, | ||
| const double & | Ground, | ||
| const double & | SlopeAngle | ||
| ) |
Returns sensor position perpendicular to slope (m). Negative vertical height indicates depth from either snow or ground surface (depending on useSoilLayers). For example, a sensor at -0.1 when useSoilLayers=false means a snow temperature at 10cm below the surface; a sensor at -0.2 when useSoilLayers=true means a soil temperature 20cm deep in the ground. NOTE: Depth from snow surface cannot be used with SNP_SOIL set.
| useSoilLayers | Are soil layers defined? |
| z_vert | Vertical position of the sensor (m) |
| hs_ref | Height of snow to refer to (m) |
| Ground | Ground level (m) |
| SlopeAngle | (rad) |
| double logisticFunction | ( | const double | input, |
| const double | threshold, | ||
| const double | width | ||
| ) |
Logistic function.
| input | value |
| threshold | Threshold of logistic function |
| width | Width of logistic function |
| bool massBalanceCheck | ( | const SnowStation & | Xdata, |
| const SurfaceFluxes & | Sdata, | ||
| double & | tot_mass_in | ||
| ) |
Performs mass balance check either before or after a calculation time step.
| Xdata | |
| Sdata | |
| tot_mass_in | Total mass after last time step (kg m-2) |
| void prn_msg | ( | const char * | fileAndPath, |
| const int | theLine, | ||
| const char * | msg_type, | ||
| const mio::Date & | date_in, | ||
| const char * | format, | ||
| ... | |||
| ) |
Print a message to screen (see p.351-352[,469] in C: The Complete Reference)
If date_in is Date(), no running date will be written,
otherwise write date_in to (<t>)
The output format depends on message type:
| *fileAndPath | |
| theLine | |
| *msg_type | See above |
| date_in | Use Date() if date_in is not available. |
| *format | Format for message |
| ... | Variable number of parameters to format |
| void typeToCode | ( | int * | F1, |
| int * | F2, | ||
| int * | F3, | ||
| int | type | ||
| ) |
Decompose type in its constituents At present decomposition into Swiss numerical code
TODO Adapt to new international code.
| F1 | Majority grain shape |
| F2 | Minority grain shape |
| F3 | 2 indicates a melt-freeze crust |
| type | aggregated shape information |
| double unitConversion | ( | const double | val, |
| char * | unitIn, | ||
| char * | unitOut | ||
| ) |
Performs simple unit conversion (supports temperature, prefixes and exponents)
| val | Value (expressed in unitIn) |
| unitIn | (units of input) |
| unitOut | (units of output) return Value (expressed in unitOut) |