Commit b7e38a4c authored by Uwe Schulzweida's avatar Uwe Schulzweida
Browse files

add support for GRID type LCC2

parent d331a850
2009-02-?? Uwe Schulzweida <Uwe.Schulzweida@zmaw.de>
* add support for GRID type LCC2 (LCC PROJ.4 version)
* Version 1.3.0 released
2009-01-15 Uwe Schulzweida <Uwe.Schulzweida@zmaw.de>
* add support for GRID type SINUSOIDAL
......
#! /bin/sh
# Guess values for system-dependent variables and create Makefiles.
# Generated by GNU Autoconf 2.61 for cdi 1.3.0.
# Generated by GNU Autoconf 2.61 for cdi 1.3.1.
#
# Report bugs to <Uwe.Schulzweida@zmaw.de>.
#
......@@ -574,8 +574,8 @@ SHELL=${CONFIG_SHELL-/bin/sh}
# Identity of this package.
PACKAGE_NAME='cdi'
PACKAGE_TARNAME='cdi'
PACKAGE_VERSION='1.3.0'
PACKAGE_STRING='cdi 1.3.0'
PACKAGE_VERSION='1.3.1'
PACKAGE_STRING='cdi 1.3.1'
PACKAGE_BUGREPORT='Uwe.Schulzweida@zmaw.de'
# Factoring default headers for most tests.
......@@ -1229,7 +1229,7 @@ if test "$ac_init_help" = "long"; then
# Omit some internal or obsolete options to make the list less imposing.
# This message is too long to be a string in the A/UX 3.1 sh.
cat <<_ACEOF
\`configure' configures cdi 1.3.0 to adapt to many kinds of systems.
\`configure' configures cdi 1.3.1 to adapt to many kinds of systems.
Usage: $0 [OPTION]... [VAR=VALUE]...
......@@ -1300,7 +1300,7 @@ fi
if test -n "$ac_init_help"; then
case $ac_init_help in
short | recursive ) echo "Configuration of cdi 1.3.0:";;
short | recursive ) echo "Configuration of cdi 1.3.1:";;
esac
cat <<\_ACEOF
......@@ -1405,7 +1405,7 @@ fi
test -n "$ac_init_help" && exit $ac_status
if $ac_init_version; then
cat <<\_ACEOF
cdi configure 1.3.0
cdi configure 1.3.1
generated by GNU Autoconf 2.61
Copyright (C) 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001,
......@@ -1419,7 +1419,7 @@ cat >config.log <<_ACEOF
This file contains any messages produced by compilers while
running configure, to aid debugging if configure makes a mistake.
It was created by cdi $as_me 1.3.0, which was
It was created by cdi $as_me 1.3.1, which was
generated by GNU Autoconf 2.61. Invocation command line was
$ $0 $@
......@@ -2244,7 +2244,7 @@ fi
# Define the identity of the package.
PACKAGE='cdi'
VERSION='1.3.0'
VERSION='1.3.1'
cat >>confdefs.h <<_ACEOF
......@@ -6919,7 +6919,7 @@ exec 6>&1
# report actual input values of CONFIG_FILES etc. instead of their
# values after options handling.
ac_log="
This file was extended by cdi $as_me 1.3.0, which was
This file was extended by cdi $as_me 1.3.1, which was
generated by GNU Autoconf 2.61. Invocation command line was
CONFIG_FILES = $CONFIG_FILES
......@@ -6972,7 +6972,7 @@ Report bugs to <bug-autoconf@gnu.org>."
_ACEOF
cat >>$CONFIG_STATUS <<_ACEOF
ac_cs_version="\\
cdi config.status 1.3.0
cdi config.status 1.3.1
configured by $0, generated by GNU Autoconf 2.61,
with options \\"`echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`\\"
......
# Process this file with autoconf to produce a configure script.
AC_INIT(cdi, 1.3.0, Uwe.Schulzweida@zmaw.de)
AC_INIT(cdi, 1.3.1, Uwe.Schulzweida@zmaw.de)
CONFIG_ABORT=yes
......
......@@ -107,9 +107,10 @@ extern "C" {
#define GRID_TRAJECTORY 8
#define GRID_CELL 9
#define GRID_CURVILINEAR 10
#define GRID_LCC 11 /* Lambert Conformal Conic */
#define GRID_LAEA 12 /* Lambert Azimuthal Equal Area */
#define GRID_SINUSOIDAL 13 /* Sinusoidal */
#define GRID_LCC 11 /* Lambert Conformal Conic (GRIB) */
#define GRID_LCC2 12 /* Lambert Conformal Conic (PROJ) */
#define GRID_LAEA 13 /* Lambert Azimuthal Equal Area */
#define GRID_SINUSOIDAL 14 /* Sinusoidal */
/* ZAXIS types */
......@@ -544,10 +545,14 @@ void gridDefGMEni2(int gridID, int ni2);
int gridInqGMEni3(int gridID);
void gridDefGMEni3(int gridID, int ni3);
/* Lambert Conformal Conic grid */
/* Lambert Conformal Conic grid (GRIB version) */
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);
/* Lambert Conformal Conic 2 grid (PROJ version) */
void gridDefLcc2(int gridID, double earth_radius, double lon_0, double lat_0, double lat_1, double lat_2);
void gridInqLcc2(int gridID, double *earth_radius, double *lon_0, double *lat_0, double *lat_1, double *lat_2);
/* Lambert Azimuthal Equal Area grid */
void gridDefLaea(int gridID, double earth_radius, double lon_0, double lat_0);
void gridInqLaea(int gridID, double *earth_radius, double *lon_0, double *lat_0);
......
......@@ -33,8 +33,9 @@ char *Grids[] = {
/* 9 */ "cell",
/* 10 */ "curvilinear",
/* 11 */ "lcc",
/* 12 */ "laea",
/* 13 */ "sinusoidal",
/* 12 */ "lcc2",
/* 13 */ "laea",
/* 14 */ "sinusoidal",
};
......@@ -194,6 +195,12 @@ static void grid_init_entry(grid_t *gridptr)
gridptr->lcc_projflag = 0;
gridptr->lcc_scanflag = 0;
gridptr->lcc_defined = FALSE;
gridptr->lcc2_lon_0 = 0.0;
gridptr->lcc2_lat_0 = 0.0;
gridptr->lcc2_lat_1 = 0.0;
gridptr->lcc2_lat_2 = 0.0;
gridptr->lcc2_a = 0.0;
gridptr->lcc2_defined = FALSE;
gridptr->laea_lon_0 = 0.0;
gridptr->laea_lat_0 = 0.0;
gridptr->laea_a = 0.0;
......@@ -704,6 +711,7 @@ int gridCreate(int gridtype, int size)
gridDefYunits(gridID, "degrees");
break;
}
case GRID_LCC2:
case GRID_SINUSOIDAL:
case GRID_LAEA:
{
......@@ -2377,6 +2385,7 @@ int gridGenerate(grid_t grid)
case GRID_CURVILINEAR:
case GRID_GENERIC:
case GRID_LCC:
case GRID_LCC2:
case GRID_SINUSOIDAL:
case GRID_LAEA:
{
......@@ -2444,6 +2453,9 @@ int gridGenerate(grid_t grid)
if ( grid.type == GRID_LAEA )
gridDefLaea(gridID, grid.laea_a, grid.laea_lon_0, grid.laea_lat_0);
if ( grid.type == GRID_LCC2 )
gridDefLcc2(gridID, grid.lcc2_a, grid.lcc2_lon_0, grid.lcc2_lat_0, grid.lcc2_lat_1, grid.lcc2_lat_2);
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,
......@@ -3061,6 +3073,7 @@ void gridPrint(int gridID, int opt)
case GRID_LONLAT:
case GRID_GAUSSIAN:
case GRID_GENERIC:
case GRID_LCC2:
case GRID_SINUSOIDAL:
case GRID_LAEA:
case GRID_CURVILINEAR:
......@@ -3092,6 +3105,17 @@ void gridPrint(int gridID, int opt)
fprintf(fp, "lat_0 = %g\n", lat_0);
}
if ( type == GRID_LCC2 )
{
double a, lon_0, lat_0, lat_1, lat_2;
gridInqLcc2(gridID, &a, &lon_0, &lat_0, &lat_1, &lat_2);
fprintf(fp, "a = %g\n", a);
fprintf(fp, "lon_0 = %g\n", lon_0);
fprintf(fp, "lat_0 = %g\n", lat_0);
fprintf(fp, "lat_1 = %g\n", lat_1);
fprintf(fp, "lat_2 = %g\n", lat_2);
}
if ( gridptr->isRotated )
{
if ( xsize > 0 ) fprintf(fp, "xnpole = %g\n", gridptr->xpole);
......@@ -3102,8 +3126,9 @@ void gridPrint(int gridID, int opt)
{
double xfirst = 0.0, xinc = 0.0;
if ( type == GRID_LONLAT || type == GRID_GAUSSIAN ||
type == GRID_GENERIC || type == GRID_SINUSOIDAL || type == GRID_LAEA )
if ( type == GRID_LONLAT || type == GRID_GAUSSIAN ||
type == GRID_GENERIC || type == GRID_LCC2 ||
type == GRID_SINUSOIDAL || type == GRID_LAEA )
{
xfirst = gridInqXval(gridID, 0);
xinc = gridInqXinc(gridID);
......@@ -3149,7 +3174,7 @@ void gridPrint(int gridID, int opt)
{
double yfirst = 0.0, yinc = 0.0;
if ( type == GRID_LONLAT || type == GRID_GENERIC ||
if ( type == GRID_LONLAT || type == GRID_GENERIC || type == GRID_LCC2 ||
type == GRID_SINUSOIDAL || type == GRID_LAEA )
{
yfirst = gridInqYval(gridID, 0);
......@@ -3326,7 +3351,7 @@ void gridDefLCC(int gridID, double originLon, double originLat, double lonParY,
gridptr = grid_to_pointer(gridID);
if ( gridptr->type != GRID_LCC )
Warning(func, "Definition of LAEA grid for %s grid not allowed!",
Warning(func, "Definition of LCC grid for %s grid not allowed!",
gridNamePtr(gridptr->type));
else
{
......@@ -3397,6 +3422,53 @@ void gridInqLCC(int gridID, double *originLon, double *originLat, double *lonPar
}
}
void gridDefLcc2(int gridID, double earth_radius, double lon_0, double lat_0, double lat_1, double lat_2)
{
static char func[] = "gridDefLcc2";
grid_t *gridptr;
gridptr = grid_to_pointer(gridID);
if ( gridptr->type != GRID_LCC2 )
Warning(func, "Definition of LCC2 grid for %s grid not allowed!",
gridNamePtr(gridptr->type));
else
{
gridptr->lcc2_a = earth_radius;
gridptr->lcc2_lon_0 = lon_0;
gridptr->lcc2_lat_0 = lat_0;
gridptr->lcc2_lat_1 = lat_1;
gridptr->lcc2_lat_2 = lat_2;
gridptr->lcc2_defined = TRUE;
}
}
void gridInqLcc2(int gridID, double *earth_radius, double *lon_0, double *lat_0, double *lat_1, double *lat_2)
{
static char func[] = "gridInqLcc2";
grid_t *gridptr;
gridptr = grid_to_pointer(gridID);
if ( gridptr->type != GRID_LCC2 )
Warning(func, "Inquire of LCC2 grid definition for %s grid not allowed!",
gridNamePtr(gridptr->type));
else
{
if ( gridptr->lcc2_defined )
{
*earth_radius = gridptr->lcc2_a;
*lon_0 = gridptr->lcc2_lon_0;
*lat_0 = gridptr->lcc2_lat_0;
*lat_1 = gridptr->lcc2_lat_1;
*lat_2 = gridptr->lcc2_lat_2;
}
else
Warning(func, "LCC2 grid undefined (gridID = %d)", gridID);
}
}
void gridDefLaea(int gridID, double earth_radius, double lon_0, double lat_0)
{
static char func[] = "gridDefLaea";
......@@ -3419,7 +3491,7 @@ void gridDefLaea(int gridID, double earth_radius, double lon_0, double lat_0)
void gridInqLaea(int gridID, double *earth_radius, double *lon_0, double *lat_0)
{
static char func[] = "gridDefLaea";
static char func[] = "gridInqLaea";
grid_t *gridptr;
gridptr = grid_to_pointer(gridID);
......
......@@ -25,6 +25,12 @@ typedef struct {
int lcc_projflag;
int lcc_scanflag;
int lcc_defined;
double lcc2_lon_0; /* Lambert Conformal Conic 2 */
double lcc2_lat_0;
double lcc2_lat_1;
double lcc2_lat_2;
double lcc2_a;
int lcc2_defined;
double laea_lon_0; /* Lambert Azimuthal Equal Area */
double laea_lat_0;
double laea_a;
......
......@@ -2283,6 +2283,40 @@ void cdfDefMapping(int streamID, int gridID)
cdf_put_att_double(fileID, ncvarid, "latitude_of_projection_origin", NC_DOUBLE, 1L, &lat_0);
}
cdf_enddef(fileID);
}
else if ( gridInqType(gridID) == GRID_LCC2 )
{
char varname[] = "Lambert_Conformal";
char mapname[] = "lambert_conformal_conic";
fileID = streamInqFileID(streamID);
cdf_redef(fileID);
ncerr = nc_def_var(fileID, varname, (nc_type) NC_CHAR, 0, NULL, &ncvarid);
if ( ncerr == NC_NOERR )
{
double a, lon_0, lat_0, lat_1, lat_2;
gridInqLcc2(gridID, &a, &lon_0, &lat_0, &lat_1, &lat_2);
cdf_put_att_text(fileID, ncvarid, "grid_mapping_name", strlen(mapname), mapname);
if ( a > 0 )
cdf_put_att_double(fileID, ncvarid, "earth_radius", NC_DOUBLE, 1L, &a);
cdf_put_att_double(fileID, ncvarid, "longitude_of_central_meridian", NC_DOUBLE, 1L, &lon_0);
cdf_put_att_double(fileID, ncvarid, "latitude_of_projection_origin", NC_DOUBLE, 1L, &lat_0);
if ( DBL_IS_EQUAL(lat_1, lat_2) )
cdf_put_att_double(fileID, ncvarid, "standard_parallel", NC_DOUBLE, 1L, &lat_1);
else
{
double lat_1_2[2];
lat_1_2[0] = lat_1;
lat_1_2[1] = lat_2;
cdf_put_att_double(fileID, ncvarid, "standard_parallel", NC_DOUBLE, 2L, lat_1_2);
}
}
cdf_enddef(fileID);
}
#endif
......@@ -2348,7 +2382,7 @@ void cdfDefGrid(int streamID, int gridID)
{
cdfDefCell(streamID, gridID);
}
else if ( gridtype == GRID_SINUSOIDAL || gridtype == GRID_LAEA )
else if ( gridtype == GRID_SINUSOIDAL || gridtype == GRID_LAEA || gridtype == GRID_LCC2 )
{
cdfDefXaxis(streamID, gridID);
cdfDefYaxis(streamID, gridID);
......@@ -2566,6 +2600,12 @@ int cdfDefVar(int streamID, int varID)
cdf_put_att_text(fileID, ncvarid, "grid_mapping", strlen(mapping), mapping);
}
if ( gridInqType(gridID) == GRID_LCC2 )
{
char mapping[] = "Lambert_Conformal";
cdf_put_att_text(fileID, ncvarid, "grid_mapping", strlen(mapping), mapping);
}
if ( gridInqType(gridID) == GRID_TRAJECTORY )
{
cdf_put_att_text(fileID, ncvarid, "coordinates", 9, "tlon tlat" );
......@@ -3594,6 +3634,7 @@ int cdfInqContents(int streamID)
char attname[256];
const int attstringlen = 8192; char attstring[8192];
char *pname, *plongname, *punits;
double datt;
int iatt, timehasunit = 0;
int time_has_bounds = FALSE;
size_t len;
......@@ -3902,6 +3943,8 @@ int cdfInqContents(int streamID)
;
else if ( strncmp(attstring, "laea", attlen) == 0 )
;
else if ( strncmp(attstring, "lcc2", attlen) == 0 )
;
else
{
static int warn = TRUE;
......@@ -4956,6 +4999,7 @@ int cdfInqContents(int streamID)
for ( iatt = 0; iatt < nvatts; iatt++ )
{
cdf_inq_attname(fileID, ncvars[ncvarid].gmapid, iatt, attname);
cdf_inq_attlen(fileID, ncvars[ncvarid].gmapid, attname, &attlen);
if ( strcmp(attname, "grid_mapping_name") == 0 )
{
......@@ -4967,18 +5011,44 @@ int cdfInqContents(int streamID)
grid.type = GRID_SINUSOIDAL;
else if ( strcmp(attstring, "lambert_azimuthal_equal_area") == 0 )
grid.type = GRID_LAEA;
else if ( strcmp(attstring, "lambert_conformal_conic") == 0 )
grid.type = GRID_LCC2;
}
else if ( strcmp(attname, "earth_radius") == 0 )
{
cdfGetAttDouble(fileID, ncvars[ncvarid].gmapid, attname, 1, &grid.laea_a);
cdfGetAttDouble(fileID, ncvars[ncvarid].gmapid, attname, 1, &datt);
grid.laea_a = datt;
grid.lcc2_a = datt;
}
else if ( strcmp(attname, "longitude_of_projection_origin") == 0 )
{
cdfGetAttDouble(fileID, ncvars[ncvarid].gmapid, attname, 1, &grid.laea_lon_0);
}
else if ( strcmp(attname, "longitude_of_central_meridian") == 0 )
{
cdfGetAttDouble(fileID, ncvars[ncvarid].gmapid, attname, 1, &grid.lcc2_lon_0);
}
else if ( strcmp(attname, "latitude_of_projection_origin") == 0 )
{
cdfGetAttDouble(fileID, ncvars[ncvarid].gmapid, attname, 1, &grid.laea_lat_0);
cdfGetAttDouble(fileID, ncvars[ncvarid].gmapid, attname, 1, &datt);
grid.laea_lat_0 = datt;
grid.lcc2_lat_0 = datt;
}
else if ( strcmp(attname, "standard_parallel") == 0 )
{
if ( attlen == 1 )
{
cdfGetAttDouble(fileID, ncvars[ncvarid].gmapid, attname, 1, &datt);
grid.lcc2_lat_1 = datt;
grid.lcc2_lat_2 = datt;
}
else
{
double datt2[2];
cdfGetAttDouble(fileID, ncvars[ncvarid].gmapid, attname, 2, datt2);
grid.lcc2_lat_1 = datt2[0];
grid.lcc2_lat_2 = datt2[1];
}
}
else if ( strcmp(attname, "grid_north_pole_latitude") == 0 )
{
......
......@@ -1143,6 +1143,17 @@ void splitTimevalue(double timevalue, int timeunit, int *date, int *time)
}
else if ( timeunit == TUNIT_YEAR )
{
if ( timevalue < -214700 )
{
Warning(func, "Year %g out of range, set to -214700", timevalue);
timevalue = -214700;
}
else if ( timevalue > 214700 )
{
Warning(func, "Year %g out of range, set to 214700", timevalue);
timevalue = 214700;
}
vdate = (int) timevalue*10000;
vtime = 0;
}
......
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