You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
114 lines
4.0 KiB
114 lines
4.0 KiB
#pragma once |
|
#include "Adapter.h" |
|
|
|
class CF |
|
{ |
|
public: |
|
struct AxisInfo |
|
{ |
|
MString tvarname, zvarname, yvarname, xvarname; |
|
MString tdimname, zdimname, ydimname, xdimname; |
|
uint tdims = 0, zdims = 0, ydims = 0, xdims = 0; |
|
}; |
|
|
|
struct VInfoTEOS10: public Adapter::VInfoBase |
|
{ |
|
enum Operation |
|
{ |
|
TEMP2PTEMP, |
|
PTEMP2TEMP, |
|
TEMP2PDENS, |
|
PTEMP2PDENS, |
|
TEMP2SSPEED, |
|
PTEMP2SSPEED |
|
}; |
|
MString tempvar, salvar; |
|
Operation op; |
|
|
|
virtual ~VInfoTEOS10() override = default; |
|
}; |
|
|
|
struct VInfoGeostrophic: public Adapter::VInfoBase |
|
{ |
|
enum Operation |
|
{ |
|
U, |
|
V |
|
}; |
|
MString sshvar; |
|
Operation op; |
|
|
|
virtual ~VInfoGeostrophic() override = default; |
|
}; |
|
|
|
// Get time variable name |
|
static MString GetTVarName(const NCZarr& nc); |
|
|
|
// Get info about dimensions |
|
static struct AxisInfo GetAxisInfo(const NCZarr& nc); |
|
|
|
// Parse reference date and time step from time description |
|
static std::tuple<MDateTime, time_t, bool> ParseRefDate(const MString& refdate); |
|
|
|
// Read time moments from file |
|
static RetVal<std::vector<MDateTime>> ReadTimes(const NCZarr& nc, const MString& tname); |
|
|
|
// Check, if vector data lays on uniform grid |
|
static bool CheckUniform(std::ranges::random_access_range auto&& data, real tolerance = 1e-8) |
|
requires std::convertible_to<std::ranges::range_value_t<decltype(data)>, real> |
|
{ |
|
if(data.size() < 2) return false; |
|
if(data.size() == 2) return true; |
|
|
|
real step = data[1] - data[0]; |
|
|
|
for(size_t i = 1; i < data.size() - 1; i++) |
|
if(michlib::Abs(1.0 - (data[i + 1] - data[i]) / step) > tolerance) return false; |
|
return true; |
|
} |
|
|
|
// Check, if vector time data lays on uniform grid |
|
static bool CheckUniform(std::ranges::random_access_range auto&& data) |
|
requires std::convertible_to<std::ranges::range_value_t<decltype(data)>, MDateTime> |
|
{ |
|
if(data.size() < 2) return false; |
|
if(data.size() == 2) return true; |
|
|
|
auto step = data[1] - data[0]; |
|
|
|
for(size_t i = 1; i < data.size() - 1; i++) |
|
if(data[i + 1] - data[i] != step) return false; |
|
return true; |
|
} |
|
|
|
static Error FillAdapterFromCF(const CLArgs& args, michlib_internal::ParameterListEx& pars, Adapter& ad, std::unique_ptr<NCZarr>&& pnc); |
|
|
|
static MString StName2Name(const MString& stname) |
|
{ |
|
if(stname == "sea_water_potential_temperature") return "ptemp"; |
|
if(stname == "sea_water_temperature") return "temp"; |
|
if(stname == "sea_water_salinity") return "sal"; |
|
if(stname == "ocean_mixed_layer_thickness_defined_by_sigma_theta") return "mld"; |
|
if(stname == "sea_surface_height_above_geoid") return "ssh"; |
|
if(stname == "sea_surface_elevation") return "ssh"; |
|
if(stname == "eastward_sea_water_velocity") return "u"; |
|
if(stname == "northward_sea_water_velocity") return "v"; |
|
if(stname == "upward_sea_water_velocity") return "w"; |
|
if(stname == "surface_geostrophic_eastward_sea_water_velocity") return "ugs"; |
|
if(stname == "surface_geostrophic_northward_sea_water_velocity") return "vgs"; |
|
if(stname == "mass_concentration_of_chlorophyll_a_in_sea_water") return "chl"; |
|
if(stname == "mole_concentration_of_nitrate_in_sea_water") return "NO3"; |
|
if(stname == "net_primary_production_of_biomass_expressed_as_carbon_per_unit_volume_in_sea_water") return "prprod"; |
|
if(stname == "mole_concentration_of_phytoplankton_expressed_as_carbon_in_sea_water") return "Cchl"; |
|
if(stname == "mole_concentration_of_phosphate_in_sea_water") return "PO4"; |
|
if(stname == "mole_concentration_of_silicate_in_sea_water") return "Si"; |
|
if(stname == "mole_concentration_of_dissolved_molecular_oxygen_in_sea_water") return "O2"; |
|
return ""; |
|
} |
|
|
|
static RetVal<std::shared_ptr<Data3D>> TEOS103DReader(Adapter& ad, const Adapter::VInfoBase* vinfo, std::shared_ptr<Projection> proj, std::shared_ptr<Vertical> vert, size_t it); |
|
static RetVal<std::shared_ptr<Data2D>> Geostrophic2DReader(Adapter& ad, const Adapter::VInfoBase* vinfo, std::shared_ptr<Projection> proj, size_t it); |
|
|
|
static Error TEOS10Module(const CLArgs& args, michlib_internal::ParameterListEx& pars, Adapter& ad); |
|
static Error GeostrophicModule(const CLArgs& args, michlib_internal::ParameterListEx& pars, Adapter& ad); |
|
};
|
|
|