Skip to content

Commit

Permalink
Cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
pmaciel committed May 14, 2024
1 parent 278d29a commit b48a5b8
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 13 deletions.
5 changes: 2 additions & 3 deletions src/mir/netcdf/Type.cc
Original file line number Diff line number Diff line change
Expand Up @@ -414,9 +414,8 @@ Value* TypeT<std::string>::attributeValue(int nc, int id, const char* name, size
return v;
}

char value[len + 1];
memset(value, 0, sizeof(value));
NC_CALL(nc_get_att_text(nc, id, name, value), path);
std::string value(len + 1, '\0');
NC_CALL(nc_get_att_text(nc, id, name, value.data()), path);
auto* v = new ValueT<std::string>(*this, value);
return v;
}
Expand Down
11 changes: 4 additions & 7 deletions src/mir/repres/regular/Lambert.cc
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@

#include "mir/repres/regular/Lambert.h"

#include <cmath>

#include "mir/param/MIRParametrisation.h"
#include "mir/util/Angles.h"
#include "mir/util/Exceptions.h"
Expand Down Expand Up @@ -71,11 +73,6 @@ RegularGrid::Projection Lambert::make_projection(const param::MIRParametrisation
void Lambert::fillGrib(grib_info& info) const {
info.grid.grid_type = CODES_UTIL_GRID_SPEC_LAMBERT_CONFORMAL;

ASSERT(x_.size() > 1);
ASSERT(y_.size() > 1);
auto Dx = (x_.max() - x_.min()) / double(x_.size() - 1);
auto Dy = (y_.max() - y_.min()) / double(y_.size() - 1);

Point2 first = {firstPointBottomLeft_ ? x_.min() : x_.front(), firstPointBottomLeft_ ? y_.min() : y_.front()};
Point2 firstLL = grid_.projection().lonlat(first);
Point2 reference = grid_.projection().lonlat({0., 0.});
Expand All @@ -91,8 +88,8 @@ void Lambert::fillGrib(grib_info& info) const {
info.grid.longitudeOfSouthernPoleInDegrees = longitudeOfSouthernPoleInDegrees_;
info.grid.uvRelativeToGrid = uvRelativeToGrid_ ? 1 : 0;

info.extra_set("DxInMetres", Dx);
info.extra_set("DyInMetres", Dy);
info.extra_set("DxInMetres", std::abs(x_.step()));
info.extra_set("DyInMetres", std::abs(y_.step()));
info.extra_set("Latin1InDegrees", reference[LLCOORDS::LAT]);
info.extra_set("Latin2InDegrees", reference[LLCOORDS::LAT]);
info.extra_set("LoVInDegrees", writeLonPositive_ ? util::normalise_longitude(reference[LLCOORDS::LON], 0)
Expand Down
6 changes: 3 additions & 3 deletions src/mir/repres/regular/RegularGrid.cc
Original file line number Diff line number Diff line change
Expand Up @@ -212,12 +212,12 @@ bool RegularGrid::isPeriodicWestEast() const {


void RegularGrid::fillGrib(grib_info& info) const {
// shape of the reference object
// shape of the reference system
shape_.fillGrib(info, grid_.projection().spec());

// scanningMode
info.grid.iScansNegatively = x_.back() < x_.front() ? 1 : 0;
info.grid.jScansPositively = y_.front() < y_.back() ? 1 : 0;
info.grid.iScansNegatively = x_.back() < x_.front() ? 1L : 0L;
info.grid.jScansPositively = y_.front() < y_.back() ? 1L : 0L;
}


Expand Down

0 comments on commit b48a5b8

Please sign in to comment.