public void dateTimeTest(String source) { var names = MongoTools.collectionNames(db); int count = 0; List <string> subset = new List <string>(); foreach (String c in names) { if (c[0] == 's') { if (c.Contains(source)) { subset.Add(c); } } } var wcss = splitList(subset, 10); foreach (List <string> wcs in wcss) { testDaysGraphic(wcs, source + "p_" + count); count++; } }
public void cleanUp() { List <string> collNames = MongoTools.collectionNames(db); string vname = ""; int stationcode = 0; string source = ""; int freq = 0; foreach (string collection in collNames) { //all station record collections start with an s_ if (collection[0] == 's') { string[] parts = collection.Split('_'); stationcode = Convert.ToInt32(parts[1]); vname = parts[4]; if (vname == "PA") { continue; } source = parts[2]; freq = Convert.ToInt32(parts[5]); VariableMeta meta = AnnualSummary.getVariableMetaFromDB(vname, source, db); if (freq == 60) { string newname = convertNameToClean(collection); CollectionMongo cm = new CollectionMongo(); cm.name = newname; removeRecordsOutsideRange(stationcode, collection, meta, newname); } } } }
public static void checkAveraging() { IMongoDatabase db = MongoTools.connect("mongodb://localhost", "climaColombia"); //clean up bog buc with PA variable List <string> collNames = MongoTools.collectionNames(db); int tenmincollections = 0; int averagedcollections = 0; foreach (string collection in collNames) { if (collection[0] == 's') { if (collection.Contains("average")) { averagedcollections++; } else { string[] parts = collection.Split('_'); if (parts[5] == "10") { tenmincollections++; } } } } }
public void outputAnnual() { //this could select the most recent annual var names = MongoTools.collectionNames(db); var summ = names.FindAll(c => c.Contains("annualStationSummary")); var coll = db.GetCollection <StationSummary>("annualStationSummary_2019_6_17_17_16_41"); List <StationSummary> stations = coll.Find(FilterDefinition <StationSummary> .Empty).ToList(); StreamWriter sw = new StreamWriter("annualSummary.csv"); sw.WriteLine("code,name,source,TS,HR,PR,VV,DV,NUB"); foreach (StationSummary ss in stations) { Station s = getStationFromMongo(ss.code, db); sw.WriteLine(string.Format("{0},{1},{2},{3},{4},{5},{6},{7},{8}", ss.code, s.name, s.source, ss.getTotalYrs("TS").ToString(), ss.getTotalYrs("HR").ToString(), ss.getTotalYrs("PR").ToString(), ss.getTotalYrs("VV").ToString(), ss.getTotalYrs("DV").ToString(), ss.getTotalYrs("NUB").ToString() )); } sw.Close(); }
private List <string> getStationsColNames(StationGroup cityGroup) { List <string> collections = MongoTools.collectionNames(db); string vname = ""; int scode = 0; string source = ""; int freq = 0; List <string> stationCollections = new List <string>(); foreach (string col in collections) { if (col[0] == 's') { string[] parts = col.Split('_'); try { scode = Convert.ToInt32(parts[1]); vname = parts[4]; source = parts[2]; freq = Convert.ToInt32(parts[5]); } catch (Exception e) { this.addLineToLogFile("WARN: error finding collection: " + col + "for city group:" + cityGroup.name); } foreach (int code in cityGroup.stationcodes) { if (scode == code) { stationCollections.Add(col); } } } } return(stationCollections); }
private List <RecordMongo> getACollection(int stationcode, string variable) { //get the collection with summary names List <RecordMongo> records = new List <RecordMongo>(); var allCollections = MongoTools.collectionNames(db); string vname = ""; int scode = 0; string source = ""; int freq = 0; int count = 0; foreach (string collection in allCollections) { if (collection[0] == 's') { string[] parts = collection.Split('_'); scode = Convert.ToInt32(parts[1]); vname = parts[4]; source = parts[2]; freq = Convert.ToInt32(parts[5]); if (scode == stationcode && vname == variable && freq == 60) { IMongoCollection <RecordMongo> stationData = db.GetCollection <RecordMongo>(collection); var filter = FilterDefinition <RecordMongo> .Empty; records = stationData.Find(filter).ToList(); return(records); } } } return(records); }
public async Task splitVariables(string dbname) { connect("mongodb://localhost", dbname); List <string> collNames = MongoTools.collectionNames(db); await splitLoop(collNames); }
public static void checkRadiationLoaded() { IMongoDatabase db = MongoTools.connect("mongodb://localhost", "climaColombia"); //clean up bog buc with PA variable List <string> collNames = MongoTools.collectionNames(db); foreach (string collection in collNames) { if (collection.Contains("rad")) { var rad = 0; } } }
public static void dropIndexes() { IMongoDatabase db = MongoTools.connect("mongodb://localhost", "climaColombia"); //clean up bog buc with PA variable List <string> collNames = MongoTools.collectionNames(db); foreach (string collection in collNames) { if (collection[0] == 's') { IMongoCollection <BsonDocument> coll = db.GetCollection <BsonDocument>(collection); coll.Indexes.DropAllAsync(); } } }
public void graphAllTS_RS() { var colls = MongoTools.collectionNames(db); foreach (string coll in colls) { if (coll[0] == 's') { if (coll.Contains("RS") || coll.Contains("TS")) { graphSingleStation(coll, coll); } } } }
public async Task splitByKeyWord(string dbname, string keyword) { connect("mongodb://localhost", dbname); List <string> collNames = MongoTools.collectionNames(db); List <string> subset = new List <string>(); foreach (String c in collNames) { if (c.Contains(keyword)) { subset.Add(c); } } await splitLoop(subset); }
public void indexAll() { List <string> collNames = MongoTools.collectionNames(db); string vname = ""; int stationcode = 0; string source = ""; int freq = 0; foreach (string collection in collNames) { //all station record collections start with an s_ if (collection[0] == 's') { createCollectionIndex(collection); } } }
private void getActiveStations() { List <string> collections = MongoTools.collectionNames(db); foreach (string collection in collections) { if (collection[0] == 's') { string[] parts = collection.Split('_'); int code = Convert.ToInt32(parts[1]); if (!activeStationCodes.Contains(code)) { activeStationCodes.Add(code); } } } }
public async Task monthlySummary() { List <string> collNames = MongoTools.collectionNames(db); string firstletter = ""; string vname = ""; int stationcode = 0; string source = ""; int freq = 0; int count = 0; foreach (string collection in collNames) { //all station record collections start with an s_ string[] parts = collection.Split('_'); firstletter = parts[0]; if (firstletter == "s") { stationcode = Convert.ToInt32(parts[1]); vname = parts[4]; if (vname == "PA") { continue; } source = parts[2]; freq = Convert.ToInt32(parts[5]); if (source.Contains("IDEAM")) { source = "IDEAM"; } else { source = "NOAA"; } VariableMeta meta = AnnualSummary.getVariableMetaFromDB(vname, source, db); VariableMonthly vm = new VariableMonthly(vname, freq); addStation(stationcode); addMonthlyRecord(stationcode, vm); await sortByDate(stationcode, collection, meta); count++; } } insertManyMonthlySummary(); }
public void convert10min(string key) { List <string> collNames = MongoTools.collectionNames(db); string vname = ""; int stationcode = 0; string source = ""; int freq = 0; int tenmincollections = 0; foreach (string collection in collNames) { //all station record collections start with an s_ if (collection[0] == 's' && collection.Contains(key)) { convertSingleCollection(collection); } } }
public static bool checkIndexes() { IMongoDatabase db = MongoTools.connect("mongodb://localhost", "climaColombia"); //clean up bog buc with PA variable List <string> collNames = MongoTools.collectionNames(db); int withindex = 0; int cleanCollection = 0; foreach (string collection in collNames) { if (collection.Contains("Clean")) { cleanCollection++; var coll = db.GetCollection <BsonDocument>(collection); IMongoIndexManager <BsonDocument> index = coll.Indexes; using (IAsyncCursor <BsonDocument> cursor = coll.Indexes.List()) { while (cursor.MoveNext()) { IEnumerable <BsonDocument> batch = cursor.Current; foreach (BsonDocument b in batch) { if (b["key"].AsBsonDocument.Contains("time")) { withindex++; } } } } } } bool success = false; if (withindex == cleanCollection) { success = true; } return(success); }
public async Task textSummaryStations(string dbname) { //summary based on total variables List <string> collNames = MongoTools.collectionNames(db); string firstletter = ""; string vname = ""; int stationcode = 0; string source = ""; int freq = 0; foreach (string collection in collNames) { //all station record collections start with an s_ string[] parts = collection.Split('_'); firstletter = parts[0]; if (firstletter == "s") { stationcode = Convert.ToInt32(parts[1]); vname = parts[4]; if (vname == "PA") { continue; } source = parts[2]; freq = Convert.ToInt32(parts[5]); VariableMeta meta = getVariableMetaFromDB(vname, source, db); RecordMeta rm = new RecordMeta(vname, freq); addStation(stationcode); addRecord(stationcode, rm); await getTotalRecords(collection, stationcode, vname); await getDateLimits(collection, stationcode, vname); await insideRange(collection, stationcode, meta); } } annualStats(); insertManyRecordStationSummary(); printToSummary(); }
public static void removeCollections() { IMongoDatabase db = MongoTools.connect("mongodb://localhost", "climaColombia"); //clean up bog buc with PA variable List <string> collNames = MongoTools.collectionNames(db); foreach (string collection in collNames) { //all station record collections start with an s_ string[] parts = collection.Split('_'); string firstletter = parts[0]; if (firstletter == "s") { string vname = parts[4]; if (vname == "PA") { var coll = db.GetCollection <BsonDocument>(collection); db.DropCollection(collection); } } } }
private List <string> getStationsColNames(StationGroup cityGroup) { List <string> collections = MongoTools.collectionNames(db); List <string> stationCollections = new List <string>(); int scode = 0; foreach (string col in collections) { if (col[0] == 's') { string[] parts = col.Split('_'); scode = Convert.ToInt32(parts[1]); foreach (int code in cityGroup.stationcodes) { if (scode == code) { stationCollections.Add(col); } } } } return(stationCollections); }