Skip to content

Commit

Permalink
Per #2565, rename LaeaGrib2Data struct to simply LaeaData since we're…
Browse files Browse the repository at this point in the history
… adopting this as the standard way of initializing an LAEA grid.
  • Loading branch information
JohnHalleyGotway committed Jul 13, 2023
1 parent f267c5c commit f534679
Show file tree
Hide file tree
Showing 9 changed files with 57 additions and 147 deletions.
15 changes: 9 additions & 6 deletions src/libcode/vx_data2d_grib2/data2d_grib2.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1298,16 +1298,16 @@ void MetGrib2DataFile::read_grib2_grid( gribfield *gfld) {

ScanMode = p[16];

// build an LaeaGrib2Data struct with the projection information
LaeaGrib2Data laea;
// build an LaeaData struct with the projection information
LaeaData laea;
laea.name = laea_proj_type;
laea.spheroid_name = "Grib template";
int earth_shape_int = p[0];
if(earth_shape_int == 4) {
laea.radius_km = 0;
laea.equatorial_radius_km = 0.5*6378.1370;
laea.polar_radius_km = 0.5*6356.752314;
laea.is_sphere = false;
laea.equatorial_radius_km = 0.5*6378.1370;
laea.polar_radius_km = 0.5*6356.752314;
laea.is_sphere = false;
}
else {
mlog << Error << "\nMetGrib2DataFile::read_grib2_grid() -> "
Expand All @@ -1316,7 +1316,9 @@ void MetGrib2DataFile::read_grib2_grid( gribfield *gfld) {
}
laea.nx = p[7];
laea.ny = p[8];
laea.lat_first = (double)p[9] / 1000000.0;
laea.lat_first = (double)p[9] / 1000000.0;

// JHG
// TODO: Suspect a bug in g2clib
// laea.lon_first = -1.0*rescale_lon( (double)p[10] / 1000000.0 );
//
Expand All @@ -1328,6 +1330,7 @@ void MetGrib2DataFile::read_grib2_grid( gribfield *gfld) {
// BAD? {140, 17, 0, {1,1,4,1,4,1,4,4,4,-4,4,4,4,1,4,4,1} },
// FIX? {140, 17, 0, {1,1,4,1,4,1,4,4,4,-4,4,-4,4,1,4,4,1} },
cout << "TODO LAEA p[10] should be 17.1171 = "<< (double)p[10] / 1000000.0 << "\n";

laea.lon_first = 17.1171;
laea.standard_lat = (double)p[11] / 1000000.0;
laea.central_lon = -1.0*rescale_lon( (double)p[12] / 1000000.0 );
Expand Down
19 changes: 1 addition & 18 deletions src/libcode/vx_grid/find_grid_by_name.cc
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,7 @@ if ( i.st ) { g.set( *(i.st) ); status = true; }
if ( i.ll ) { g.set( *(i.ll) ); status = true; }
if ( i.m ) { g.set( *(i.m) ); status = true; }
if ( i.g ) { g.set( *(i.g) ); status = true; }
// if ( i.la ) { g.set( *(i.la) ); status = true; }
if ( i.lg ) { g.set( *(i.lg) ); status = true; }
if ( i.la ) { g.set( *(i.la) ); status = true; }

return ( status );

Expand Down Expand Up @@ -205,22 +204,6 @@ for (j=0; j<n_misc_laea_grids; ++j) {

}

}

//
// try misc laea grib2 grids
//

for (j=0; j<n_misc_laea_grib2_grids; ++j) {

if ( strcmp(name, misc_laea_grib2_grids[j].name) == 0 ) {

i.set( misc_laea_grib2_grids[j] );

return ( true );

}

}

//
Expand Down
20 changes: 2 additions & 18 deletions src/libcode/vx_grid/find_grid_by_name.h
Original file line number Diff line number Diff line change
Expand Up @@ -328,31 +328,15 @@ static const int n_ncep_gaussian_grids = sizeof(ncep_gaussian_grids)/sizeof(*nce
//


static const LaeaGrib2Data misc_laea_grids [] = {
static const LaeaData misc_laea_grids [] = {

// { "EUMETNET", "WGS_84", 31.7462, 10.4346, 67.0228, 39.5358, 31.9877, -29.421, 55.0, -10.0, 1900, 2200 },
{ "UKV", "Grib template 4", 0.0, 0.5*6378.1370, 0.5*6356.752314, 44.5172, 17.1171, 54.9, 2.5, 2.0, 2.0, 1042, 970, false }

};

static const int n_misc_laea_grids = sizeof(misc_laea_grids)/sizeof(*misc_laea_grids);


////////////////////////////////////////////////////////////////////////


//
// Grib2 Lambert Azimuthal Equal Area grids
//


static const LaeaGrib2Data misc_laea_grib2_grids [] = {

{ "UKV", "Grib template 4", 0.0, 0.5*6378.1370, 0.5*6356.752314, 44.5172, 17.1171, 54.9, 2.5, 2.0, 2.0, 1042, 970, false }

};

static const int n_misc_laea_grib2_grids = sizeof(misc_laea_grib2_grids)/sizeof(*misc_laea_grib2_grids);

////////////////////////////////////////////////////////////////////////


Expand Down
26 changes: 13 additions & 13 deletions src/libcode/vx_grid/grid_base.cc
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ mlog << Debug(grid_debug_level)
////////////////////////////////////////////////////////////////////////


void LaeaGrib2Data::dump() const
void LaeaData::dump() const

{

Expand Down Expand Up @@ -353,7 +353,7 @@ rll = (const RotatedLatLonData *) 0;
m = (const MercatorData *) 0;
g = (const GaussianData *) 0;
gi = (const GoesImagerData *) 0;
lg = (const LaeaGrib2Data *) 0;
la = (const LaeaData *) 0;
tc = (const TcrmwData *) 0;
sl = (const SemiLatLonData *) 0;

Expand All @@ -378,7 +378,7 @@ if ( rll ) { delete rll; rll = (const RotatedLatLonData *) 0; };
if ( m ) { delete m; m = (const MercatorData *) 0; };
if ( g ) { delete g; g = (const GaussianData *) 0; };
if ( gi ) { delete gi; gi = (const GoesImagerData *) 0; };
if ( lg ) { delete lg; lg = (const LaeaGrib2Data *) 0; };
if ( la ) { delete la; la = (const LaeaData *) 0; };
if ( tc ) { delete tc; tc = (const TcrmwData *) 0; };
if ( sl ) { delete sl; sl = (const SemiLatLonData *) 0; };

Expand All @@ -401,7 +401,7 @@ if ( info.rll ) set( *(info.rll) );
if ( info.m ) set( *(info.m) );
if ( info.g ) set( *(info.g) );
if ( info.gi ) set( *(info.gi) );
if ( info.lg ) set( *(info.lg) );
if ( info.la ) set( *(info.la) );
if ( info.sl ) set( *(info.sl) );

return;
Expand All @@ -425,7 +425,7 @@ if ( rll ) ++count;
if ( m ) ++count;
if ( g ) ++count;
if ( gi ) ++count;
if ( lg ) ++count;
if ( la ) ++count;
if ( sl ) ++count;

return ( count == 1 );
Expand Down Expand Up @@ -455,7 +455,7 @@ else if ( rll ) gg.set( *rll );
else if ( m ) gg.set( *m );
else if ( g ) gg.set( *g );
else if ( gi ) gg.set( *gi );
else if ( lg ) gg.set( *lg );
else if ( la ) gg.set( *la );
else if ( sl ) gg.set( *sl );

return;
Expand Down Expand Up @@ -620,19 +620,19 @@ return;
////////////////////////////////////////////////////////////////////////


void GridInfo::set(const LaeaGrib2Data & grib2_data)
void GridInfo::set(const LaeaData & data)

{

clear();

LaeaGrib2Data * D = (LaeaGrib2Data *) 0;
LaeaData * D = (LaeaData *) 0;

D = new LaeaGrib2Data;
D = new LaeaData;

memcpy(D, &grib2_data, sizeof(grib2_data));
memcpy(D, &data, sizeof(data));

lg = D; D = (LaeaGrib2Data *) 0;
la = D; D = (LaeaData *) 0;

return;

Expand Down Expand Up @@ -1316,7 +1316,7 @@ else if ( i1.rll && i2.rll ) return ( is_eq(i1.rll, i2.rll) );
else if ( i1.m && i2.m ) return ( is_eq(i1.m, i2.m ) );
else if ( i1.g && i2.g ) return ( is_eq(i1.g, i2.g ) );
else if ( i1.gi && i2.gi ) return ( is_eq(i1.gi, i2.gi ) );
else if ( i1.lg && i2.lg ) return ( is_eq(i1.lg, i2.lg ) );
else if ( i1.la && i2.la ) return ( is_eq(i1.la, i2.la ) );
else if ( i1.sl && i2.sl ) return ( is_eq(i1.sl, i2.sl ) );

return ( false );
Expand Down Expand Up @@ -1524,7 +1524,7 @@ return ( status );
////////////////////////////////////////////////////////////////////////


bool is_eq(const LaeaGrib2Data * g1, const LaeaGrib2Data * g2)
bool is_eq(const LaeaData * g1, const LaeaData * g2)

{

Expand Down
10 changes: 5 additions & 5 deletions src/libcode/vx_grid/grid_base.h
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ class GridInfo {
void set(const GaussianData &);
void set(const GoesImagerData &);
void set(const TcrmwData &);
void set(const LaeaGrib2Data &);
void set(const LaeaData &);
void set(const SemiLatLonData &);

void create_grid(Grid &) const;
Expand All @@ -87,7 +87,7 @@ class GridInfo {
const GaussianData * g; // allocated
const GoesImagerData * gi; // allocated
const TcrmwData * tc; // allocated
const LaeaGrib2Data * lg; // allocated
const LaeaData * la; // allocated
const SemiLatLonData * sl; // allocated

};
Expand Down Expand Up @@ -207,7 +207,7 @@ class Grid : public GridInterface {
Grid(const GaussianData &);
Grid(const GoesImagerData &);
Grid(const TcrmwData &);
Grid(const LaeaGrib2Data &);
Grid(const LaeaData &);
Grid(const LaeaNetcdfData &);
Grid(const SemiLatLonData &);
virtual ~Grid();
Expand All @@ -229,7 +229,7 @@ class Grid : public GridInterface {
void set (const GaussianData &);
void set (const GoesImagerData &);
void set (const TcrmwData &);
void set (const LaeaGrib2Data &);
void set (const LaeaData &);
void set (const LaeaNetcdfData &);
void set (const SemiLatLonData &);

Expand Down Expand Up @@ -291,7 +291,7 @@ extern bool is_eq(const RotatedLatLonData *, const RotatedLatLonData *);
extern bool is_eq(const MercatorData *, const MercatorData *);
extern bool is_eq(const GaussianData *, const GaussianData *);
extern bool is_eq(const GoesImagerData *, const GoesImagerData *);
extern bool is_eq(const LaeaGrib2Data *, const LaeaGrib2Data *);
extern bool is_eq(const LaeaData *, const LaeaData *);
extern bool is_eq(const SemiLatLonData *, const SemiLatLonData *);


Expand Down
Loading

0 comments on commit f534679

Please sign in to comment.