|
OpenCPN Partial API docs
|
A meteorological data grid from a GRIB (Gridded Binary) file. More...
#include <grib_record.h>
Public Member Functions | |
| GribRecord (const GribRecord &rec) | |
| Copy constructor performs a deep copy of the GribRecord. | |
| void | multiplyAllData (double k) |
| void | Substract (const GribRecord &rec, bool positive=true) |
| void | Average (const GribRecord &rec) |
| bool | IsOk () const |
| bool | IsDataKnown () const |
| bool | IsEof () const |
| bool | isDuplicated () const |
| zuchar | GetDataType () const |
| Returns the type of meteorological parameter stored in this grid. | |
| void | SetDataType (zuchar t) |
| zuchar | GetLevelType () const |
| Returns the type of vertical level for this grid's data. | |
| zuint | GetLevelValue () const |
| Returns the numeric value associated with the level type. | |
| zuint | GetDataCenterModel () const |
| Returns the numerical weather prediction model/center that produced this data. | |
| zuchar | GetIdCenter () const |
| Returns the originating center ID as defined by WMO (World Meteorological Organization). | |
| zuchar | GetIdModel () const |
| Returns the model/process ID within the originating center. | |
| zuchar | GetIdGrid () const |
| Returns the grid definition template number. | |
| std::string | GetKey () const |
| int | GetPeriodP1 () const |
| Returns the start of the period (P1) used for this record. | |
| int | GetPeriodP2 () const |
| Returns the end of the period (P2) used for this record. | |
| zuint | GetPeriodSec () const |
| Returns the forecast period in seconds from reference time. | |
| zuchar | GetTimeRange () const |
| Returns the time range indicator that defines how P1 and P2 should be interpreted. | |
| int | GetNi () const |
| Returns the number of points in the longitude (i) direction of the grid. | |
| int | GetNj () const |
| Returns the number of points in the latitude (j) direction of the grid. | |
| double | GetDi () const |
| Returns the grid spacing in longitude (i) direction in degrees. | |
| double | GetDj () const |
| Returns the grid spacing in latitude (j) direction in degrees. | |
| double | GetValue (int i, int j) const |
| Returns the data value at a specific grid point. | |
| void | SetValue (zuint i, zuint j, double v) |
| double | GetInterpolatedValue (double px, double py, bool numericalInterpolation=true, bool dir=false) const |
| Get spatially interpolated value at exact lat/lon position. | |
| double | GetX (int i) const |
| Converts grid index i to longitude in degrees. | |
| double | GetY (int j) const |
| Converts grid index j to latitude in degrees. | |
| void | getXY (int i, int j, double *x, double *y) const |
| Converts grid indices to longitude/latitude coordinates. | |
| double | GetLatMin () const |
| double | GetLonMin () const |
| double | GetLatMax () const |
| double | GetLonMax () const |
| bool | HasValue (int i, int j) const |
| bool | IsDefined (int i, int j) const |
| time_t | GetRecordRefDate () const |
| const char * | GetStrRecordRefDate () const |
| time_t | GetRecordCurrentDate () const |
| const char * | GetStrRecordCurDate () const |
| void | SetRecordCurrentDate (time_t t) |
| void | Print () const |
| bool | IsFilled () const |
| void | SetFilled (bool val=true) |
Static Public Member Functions | |
| static GribRecord * | InterpolatedRecord (const GribRecord &rec1, const GribRecord &rec2, double d, bool dir=false) |
| Creates a new GribRecord by temporally interpolating between two time points. | |
| static GribRecord * | Interpolated2DRecord (GribRecord *&rety, const GribRecord &rec1x, const GribRecord &rec1y, const GribRecord &rec2x, const GribRecord &rec2y, double d) |
| Creates temporally interpolated records for vector fields (wind, currents). | |
| static GribRecord * | MagnitudeRecord (const GribRecord &rec1, const GribRecord &rec2) |
| static void | Polar2UV (GribRecord *pDIR, GribRecord *pSPEED) |
| Converts wind or current values from polar (direction/speed) to cartesian (U/V) components. | |
| static std::string | MakeKey (int dataType, int levelType, int levelValue) |
| static bool | GetInterpolatedValues (double &M, double &A, const GribRecord *GRX, const GribRecord *GRY, double px, double py, bool numericalInterpolation=true) |
| Gets spatially interpolated wind or current vector values at a specific latitude/longitude point. | |
Protected Member Functions | |
| time_t | MakeDate (zuint year, zuint month, zuint day, zuint hour, zuint min, zuint sec) |
Static Protected Member Functions | |
| static bool | GetInterpolatedParameters (const GribRecord &rec1, const GribRecord &rec2, double &La1, double &Lo1, double &La2, double &Lo2, double &Di, double &Dj, int &im1, int &jm1, int &im2, int &jm2, int &Ni, int &Nj, int &rec1offi, int &rec1offj, int &rec2offi, int &rec2offj) |
Protected Attributes | |
| int | id |
| Unique identifier for this record. | |
| bool | ok |
| Indicates record validity. | |
| bool | known_data |
| Indicates whether the data type in this record is recognized by the parser. | |
| bool | wave_data |
| Differentiates wave-related parameters (height, direction, period) from other meteorological data for specialized processing. | |
| bool | is_duplicated |
| Indicates if this record was created through copying rather than direct reading. | |
| bool | eof |
| Signals when the end of the GRIB file has been reached during parsing. | |
| std::string | data_key |
| Unique string identifier constructed from data type, level type, and level value. | |
| char | str_ref_date [32] |
| char | str_cur_date [32] |
| int | data_center_model |
| Identifies the numerical weather model that produced this data. | |
| bool | is_filled |
| Indicates whether the data array has been populated. | |
| zuchar | edition_number |
| GRIB edition number, indicating the version of the GRIB specification used. | |
| zuchar | id_center |
| Originating center ID as defined by WMO common table C-1. | |
| zuchar | id_model |
| Model identifier within the originating center. | |
| zuchar | id_grid |
| Grid identifier used by the originating center. | |
| zuchar | data_type |
| Parameter identifier as defined by GRIB tables. | |
| zuchar | level_type |
| Vertical level type indicator. | |
| zuint | level_value |
| Numeric value associated with level_type. | |
| bool | hasBMS |
| Indicates presence of a bitmap section. | |
| zuint | refyear |
| Components of the reference time for this forecast. | |
| zuint | refmonth |
| zuint | refday |
| zuint | refhour |
| zuint | refminute |
| zuint | period_p1 |
| Time range indicators for this forecast step. | |
| zuint | period_p2 |
| zuchar | time_range |
| Statistical processing indicator. | |
| zuint | periodsec |
| Forecast period in seconds. | |
| time_t | ref_date |
| Unix timestamp of model initialization time. | |
| time_t | cur_date |
| Unix timestamp of when this forecast is valid. | |
| zuchar | NV |
| zuchar | PV |
| zuchar | grid_type |
| zuint | Ni |
| zuint | Nj |
| double | La1 |
| double | Lo1 |
| Grid origin coordinates. | |
| double | La2 |
| double | Lo2 |
| Grid end coordinates. | |
| double | lat_min |
| double | lon_min |
| double | lat_max |
| double | lon_max |
| double | Di |
| double | Dj |
| zuchar | resol_flags |
| zuchar | scan_flags |
| bool | has_di_dj |
| bool | is_earth_spheric |
| bool | is_ueast_vnorth |
| bool | is_scan_i_positive |
| bool | is_scan_j_positive |
| bool | is_adjacent_i |
| zuint | bms_size |
| zuchar * | bms_bits |
| double * | data |
A meteorological data grid from a GRIB (Gridded Binary) file.
A GribRecord contains a regular latitude/longitude grid of values representing a single meteorological parameter (e.g., wind component, pressure, temperature) at a specific:
Grid Structure:
Features:
Definition at line 186 of file grib_record.h.
| GribRecord::GribRecord | ( | const GribRecord & | rec | ) |
Copy constructor performs a deep copy of the GribRecord.
Definition at line 61 of file grib_record.cpp.
|
inline |
Definition at line 190 of file grib_record.h.
|
virtual |
Definition at line 445 of file grib_record.cpp.
| void GribRecord::Average | ( | const GribRecord & | rec | ) |
Definition at line 394 of file grib_record.cpp.
|
inline |
Returns the numerical weather prediction model/center that produced this data.
Known data centers and models include:
Definition at line 352 of file grib_record.h.
|
inline |
Returns the type of meteorological parameter stored in this grid.
Standard meteorological parameters are defined as constants, including:
Definition at line 302 of file grib_record.h.
|
inline |
Returns the grid spacing in longitude (i) direction in degrees.
Definition at line 464 of file grib_record.h.
|
inline |
Returns the grid spacing in latitude (j) direction in degrees.
Definition at line 471 of file grib_record.h.
|
inline |
Returns the originating center ID as defined by WMO (World Meteorological Organization).
Standard center IDs include:
Definition at line 368 of file grib_record.h.
|
inline |
Returns the grid definition template number.
Identifies how the grid coordinates are defined, including:
Definition at line 391 of file grib_record.h.
|
inline |
Returns the model/process ID within the originating center.
Each center can run multiple forecast models or analysis processes. This ID distinguishes between them (e.g., global vs. regional models). The meaning depends on the center ID.
Definition at line 380 of file grib_record.h.
|
staticprotected |
Definition at line 77 of file grib_record.cpp.
| double GribRecord::GetInterpolatedValue | ( | double | px, |
| double | py, | ||
| bool | numericalInterpolation = true, |
||
| bool | dir = false |
||
| ) | const |
Get spatially interpolated value at exact lat/lon position.
This method performs specialized vector interpolation for meteorological vector fields like wind or ocean currents.
| px | Longitude in degrees. |
| py | Latitude in degrees. |
| numericalInterpolation | Use bilinear interpolation if true. |
| dir | Handle directional interpolation if true (e.g. for wind direction). |
Definition at line 523 of file grib_record.cpp.
|
static |
Gets spatially interpolated wind or current vector values at a specific latitude/longitude point.
Takes X and Y component records and interpolates both magnitude and angle using bilinear interpolation between grid points.
| M | [out] Vector magnitude at the interpolated point (preserves input units). This is the speed or strength of the wind/current, typically measured in meters per second (m/s). |
| A | [out] Vector direction in meteorological degrees at the interpolated point. This is the direction the wind/current is coming FROM, measured in meteorological degrees (0 = North, 90 = East). |
| GRX | X-component record of the vector field (u-component, West-East) |
| GRY | Y-component record of the vector field (v-component, South-North) |
| px | [in] Longitude in degrees of the interpolation point. |
| py | [in] Latitude in degrees of the interpolation point. |
| numericalInterpolation | If true, uses bilinear interpolation; if false, uses nearest neighbor interpolation. |
Definition at line 654 of file grib_record.cpp.
|
inline |
Definition at line 394 of file grib_record.h.
|
inline |
Definition at line 573 of file grib_record.h.
|
inline |
Definition at line 571 of file grib_record.h.
|
inline |
Returns the type of vertical level for this grid's data.
Level types define the vertical coordinate system, including:
Definition at line 319 of file grib_record.h.
|
inline |
Returns the numeric value associated with the level type.
The meaning of this value depends on getLevelType():
Definition at line 332 of file grib_record.h.
|
inline |
Definition at line 574 of file grib_record.h.
|
inline |
Definition at line 572 of file grib_record.h.
|
inline |
Returns the number of points in the longitude (i) direction of the grid.
Definition at line 452 of file grib_record.h.
|
inline |
Returns the number of points in the latitude (j) direction of the grid.
Definition at line 458 of file grib_record.h.
|
inline |
Returns the start of the period (P1) used for this record.
The meaning depends on the time range indicator (GetTimeRange()):
Definition at line 409 of file grib_record.h.
|
inline |
Returns the end of the period (P2) used for this record.
The meaning depends on the time range indicator (GetTimeRange()):
Definition at line 421 of file grib_record.h.
|
inline |
Returns the forecast period in seconds from reference time.
This is the time offset from the model reference time (analysis time) when this data is valid.
Definition at line 431 of file grib_record.h.
|
inline |
Definition at line 588 of file grib_record.h.
|
inline |
Definition at line 584 of file grib_record.h.
|
inline |
Definition at line 589 of file grib_record.h.
|
inline |
Definition at line 585 of file grib_record.h.
|
inline |
Returns the time range indicator that defines how P1 and P2 should be interpreted.
Common values include:
Definition at line 444 of file grib_record.h.
|
inline |
Returns the data value at a specific grid point.
The grid is stored as a one-dimensional array in row-major order (longitude varies fastest).
| i | Index in longitude direction (0 to Ni-1) |
| j | Index in latitude direction (0 to Nj-1) |
Definition at line 484 of file grib_record.h.
|
inline |
Converts grid index i to longitude in degrees.
Uses the grid's origin (Lo1) and spacing (Di) to convert from grid index to geographic coordinate.
| i | Grid index in longitude direction (0 to Ni-1) |
Definition at line 544 of file grib_record.h.
|
inline |
Converts grid indices to longitude/latitude coordinates.
Convenience method that performs both X and Y conversions.
| i | Grid index in longitude direction | |
| j | Grid index in latitude direction | |
| [out] | x | Pointer to store longitude in degrees |
| [out] | y | Pointer to store latitude in degrees |
Definition at line 566 of file grib_record.h.
|
inline |
Converts grid index j to latitude in degrees.
Uses the grid's origin (La1) and spacing (Dj) to convert from grid index to geographic coordinate.
| j | Grid index in latitude direction (0 to Nj-1) |
Definition at line 555 of file grib_record.h.
|
inline |
Definition at line 780 of file grib_record.h.
|
static |
Creates temporally interpolated records for vector fields (wind, currents).
Unlike scalar interpolation, vector fields require both X and Y components to be interpolated together to preserve the vector characteristics. This method:
| rety | [out] Pointer to store interpolated Y-component record |
| rec1x | X-component record at earlier time t1 (e.g., wind u-component) |
| rec1y | Y-component record at earlier time t1 (e.g., wind v-component) |
| rec2x | X-component record at later time t2 |
| rec2y | Y-component record at later time t2 |
| d | Interpolation factor between [0,1] where:
|
Definition at line 232 of file grib_record.cpp.
|
static |
Creates a new GribRecord by temporally interpolating between two time points.
Performs linear interpolation between two GribRecords that:
The interpolation is done value-by-value across the entire grid using:
| rec1 | GribRecord at earlier time t1 |
| rec2 | GribRecord at later time t2 |
| d | Interpolation factor between [0,1] where:
|
| dir | If true, treats values as angles in degrees and uses proper angular interpolation (e.g., for wind direction) |
Definition at line 163 of file grib_record.cpp.
|
inline |
Definition at line 282 of file grib_record.h.
|
inline |
Definition at line 579 of file grib_record.h.
|
inline |
Definition at line 284 of file grib_record.h.
|
inline |
Definition at line 283 of file grib_record.h.
|
inline |
Definition at line 592 of file grib_record.h.
|
inline |
Definition at line 281 of file grib_record.h.
|
static |
Definition at line 317 of file grib_record.cpp.
|
protected |
Definition at line 492 of file grib_record.cpp.
|
static |
Definition at line 433 of file grib_record.cpp.
| void GribRecord::multiplyAllData | ( | double | k | ) |
Definition at line 460 of file grib_record.cpp.
|
static |
Converts wind or current values from polar (direction/speed) to cartesian (U/V) components.
U component represents East/West velocity (positive = eastward) V component represents North/South velocity (positive = northward)
| pDIR | Direction record in meteorological degrees (0 = N, 90 = E). |
| pSPEED | Speed record (units preserved). |
Definition at line 344 of file grib_record.cpp.
| void GribRecord::Print | ( | ) | const |
Definition at line 50 of file grib_record.cpp.
| void GribRecord::SetDataType | ( | zuchar | t | ) |
Definition at line 428 of file grib_record.cpp.
|
inline |
Definition at line 593 of file grib_record.h.
| void GribRecord::SetRecordCurrentDate | ( | time_t | t | ) |
Definition at line 473 of file grib_record.cpp.
|
inline |
Definition at line 486 of file grib_record.h.
| void GribRecord::Substract | ( | const GribRecord & | rec, |
| bool | positive = true |
||
| ) |
Definition at line 366 of file grib_record.cpp.
|
protected |
Definition at line 768 of file grib_record.h.
|
protected |
Definition at line 767 of file grib_record.h.
|
protected |
Unix timestamp of when this forecast is valid.
Definition at line 750 of file grib_record.h.
|
protected |
Definition at line 770 of file grib_record.h.
|
protected |
Identifies the numerical weather model that produced this data.
Standard WMO values from GRIB2 Table C-11 include:
Definition at line 667 of file grib_record.h.
|
protected |
Unique string identifier constructed from data type, level type, and level value.
Used for record lookup and comparison.
Definition at line 652 of file grib_record.h.
|
protected |
Parameter identifier as defined by GRIB tables.
Specifies what physical quantity is represented (wind, temperature, etc).
Definition at line 703 of file grib_record.h.
|
protected |
Definition at line 758 of file grib_record.h.
|
protected |
Definition at line 758 of file grib_record.h.
|
protected |
GRIB edition number, indicating the version of the GRIB specification used.
Determines how subsequent sections should be parsed.
Definition at line 681 of file grib_record.h.
|
protected |
Signals when the end of the GRIB file has been reached during parsing.
Definition at line 647 of file grib_record.h.
|
protected |
Definition at line 753 of file grib_record.h.
|
protected |
Definition at line 760 of file grib_record.h.
|
protected |
Indicates presence of a bitmap section.
When true, the data section uses a bitmap to indicate valid data points.
Definition at line 720 of file grib_record.h.
|
protected |
Unique identifier for this record.
Set during file reading for original records. Monotonically increasing for records read from file.
Definition at line 617 of file grib_record.h.
|
protected |
Originating center ID as defined by WMO common table C-1.
Identifies which meteorological center generated the forecast.
Definition at line 688 of file grib_record.h.
|
protected |
Grid identifier used by the originating center.
Specifies the coordinate system and projection of the data grid.
Definition at line 698 of file grib_record.h.
|
protected |
Model identifier within the originating center.
Distinguishes between different forecast models run by the same center.
Definition at line 693 of file grib_record.h.
|
protected |
Definition at line 765 of file grib_record.h.
|
protected |
Indicates if this record was created through copying rather than direct reading.
Tracks whether this record was copied to maintain data continuity. This happens with wave data gaps or initial values for cumulative parameters.
Definition at line 643 of file grib_record.h.
|
protected |
Definition at line 761 of file grib_record.h.
|
protected |
Indicates whether the data array has been populated.
Used to track partial loading states during record construction.
Definition at line 672 of file grib_record.h.
|
protected |
Definition at line 763 of file grib_record.h.
|
protected |
Definition at line 764 of file grib_record.h.
|
protected |
Definition at line 762 of file grib_record.h.
|
protected |
Indicates whether the data type in this record is recognized by the parser.
Used to skip unknown data types during processing.
Definition at line 630 of file grib_record.h.
|
protected |
Definition at line 755 of file grib_record.h.
|
protected |
Definition at line 756 of file grib_record.h.
|
protected |
Definition at line 757 of file grib_record.h.
|
protected |
Definition at line 757 of file grib_record.h.
|
protected |
Vertical level type indicator.
Specifies the type of vertical coordinate (pressure level, height above ground, etc).
Definition at line 709 of file grib_record.h.
|
protected |
Numeric value associated with level_type.
For example, the specific pressure level in hectopascals.
Definition at line 714 of file grib_record.h.
|
protected |
Grid origin coordinates.
Definition at line 755 of file grib_record.h.
|
protected |
Grid end coordinates.
Definition at line 756 of file grib_record.h.
|
protected |
Definition at line 757 of file grib_record.h.
|
protected |
Definition at line 757 of file grib_record.h.
|
protected |
Definition at line 754 of file grib_record.h.
|
protected |
Definition at line 754 of file grib_record.h.
|
protected |
Definition at line 752 of file grib_record.h.
|
protected |
Indicates record validity.
A record may be invalid if source records have mismatched dimensions, missing data arrays, failed interpolation, or the source records themselves are invalid when creating derived records.
Definition at line 625 of file grib_record.h.
|
protected |
Time range indicators for this forecast step.
Used to calculate the valid time period for this data.
Definition at line 731 of file grib_record.h.
|
protected |
Definition at line 731 of file grib_record.h.
|
protected |
Forecast period in seconds.
Time offset from the reference time.
Definition at line 742 of file grib_record.h.
|
protected |
Definition at line 752 of file grib_record.h.
|
protected |
Unix timestamp of model initialization time.
Definition at line 746 of file grib_record.h.
|
protected |
Definition at line 725 of file grib_record.h.
|
protected |
Definition at line 725 of file grib_record.h.
|
protected |
Definition at line 725 of file grib_record.h.
|
protected |
Definition at line 725 of file grib_record.h.
|
protected |
Components of the reference time for this forecast.
Specifies when the forecast model was initialized.
Definition at line 725 of file grib_record.h.
|
protected |
Definition at line 759 of file grib_record.h.
|
protected |
Definition at line 759 of file grib_record.h.
|
protected |
Definition at line 654 of file grib_record.h.
|
protected |
Definition at line 653 of file grib_record.h.
|
protected |
Statistical processing indicator.
Describes how the data was processed over time (e.g., accumulation, average).
Definition at line 737 of file grib_record.h.
|
protected |
Differentiates wave-related parameters (height, direction, period) from other meteorological data for specialized processing.
Definition at line 635 of file grib_record.h.