#include "StrideSearchSector.h" #include "StrideSearchUtilities.h" #include #include #include #include namespace StrideSearch { void Sector::defineWorkspace(const std::vector& criteria){ workspace = std::vector(criteria.size()); }; void Sector::allocWorkspace(const std::vector& criteria) { for (int i = 0; i < criteria.size(); ++i) { workspace[i] = WorkspaceDict(criteria[i]->varnames, data_indices.size()); } } std::vector> Sector::evaluateCriteriaAtTimestep(std::vector& criteria, const DateTime& dt, const std::string& fname, const index_type timeIndex) { std::vector> result; for (index_type i = 0; i < criteria.size(); ++i) { if (criteria[i]->evaluate(workspace[i])) { result.push_back(std::shared_ptr(new Event(criteria[i]->description(), criteria[i]->val, data_coords[criteria[i]->wspcIndex], dt, data_indices[criteria[i]->wspcIndex], fname, timeIndex, criteria[i]->compareKind))); } } return result; } scalar_type Sector::distanceToSectorCenter(const scalar_type lat, const scalar_type lon) const { return sphereDistance(lat, lon, centerLat, centerLon); } void Sector::outputCoordsToCSV(std::ostream& os) const { os << "x,y,z" << std::endl; scalar_type x; scalar_type y; scalar_type z; llToXYZ(x, y, z, centerLat, centerLon); os << x << "," << y << "," << z << std::endl; for (index_type i = 0; i < data_coords.size(); ++i) { llToXYZ(x, y, z, data_coords[i].first, data_coords[i].second); os << x << "," << y << "," << z << std::endl; } } std::string Sector::infoString(const int tabLevel, const bool printWspc) const { std::string tabstr(""); for (int i = 0; i < tabLevel; ++i) tabstr += "\t"; std::ostringstream ss; ss << tabstr << "Sector Record: \n"; ss << tabstr << "\tcenter (lat,lon) = (" << centerLat << ", " << centerLon << ")\n"; ss << tabstr << "\tworkspace.size() = " << workspace.size() << std::endl; ss << tabstr << "\tdata_coords (lat,lon) :\n" << tabstr << "\t"; for (index_type i = 0; i < data_coords.size(); ++i) { ss << "(" << data_coords[i].first << ", " << data_coords[i].second << ") "; } ss << std::endl << tabstr << "\tdata_indices : \n" << tabstr << "\t"; for (index_type i = 0; i < data_indices.size(); ++i) { ss << "("; for (index_type j = 0; j < data_indices[i].size() - 1; ++j) { ss << data_indices[i][j] << ", "; } ss << data_indices[i][data_indices[i].size()-1] << ") " ; } if (printWspc) { ss << std::endl << "-- local data -- " << std::endl; for (int i = 0; i < workspace.size(); ++i) ss << workspace[i] << std::endl; } ss << std::endl << "--------------------------" << std::endl; return ss.str(); } };