Commit 316b9569 authored by Uwe Schulzweida's avatar Uwe Schulzweida
Browse files

gridDefParamLCC: refactor interface.

parent f6bf667e
...@@ -932,7 +932,7 @@ void gridDefParamGME(int gridID, int nd, int ni, int ni2, int ni3); ...@@ -932,7 +932,7 @@ void gridDefParamGME(int gridID, int nd, int ni, int ni2, int ni3);
void gridInqParamGME(int gridID, int *nd, int *ni, int *ni2, int *ni3); void gridInqParamGME(int gridID, int *nd, int *ni, int *ni2, int *ni3);
/* Lambert Conformal Conic grid (GRIB version) */ /* Lambert Conformal Conic grid (GRIB version) */
void gridDefParamLCC(int gridID, double a, double rf, double xval_0, double yval_0, double lon_0, double lat_1, double lat_2); void gridDefParamLCC(int gridID, double missval, double lon_0, double lat_0, double lat_1, double lat_2, double a, double rf, double xval_0, double yval_0, double x_0, double y_0);
int gridInqParamLCC(int gridID, double missval, double *lon_0, double *lat_0, double *lat_1, double *lat_2, double *a, double *rf, double *xval_0, double *yval_0, double *x_0, double *y_0); int gridInqParamLCC(int gridID, double missval, double *lon_0, double *lat_0, double *lat_1, double *lat_2, double *a, double *rf, double *xval_0, double *yval_0, double *x_0, double *y_0);
void gridDefArea(int gridID, const double area[]); void gridDefArea(int gridID, const double area[]);
......
...@@ -1846,13 +1846,17 @@ ...@@ -1846,13 +1846,17 @@
! !
! gridDefParamLCC ! gridDefParamLCC
! (INTEGER gridID, ! (INTEGER gridID,
! DOUBLEPRECISION missval,
! DOUBLEPRECISION lon_0,
! DOUBLEPRECISION lat_0,
! DOUBLEPRECISION lat_1,
! DOUBLEPRECISION lat_2,
! DOUBLEPRECISION a, ! DOUBLEPRECISION a,
! DOUBLEPRECISION rf, ! DOUBLEPRECISION rf,
! DOUBLEPRECISION xval_0, ! DOUBLEPRECISION xval_0,
! DOUBLEPRECISION yval_0, ! DOUBLEPRECISION yval_0,
! DOUBLEPRECISION lon_0, ! DOUBLEPRECISION x_0,
! DOUBLEPRECISION lat_1, ! DOUBLEPRECISION y_0)
! DOUBLEPRECISION lat_2)
EXTERNAL gridDefParamLCC EXTERNAL gridDefParamLCC
INTEGER gridInqParamLCC INTEGER gridInqParamLCC
......
...@@ -397,7 +397,7 @@ FCALLSCSUB5 (gridInqParamGME, GRIDINQPARAMGME, gridinqparamgme, INT, PINT, PINT, ...@@ -397,7 +397,7 @@ FCALLSCSUB5 (gridInqParamGME, GRIDINQPARAMGME, gridinqparamgme, INT, PINT, PINT,
/* Lambert Conformal Conic grid (GRIB version) */ /* Lambert Conformal Conic grid (GRIB version) */
FCALLSCSUB8 (gridDefParamLCC, GRIDDEFPARAMLCC, griddefparamlcc, INT, DOUBLE, DOUBLE, DOUBLE, DOUBLE, DOUBLE, DOUBLE, DOUBLE) FCALLSCSUB12 (gridDefParamLCC, GRIDDEFPARAMLCC, griddefparamlcc, INT, DOUBLE, DOUBLE, DOUBLE, DOUBLE, DOUBLE, DOUBLE, DOUBLE, DOUBLE, DOUBLE, DOUBLE, DOUBLE)
FCALLSCFUN12 (INT, gridInqParamLCC, GRIDINQPARAMLCC, gridinqparamlcc, INT, DOUBLE, PDOUBLE, PDOUBLE, PDOUBLE, PDOUBLE, PDOUBLE, PDOUBLE, PDOUBLE, PDOUBLE, PDOUBLE, PDOUBLE) FCALLSCFUN12 (INT, gridInqParamLCC, GRIDINQPARAMLCC, gridinqparamlcc, INT, DOUBLE, PDOUBLE, PDOUBLE, PDOUBLE, PDOUBLE, PDOUBLE, PDOUBLE, PDOUBLE, PDOUBLE, PDOUBLE, PDOUBLE)
FCALLSCSUB2 (gridDefArea, GRIDDEFAREA, griddefarea, INT, DOUBLEV) FCALLSCSUB2 (gridDefArea, GRIDDEFAREA, griddefarea, INT, DOUBLEV)
FCALLSCSUB2 (gridInqArea, GRIDINQAREA, gridinqarea, INT, DOUBLEV) FCALLSCSUB2 (gridInqArea, GRIDINQAREA, gridinqarea, INT, DOUBLEV)
......
...@@ -20,7 +20,7 @@ ...@@ -20,7 +20,7 @@
#include "serialize.h" #include "serialize.h"
#include "vlist.h" #include "vlist.h"
double grid_missval = 9999.; double grid_missval = -9999.;
/* the value in the second pair of brackets must match the length of /* the value in the second pair of brackets must match the length of
* the longest string (including terminating NUL) */ * the longest string (including terminating NUL) */
...@@ -3590,23 +3590,28 @@ const double *gridInqYvalsPtr(int gridID) ...@@ -3590,23 +3590,28 @@ const double *gridInqYvalsPtr(int gridID)
@Function gridDefParamLCC @Function gridDefParamLCC
@Title Define the parameter of a Lambert Conformal Conic grid @Title Define the parameter of a Lambert Conformal Conic grid
@Prototype void gridDefParamLCC(int gridID, double a, double rf, double xval_0, double yval_0, double lon_0, double lat_1, double lat_2) @Prototype void gridDefParamLCC(int gridID, double missval, double lon_0, double lat_0, double lat_1, double lat_2, double a, double rf, double xval_0, double yval_0, double x_0, double y_0)
@Parameter @Parameter
@Item gridID Grid ID, from a previous call to @fref{gridCreate}. @Item gridID Grid ID, from a previous call to @fref{gridCreate}.
@Item a Earth radius. @Item missval Missing value
@Item rf Inverse flattening
@Item xval_0 Longitude of the first grid point.
@Item yval_0 Latitude of the first grid point.
@Item lon_0 The East longitude of the meridian which is parallel to the Y-axis. @Item lon_0 The East longitude of the meridian which is parallel to the Y-axis.
@Item lat_0 Latitude of the projection origin
@Item lat_1 First latitude from the pole at which the secant cone cuts the sphere. @Item lat_1 First latitude from the pole at which the secant cone cuts the sphere.
@Item lat_2 Second latitude at which the secant cone cuts the sphere. @Item lat_2 Second latitude at which the secant cone cuts the sphere.
@Item a Earth radius in metres (optional).
@Item rf Inverse flattening (1/f) (optional).
@Item xval_0 Longitude of the first grid point in degree (optional).
@Item yval_0 Latitude of the first grid point in degree (optional).
@Item x_0 False easting (optional).
@Item y_0 False northing (optional).
@Description @Description
The function @func{gridDefParamLCC} defines the parameter of a Lambert Conformal Conic grid. The function @func{gridDefParamLCC} defines the parameter of a Lambert Conformal Conic grid.
@EndFunction @EndFunction
*/ */
void gridDefParamLCC(int gridID, double a, double rf, double xval_0, double yval_0, double lon_0, double lat_1, double lat_2) void gridDefParamLCC(int gridID, double missval, double lon_0, double lat_0, double lat_1, double lat_2,
double a, double rf, double xval_0, double yval_0, double x_0, double y_0)
{ {
cdiGridDefKeyStr(gridID, CDI_KEY_MAPPING, CDI_MAX_NAME, "Lambert_Conformal"); cdiGridDefKeyStr(gridID, CDI_KEY_MAPPING, CDI_MAX_NAME, "Lambert_Conformal");
...@@ -3622,8 +3627,10 @@ void gridDefParamLCC(int gridID, double a, double rf, double xval_0, double yval ...@@ -3622,8 +3627,10 @@ void gridDefParamLCC(int gridID, double a, double rf, double xval_0, double yval
cdiDefAttFlt(gridID, CDI_GLOBAL, "latitude_of_projection_origin", CDI_DATATYPE_FLT64, 1, &lat_2); cdiDefAttFlt(gridID, CDI_GLOBAL, "latitude_of_projection_origin", CDI_DATATYPE_FLT64, 1, &lat_2);
if ( a > 0 ) cdiDefAttFlt(gridID, CDI_GLOBAL, "earth_radius", CDI_DATATYPE_FLT64, 1, &a); if ( a > 0 ) cdiDefAttFlt(gridID, CDI_GLOBAL, "earth_radius", CDI_DATATYPE_FLT64, 1, &a);
if ( rf > 0 ) cdiDefAttFlt(gridID, CDI_GLOBAL, "inverse_flattening", CDI_DATATYPE_FLT64, 1, &rf); if ( rf > 0 ) cdiDefAttFlt(gridID, CDI_GLOBAL, "inverse_flattening", CDI_DATATYPE_FLT64, 1, &rf);
cdiDefAttFlt(gridID, CDI_GLOBAL, "longitudeOfFirstGridPointInDegrees", CDI_DATATYPE_FLT64, 1, &xval_0); if ( IS_NOT_EQUAL(xval_0, missval) ) cdiDefAttFlt(gridID, CDI_GLOBAL, "longitudeOfFirstGridPointInDegrees", CDI_DATATYPE_FLT64, 1, &xval_0);
cdiDefAttFlt(gridID, CDI_GLOBAL, "latitudeOfFirstGridPointInDegrees", CDI_DATATYPE_FLT64, 1, &yval_0); if ( IS_NOT_EQUAL(yval_0, missval) ) cdiDefAttFlt(gridID, CDI_GLOBAL, "latitudeOfFirstGridPointInDegrees", CDI_DATATYPE_FLT64, 1, &yval_0);
if ( IS_NOT_EQUAL(x_0, missval) ) cdiDefAttFlt(gridID, CDI_GLOBAL, "false_easting", CDI_DATATYPE_FLT64, 1, &x_0);
if ( IS_NOT_EQUAL(y_0, missval) ) cdiDefAttFlt(gridID, CDI_GLOBAL, "false_northing", CDI_DATATYPE_FLT64, 1, &y_0);
grid_t *gridptr = grid_to_pointer(gridID); grid_t *gridptr = grid_to_pointer(gridID);
gridptr->projtype = CDI_PROJ_LCC; gridptr->projtype = CDI_PROJ_LCC;
......
...@@ -402,7 +402,11 @@ void cgribexAddRecord(stream_t * streamptr, int param, int *isec1, int *isec2, d ...@@ -402,7 +402,11 @@ void cgribexAddRecord(stream_t * streamptr, int param, int *isec1, int *isec2, d
double lat_2 = ISEC2_Lambert_LatS2 * 0.001; double lat_2 = ISEC2_Lambert_LatS2 * 0.001;
bool lsouth = gribbyte_get_bit(ISEC2_Lambert_ProjFlag, 1); bool lsouth = gribbyte_get_bit(ISEC2_Lambert_ProjFlag, 1);
if ( lsouth ) { lat_1 = -lat_1; lat_2 = -lat_2; } if ( lsouth ) { lat_1 = -lat_1; lat_2 = -lat_2; }
gridDefParamLCC(gridID, a, rf, xval_0, yval_0, lon_0, lat_1, lat_2);
double lat_0 = lat_2;
double x_0 = grid_missval;
double y_0 = grid_missval;
gridDefParamLCC(gridID, grid_missval, lon_0, lat_0, lat_1, lat_2, a, rf, xval_0, yval_0, x_0, y_0);
} }
} }
else else
......
...@@ -492,7 +492,7 @@ void gribapiAddRecord(stream_t * streamptr, int param, grib_handle *gh, ...@@ -492,7 +492,7 @@ void gribapiAddRecord(stream_t * streamptr, int param, grib_handle *gh,
long earthIsOblate; long earthIsOblate;
grib_get_long(gh, "earthIsOblate", &earthIsOblate); grib_get_long(gh, "earthIsOblate", &earthIsOblate);
if ( earthIsOblate ) { a = 6378160.; rf = 297.0; } if ( earthIsOblate ) { a = 6378160.; rf = 297.0; }
double xval_0, yval_0, lon_0, lat_1, lat_2; double lon_0, lat_0, lat_1, lat_2, xval_0, yval_0, x_0 = grid_missval, y_0 = grid_missval;
long projflag = 0; long projflag = 0;
grib_get_double(gh, "longitudeOfFirstGridPointInDegrees", &xval_0); grib_get_double(gh, "longitudeOfFirstGridPointInDegrees", &xval_0);
grib_get_double(gh, "latitudeOfFirstGridPointInDegrees", &yval_0); grib_get_double(gh, "latitudeOfFirstGridPointInDegrees", &yval_0);
...@@ -503,7 +503,8 @@ void gribapiAddRecord(stream_t * streamptr, int param, grib_handle *gh, ...@@ -503,7 +503,8 @@ void gribapiAddRecord(stream_t * streamptr, int param, grib_handle *gh,
bool lsouth = gribbyte_get_bit(projflag, 1); bool lsouth = gribbyte_get_bit(projflag, 1);
if ( lsouth ) { lat_1 = -lat_1; lat_2 = -lat_2; } if ( lsouth ) { lat_1 = -lat_1; lat_2 = -lat_2; }
gridDefParamLCC(gridID, a, rf, xval_0, yval_0, lon_0, lat_1, lat_2); lat_0 = lat_2;
gridDefParamLCC(gridID, grid_missval, lon_0, lat_0, lat_1, lat_2, a, rf, xval_0, yval_0, x_0, y_0);
} }
int zaxistype = gribapiGetZaxisType(gribEditionNumber(gh), leveltype1); int zaxistype = gribapiGetZaxisType(gribEditionNumber(gh), leveltype1);
......
Markdown is supported
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