WSL/SLF GitLab Repository

Commit 3125e78d authored by Mathias Bavay's avatar Mathias Bavay
Browse files

Some documentation fixes, new gradients (black to white, white to black and...

Some documentation fixes, new gradients (black to white, white to black and blue-white-red) defined and used for new variables in PNGIO (P, ALB and DW). A bug has been fixed for ILWR in GRIBIO as well as a bug when converting geographic coordinates to rotated ones.

New options have been added to the undercatch filter, allowing to specify the temperature thresholds with the CST argument (to make it more similar to GeoTop).
parent bbf8923c
......@@ -309,6 +309,9 @@ void Gradient::set(const Type& type, const double& i_min, const double& i_max, c
else if(type==heat) model = new gr_heat(i_min, i_max, i_autoscale);
else if(type==freeze) model = new gr_freeze(i_min, i_max, i_autoscale);
else if(type==blue) model = new gr_blue(i_min, i_max, i_autoscale);
else if(type==bluewhitered) model = new gr_bluewhitered(i_min, i_max, i_autoscale);
else if(type==whitetoblk) model = new gr_whitetoblk(i_min, i_max, i_autoscale);
else if(type==blktowhite) model = new gr_blktowhite(i_min, i_max, i_autoscale);
else if(type==blue_pink) model = new gr_blue_pink(i_min, i_max, i_autoscale);
else if(type==pastel) model = new gr_pastel(i_min, i_max, i_autoscale);
else if(type==bg_isomorphic) model = new gr_bg_isomorphic(i_min, i_max, i_autoscale);
......@@ -551,6 +554,22 @@ void gr_freeze::getColor(const double &val, double &r, double &g, double &b) con
b = getInterpol(val, X, v_b);
}
gr_bluewhitered::gr_bluewhitered(const double& /*i_min*/, const double& /*i_max*/, const bool& /*i_autoscale*/) {
X.push_back(0.); v_h.push_back(240.); v_s.push_back(.78); v_v.push_back(.99); //deep blue
X.push_back(0.5); v_h.push_back(240.); v_s.push_back(.0); v_v.push_back(.99); //white
X.push_back(1.); v_h.push_back(360.); v_s.push_back(.78); v_v.push_back(.99); //red
}
gr_whitetoblk::gr_whitetoblk(const double& /*i_min*/, const double& /*i_max*/, const bool& /*i_autoscale*/) {
X.push_back(0.); v_h.push_back(0.); v_s.push_back(0.); v_v.push_back(.99); //white
X.push_back(1.); v_h.push_back(0.); v_s.push_back(0.); v_v.push_back(0.); //black
}
gr_blktowhite::gr_blktowhite(const double& /*i_min*/, const double& /*i_max*/, const bool& /*i_autoscale*/) {
X.push_back(0.); v_h.push_back(0.); v_s.push_back(0.); v_v.push_back(0.); //black
X.push_back(1.); v_h.push_back(0.); v_s.push_back(0.); v_v.push_back(.99); //white
}
gr_blue::gr_blue(const double& /*i_min*/, const double& /*i_max*/, const bool& /*i_autoscale*/) {
X.push_back(0.); v_h.push_back(0.); v_s.push_back(0.); v_v.push_back(.99); //5
X.push_back(.16667); v_h.push_back(180.); v_s.push_back(.2); v_v.push_back(.99); //10
......
......@@ -189,6 +189,9 @@ class Gradient {
blue_pink, ///< blue to pink gradient
pastel, ///< same color scale as "slope" but linear
bg_isomorphic, ///< drak-blue to light-green isomorphic gradient
bluewhitered, ///< blue to white, then white to red
whitetoblk, ///< white to black gradient
blktowhite, ///< black to white gradient
blue ///< white to slightly violet gradient. This is similar to the one used for the SLF avalanche bulletin
} Type;
......@@ -291,6 +294,21 @@ class gr_freeze : public Gradient_model {
std::vector<double> X, v_r,v_g,v_b; ///<control points: vector of X and associated r,g,b. They must be in X ascending order
};
class gr_bluewhitered : public Gradient_model {
public:
gr_bluewhitered(const double& i_min, const double& i_max, const bool& i_autoscale);
};
class gr_whitetoblk : public Gradient_model {
public:
gr_whitetoblk(const double& i_min, const double& i_max, const bool& i_autoscale);
};
class gr_blktowhite : public Gradient_model {
public:
gr_blktowhite(const double& i_min, const double& i_max, const bool& i_autoscale);
};
class gr_blue : public Gradient_model {
public:
gr_blue(const double& i_min, const double& i_max, const bool& i_autoscale);
......
......@@ -26,21 +26,21 @@ namespace mio {
* The data access is handled by a system of plugins. They all offer the same interface, meaning that a plugin can transparently be replaced by another one. Since they might rely on third party libraries for accessing the data, they have been created as plugins, that is they are loaded on demand (and also compiled only if requested at compile time). A plugin can therefore fail to load (for example if it does not exist) at run time.
*
* @section available_plugins Available plugins
* So far the following children have been implemented (by keyword for the io.ini key/value config file). Please read the documentation for each plugin in order to know the plugin-specific keywords:
* So far the following plugins have been implemented (by keyword for the io.ini key/value config file). Please read the documentation for each plugin in order to know the plugin-specific keywords:
* - \subpage a3d "A3D" for reading original Alpine3D meteo files (no extra requirements)
* - \subpage arc "ARC" for reading ESRI/ARC DEM files (no extra requirements)
* - \subpage arps "ARPSIO" for reading ARPS formatted DEM (no extra requirements)
* - \subpage borma "BORMA" for reading Borma xml meteo files (requires libxml)
* - \subpage cosmoxml "COSMO" for treading XML files produced by MeteoSwiss COSMO's postprocessing (requires libxml)
* - \subpage imis "IMIS" for reading meteo data out of the IMIS database (requires Oracle's OCCI library)
* - \subpage geotop "GEOTOP" for reading original GeoTop meteo files (no extra requirements)
* - \subpage snowpack "SNOWPACK" for reading original SNOWPACK meteo files (no extra requirements)
* - \subpage gsn "GSN" for reading meteo data out of the Global Sensor Network web service interface (requires GSoap)
* - \subpage arc "ARC" for reading ESRI/ARC DEM files (no extra requirements)
* - \subpage grass "GRASS" for reading Grass DEM files (no extra requirements)
* - \subpage arps "ARPSIO" for reading ARPS formatted DEM (no extra requirements)
* - \subpage gribio "GRIBIO" for reading GRIB meteo grid files (requires grib-api)
* - \subpage gsn "GSN" for reading meteo data out of the Global Sensor Network web service interface (requires GSoap)
* - \subpage imis "IMIS" for reading meteo data out of the IMIS database (requires Oracle's OCCI library)
* - \subpage pgmio "PGMIO" for reading PGM grid files (no extra requirements)
* - \subpage pngio "PNGIO" for reading PNG grid files (requires libpng)
* - \subpage smetio "SMETIO" for reading SMET meteo data files (no extra requirements)
* - \subpage gribio "GribIO" for reading GRIB meteo grid files (requires libgrib)
* - \subpage snowpack "SNOWPACK" for reading original SNOWPACK meteo files (no extra requirements)
*
* @section data_generators Data generators
* It is also possible to duplicate a meteorological parameter as another meteorological parameter. This is done by specifying a COPY key, following the syntax
......
......@@ -23,9 +23,11 @@ using namespace std;
namespace mio {
const double ProcUndercatch::Tsnow=-2., ProcUndercatch::Train=2.; //WMO values from Yan et al (2001)
const double ProcUndercatch::Tsnow_WMO=-2., ProcUndercatch::Train_WMO=2.; //WMO values from Yan et al (2001)
ProcUndercatch::ProcUndercatch(const std::vector<std::string>& vec_args) : ProcessingBlock("UNDERCATCH") {
Tsnow = Tsnow_WMO;
Train = Train_WMO;
parse_args(vec_args);
properties.stage = ProcessingProperties::first; //for the rest: default values
}
......@@ -131,10 +133,16 @@ void ProcUndercatch::parse_args(std::vector<std::string> filter_args)
if(filter_args[0]=="cst") {
type=cst;
if (filter_args.size() < 3)
if(filter_args.size() < 3 || filter_args.size() > 5 || filter_args.size() == 4)
throw InvalidArgumentException("Wrong number of arguments for filter "+getName()+" with rain gauge type \"cst\"", AT);
IOUtils::convertString(factor_snow, filter_args[1]);
IOUtils::convertString(factor_mixed, filter_args[2]);
if(filter_args.size()==5) {
IOUtils::convertString(Tsnow, filter_args[1]);
Tsnow = K_TO_C(Tsnow);
IOUtils::convertString(Train, filter_args[2]);
Train = K_TO_C(Train);
}
} else if(filter_args[0]=="nipher") {
type=nipher;
} else if(filter_args[0]=="tretyakov") {
......
......@@ -46,7 +46,7 @@ of the Hellmann Gauges"</i>, Daqing Yang et al, Nordic Hydrology, <b>30</b>, 199
* therefore this type must be specified as an argument. The coefficients are not always available both for shielded and
* unshielded gauges, so most of the time only one variation will be available and is specified below.
* The following methods can be specified as argument (only one can be specified):
* - cst {factor for snow} {factor for mixed precipitation} - this applies a constant factor to the precipitation
* - cst {factor for snow} {factor for mixed precipitation} - this applies a constant factor to the precipitation. Optionally, the snow and rain threshold temperatures can be given instead of relying on the above values (by adding them at the end of the line).
* - Nipher - National standard rain gauge in Canada, shielded
* - Tretyakov - Designed in USSR in the 1950s, deployed by some national networks in ex-USSR territories, shielded
* - US8sh - US national 8\" rain gauge, shielded
......@@ -90,7 +90,8 @@ class ProcUndercatch : public ProcessingBlock {
sensor_type type;
double factor_snow, factor_mixed;
static const double Tsnow, Train;
double Tsnow, Train;
static const double Tsnow_WMO, Train_WMO;
};
} //end namespace
......
......@@ -30,10 +30,10 @@ using namespace std;
namespace mio {
/**
* @page gribio GRIBIO
* @section gribio_format Format
* @section gribio_format Format and limitations
* This plugin reads GRIB (https://en.wikipedia.org/wiki/GRIB) files as produced by meteorological models.
* Being based on GRIB API (http://www.ecmwf.int/products/data/software/grib_api.html), it should support both version 1 and 2 of the format.
* This has been developed for reading MeteoSwiss Cosmo data and reads fields based on their marsParam code (this is built as {grib parameter number}.{grib table number} the table being preferably table 2, the parameter being preferably WMO standardized, as in http://dss.ucar.edu/docs/formats/grib/gribdoc/params.html) and levels
* Fields are read based on their marsParam code (this is built as {grib parameter number}.{grib table number} the table being preferably table 2, the parameter being preferably WMO standardized, as in http://dss.ucar.edu/docs/formats/grib/gribdoc/params.html) and levels
* (levels description is available at http://www.nco.ncep.noaa.gov/pmb/docs/on388/).
*
* Several assumptions/approximations are held/made when reading grids:
......@@ -46,6 +46,21 @@ namespace mio {
*
* As a side note, when calling read2DGrid(grid, filename), it will returns the first grid that is found.
*
* @section cosmo_partners COSMO Group
* This plugin has been developed primarily for reading GRIB files produced by COSMO (http://www.cosmo-model.org/) at MeteoSwiss.
* COSMO (COnsortium for Small scale MOdelling) represents a non-hydrostatic limited-area atmospheric model, to be used both for operational and for research applications by the members of the consortium. The Consortium has the following members:
* - Germany, DWD, Deutscher Wetterdienst
* - Switzerland, MCH, MeteoSchweiz
* - Italy, USAM, Ufficio Generale Spazio Aereo e Meteorologia
* - Greece, HNMS, Hellenic National Meteorological Service
* - Poland, IMGW, Institute of Meteorology and Water Management
* - Romania, NMA, National Meteorological Administration
* - Russia, RHM, Federal Service for Hydrometeorology and Environmental Monitoring
* - Germany, AGeoBw, Amt für GeoInformationswesen der Bundeswehr
* - Italy, CIRA, Centro Italiano Ricerche Aerospaziali
* - Italy, ARPA-SIMC, ARPA Emilia Romagna Servizio Idro Meteo Clima
* - Italy, ARPA Piemonte, Agenzia Regionale per la Protezione Ambientale Piemonte
*
* @section gribio_units Units
* As specified by WMO.
*
......@@ -234,7 +249,7 @@ void GRIBIO::rotatedToTrueLatLon(const double& lat_rot, const double& lon_rot, d
{
const double lat_rot_rad = lat_rot*to_rad;
const double lon_rot_rad = lon_rot*to_rad;
const double lat_pole_rad = -latitudeOfSouthernPole*to_rad;
const double lat_pole_rad = -latitudeOfSouthernPole*to_rad; //HACK
if(latitudeOfSouthernPole==IOUtils::nodata || longitudeOfSouthernPole==IOUtils::nodata) {
throw NoAvailableDataException("Attempting to use latitudeOfSouthernPole and/or longitudeOfSouthernPole without reading them from GRIB!");
......@@ -248,7 +263,7 @@ void GRIBIO::trueLatLonToRotated(const double& lat_true, const double& lon_true,
{
const double lat_true_rad = lat_true*to_rad;
const double lon_true_rad = lon_true*to_rad;
const double lat_pole_rad = -latitudeOfSouthernPole*to_rad;
const double lat_pole_rad = latitudeOfSouthernPole*to_rad;
const double lon_pole_rad = longitudeOfSouthernPole*to_rad;
const double delta_lon_rad = lon_true_rad-lon_pole_rad;
......@@ -484,6 +499,11 @@ void GRIBIO::read2DGrid(const std::string& filename, Grid2DObject& grid_out, con
grid_out.grid2D *= -1.;
} else read2DGrid_indexed(25.201, 1, 0, date, grid_out); //ALWD_S
}
/*if(parameter==MeteoGrids::CLD) { //cloudiness // HACK
if(read2DGrid_indexed(74.2, 1, 0, date, grid_out)) //CLCM
grid_out.grid2D /= 100.;
}*/
if(parameter==MeteoGrids::ISWR) {
if(read2DGrid_indexed(116.2, 1, 0, date, grid_out)) { //short wave
grid_out.grid2D *= -1.;
......@@ -745,7 +765,6 @@ bool GRIBIO::readMeteoMeta(std::vector<Coords>& vecPts, std::vector<StationData>
//build GRIB local coordinates for the points
for(unsigned int ii=0; ii<(unsigned)npoints; ii++) {
trueLatLonToRotated(vecPts[ii].getLat(), vecPts[ii].getLon(), lats[ii], lons[ii]);
std::cout << "lats[" << ii << "]=" << lats[ii] << " lons[" << ii << "]=" << lons[ii] << "\n";
}
//retrieve nearest points
......@@ -871,8 +890,11 @@ void GRIBIO::readMeteoStep(std::vector<StationData> &stations, double *lats, dou
}
//radiation parameters
if(readMeteoValues(115.2, 1, 0, i_date, npoints, lats, lons, values)) fillMeteo(values, MeteoData::ILWR, npoints, Meteo);
else if(readMeteoValues(25.201, 1, 0, i_date, npoints, lats, lons, values)) fillMeteo(values, MeteoData::ILWR, npoints, Meteo); //ALWD_S
if(readMeteoValues(115.2, 1, 0, i_date, npoints, lats, lons, values)) { //long wave
for(unsigned int ii=0; ii<(unsigned)npoints; ii++) {
Meteo[ii](MeteoData::ISWR) = -values[ii];
}
} else if(readMeteoValues(25.201, 1, 0, i_date, npoints, lats, lons, values)) fillMeteo(values, MeteoData::ILWR, npoints, Meteo); //ALWD_S
if(readMeteoValues(116.2, 1, 0, i_date, npoints, lats, lons, values)) fillMeteo(values, MeteoData::ISWR, npoints, Meteo);
else if(readMeteoValues(111.250, 1, 0, i_date, npoints, lats, lons, values)) fillMeteo(values, MeteoData::ISWR, npoints, Meteo); //GLOB
else {
......
......@@ -28,7 +28,7 @@ namespace mio {
/**
* @class GRIBIO
* @brief This is to read GRIB 1 or 2 data files
* @brief This plugin reads GRIB 1 or 2 data files
*
* @ingroup plugins
* @author Mathias Bavay
......
......@@ -18,6 +18,7 @@
#include "PNGIO.h"
#include <meteoio/ResamplingAlgorithms2D.h>
#include <meteoio/Graphics.h>
#include <meteoio/meteolaws/Meteoconst.h>
#include <algorithm>
#include <errno.h>
......@@ -532,6 +533,12 @@ void PNGIO::write2DGrid(const Grid2DObject& grid_in, const MeteoGrids::Parameter
max = 360.;
}
gradient.set(Gradient::azi, min, max, autoscale);
} else if(parameter==MeteoGrids::DW) {
if(!autoscale) {
min = 0.;
max = 360.;
}
gradient.set(Gradient::azi, min, max, autoscale);
} else if(parameter==MeteoGrids::HS) {
if(!autoscale) {
min = 0.; max = 2.5;
......@@ -560,11 +567,22 @@ void PNGIO::write2DGrid(const Grid2DObject& grid_in, const MeteoGrids::Parameter
min = 0.; max = 1.;
}
gradient.set(Gradient::bg_isomorphic, min, max, autoscale);
} else if(parameter==MeteoGrids::P) {
if(!autoscale) {
//lowest and highest pressures ever recorded on Earth: 87000 and 108570
min = 87000.; max = 115650.; //centered around 1 atm
gradient.set(Gradient::bluewhitered, min, max, autoscale);
} else {
const double delta1 = fabs(Cst::std_press-min);
const double delta2 = fabs(max - Cst::std_press);
const double delta = (delta1>delta2)?delta1:delta2;
gradient.set(Gradient::bluewhitered, Cst::std_press-delta, Cst::std_press+delta, autoscale);
}
} else if(parameter==MeteoGrids::ALB) {
if(!autoscale) {
min = 0.; max = 1.;
}
gradient.set(Gradient::bg_isomorphic, min, max, autoscale);
gradient.set(Gradient::blktowhite, min, max, autoscale);
} else if(parameter==MeteoGrids::ISWR) {
if(!autoscale) {
min = 0.; max = 800.;
......
......@@ -28,11 +28,11 @@
namespace mio {
/**
* @class PNGIO
* @brief This (empty) class is to be used as a template for developing new plugins
* @brief This plugin write 2D grids as PNG images.
*
* @ingroup plugins
* @author Mathias Bavay
* @date 2010-06-14
* @date 2012-02-26
*/
class PNGIO : public IOInterface {
public:
......
......@@ -28,7 +28,7 @@ namespace mio {
/**
* @class SMETIO
* @brief This (empty) class is to be used as a template for developing new plugins
* @brief Reads meteo data in the SMET ASCII or binary format.
*
* @ingroup plugins
* @author Mathias Bavay
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment