diff --git a/src/AVISOLOCAL.cpp b/src/AVISOLOCAL.cpp index 69aa683..0d92a26 100644 --- a/src/AVISOLOCAL.cpp +++ b/src/AVISOLOCAL.cpp @@ -183,6 +183,10 @@ template AVISOLOCALData::Data AVISOLOCALData::ReadVarRaw(const N real lat1 = p->latb; real lat2 = p->late; + // Special case when the longitude lies in a small sector between the end and the start + if(lon1 < lonb) lon1 = lone; + if(lon2 > lone) lon2 = lonb; + auto yb = static_cast(Floor((lat1 - latb) / latstep)); auto ye = static_cast(Ceil((lat2 - latb) / latstep)); if(ye > dn.ny - 1) ye = dn.ny - 1; diff --git a/src/layereddata.cpp b/src/layereddata.cpp index c7eada3..bfc646c 100644 --- a/src/layereddata.cpp +++ b/src/layereddata.cpp @@ -142,6 +142,10 @@ std::pair LayeredData::Parameters(michlib_intern real lat1 = args.at("latb").ToReal(); real lat2 = args.at("late").ToReal(); + // Special case when the longitude lies in a small sector between the end and the start + if(lon1 < lonb) lon1 = lone; + if(lon2 > lone) lon2 = lonb; + ppar->yb = static_cast(Floor((lat1 - latb) / latstep)); ppar->ye = static_cast(Ceil((lat2 - latb) / latstep)); if(ppar->ye > dname.ny - 1) ppar->ye = dname.ny - 1;