Public Member Functions | |
ECMWFFileData (const string &name, const string &mode="r") | |
constructor | |
~ECMWFFileData () | |
destructor | |
void | free_geolocation_data () |
free eventually loaded data. Not used here, only for interface compatibility | |
const bool | get_index (const float &lat, const float &lon, const double &time, int *indexes) |
find the index of the nearest point to (lat,lon,time) in the data. time is ignored for ECMWF files because only one time level is used | |
const bool | get_index (const float &lat, const float &lon, int *indexes) |
find the index of the nearest point to (lat,lon) in the data. If (lat,lon,time) is not contained in this file, returned indexes are [-1,-1] | |
const bool | get_index (const float &lat, const float &lon, const float &p_lvl, int *indexes) |
find the index of the nearest point to (lat,lon, p_lvl) in the data. | |
const int | get_lat_index (const float &lat) const |
return the index of the grid point that has the nearest latitude to lat | |
const int | get_lon_index (const float &lon) const |
return the index of the grid point that has the nearest longitude to lon | |
const float32 | get_lat (const int &i_y) const |
return the latitude of the grid point at indice i_y | |
const float32 | get_lon (const int &i_x) const |
return the longitude of the grid point at indice i_x | |
void * | read_data (void *data, const char *sds_name, int *start=NULL, int *stride=NULL, int *edges=NULL, int rank=-1) |
read a subset of a data set | |
ECMWFProductType | get_product_id () const |
accessor to the product type ID | |
const string | get_s_product_id () const |
accessor to the product type as a string | |
int | get_sz_x () const |
accessor to the number of grid cells along the longitudes | |
int | get_sz_y () const |
accessor to the number of grid cells along the latitudes | |
const string | get_grid_desc () |
return a description of the grid (resolution, number of cells,...) as a string | |
const vector< int > | get_pressure_levels (const string &var_name) |
returns the pressure levels of the given variable | |
const int | get_nb_pressure_levels (const string &var_name) |
returns the number of vertical levels of the given variable | |
void | get_hybrid_level_pressures (const double &p_surf, double *v_p_hybrid) const |
accessor to the pressures of the 91 model levels in hPa Source : http://www.ecmwf.int/research/ifsdocs/DYNAMICS/Chap2_Discretization4.html#961180 | |
const double | get_hybrid_level_pressure (const int i_level, const double &p_surf) const |
compute the pressure of an hybrid level, in the 91 levels model Source : http://www.ecmwf.int/research/ifsdocs/DYNAMICS/Chap2_Discretization4.html#961180 | |
template<typename Txout , typename Tyout , typename Txin , typename Tyin > | |
void | get_v_pres_on_alt (Tyout *v_out_pres, const Txout *v_alt, const int sz_alt, const Txin *v_geop, const Tyin *v_inpres, const int n_pres, const string interp_type="linear") |
compute the pressure at a list of altitudes | |
template<typename Txout , typename Txin , typename Tyin > | |
double | get_pres_on_alt (const Txout alt, const Txin *v_ingeop, const Tyin *v_inpres, const int sz_inpres, const string interp_type="linear") |
compute the pressure at a given altitude | |
double | alt_to_geop (const double &alt) |
compute the geopotential of an altitude in m The formula used is : geop = g0 * alt. g0 is assumed to be constant in the atmosphere and on the surface on the earth | |
template<typename Txout , typename Tyout > | |
void | get_abscissa_iso (Tyout *v_out_abs, const Txout *v_out_pres, const int sz_out_pres) |
compute the abscissa of the given pressures in the isobaric levels system. The abscissa is designed to be used lineary with log(P) | |
template<typename Txout , typename Tyout , typename Txin > | |
void | get_abscissa_hybrid (Tyout *v_out_abs, const Txout *v_out_pres, const int sz_out_pres, const Txin *v_in_pres, const int sz_in_pres) |
compute the abscissa of the given pressures in the hybrid levels system. The abscissa is designed to be used lineary with log(P) | |
template<typename Txout , typename Tyout , typename Txin , typename Tyin > | |
void | interp_on_pres (Tyout *v_out_var, const Txout *v_out_abs, const int sz_out, const Tyin *v_in_var, const Txin *v_in_pres, const int sz_in) |
interpolate the variable on the given pressures, using precomputed abscissa based on a linear approach on log(P) | |
void | close_data_file () |
void | open_data_file () |
open the file | |
int | get_n_dataset () |
string | get_dataset_name (int i) |
int | get_dataset_data_type (string sds_name) |
string | get_values_attr_dataset (string sds_name, string attr) |
bool | has_attr_dataset (string sds_name, string attr) |
Static Public Member Functions | |
static const unsigned short * | get_isobaric_level_pressures () |
access to the isobaric levels pressures vector, in hPa and sorted in decreasing order | |
Static Public Attributes | |
static const unsigned short | isobaric_level_pressures [] |
static const int | nb_max_isobaric_level = 26 |
static const double | a_hybrid_91 [92] |
static const double | b_hybrid_91 [92] |
static const int | nb_level_hybrid_91 = 91 |
Protected Types | |
enum | ECMWFProductType { UNDEFINED = 0, ANALYSIS, FORECAST } |
Protected Member Functions | |
void | set_time_coverage () |
compute the time range covered by this file, depending of the product | |
void | parse_filename (const string &short_filename) |
extract sone informations using the filename | |
bool | check_filename (const string &short_filename) const |
test if the filename seems to be a valid ECMWF file | |
void | init_grid () |
read the grid characteristics in the file attributes | |
virtual void | load_time_level () |
if not already set, read the time levels in the file Interface implementation purpose. GRIB ECMWF files are composed of only one time | |
Protected Attributes | |
ECMWFProductType | product_id |
string | version |
int | sz_x |
int | sz_y |
float | lat0 |
float | lon0 |
enum ECMWFFileData::ECMWFProductType [protected] |
the different types of ECMWF products
ECMWFFileData::ECMWFFileData | ( | const string & | name, | |
const string & | mode = "r" | |||
) |
constructor
name | the filename | |
mode | opening mode. only "r" at this time |
References close_data_file(), MeteoFileData::delta_lat, MeteoFileData::delta_lon, MeteoFileData::delta_time, init_grid(), parse_filename(), product_id, FileData::time_coverage, and version.
double ECMWFFileData::alt_to_geop | ( | const double & | alt | ) | [inline] |
compute the geopotential of an altitude in m The formula used is : geop = g0 * alt. g0 is assumed to be constant in the atmosphere and on the surface on the earth
alt | an altitude in m |
Referenced by get_pres_on_alt(), and get_v_pres_on_alt().
bool ECMWFFileData::check_filename | ( | const string & | short_filename | ) | const [protected] |
test if the filename seems to be a valid ECMWF file
short_filename | the filename without its path |
Referenced by parse_filename().
void ECMWFFileData::close_data_file | ( | ) | [virtual] |
--- FOR OLD DATA2GRID INTERFACE compatibility - START ---
Reimplemented from FileData.
Referenced by ECMWFFileData().
void ECMWFFileData::get_abscissa_hybrid | ( | Tyout * | v_out_abs, | |
const Txout * | v_out_pres, | |||
const int | sz_out_pres, | |||
const Txin * | v_in_pres, | |||
const int | sz_in_pres | |||
) |
compute the abscissa of the given pressures in the hybrid levels system. The abscissa is designed to be used lineary with log(P)
v_out_abs | [OUT] pressures abscissa | |
v_out_pres | [IN] searched pressures | |
sz_out_pres | [IN] number of searched pressures | |
v_in_pres | [IN] hybrid levels pressures | |
sz_in_pres | [IN] number of hybrid levels pressures |
void ECMWFFileData::get_abscissa_iso | ( | Tyout * | v_out_abs, | |
const Txout * | v_out_pres, | |||
const int | sz_out_pres | |||
) |
compute the abscissa of the given pressures in the isobaric levels system. The abscissa is designed to be used lineary with log(P)
v_out_abs | [OUT] pressures abscissa | |
v_out_pres | [IN] searched pressures | |
sz_out_pres | [IN] number of searched pressures |
References isobaric_level_pressures, and nb_max_isobaric_level.
const string ECMWFFileData::get_grid_desc | ( | ) |
return a description of the grid (resolution, number of cells,...) as a string
References MeteoFileData::delta_lat, MeteoFileData::delta_lon, lat0, lon0, sz_x, and sz_y.
const double ECMWFFileData::get_hybrid_level_pressure | ( | const int | i_level, | |
const double & | p_surf | |||
) | const [inline] |
compute the pressure of an hybrid level, in the 91 levels model Source : http://www.ecmwf.int/research/ifsdocs/DYNAMICS/Chap2_Discretization4.html#961180
i_level | number of the level. Must ne in range [0,90] | |
p_surf | surface pressure in hPa |
References a_hybrid_91, and nb_level_hybrid_91.
Referenced by get_hybrid_level_pressures().
void ECMWFFileData::get_hybrid_level_pressures | ( | const double & | p_surf, | |
double * | v_p_hybrid | |||
) | const [inline] |
accessor to the pressures of the 91 model levels in hPa Source : http://www.ecmwf.int/research/ifsdocs/DYNAMICS/Chap2_Discretization4.html#961180
p_surf | surface pressure in hPa | |
v_p_hybrid | [OUT] vector of hybrid pressure full levels, from top to bottom. |
References get_hybrid_level_pressure(), and nb_level_hybrid_91.
const bool ECMWFFileData::get_index | ( | const float & | lat, | |
const float & | lon, | |||
int * | indexes | |||
) | [inline] |
find the index of the nearest point to (lat,lon) in the data. If (lat,lon,time) is not contained in this file, returned indexes are [-1,-1]
lat | the latitude | |
lon | the longitude | |
indexes | the output indexes : a 2 values array {lat_index,lon_index} |
References get_lat_index(), and get_lon_index().
const bool ECMWFFileData::get_index | ( | const float & | lat, | |
const float & | lon, | |||
const float & | p_lvl, | |||
int * | indexes | |||
) | [inline] |
find the index of the nearest point to (lat,lon, p_lvl) in the data.
lat | the latitude | |
lon | the longitude | |
p_lvl | the isobaric pressure level in hPa | |
indexes | the output indexes : a 2 values array {lat_index,lon_index} |
const bool ECMWFFileData::get_index | ( | const float & | lat, | |
const float & | lon, | |||
const double & | time, | |||
int * | indexes | |||
) | [inline] |
find the index of the nearest point to (lat,lon,time) in the data. time is ignored for ECMWF files because only one time level is used
g_exception | if lat or lon are invalid |
lat | the latitude | |
lon | the longitude | |
time | the time (using TAI convention) | |
indexes | the output indexes : a 3 values array {lat_index,lon_index,time_index} |
static const unsigned short* ECMWFFileData::get_isobaric_level_pressures | ( | ) | [inline, static] |
access to the isobaric levels pressures vector, in hPa and sorted in decreasing order
References isobaric_level_pressures.
const float32 ECMWFFileData::get_lat | ( | const int & | i_y | ) | const [inline] |
return the latitude of the grid point at indice i_y
i_y | grid point indice along Y |
References MeteoFileData::delta_lat, and lat0.
const int ECMWFFileData::get_lat_index | ( | const float & | lat | ) | const [inline] |
return the index of the grid point that has the nearest latitude to lat
lat | the latitude |
References MeteoFileData::delta_lat, and lat0.
Referenced by get_index().
const float32 ECMWFFileData::get_lon | ( | const int & | i_x | ) | const [inline] |
return the longitude of the grid point at indice i_x
i_x | grid point indice along X |
References MeteoFileData::delta_lon, and lon0.
const int ECMWFFileData::get_lon_index | ( | const float & | lon | ) | const [inline] |
return the index of the grid point that has the nearest longitude to lon
lon | the longitude, in [-180, 180] range |
References MeteoFileData::delta_lon, lon0, and sz_x.
Referenced by get_index().
const int ECMWFFileData::get_nb_pressure_levels | ( | const string & | var_name | ) |
returns the number of vertical levels of the given variable
var_name | the name of the searched variable |
References GribFileData::get_dataset_desc(), and t_grib_var_desc::v_lvl.
double ECMWFFileData::get_pres_on_alt | ( | const Txout | alt, | |
const Txin * | v_ingeop, | |||
const Tyin * | v_inpres, | |||
const int | sz_inpres, | |||
const string | interp_type = "linear" | |||
) |
compute the pressure at a given altitude
alt | [IN] altitude where to compute the pressure in km | |
v_ingeop | [IN] geopotential on input levels in m^2.s^-2 | |
v_inpres | [IN] pressure on input levels in hPa. Stricly decreasing | |
sz_inpres | [IN] number of input levels | |
interp_type | [IN] type of interpolation to use : "linear" , "linear_log" or "spline" |
References alt_to_geop().
Referenced by get_v_pres_on_alt().
const vector< int > ECMWFFileData::get_pressure_levels | ( | const string & | var_name | ) |
returns the pressure levels of the given variable
var_name | the name of the searched variable |
References GribFileData::get_dataset_desc(), and t_grib_var_desc::v_lvl.
ECMWFProductType ECMWFFileData::get_product_id | ( | ) | const [inline] |
const string ECMWFFileData::get_s_product_id | ( | ) | const [inline] |
accessor to the product type as a string
References product_id.
int ECMWFFileData::get_sz_x | ( | ) | const [inline] |
accessor to the number of grid cells along the longitudes
References sz_x.
int ECMWFFileData::get_sz_y | ( | ) | const [inline] |
accessor to the number of grid cells along the latitudes
References sz_y.
void ECMWFFileData::get_v_pres_on_alt | ( | Tyout * | v_out_pres, | |
const Txout * | v_alt, | |||
const int | sz_alt, | |||
const Txin * | v_geop, | |||
const Tyin * | v_inpres, | |||
const int | n_pres, | |||
const string | interp_type = "linear" | |||
) |
compute the pressure at a list of altitudes
v_out_pres | [OUT] output pressure in hPa | |
v_alt | [IN] altitudes where to compute the pressure in km | |
sz_alt | [IN] number of altitudes and output pressures | |
v_geop | [IN] geopotential on input levels in m^2.s^-2 | |
v_inpres | [IN] pressure on input levels in hPa. Stricly decreasing | |
n_pres | [IN] number of input levels | |
interp_type | [IN] type of interpolation to use : "linear" , "linear_log" or "spline" |
References alt_to_geop(), and get_pres_on_alt().
void ECMWFFileData::interp_on_pres | ( | Tyout * | v_out_var, | |
const Txout * | v_out_abs, | |||
const int | sz_out, | |||
const Tyin * | v_in_var, | |||
const Txin * | v_in_pres, | |||
const int | sz_in | |||
) |
interpolate the variable on the given pressures, using precomputed abscissa based on a linear approach on log(P)
v_out_var | [OUT] output variable interpolated on abscissa | |
v_out_abs | [IN] abscissa of output level, in the reference coordinates system | |
sz_out | [IN] number of elements to interpolate | |
v_in_var | [IN] value of variable at reference levels | |
v_in_pres | [IN] pressure of reference levels | |
sz_in | [IN] number of reference levels |
void ECMWFFileData::open_data_file | ( | ) | [virtual] |
open the file
Reimplemented from FileData.
void ECMWFFileData::parse_filename | ( | const string & | short_filename | ) | [protected] |
extract sone informations using the filename
short_filename | the filename without its path |
References check_filename(), FileData::date, product_id, Date::set_date_str(), FileData::time_coverage, and version.
Referenced by ECMWFFileData().
void* ECMWFFileData::read_data | ( | void * | data, | |
const char * | sds_name, | |||
int * | start = NULL , |
|||
int * | stride = NULL , |
|||
int * | edges = NULL , |
|||
int | rank = -1 | |||
) | [inline, virtual] |
read a subset of a data set
data | the data output buffer | |
sds_name | the data set to read | |
start | the start point | |
stride | the step between to read values | |
edges | the number of values to read in each direction | |
rank | the rank of the sds |
Implements FileData.
const double ECMWFFileData::a_hybrid_91 [static] |
{0.000000, 2.000040, 3.980832, 7.387186, 12.908319, 21.413612, 33.952858, 51.746601, 76.167656, 108.715561, 150.986023, 204.637451, 271.356506, 352.824493, 450.685791, 566.519226, 701.813354, 857.945801, 1036.166504, 1237.585449, 1463.163940, 1713.709595, 1989.874390, 2292.155518, 2620.898438, 2976.302246, 3358.425781, 3767.196045, 4202.416504, 4663.776367, 5150.859863, 5663.156250, 6199.839355, 6759.727051, 7341.469727, 7942.926270, 8564.624023, 9208.305664, 9873.560547, 10558.881836, 11262.484375, 11982.662109, 12713.897461, 13453.225586, 14192.009766, 14922.685547, 15638.053711, 16329.560547, 16990.623047, 17613.281250, 18191.029297, 18716.968750, 19184.544922, 19587.513672, 19919.796875, 20175.394531, 20348.916016, 20434.158203, 20426.218750, 20319.011719, 20107.031250, 19785.357422, 19348.775391, 18798.822266, 18141.296875, 17385.595703, 16544.585938, 15633.566406, 14665.645508, 13653.219727, 12608.383789, 11543.166992, 10471.310547, 9405.222656, 8356.252930, 7335.164551, 6353.920898, 5422.802734, 4550.215820, 3743.464355, 3010.146973, 2356.202637, 1784.854614, 1297.656128, 895.193542, 576.314148, 336.772369, 162.043427, 54.208336, 6.575628, 0.003160, 0.000000}
a, b coefficients used to compute the pressure of the ECMWF 91 vertical hybrid levels Source : http://www.ecmwf.int/products/data/technical/model_levels/model_def_91.html
Referenced by get_hybrid_level_pressure().
const double ECMWFFileData::b_hybrid_91 [static] |
{0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000014, 0.000055, 0.000131, 0.000279, 0.000548, 0.001000, 0.001701, 0.002765, 0.004267, 0.006322, 0.009035, 0.012508, 0.016860, 0.022189, 0.028610, 0.036227, 0.045146, 0.055474, 0.067316, 0.080777, 0.095964, 0.112979, 0.131935, 0.152934, 0.176091, 0.201520, 0.229315, 0.259554, 0.291993, 0.326329, 0.362203, 0.399205, 0.436906, 0.475016, 0.513280, 0.551458, 0.589317, 0.626559, 0.662934, 0.698224, 0.732224, 0.764679, 0.795385, 0.824185, 0.850950, 0.875518, 0.897767, 0.917651, 0.935157, 0.950274, 0.963007, 0.973466, 0.982238, 0.989153, 0.994204, 0.997630, 1.000000}
const unsigned short ECMWFFileData::isobaric_level_pressures [static] |
{ 1000, 950, 925, 900, 850, 800, 700, 600, 500, 400, 300, 250, 200, 150, 100, 70, 50, 30, 20, 10, 7, 5, 3, 2, 1, 0 }
vector of isobaric pressures, in hPa
Referenced by get_abscissa_iso(), and get_isobaric_level_pressures().
float ECMWFFileData::lat0 [protected] |
latitude of the up grid point (border of cell)
Referenced by get_grid_desc(), get_lat(), get_lat_index(), and init_grid().
float ECMWFFileData::lon0 [protected] |
longitude of the left grid point (border of cell)
Referenced by get_grid_desc(), get_lon(), get_lon_index(), and init_grid().
const int ECMWFFileData::nb_level_hybrid_91 = 91 [static] |
number of hybrid levels
Referenced by get_hybrid_level_pressure(), and get_hybrid_level_pressures().
const int ECMWFFileData::nb_max_isobaric_level = 26 [static] |
maximum number of isobaric pressure levels
Referenced by get_abscissa_iso().
ECMWFProductType ECMWFFileData::product_id [protected] |
the type of ECMWF product
Referenced by ECMWFFileData(), get_product_id(), get_s_product_id(), and parse_filename().
int ECMWFFileData::sz_x [protected] |
number of grid cells along the longitudes
Referenced by get_grid_desc(), get_lon_index(), get_sz_x(), and init_grid().
int ECMWFFileData::sz_y [protected] |
number of grid cells along the latitudes
Referenced by get_grid_desc(), get_sz_y(), and init_grid().
string ECMWFFileData::version [protected] |
the product version
Referenced by ECMWFFileData(), and parse_filename().