|
|
@ -193,16 +193,15 @@ LayeredData::Data LayeredData::Read(const MString& vname, const BaseParameters* |
|
|
|
auto temp = Read("temp", ip, i); |
|
|
|
auto temp = Read("temp", ip, i); |
|
|
|
auto sal = Read("sal", ip, i); |
|
|
|
auto sal = Read("sal", ip, i); |
|
|
|
if(!(temp && sal)) return Data(); |
|
|
|
if(!(temp && sal)) return Data(); |
|
|
|
auto out = temp; |
|
|
|
temp.SetUnit("degrees_C"); |
|
|
|
out.SetUnit("degrees_C"); |
|
|
|
for(size_t ind = 0; ind < temp.N(); ind++) |
|
|
|
for(size_t ind = 0; ind < out.N(); ind++) |
|
|
|
|
|
|
|
{ |
|
|
|
{ |
|
|
|
if(temp.IsFill(ind) || sal.IsFill(ind)) |
|
|
|
if(temp.IsFill(ind) || sal.IsFill(ind)) |
|
|
|
out.V(ind) = out.Fillval(); |
|
|
|
temp.V(ind) = temp.Fillval(); |
|
|
|
else |
|
|
|
else |
|
|
|
out.V(ind) = Temp2PTemp(temp.V(ind), sal.V(ind), Depth(p->layer), out.Lon(ind), out.Lat(ind)); |
|
|
|
temp.V(ind) = Temp2PTemp(temp.V(ind), sal.V(ind), Depth(p->layer), temp.Lon(ind), temp.Lat(ind)); |
|
|
|
} |
|
|
|
} |
|
|
|
return out; |
|
|
|
return temp; |
|
|
|
} |
|
|
|
} |
|
|
|
// temp from ptemp and sal
|
|
|
|
// temp from ptemp and sal
|
|
|
|
if(vname == "temp") |
|
|
|
if(vname == "temp") |
|
|
@ -210,16 +209,15 @@ LayeredData::Data LayeredData::Read(const MString& vname, const BaseParameters* |
|
|
|
auto temp = Read("ptemp", ip, i); |
|
|
|
auto temp = Read("ptemp", ip, i); |
|
|
|
auto sal = Read("sal", ip, i); |
|
|
|
auto sal = Read("sal", ip, i); |
|
|
|
if(!(temp && sal)) return Data(); |
|
|
|
if(!(temp && sal)) return Data(); |
|
|
|
auto out = temp; |
|
|
|
temp.SetUnit("degrees_C"); |
|
|
|
out.SetUnit("degrees_C"); |
|
|
|
for(size_t ind = 0; ind < temp.N(); ind++) |
|
|
|
for(size_t ind = 0; ind < out.N(); ind++) |
|
|
|
|
|
|
|
{ |
|
|
|
{ |
|
|
|
if(temp.IsFill(ind) || sal.IsFill(ind)) |
|
|
|
if(temp.IsFill(ind) || sal.IsFill(ind)) |
|
|
|
out.V(ind) = out.Fillval(); |
|
|
|
temp.V(ind) = temp.Fillval(); |
|
|
|
else |
|
|
|
else |
|
|
|
out.V(ind) = PTemp2Temp(temp.V(ind), sal.V(ind), Depth(p->layer), out.Lon(ind), out.Lat(ind)); |
|
|
|
temp.V(ind) = PTemp2Temp(temp.V(ind), sal.V(ind), Depth(p->layer), temp.Lon(ind), temp.Lat(ind)); |
|
|
|
} |
|
|
|
} |
|
|
|
return out; |
|
|
|
return temp; |
|
|
|
} |
|
|
|
} |
|
|
|
// pdens from temp and sal
|
|
|
|
// pdens from temp and sal
|
|
|
|
if(vname == "pdens") |
|
|
|
if(vname == "pdens") |
|
|
@ -228,17 +226,16 @@ LayeredData::Data LayeredData::Read(const MString& vname, const BaseParameters* |
|
|
|
auto temp = Read(tempispot ? "ptemp" : "temp", ip, i); |
|
|
|
auto temp = Read(tempispot ? "ptemp" : "temp", ip, i); |
|
|
|
auto sal = Read("sal", ip, i); |
|
|
|
auto sal = Read("sal", ip, i); |
|
|
|
if(!(temp && sal)) return Data(); |
|
|
|
if(!(temp && sal)) return Data(); |
|
|
|
auto out = temp; |
|
|
|
temp.SetUnit("kg m-3"); |
|
|
|
out.SetUnit("kg m-3"); |
|
|
|
for(size_t ind = 0; ind < temp.N(); ind++) |
|
|
|
for(size_t ind = 0; ind < out.N(); ind++) |
|
|
|
|
|
|
|
{ |
|
|
|
{ |
|
|
|
if(temp.IsFill(ind) || sal.IsFill(ind)) |
|
|
|
if(temp.IsFill(ind) || sal.IsFill(ind)) |
|
|
|
out.V(ind) = out.Fillval(); |
|
|
|
temp.V(ind) = temp.Fillval(); |
|
|
|
else |
|
|
|
else |
|
|
|
out.V(ind) = tempispot ? PTemp2PDens(temp.V(ind), sal.V(ind), Depth(p->layer), out.Lon(ind), out.Lat(ind)) |
|
|
|
temp.V(ind) = tempispot ? PTemp2PDens(temp.V(ind), sal.V(ind), Depth(p->layer), temp.Lon(ind), temp.Lat(ind)) |
|
|
|
: Temp2PDens(temp.V(ind), sal.V(ind), Depth(p->layer), out.Lon(ind), out.Lat(ind)); |
|
|
|
: Temp2PDens(temp.V(ind), sal.V(ind), Depth(p->layer), temp.Lon(ind), temp.Lat(ind)); |
|
|
|
} |
|
|
|
} |
|
|
|
return out; |
|
|
|
return temp; |
|
|
|
} |
|
|
|
} |
|
|
|
// U and U2 from u and v
|
|
|
|
// U and U2 from u and v
|
|
|
|
if(vname == "U" || vname == "U2") |
|
|
|
if(vname == "U" || vname == "U2") |
|
|
@ -247,16 +244,15 @@ LayeredData::Data LayeredData::Read(const MString& vname, const BaseParameters* |
|
|
|
auto u = Read("u", ip, i); |
|
|
|
auto u = Read("u", ip, i); |
|
|
|
auto v = Read("v", ip, i); |
|
|
|
auto v = Read("v", ip, i); |
|
|
|
if(!(u && v)) return Data(); |
|
|
|
if(!(u && v)) return Data(); |
|
|
|
auto out = u; |
|
|
|
if(square && u.Unit().Exist()) u.SetUnit("(" + u.Unit() + ")2"); |
|
|
|
out.SetUnit(square ? ("(" + u.Unit() + ")2") : u.Unit()); |
|
|
|
for(size_t ind = 0; ind < u.N(); ind++) |
|
|
|
for(size_t ind = 0; ind < out.N(); ind++) |
|
|
|
|
|
|
|
{ |
|
|
|
{ |
|
|
|
if(u.IsFill(ind) || v.IsFill(ind)) |
|
|
|
if(u.IsFill(ind) || v.IsFill(ind)) |
|
|
|
out.V(ind) = out.Fillval(); |
|
|
|
u.V(ind) = u.Fillval(); |
|
|
|
else |
|
|
|
else |
|
|
|
out.V(ind) = square ? (u(ind) * u(ind) + v(ind) * v(ind)) : michlib::Hypot(u(ind), v(ind)); |
|
|
|
u.V(ind) = square ? (u(ind) * u(ind) + v(ind) * v(ind)) : michlib::Hypot(u(ind), v(ind)); |
|
|
|
} |
|
|
|
} |
|
|
|
return out; |
|
|
|
return u; |
|
|
|
} |
|
|
|
} |
|
|
|
return Data(); |
|
|
|
return Data(); |
|
|
|
} |
|
|
|
} |
|
|
|