Add helper function for oblate spheroid

This commit is contained in:
Shahram Najm 2020-01-15 17:56:02 +00:00
parent e6e9501d25
commit 2db50f6186
5 changed files with 19 additions and 4 deletions

View File

@ -1484,6 +1484,7 @@ int grib2_is_PDTN_AerosolOptical(long productDefinitionTemplateNumber);
int grib2_select_PDTN(int is_eps, int is_instant, int is_chemical, int is_chemical_distfn, int is_aerosol, int is_aerosol_optical);
int is_grib_index_file(const char *filename);
size_t sum_of_pl_array(const long* pl, size_t plsize);
int grib_is_earth_oblate(grib_handle* h);
int grib_util_grib_data_quality_check(grib_handle* h, double min_val, double max_val);
/* bufr_util.c */

View File

@ -138,11 +138,11 @@ static int init(grib_iterator* iter,grib_handle* h,grib_arguments* args)
if((ret = grib_get_double_internal(h, sradius,&radius)) != GRIB_SUCCESS) {
/* Check if it's an oblate spheroid */
long oblate=0;
if (grib_get_long(h,"earthIsOblate",&oblate)==GRIB_SUCCESS && oblate==1)
if (grib_is_earth_oblate(h))
grib_context_log(h->context,GRIB_LOG_ERROR,"Lambert Azimuthal Equal Area only supported for spherical earth.");
return ret;
}
if((ret = grib_get_long_internal(h, snx,&nx)) != GRIB_SUCCESS)
return ret;
if((ret = grib_get_long_internal(h, sny,&ny)) != GRIB_SUCCESS)

View File

@ -116,7 +116,6 @@ static int init(grib_iterator* iter, grib_handle* h, grib_arguments* args)
int i, j, err=0;
double *lats, *lons; /* the lat/lon arrays to be populated */
long nx,ny,iScansNegatively,jScansPositively,jPointsAreConsecutive,alternativeRowScanning;
long oblate=0;
double LoVInDegrees,LaDInDegrees,Latin1InDegrees,Latin2InDegrees,latFirstInDegrees,
lonFirstInDegrees, Dx, Dy, radius=0;
double latFirstInRadians, lonFirstInRadians, LoVInRadians, Latin1InRadians, Latin2InRadians,
@ -147,7 +146,7 @@ static int init(grib_iterator* iter, grib_handle* h, grib_arguments* args)
if((err = grib_get_long_internal(h, sny,&ny)) != GRIB_SUCCESS)
return err;
if(grib_get_long(h, "earthIsOblate", &oblate) == GRIB_SUCCESS && oblate == 1) {
if (grib_is_earth_oblate(h)) {
grib_context_log(h->context,GRIB_LOG_ERROR,"Lambert Conformal only supported for spherical earth.");
return GRIB_GEOCALCULUS_PROBLEM;
}

View File

@ -151,6 +151,11 @@ static int init(grib_iterator* iter,grib_handle* h,grib_arguments* args)
if((ret = grib_get_long_internal(h, snx,&nx)) != GRIB_SUCCESS) return ret;
if((ret = grib_get_long_internal(h, sny,&ny)) != GRIB_SUCCESS) return ret;
if (grib_is_earth_oblate(h)) {
grib_context_log(h->context,GRIB_LOG_ERROR,"Polar stereographic only supported for spherical earth.");
return GRIB_GEOCALCULUS_PROBLEM;
}
if (iter->nv!=nx*ny) {
grib_context_log(h->context,GRIB_LOG_ERROR, "Wrong number of points (%ld!=%ldx%ld)", iter->nv,nx,ny);
return GRIB_WRONG_GRID;

View File

@ -2049,6 +2049,16 @@ size_t sum_of_pl_array(const long* pl, size_t plsize)
return count;
}
int grib_is_earth_oblate(grib_handle* h)
{
long oblate = 0;
int err = grib_get_long(h, "earthIsOblate", &oblate);
if (!err && oblate == 1) {
return 1;
}
return 0;
}
int grib_util_grib_data_quality_check(grib_handle* h, double min_val, double max_val)
{
int err = 0;