From 07e0b9a9fa6dabe437d4a6ed857a8c51311b32e3 Mon Sep 17 00:00:00 2001 From: Michael Uleysky Date: Tue, 4 Apr 2023 14:28:01 +1000 Subject: [PATCH] Update michlib --- include/HYCOM.h | 16 +++++++--------- include/NEMO.h | 15 +++++++-------- michlib | 2 +- 3 files changed, 15 insertions(+), 18 deletions(-) diff --git a/include/HYCOM.h b/include/HYCOM.h index 3bc62fd..6c2ad84 100644 --- a/include/HYCOM.h +++ b/include/HYCOM.h @@ -80,7 +80,6 @@ class HYCOMData { auto var = nodepth ? f.V(name, {lonname, p->xb, p->xe - p->xb + 1}, {latname, p->yb, p->ye - p->yb + 1}, {"time", i, 1}) : f.V(name, {lonname, p->xb, p->xe - p->xb + 1}, {latname, p->yb, p->ye - p->yb + 1}, {"time", i, 1}, {"depth", p->layer, 1}); - if(!var) return Data(); if(var.DimLen(0) != data.Nx() || var.DimLen(1) != data.Ny()) return Data(); @@ -220,7 +219,7 @@ class HYCOMData return "Can't find longitude/latitude"; } - auto rdepths = nc[0].V("depth"); + auto rdepths = nc[0].VR("depth"); if(!rdepths) { nc.clear(); @@ -229,9 +228,8 @@ class HYCOMData depths.resize(rdepths.DimLen(0)); for(size_t i = 0; i < depths.size(); i++) depths[i] = rdepths(i); - auto timeD = nc[0].V("time"); - auto timeF = nc[0].V("time"); - if(!(timeD || timeF)) + auto time = nc[0].VR("time"); + if(!time) { nc.clear(); return "Can't read times"; @@ -260,11 +258,11 @@ class HYCOMData } } - timeD ? times.resize(timeD.DimLen(0)) : times.resize(timeF.DimLen(0)); - for(size_t i = 0; i < times.size(); i++) times[i] = refdate + static_cast(timeD ? timeD(i) : timeF(i)) * 3600; + times.resize(time.DimLen(0)); + for(size_t i = 0; i < times.size(); i++) times[i] = refdate + static_cast(time(i)) * 3600; - auto lons = nc[0].V("lon"); - auto lats = nc[0].V("lat"); + auto lons = nc[0].VR(lonname); + auto lats = nc[0].VR(latname); if(!(lons && lats)) { nc.clear(); diff --git a/include/NEMO.h b/include/NEMO.h index 447d8ce..f63578a 100644 --- a/include/NEMO.h +++ b/include/NEMO.h @@ -268,7 +268,7 @@ class NEMOData return "Can't find longitude/latitude"; } - auto rdepths = nc[0].V("depth"); + auto rdepths = nc[0].VR("depth"); if(!rdepths) { nc.clear(); @@ -277,9 +277,8 @@ class NEMOData depths.resize(rdepths.DimLen(0)); for(size_t i = 0; i < depths.size(); i++) depths[i] = rdepths(i); - auto timeD = nc[0].V("time"); - auto timeF = nc[0].V("time"); - if(!(timeD || timeF)) + auto time = nc[0].VR("time"); + if(!time) { nc.clear(); return "Can't read times"; @@ -308,11 +307,11 @@ class NEMOData } } - timeD ? times.resize(timeD.DimLen(0)) : times.resize(timeF.DimLen(0)); - for(size_t i = 0; i < times.size(); i++) times[i] = refdate + static_cast(timeD ? timeD(i) : timeF(i)) * 3600; + times.resize(time.DimLen(0)); + for(size_t i = 0; i < times.size(); i++) times[i] = refdate + static_cast(time(i)) * 3600; - auto lons = nc[0].V("longitude"); - auto lats = nc[0].V("latitude"); + auto lons = nc[0].VR(lonname); + auto lats = nc[0].VR(latname); if(!(lons && lats)) { nc.clear(); diff --git a/michlib b/michlib index bfa475d..f038519 160000 --- a/michlib +++ b/michlib @@ -1 +1 @@ -Subproject commit bfa475d14453f4b2c917c97343cfe114ecb1410a +Subproject commit f03851992cf6a4f00c50be94aaac1d3bf77ae742