OpenCPN Partial API docs
|
Represents a meteorological data grid from a GRIB (Gridded Binary) file. More...
#include <GribRecord.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 (const 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 () |
bool | isFilled () |
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 | knownData |
Indicates whether the data type in this record is recognized by the parser. | |
bool | waveData |
Differentiates wave-related parameters (height, direction, period) from other meteorological data for specialized processing. | |
bool | IsDuplicated |
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 | dataKey |
Unique string identifier constructed from data type, level type, and level value. | |
char | strRefDate [32] |
char | strCurDate [32] |
int | dataCenterModel |
Identifies the numerical weather model that produced this data. | |
bool | m_bfilled |
Indicates whether the data array has been populated. | |
zuchar | editionNumber |
GRIB edition number, indicating the version of the GRIB specification used. | |
zuchar | idCenter |
Originating center ID as defined by WMO common table C-1. | |
zuchar | idModel |
Model identifier within the originating center. | |
zuchar | idGrid |
Grid identifier used by the originating center. | |
zuchar | dataType |
Parameter identifier as defined by GRIB tables. | |
zuchar | levelType |
Vertical level type indicator. | |
zuint | levelValue |
Numeric value associated with levelType. | |
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 | periodP1 |
Time range indicators for this forecast step. | |
zuint | periodP2 |
zuchar | timeRange |
Statistical processing indicator. | |
zuint | periodsec |
Forecast period in seconds. | |
time_t | refDate |
Unix timestamp of model initialization time. | |
time_t | curDate |
Unix timestamp of when this forecast is valid. | |
zuchar | NV |
zuchar | PV |
zuchar | gridType |
zuint | Ni |
zuint | Nj |
double | La1 |
double | Lo1 |
Grid origin coordinates. | |
double | La2 |
double | Lo2 |
Grid end coordinates. | |
double | latMin |
double | lonMin |
double | latMax |
double | lonMax |
double | Di |
double | Dj |
zuchar | resolFlags |
zuchar | scanFlags |
bool | hasDiDj |
bool | isEarthSpheric |
bool | isUeastVnorth |
bool | isScanIpositive |
bool | isScanJpositive |
bool | isAdjacentI |
zuint | BMSsize |
zuchar * | BMSbits |
double * | data |
Represents 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 182 of file GribRecord.h.
GribRecord::GribRecord | ( | const GribRecord & | rec | ) |
Copy constructor performs a deep copy of the GribRecord.
Definition at line 58 of file GribRecord.cpp.
|
inline |
Definition at line 186 of file GribRecord.h.
|
virtual |
Definition at line 441 of file GribRecord.cpp.
void GribRecord::Average | ( | const GribRecord & | rec | ) |
Definition at line 390 of file GribRecord.cpp.
|
inline |
Returns the numerical weather prediction model/center that produced this data.
Known data centers and models include:
Definition at line 348 of file GribRecord.h.
|
inline |
Returns the type of meteorological parameter stored in this grid.
Standard meteorological parameters are defined as constants, including:
Definition at line 298 of file GribRecord.h.
|
inline |
Returns the grid spacing in longitude (i) direction in degrees.
Definition at line 460 of file GribRecord.h.
|
inline |
Returns the grid spacing in latitude (j) direction in degrees.
Definition at line 467 of file GribRecord.h.
|
inline |
Returns the originating center ID as defined by WMO (World Meteorological Organization).
Standard center IDs include:
Definition at line 364 of file GribRecord.h.
|
inline |
Returns the grid definition template number.
Identifies how the grid coordinates are defined, including:
Definition at line 387 of file GribRecord.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 376 of file GribRecord.h.
|
staticprotected |
Definition at line 74 of file GribRecord.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 519 of file GribRecord.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 650 of file GribRecord.cpp.
|
inline |
Definition at line 390 of file GribRecord.h.
|
inline |
Definition at line 569 of file GribRecord.h.
|
inline |
Definition at line 567 of file GribRecord.h.
|
inline |
Returns the type of vertical level for this grid's data.
Level types define the vertical coordinate system, including:
Definition at line 315 of file GribRecord.h.
|
inline |
Returns the numeric value associated with the level type.
The meaning of this value depends on getLevelType():
Definition at line 328 of file GribRecord.h.
|
inline |
Definition at line 570 of file GribRecord.h.
|
inline |
Definition at line 568 of file GribRecord.h.
|
inline |
Returns the number of points in the longitude (i) direction of the grid.
Definition at line 448 of file GribRecord.h.
|
inline |
Returns the number of points in the latitude (j) direction of the grid.
Definition at line 454 of file GribRecord.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 405 of file GribRecord.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 417 of file GribRecord.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 427 of file GribRecord.h.
|
inline |
Definition at line 584 of file GribRecord.h.
|
inline |
Definition at line 580 of file GribRecord.h.
|
inline |
Definition at line 585 of file GribRecord.h.
|
inline |
Definition at line 581 of file GribRecord.h.
|
inline |
Returns the time range indicator that defines how P1 and P2 should be interpreted.
Common values include:
Definition at line 440 of file GribRecord.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 480 of file GribRecord.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 540 of file GribRecord.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 562 of file GribRecord.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 551 of file GribRecord.h.
|
inline |
Definition at line 776 of file GribRecord.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 228 of file GribRecord.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 159 of file GribRecord.cpp.
|
inline |
Definition at line 278 of file GribRecord.h.
|
inline |
Definition at line 575 of file GribRecord.h.
|
inline |
Definition at line 280 of file GribRecord.h.
|
inline |
Definition at line 279 of file GribRecord.h.
|
inline |
Definition at line 588 of file GribRecord.h.
|
inline |
Definition at line 277 of file GribRecord.h.
|
static |
Definition at line 313 of file GribRecord.cpp.
|
protected |
Definition at line 488 of file GribRecord.cpp.
|
static |
Definition at line 429 of file GribRecord.cpp.
void GribRecord::multiplyAllData | ( | double | k | ) |
Definition at line 456 of file GribRecord.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 340 of file GribRecord.cpp.
void GribRecord::print | ( | ) |
Definition at line 47 of file GribRecord.cpp.
void GribRecord::setDataType | ( | const zuchar | t | ) |
Definition at line 424 of file GribRecord.cpp.
|
inline |
Definition at line 589 of file GribRecord.h.
void GribRecord::setRecordCurrentDate | ( | time_t | t | ) |
Definition at line 469 of file GribRecord.cpp.
|
inline |
Definition at line 482 of file GribRecord.h.
void GribRecord::Substract | ( | const GribRecord & | rec, |
bool | positive = true |
||
) |
Definition at line 362 of file GribRecord.cpp.
|
protected |
Definition at line 764 of file GribRecord.h.
|
protected |
Definition at line 763 of file GribRecord.h.
|
protected |
Unix timestamp of when this forecast is valid.
Definition at line 746 of file GribRecord.h.
|
protected |
Definition at line 766 of file GribRecord.h.
|
protected |
Identifies the numerical weather model that produced this data.
Standard WMO values from GRIB2 Table C-11 include:
Definition at line 663 of file GribRecord.h.
|
protected |
Unique string identifier constructed from data type, level type, and level value.
Used for record lookup and comparison.
Definition at line 648 of file GribRecord.h.
|
protected |
Parameter identifier as defined by GRIB tables.
Specifies what physical quantity is represented (wind, temperature, etc).
Definition at line 699 of file GribRecord.h.
|
protected |
Definition at line 754 of file GribRecord.h.
|
protected |
Definition at line 754 of file GribRecord.h.
|
protected |
GRIB edition number, indicating the version of the GRIB specification used.
Determines how subsequent sections should be parsed.
Definition at line 677 of file GribRecord.h.
|
protected |
Signals when the end of the GRIB file has been reached during parsing.
Definition at line 643 of file GribRecord.h.
|
protected |
Definition at line 749 of file GribRecord.h.
|
protected |
Indicates presence of a bitmap section.
When true, the data section uses a bitmap to indicate valid data points.
Definition at line 716 of file GribRecord.h.
|
protected |
Definition at line 756 of file GribRecord.h.
|
protected |
Unique identifier for this record.
Set during file reading for original records. Monotonically increasing for records read from file.
Definition at line 613 of file GribRecord.h.
|
protected |
Originating center ID as defined by WMO common table C-1.
Identifies which meteorological center generated the forecast.
Definition at line 684 of file GribRecord.h.
|
protected |
Grid identifier used by the originating center.
Specifies the coordinate system and projection of the data grid.
Definition at line 694 of file GribRecord.h.
|
protected |
Model identifier within the originating center.
Distinguishes between different forecast models run by the same center.
Definition at line 689 of file GribRecord.h.
|
protected |
Definition at line 761 of file GribRecord.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 639 of file GribRecord.h.
|
protected |
Definition at line 757 of file GribRecord.h.
|
protected |
Definition at line 759 of file GribRecord.h.
|
protected |
Definition at line 760 of file GribRecord.h.
|
protected |
Definition at line 758 of file GribRecord.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 626 of file GribRecord.h.
|
protected |
Definition at line 751 of file GribRecord.h.
|
protected |
Definition at line 752 of file GribRecord.h.
|
protected |
Definition at line 753 of file GribRecord.h.
|
protected |
Definition at line 753 of file GribRecord.h.
|
protected |
Vertical level type indicator.
Specifies the type of vertical coordinate (pressure level, height above ground, etc).
Definition at line 705 of file GribRecord.h.
|
protected |
Numeric value associated with levelType.
For example, the specific pressure level in hectopascals.
Definition at line 710 of file GribRecord.h.
|
protected |
Grid origin coordinates.
Definition at line 751 of file GribRecord.h.
|
protected |
Grid end coordinates.
Definition at line 752 of file GribRecord.h.
|
protected |
Definition at line 753 of file GribRecord.h.
|
protected |
Definition at line 753 of file GribRecord.h.
|
protected |
Indicates whether the data array has been populated.
Used to track partial loading states during record construction.
Definition at line 668 of file GribRecord.h.
|
protected |
Definition at line 750 of file GribRecord.h.
|
protected |
Definition at line 750 of file GribRecord.h.
|
protected |
Definition at line 748 of file GribRecord.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 621 of file GribRecord.h.
|
protected |
Time range indicators for this forecast step.
Used to calculate the valid time period for this data.
Definition at line 727 of file GribRecord.h.
|
protected |
Definition at line 727 of file GribRecord.h.
|
protected |
Forecast period in seconds.
Time offset from the reference time.
Definition at line 738 of file GribRecord.h.
|
protected |
Definition at line 748 of file GribRecord.h.
|
protected |
Unix timestamp of model initialization time.
Definition at line 742 of file GribRecord.h.
|
protected |
Definition at line 721 of file GribRecord.h.
|
protected |
Definition at line 721 of file GribRecord.h.
|
protected |
Definition at line 721 of file GribRecord.h.
|
protected |
Definition at line 721 of file GribRecord.h.
|
protected |
Components of the reference time for this forecast.
Specifies when the forecast model was initialized.
Definition at line 721 of file GribRecord.h.
|
protected |
Definition at line 755 of file GribRecord.h.
|
protected |
Definition at line 755 of file GribRecord.h.
|
protected |
Definition at line 650 of file GribRecord.h.
|
protected |
Definition at line 649 of file GribRecord.h.
|
protected |
Statistical processing indicator.
Describes how the data was processed over time (e.g., accumulation, average).
Definition at line 733 of file GribRecord.h.
|
protected |
Differentiates wave-related parameters (height, direction, period) from other meteorological data for specialized processing.
Definition at line 631 of file GribRecord.h.