75 return (std::string::npos ==
name.find(
'@')) && (std::string::npos ==
name.find(
'/')) ?
true
80 const std::vector<std::string> allVars = from.
g_.
listObjects<ObjectType::Variable>(
true);
82 size_t max_var_size_ = 0;
83 std::vector<std::string> var_list_, dim_var_list_;
84 var_list_.reserve(allVars.size());
85 dim_var_list_.reserve(allVars.size());
86 std::map<std::string, std::vector<std::string>> dims_attached_to_vars_;
93 std::list<std::string> sortedAllVars;
94 for (
const auto&
name : allVars) {
95 if (sortedAllVars.empty())
96 sortedAllVars.push_back(
name);
99 auto second = sortedAllVars.begin();
101 if (sortedAllVars.front() ==
"nlocs")
102 sortedAllVars.insert(second,
name);
104 sortedAllVars.push_front(
name);
106 sortedAllVars.push_back(
name);
115 std::list<std::pair<std::string, Variable>> dimension_scales;
117 auto group = from.
g_;
119 for (
const auto& vname : sortedAllVars) {
120 Variable v = group.vars.open(vname);
122 if (dims.dimensionality >= 1) {
126 max_var_size_ = std::max(max_var_size_, (
size_t)dims.dimsCur[0]);
133 ? dimension_scales.push_front(std::make_pair(vname, v))
134 : dimension_scales.push_back(std::make_pair(vname, v));
135 dim_var_list_.push_back(vname);
141 var_list_.push_back(vname);
144 std::vector<std::string> dimVarNames;
145 dimVarNames.reserve(dims.dimensionality);
146 for (
const auto& dim_scales_along_axis : attached_dimensions) {
147 if (dim_scales_along_axis.empty())
148 throw jedi_throw.add(
"Reason",
149 "Bad dimension mapping. Not all dimension scales are known.");
150 dimVarNames.push_back(dim_scales_along_axis[0].first);
152 dims_attached_to_vars_.emplace(vname, dimVarNames);
Generic copying facility.
Groups are a new implementation of ObsSpaces.
Allows you to select objects for a copy operation.
virtual std::map< ObjectType, std::vector< std::string > > listObjects(ObjectType filter=ObjectType::Ignored, bool recurse=false) const
List all objects (groups + variables) within this group.
virtual bool isDimensionScale() const
Is this Variable used as a dimension scale?
virtual Dimensions getDimensions() const
virtual std::vector< std::vector< Named_Variable > > getDimensionScaleMappings(const std::list< Named_Variable > &scalesToQueryAgainst, bool firstOnly=true) const
Which dimensions are attached at which positions? This function may offer improved performance on som...
IODA_DL void copy(const ObjectSelection &from, ObjectSelection &to, const ScaleMapping &scale_map)
Generic data copying function.
Settings for how to remap dimension scales.
bool isPossiblyScale(const std::string &name)
Convenience lambda to hint if a variable might be a scale.