Commit 78106ebd authored by Uwe Schulzweida's avatar Uwe Schulzweida
Browse files

lambert grid: support of projection flag

parent 2dd8dbbf
......@@ -4,6 +4,7 @@
* add new taxis functions: taxisXXXVdateBounds and taxisXXXVtimeBounds
* cdfReadVarSliceDP: add swapxy support
* cdfInqContents: support of grid stdname 'longitude' and 'latitude'
* lambert grid: support of projection flag (bug fix) [report: Andrew Digby]
* streamFilesuffix: bug fix for IEG [report: Class Teichmann]
* gridCompare: bug fix for lonlat grids and type = 1 (cdfInqContents)
* netcdf: support of timeunit 'year'
......
......@@ -377,10 +377,16 @@ static void printGridInfo(int vlistID)
else if ( gridtype == GRID_LCC )
{
double originLon, originLat, lonParY, lat1, lat2, xincm, yincm;
int projflag, scanflag;
gridInqLCC(gridID, &originLon, &originLat, &lonParY, &lat1, &lat2, &xincm, &yincm);
gridInqLCC(gridID, &originLon, &originLat, &lonParY, &lat1, &lat2, &xincm, &yincm,
&projflag, &scanflag);
fprintf(stdout, "size : dim = %d nx = %d ny = %d\n", gridsize, xsize, ysize);
fprintf(stdout, "size : dim = %d nx = %d ny = %d ", gridsize, xsize, ysize);
if ( (projflag&128) == 0 )
fprintf(stdout, "North Pole\n");
else
fprintf(stdout, "South Pole\n");
fprintf(stdout, "%*s", nbyte0, "");
fprintf(stdout, " originLon = %g originLat = %g lonParY = %g\n",
originLon, originLat, lonParY);
......
......@@ -543,8 +543,8 @@ int gridInqGMEni3(int gridID);
void gridDefGMEni3(int gridID, int ni3);
/* Lambert grid */
void gridDefLCC(int gridID, double originLon, double originLat, double lonParY, double lat1, double lat2, double xinc, double yinc);
void gridInqLCC(int gridID, double *originLon, double *originLat, double *lonParY, double *lat1, double *lat2, double *xinc, double *yinc);
void gridDefLCC(int gridID, double originLon, double originLat, double lonParY, double lat1, double lat2, double xinc, double yinc, int projflag, int scanflag);
void gridInqLCC(int gridID, double *originLon, double *originLat, double *lonParY, double *lat1, double *lat2, double *xinc, double *yinc, int *projflag, int *scanflag);
void gridDefArea(int gridID, double *area);
void gridInqArea(int gridID, double *area);
......
......@@ -1229,7 +1229,9 @@
! DOUBLEPRECISION lat1,
! DOUBLEPRECISION lat2,
! DOUBLEPRECISION xinc,
! DOUBLEPRECISION yinc)
! DOUBLEPRECISION yinc,
! INTEGER projflag,
! INTEGER scanflag)
EXTERNAL gridDefLCC
! gridInqLCC
......@@ -1240,7 +1242,9 @@
! DOUBLEPRECISION lat1,
! DOUBLEPRECISION lat2,
! DOUBLEPRECISION xinc,
! DOUBLEPRECISION yinc)
! DOUBLEPRECISION yinc,
! INTEGER projflag,
! INTEGER scanflag)
EXTERNAL gridInqLCC
! gridDefArea
......
......@@ -261,8 +261,8 @@ FCALLSCSUB2 (gridDefGMEni3, GRIDDEFGMENI3, griddefgmeni3, INT, INT)
/* Lambert grid */
FCALLSCSUB8 (gridDefLCC, GRIDDEFLCC, griddeflcc, INT, DOUBLE, DOUBLE, DOUBLE, DOUBLE, DOUBLE, DOUBLE, DOUBLE)
FCALLSCSUB8 (gridInqLCC, GRIDINQLCC, gridinqlcc, INT, PDOUBLE, PDOUBLE, PDOUBLE, PDOUBLE, PDOUBLE, PDOUBLE, PDOUBLE)
FCALLSCSUB10 (gridDefLCC, GRIDDEFLCC, griddeflcc, INT, DOUBLE, DOUBLE, DOUBLE, DOUBLE, DOUBLE, DOUBLE, DOUBLE, INT, INT)
FCALLSCSUB10 (gridInqLCC, GRIDINQLCC, gridinqlcc, INT, PDOUBLE, PDOUBLE, PDOUBLE, PDOUBLE, PDOUBLE, PDOUBLE, PDOUBLE, PINT, PINT)
FCALLSCSUB2 (gridDefArea, GRIDDEFAREA, griddefarea, INT, PDOUBLE)
FCALLSCSUB2 (gridInqArea, GRIDINQAREA, gridinqarea, INT, PDOUBLE)
FCALLSCFUN1 (INT, gridHasArea, GRIDHASAREA, gridhasarea, INT)
......
......@@ -122,11 +122,14 @@
#define ISEC2_NumVCP (isec2[11]) /* Number of vertical coordinate parameters */
/* Lambert */
#define ISEC2_LoV (isec2[ 6]) /* Orientation of the grid */
#define ISEC2_Xinc (isec2[ 8]) /* X-direction grid length */
#define ISEC2_Yinc (isec2[ 9]) /* Y-direction grid length */
#define ISEC2_LatS1 (isec2[13]) /* First lat at which the secant cone cuts the sphere */
#define ISEC2_LatS2 (isec2[14]) /* Second lat at which the secant cone cuts the sphere */
#define ISEC2_Lambert_Lov (isec2[ 6]) /* Orientation of the grid */
#define ISEC2_Lambert_dx (isec2[ 8]) /* X-direction grid length */
#define ISEC2_Lambert_dy (isec2[ 9]) /* Y-direction grid length */
#define ISEC2_Lambert_ProjFlag (isec2[12]) /* Projection centre flag */
#define ISEC2_Lambert_LatS1 (isec2[13]) /* First lat at which the secant cone cuts the sphere */
#define ISEC2_Lambert_LatS2 (isec2[14]) /* Second lat at which the secant cone cuts the sphere */
#define ISEC2_Lambert_LatSP (isec2[19]) /* Latitude of the southern pole */
#define ISEC2_Lambert_LonSP (isec2[20]) /* Longitude of the southern pole */
#define ISEC2_Reduced (isec2[16]) /* 0: regular, 1: reduced grid */
......
/* Generated automatically from m214003 on Wed Aug 13 11:39:57 CEST 2008 */
/* Generated automatically from m214003 on Thu Oct 23 13:39:51 CEST 2008 */
/* GRIBLIB_VERSION="1.2.0" */
/* GRIBLIB_VERSION="1.2.1" */
#if defined (HAVE_CONFIG_H)
# include "config.h"
......@@ -215,11 +215,14 @@ void gribDecode(int *isec0, int *isec1, int *isec2, double *fsec2, int *isec3,
#define GDS_RotAngle GET_Real(&(gds[38]))
/* Lambert */
#define GDS_LoV GET_INT3(gds[17], gds[18], gds[19])
#define GDS_Xinc GET_INT3(gds[20], gds[21], gds[22])
#define GDS_Yinc GET_INT3(gds[23], gds[24], gds[25])
#define GDS_LatS1 GET_INT3(gds[28], gds[29], gds[30])
#define GDS_LatS2 GET_INT3(gds[31], gds[32], gds[33])
#define GDS_Lambert_Lov GET_INT3(gds[17], gds[18], gds[19])
#define GDS_Lambert_dx GET_INT3(gds[20], gds[21], gds[22])
#define GDS_Lambert_dy GET_INT3(gds[23], gds[24], gds[25])
#define GDS_Lambert_ProjFlag GET_UINT1(gds[26])
#define GDS_Lambert_LatS1 GET_INT3(gds[28], gds[29], gds[30])
#define GDS_Lambert_LatS2 GET_INT3(gds[31], gds[32], gds[33])
#define GDS_Lambert_LatSP GET_INT3(gds[34], gds[35], gds[36])
#define GDS_Lambert_LonSP GET_INT3(gds[37], gds[37], gds[37])
/* Section 3: Bit Map Section (BMS) */
......@@ -3068,14 +3071,16 @@ void encodeGDS(GRIBPACK *lGrib, int *gribLen, int *isec2, double *fsec2)
Put3Int(ISEC2_FirstLat);
Put3Int(ISEC2_FirstLon);
Put1Byte(ISEC2_ResFlag); /* 16 Resolution flag */
Put3Int(ISEC2_LoV); /* 17-19 */
Put3Int(ISEC2_Xinc); /* 20-22 */
Put3Int(ISEC2_Yinc); /* 23-25 */
PutnZero(1);
Put3Int(ISEC2_Lambert_Lov); /* 17-19 */
Put3Int(ISEC2_Lambert_dx); /* 20-22 */
Put3Int(ISEC2_Lambert_dy); /* 23-25 */
Put1Byte(ISEC2_Lambert_ProjFlag);/* 26 Projection flag */
Put1Byte(ISEC2_ScanFlag); /* 27 Scanning mode */
Put3Int(ISEC2_LatS1); /* 28-30 */
Put3Int(ISEC2_LatS2); /* 31-33 */
PutnZero(8); /* 34-41 */
Put3Int(ISEC2_Lambert_LatS1); /* 28-30 */
Put3Int(ISEC2_Lambert_LatS2); /* 31-33 */
Put3Int(ISEC2_Lambert_LatSP); /* 34-36 */
Put3Int(ISEC2_Lambert_LonSP); /* 37-39 */
PutnZero(2); /* 34-41 */
}
else if ( ISEC2_GridType == GTYPE_LATLON ||
ISEC2_GridType == GTYPE_GAUSSIAN ||
......@@ -4196,12 +4201,15 @@ static int decodeGDS(unsigned char *gds, int *isec0, int *isec2, double *fsec2,
ISEC2_FirstLat = GDS_FirstLat;
ISEC2_FirstLon = GDS_FirstLon;
ISEC2_ResFlag = GDS_ResFlag;
ISEC2_LoV = GDS_LoV;
ISEC2_Xinc = GDS_Xinc;
ISEC2_Yinc = GDS_Yinc;
ISEC2_LatS1 = GDS_LatS1;
ISEC2_LatS2 = GDS_LatS2;
ISEC2_ScanFlag = GDS_ScanFlag;
ISEC2_Lambert_Lov = GDS_Lambert_Lov;
ISEC2_Lambert_dx = GDS_Lambert_dx;
ISEC2_Lambert_dy = GDS_Lambert_dy;
ISEC2_Lambert_LatS1 = GDS_Lambert_LatS1;
ISEC2_Lambert_LatS2 = GDS_Lambert_LatS2;
ISEC2_Lambert_LatSP = GDS_Lambert_LatSP;
ISEC2_Lambert_LonSP = GDS_Lambert_LonSP;
ISEC2_Lambert_ProjFlag = GDS_Lambert_ProjFlag;
ISEC2_ScanFlag = GDS_ScanFlag;
}
else if ( ISEC2_GridType == GTYPE_SPECTRAL )
{
......@@ -8354,7 +8362,7 @@ int gribUnzip(unsigned char *dbuf, long dbufsize, unsigned char *sbuf, long sbu
return (gribLen);
}
static const char grb_libvers[] = "1.2.0" " of ""Aug 13 2008"" ""11:39:57";
static const char grb_libvers[] = "1.2.1" " of ""Oct 23 2008"" ""13:39:51";
const char *
gribLibraryVersion(void)
{
......
......@@ -190,6 +190,8 @@ static void grid_init_entry(GRID *gridptr)
gridptr->lcc_lat2 = 0.0;
gridptr->lcc_xinc = 0.0;
gridptr->lcc_yinc = 0.0;
gridptr->lcc_projflag = 0;
gridptr->lcc_scanflag = 0;
gridptr->lcc_defined = FALSE;
gridptr->trunc = 0;
gridptr->nvertex = 0;
......@@ -2410,7 +2412,8 @@ int gridGenerate(GRID grid)
if ( grid.type == GRID_LCC )
gridDefLCC(gridID, grid.lcc_originLon, grid.lcc_originLat, grid.lcc_lonParY,
grid.lcc_lat1, grid.lcc_lat2, grid.lcc_xinc, grid.lcc_yinc);
grid.lcc_lat1, grid.lcc_lat2, grid.lcc_xinc, grid.lcc_yinc,
grid.lcc_projflag, grid.lcc_scanflag);
break;
}
......@@ -3185,7 +3188,9 @@ void gridPrint(int gridID, int opt)
case GRID_LCC:
{
double originLon, originLat, lonParY, lat1, lat2, xincm, yincm;
gridInqLCC(gridID, &originLon, &originLat, &lonParY, &lat1, &lat2, &xincm, &yincm);
int projflag, scanflag;
gridInqLCC(gridID, &originLon, &originLat, &lonParY, &lat1, &lat2, &xincm, &yincm,
&projflag, &scanflag);
fprintf(fp, "xsize : %d\n", xsize);
fprintf(fp, "ysize : %d\n", ysize);
......@@ -3197,6 +3202,10 @@ void gridPrint(int gridID, int opt)
fprintf(fp, "lat2 : %g\n", lat2);
fprintf(fp, "xinc : %g\n", xincm);
fprintf(fp, "yinc : %g\n", yincm);
if ( (projflag & 128) == 0 )
fprintf(fp, "projection: northpole\n");
else
fprintf(fp, "projection: southpole\n");
break;
}
......@@ -3473,9 +3482,11 @@ int gridToCurvilinear(int gridID1)
double xi, xj;
double originLon, originLat, lonParY, lat1, lat2, xincm, yincm;
double zlat, zlon;
int projflag, scanflag;
int status;
gridInqLCC(gridID1, &originLon, &originLat, &lonParY, &lat1, &lat2, &xincm, &yincm);
gridInqLCC(gridID1, &originLon, &originLat, &lonParY, &lat1, &lat2, &xincm, &yincm,
&projflag, &scanflag);
/*
while ( originLon < 0 ) originLon += 360;
while ( lonParY < 0 ) lonParY += 360;
......@@ -3544,10 +3555,12 @@ int gridToCurvilinear(int gridID1)
double xi, xj;
double originLon, originLat, lonParY, lat1, lat2, xincm, yincm;
double zlat, zlon;
int projflag, scanflag;
int status;
int index;
gridInqLCC(gridID1, &originLon, &originLat, &lonParY, &lat1, &lat2, &xincm, &yincm);
gridInqLCC(gridID1, &originLon, &originLat, &lonParY, &lat1, &lat2, &xincm, &yincm,
&projflag, &scanflag);
xbounds2D = (double *) malloc(4*gridsize*sizeof(double));
ybounds2D = (double *) malloc(4*gridsize*sizeof(double));
......@@ -3862,7 +3875,7 @@ const double *gridInqYvalsPtr(int gridID)
@Function gridDefLCC
@Title Define the parameter of a Lambert Conformal Conic grid
@Prototype void gridDefLCC(int gridID, double originLon, double originLat, double lonParY, double lat1, double lat2, double xinc, double yinc)
@Prototype void gridDefLCC(int gridID, double originLon, double originLat, double lonParY, double lat1, double lat2, double xinc, double yinc, int projflag, int scanflag)
@Parameter
@Item gridID Grid ID, from a previous call to @fref{gridCreate}
@Item originLon Longitude of the first grid point
......@@ -3872,6 +3885,8 @@ const double *gridInqYvalsPtr(int gridID)
@Item lat2 Second latitude at which the secant cone cuts the sphere
@Item xinc X-direction grid lenght in meter
@Item yinc Y-direction grid lenght in meter
@Item projflag Projection centre flag
@Item scanflag Scanning mode flag
@Description
The function @func{gridDefLCC} defines the parameter of a Lambert Conformal Conic grid.
......@@ -3879,7 +3894,8 @@ The function @func{gridDefLCC} defines the parameter of a Lambert Conformal Coni
@EndFunction
*/
void gridDefLCC(int gridID, double originLon, double originLat, double lonParY,
double lat1, double lat2, double xinc, double yinc)
double lat1, double lat2, double xinc, double yinc,
int projflag, int scanflag)
{
static char func[] = "gridDefLCC";
GRID *gridptr;
......@@ -3897,6 +3913,8 @@ void gridDefLCC(int gridID, double originLon, double originLat, double lonParY,
gridptr->lcc_lat2 = lat2;
gridptr->lcc_xinc = xinc;
gridptr->lcc_yinc = yinc;
gridptr->lcc_projflag = projflag;
gridptr->lcc_scanflag = scanflag;
gridptr->lcc_defined = TRUE;
}
}
......@@ -3906,7 +3924,7 @@ void gridDefLCC(int gridID, double originLon, double originLat, double lonParY,
@Function gridInqLCC
@Title Get the parameter of a Lambert Conformal Conic grid
@Prototype void gridInqLCC(int gridID, double *originLon, double *originLat, double *lonParY, double *lat1, double *lat2, double *xinc, double *yinc)
@Prototype void gridInqLCC(int gridID, double *originLon, double *originLat, double *lonParY, double *lat1, double *lat2, double *xinc, double *yinc, int *projflag, int *scanflag)
@Parameter
@Item gridID Grid ID, from a previous call to @fref{gridCreate}
@Item originLon Longitude of the first grid point
......@@ -3916,6 +3934,8 @@ void gridDefLCC(int gridID, double originLon, double originLat, double lonParY,
@Item lat2 Second latitude at which the secant cone cuts the sphere
@Item xinc X-direction grid lenght in meter
@Item yinc Y-direction grid lenght in meter
@Item projflag Projection centre flag
@Item scanflag Scanning mode flag
@Description
The function @func{gridInqLCC} returns the parameter of a Lambert Conformal Conic grid.
......@@ -3923,7 +3943,8 @@ The function @func{gridInqLCC} returns the parameter of a Lambert Conformal Coni
@EndFunction
*/
void gridInqLCC(int gridID, double *originLon, double *originLat, double *lonParY,
double *lat1, double *lat2, double *xinc, double *yinc)
double *lat1, double *lat2, double *xinc, double *yinc,
int *projflag, int *scanflag)
{
static char func[] = "gridDefLCC";
GRID *gridptr;
......@@ -3943,6 +3964,8 @@ void gridInqLCC(int gridID, double *originLon, double *originLat, double *lonPar
*lat2 = gridptr->lcc_lat2;
*xinc = gridptr->lcc_xinc;
*yinc = gridptr->lcc_yinc;
*projflag = gridptr->lcc_projflag;
*scanflag = gridptr->lcc_scanflag;
}
else
Warning(func, "Lambert Conformal grid undefined (gridID = %d)", gridID);
......
......@@ -22,6 +22,8 @@ typedef struct {
double lcc_lat2;
double lcc_xinc;
double lcc_yinc;
int lcc_projflag;
int lcc_scanflag;
int lcc_defined;
double xpole, ypole, angle; /* rotated north pole */
int isCyclic; /* TRUE for global cyclic grids */
......
......@@ -848,13 +848,15 @@ void grbAddRecord(int streamID, int code, int *isec1, int *isec2, double *fsec2,
grid.xsize = ISEC2_NumLon;
grid.ysize = ISEC2_NumLat;
grid.lcc_xinc = ISEC2_Xinc;
grid.lcc_yinc = ISEC2_Yinc;
grid.lcc_xinc = ISEC2_Lambert_dx;
grid.lcc_yinc = ISEC2_Lambert_dy;
grid.lcc_originLon = ISEC2_FirstLon * 0.001;
grid.lcc_originLat = ISEC2_FirstLat * 0.001;
grid.lcc_lonParY = ISEC2_LoV * 0.001;
grid.lcc_lat1 = ISEC2_LatS1 * 0.001;
grid.lcc_lat2 = ISEC2_LatS2 * 0.001;
grid.lcc_lonParY = ISEC2_Lambert_Lov * 0.001;
grid.lcc_lat1 = ISEC2_Lambert_LatS1 * 0.001;
grid.lcc_lat2 = ISEC2_Lambert_LatS2 * 0.001;
grid.lcc_projflag = ISEC2_Lambert_ProjFlag;
grid.lcc_scanflag = ISEC2_ScanFlag;
grid.xdef = 0;
grid.ydef = 0;
......@@ -1944,24 +1946,28 @@ void grbDefGrid(int *isec1, int *isec2, int gridID)
{
double originLon, originLat, lonParY, lat1, lat2, xincm, yincm;
int xsize, ysize;
int projflag, scanflag;
xsize = gridInqXsize(gridID);
ysize = gridInqYsize(gridID);
gridInqLCC(gridID, &originLon, &originLat, &lonParY, &lat1, &lat2, &xincm, &yincm);
gridInqLCC(gridID, &originLon, &originLat, &lonParY, &lat1, &lat2, &xincm, &yincm,
&projflag, &scanflag);
ISEC2_GridType = GTYPE_LCC;
ISEC2_NumLon = xsize;
ISEC2_NumLat = ysize;
ISEC2_FirstLon = NINT(originLon * 1000);
ISEC2_FirstLat = NINT(originLat * 1000);
ISEC2_LoV = NINT(lonParY * 1000);
ISEC2_LatS1 = NINT(lat1 * 1000);
ISEC2_LatS2 = NINT(lat2 * 1000);
ISEC2_Xinc = NINT(xincm);
ISEC2_Yinc = NINT(yincm);
ISEC2_ScanFlag = 2; /* scanning west to east, south to north */
ISEC2_Lambert_Lov = NINT(lonParY * 1000);
ISEC2_Lambert_LatS1 = NINT(lat1 * 1000);
ISEC2_Lambert_LatS2 = NINT(lat2 * 1000);
ISEC2_Lambert_dx = NINT(xincm);
ISEC2_Lambert_dy = NINT(yincm);
ISEC2_Lambert_LatSP = 0;
ISEC2_Lambert_LatSP = 0;
ISEC2_Lambert_ProjFlag = projflag;
ISEC2_ScanFlag = scanflag;
break;
}
......
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