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 void cleanSingle(string collection) { string[] parts = collection.Split('_'); int stationcode = Convert.ToInt32(parts[1]); string vname = parts[4]; if (vname == "PA") { return; } string source = parts[2]; int freq = Convert.ToInt32(parts[5]); VariableMeta meta = AnnualSummary.getVariableMetaFromDB(vname, source, db); string newname = convertNameToClean(collection); //collection for the avergaed data CollectionMongo cm = new CollectionMongo(); cm.name = newname; newCleanData.Add(cm); Task t1 = Task.Run(() => removeRecordsOutsideRange(stationcode, collection, meta, newname)); t1.Wait(); insertMany(cm.records, cm.name); }
private CollectionMongo generateVariableYear(string name) { //one collection per variable CollectionMongo cm = new CollectionMongo(); cm.name = name; //loop all hours in 8760 add a new RecordMongo int[] daysInMonths = new int[] { 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 }; int month = 0; int year = 2001; foreach (int m in daysInMonths) { month++; for (int d = 1; d <= m; d++) { for (int h = 0; h < 24; h++) { RecordMongo rm = new RecordMongo(); DateTime dt = new DateTime(year, month, d, h, 0, 0); rm.value = -999.9; rm.time = dt; rm.processNote = "ccSyntheticYear"; cm.records.Add(rm); } } } return(cm); }
public void convertSingleCollection(string collection) { string[] parts = collection.Split('_'); int stationcode = Convert.ToInt32(parts[1]); string vname = parts[4]; string source = parts[2]; int freq = Convert.ToInt32(parts[5]); if (freq == 60) { return; } VariableMeta meta = AnnualSummary.getVariableMetaFromDB(vname, source, db); string newname = convertNameTo60min(collection); //collection for the avergaed data CollectionMongo cm = new CollectionMongo(); cm.name = newname; newAveragedData.Add(cm); Task t1 = Task.Run(() => sortByDateAndAverage(stationcode, collection, meta, newname)); t1.Wait(); insertMany(cm.records, cm.name); }
private void nightRadiation(ref CollectionMongo radvariables) { foreach (RecordMongo rm in radvariables.records) { if (rm.time.Hour < 6 || rm.time.Hour > 18) { rm.value = 0; } } }
private void addValuesToSynthYear(List <RecordMongo> candidateDay, ref CollectionMongo variableRecords, int doy, string vcode) { try { //assign to synthetic year List <RecordMongo> synthDay = variableRecords.records.FindAll(x => x.time.DayOfYear == doy); if (synthDay.Count > 0) { foreach (RecordMongo cm in candidateDay) { double value = cm.value; RecordMongo synthRecordForUpdate = synthDay.Find(x => x.time.Hour == cm.time.Hour); synthRecordForUpdate.value = value; } } } catch (Exception e) { this.addLineToLogFile("WARN: " + vcode + " error adding cdf day on day of year: " + doy); } }