/// <summary> /// Constructor. Loads data from weather database entry .ini file. /// </summary> /// <param name="ini">The .ini file to load from.</param> /// <param name="key">The value key.</param> public DBEntryWeather(INIFile ini, string key) { CloudsBase = ini.GetValue <MinMaxI>("Weather", key + ".Clouds.Base"); CloudsDensity = ini.GetValue <MinMaxI>("Weather", key + ".Clouds.Density"); CloudsPrecipitation = ini.GetValueArray <Precipitation>("Weather", key + ".Clouds.Precipitation"); if (CloudsPrecipitation.Length == 0) { CloudsPrecipitation = new Precipitation[] { Precipitation.None } } ; CloudsThickness = ini.GetValue <MinMaxI>("Weather", key + ".Clouds.Thickness"); DustEnabled = ini.GetValueArray <bool>("Weather", key + ".Dust.Enabled"); if (DustEnabled.Length == 0) { DustEnabled = new bool[] { false } } ; DustDensity = ini.GetValue <MinMaxI>("Weather", key + ".Dust.Density"); FogEnabled = ini.GetValueArray <bool>("Weather", key + ".Fog.Enabled"); if (FogEnabled.Length == 0) { DustEnabled = new bool[] { false } } ; FogThickness = ini.GetValue <MinMaxI>("Weather", key + ".Fog.Thickness"); FogVisibility = ini.GetValue <MinMaxI>("Weather", key + ".Fog.Visibility"); QNH = ini.GetValue <MinMaxI>("Weather", key + ".QNH"); Turbulence = ini.GetValue <MinMaxI>("Weather", key + ".Turbulence"); Visibility = ini.GetValue <MinMaxI>("Weather", key + ".Visibility"); } } }
public bool Equals(WeatherEntity anotherWeatherEntity) { if (anotherWeatherEntity == null) { return(false); } if (!City.Equals(anotherWeatherEntity.City)) { return(false); } if (!Temperature.Equals(anotherWeatherEntity.Temperature)) { return(false); } if (!Precipitation.Equals(anotherWeatherEntity.Precipitation)) { return(false); } if (!Weather.Equals(anotherWeatherEntity.Weather)) { return(false); } return(true); }
static void WritePrecipitationHeader(ISheet sheet) { var header = sheet.CreateRow(0); header.CreateCell(0).SetCellValue(Precipitation.GetDisplayName(nameof(Precipitation.Date))); header.CreateCell(1).SetCellValue(Precipitation.GetDisplayName(nameof(Precipitation.Millimeters))); }
public override string ToString() { string PrecipDesc = Precipitation.ToString() + " " + PrecipitationType.ToString(); if (Precipitation == GameConstants.PrecipitationLevel.None) { PrecipDesc = "None"; } string temp = string.Format( "Temp: {0}C, Clouds: {1}/8ths, {2} m/s wind from {3}, Beaufort: {4}," + " Precipitation: {5}, Sea state: {6} \nMoon phase: {7}, Is Moon Up? {8}, Sunshine: {9:F} Wm2 {10}% \n", TemperatureC, CloudCover8ths, WindSpeedMSec, WindDirectionFrom, WindForceBeaufort, PrecipDesc, SeaState, CurrentMoonPhase, IsMoonUp, SunshineWm2, SunshinePercent); string sunRiseSetDesc = string.Empty; if (IsSunRising) { sunRiseSetDesc = "Sun rising: " + SunriseTime.ToString() + " \n"; } if (IsSunSetting) { sunRiseSetDesc += "Sun setting: " + SunsetTime.ToString() + " \n "; } temp += string.Format("Sun height: {0:F} deg, Sun declination: {1:F} deg \n{2}", CurrentSunheightDeg, CurrentSunDeclinationDeg, sunRiseSetDesc); return(temp); }
private static string GetPrecipitation(Precipitation? precipitation, StrengthPrecipitation? strengthPrecipitation, bool isFog, bool isThunderstorm) { var sb = new StringBuilder(); sb.Append(GetPrecipitation(precipitation, strengthPrecipitation, sb.Length == 0)); sb.AppendFormat(GetThunderstorm(isThunderstorm, sb.Length == 0)); sb.Append(isFog ? GetEditedMessage(AppResource.WeatherData_Fog, sb.Length == 0) : string.Empty); return sb.ToString(); }
/// <summary> /// Initializes all config classes /// </summary> public Config() { map = new Map(); elevation = new Elevation(); temperature = new Temperature(); precipitation = new Precipitation(); humidity = new Humidity(); circulation = new Circulation(); }
public Weather() { Precipitation = new Precipitation(); Wind = new Wind(); Temperature = new Temperature(); Pressure = new Pressure(); Humidity = new Humidity(); Clouds = new Clouds(); }
public Weather(DateTime date, eWindSpeed windspeed, WindDirection direction, CloudCover cover,Precipitation precip, HourlyWeather[] temperatures,double temperatureLow, double temperatureHigh) { this.Date = date; this.WindSpeed = windspeed; this.Direction = direction; this.Cover = cover; this.Precip = precip; this.Temperatures = temperatures; this.TemperatureLow = temperatureLow; this.TemperatureHigh = temperatureHigh; }
static void WritePrecipitation(Precipitation precipitation, ISheet sheet, int rowIndex, ICellStyle cellDateStyle) { var row = sheet.CreateRow(rowIndex); row.CreateCell(0).SetCellValue(precipitation.Date); var cell = row.CreateCell(0, CellType.Numeric); cell.SetCellValue(precipitation.Date); cell.CellStyle = cellDateStyle; row.CreateCell(1, CellType.Numeric).SetCellValue(precipitation.Millimeters); }
static void SeedPrecipitation() { MongoClient client = new MongoClient("mongodb://*****:*****@"C:\Users\marti\Desktop\School\AirData\Data\precipitation.xml"); while (xmlReader.Read()) { // Read node if ((xmlReader.NodeType == XmlNodeType.Element)) { if (precipitation.DateTimeStart != null && precipitation.Prep_Hour != null && precipitation.Prep_Tot != null) { precipitationCollection.InsertOne(precipitation); precipitation = new Precipitation(); //Console.WriteLine("new created"); } if (xmlReader.Name.Equals("DateTimeStart")) { precipitation.DateTimeStart = DateTime.Parse(xmlReader.ReadElementContentAsString()); //Console.WriteLine("DateTimeStart read"); } if (xmlReader.Name.Equals("Prep_Hour")) { precipitation.Prep_Hour = double.Parse(xmlReader.ReadElementContentAsString()); //Console.WriteLine("Hg read"); } if (xmlReader.Name.Equals("Prep_Tot")) { precipitation.Prep_Tot = double.Parse(xmlReader.ReadElementContentAsString()); //Console.WriteLine("unit read"); } //Console.WriteLine(ozone); // Insert into DB Console.WriteLine("So far: " + counter++); } } precipitationCollection.InsertOne(precipitation); Console.WriteLine("Done"); Console.ReadKey(); }
public WeatherForecastViewModel(WeatherForecast forecast, DateTime nextForcastDate) { Rain = new Precipitation(Math.Round(forecast.Precipitation.Value, _decimalAccuracy), forecast.Precipitation.PrecipitationType); Temperature = new Temperature( Math.Round(forecast.Temperature.Min, _decimalAccuracy), Math.Round(forecast.Temperature.Max, _decimalAccuracy), forecast.Temperature.Humidity); Wind = new Wind(Math.Round(forecast.Wind.Speed, _decimalAccuracy)); Description = forecast.Description; ForecastStartTime = forecast.ForecastTime.ToLocalTime().ToShortTimeString(); ForecastEndTime = nextForcastDate.ToLocalTime().ToShortTimeString(); }
public void SetData(int tempLo, int tempHi, int presLo, int presHi, int cloudLo, int cloudHi, int humidLo, int humidHi, int precipLo, int precipHi, int energyLo, int energyHi, int windXLo, int windXHi, int windYLo, int windYHi) { Temperature.ToList()[0] = tempLo; Temperature.ToList()[1] = tempHi; Pressure.ToList()[0] = presLo; Pressure.ToList()[1] = presHi; CloudCover.ToList()[0] = cloudLo; CloudCover.ToList()[1] = cloudHi; Humidity.ToList()[0] = humidLo; Humidity.ToList()[1] = humidHi; Precipitation.ToList()[0] = precipLo; Precipitation.ToList()[1] = precipHi; Energy.ToList()[0] = energyLo; Energy.ToList()[1] = energyHi; WindSpeedX.ToList()[0] = windXLo; WindSpeedX.ToList()[1] = windXHi; WindSpeedY.ToList()[0] = windYLo; WindSpeedY.ToList()[1] = windYHi; }
public static List <Precipitation> ReadPrecipitations(IWorkbook workbook, int sheetIndex, IProgress <int> progress) { var sheet = workbook.GetSheetAt(sheetIndex); IRow row; List <Precipitation> precipitations = new List <Precipitation>(); int indexError = 1; CreateRejectedRows(sheet.GetRow(0)); try { var maxCount = sheet.LastRowNum; for (int i = 1; i < maxCount + 1; i++) { indexError = i; row = sheet.GetRow(i); var prec = new Precipitation { Date = ParseStringDate(ReadCellAsDateString(row, 0)), Millimeters = ReadCellAsDouble(row, 1) }; prec.Millimeters = prec.Millimeters == BusinessObject.NumericNullValue ? 0 : prec.Millimeters; precipitations.Add(prec); progress?.Report(i / maxCount * 100); } } catch (Exception ex) { throw new Exception("Error leyendo la fila " + indexError.ToString(), ex); } return(precipitations); }
private Precipitation CreatePrecipitation(IXmlService xmlService, XElement w) { Precipitation precipitation = new Precipitation() { Value = xmlService.GetXmlAttributeValue(w, "precipitation", "value"), _Type = xmlService.GetXmlAttributeText(w, "precipitation", "type") }; if (precipitation.Value == 0 && string.IsNullOrEmpty(precipitation._Type)) { return null; } else { return precipitation; } }
/// <summary> /// initForecastObjects init and allocate all forecast objects /// </summary> private void initForecastObjects() { this.location = new Location(); this.sunRise = new SunRise(); this.temperature = new Temperature(); this.humidity = new Humidity(); this.pressure = new Pressure(); this.windSpeed = new WindSpeed(); this.windDirection = new WindDirection(); this.clouds = new Clouds(); this.precipitation = new Precipitation(); this.weather = new Weather(); this.lastupdate = new Lastupdate(); }
public Weather(Temperature temperature, Precipitation precipitation) { Temperature = temperature; Precipitation = precipitation; }
private static string GetPrecipitation(Precipitation? precipitation, StrengthPrecipitation? strengthPrecipitation, bool isFirst) { if (!precipitation.HasValue) return string.Empty; var result = GetStrengthPrecipitation(strengthPrecipitation, isFirst); switch (precipitation) { case Precipitation.Rain: return string.IsNullOrEmpty(result) ? AppResource.Precipitation_Rain : " {0}".F(AppResource.Precipitation_Rain.ToLower()); case Precipitation.Sleet: return string.IsNullOrEmpty(result) ? AppResource.Precipitation_Sleet : " {0}".F(AppResource.Precipitation_Sleet.ToLower()); case Precipitation.Snow: return string.IsNullOrEmpty(result) ? AppResource.Precipitation_Snow : " {0}".F(AppResource.Precipitation_Snow.ToLower()); } return string.Empty; }
public Weather(DateTime date, eWindSpeed windspeed, WindDirection direction, CloudCover cover, Precipitation precip, HourlyWeather[] temperatures, double temperatureLow, double temperatureHigh) { this.Date = date; this.WindSpeed = windspeed; this.Direction = direction; this.Cover = cover; this.Precip = precip; this.Temperatures = temperatures; this.TemperatureLow = temperatureLow; this.TemperatureHigh = temperatureHigh; }
public CityModel(string Name, DateTime Date, int PressureMax, int PressureMin, int TemperatureMax, int TemperatureMin, Сloudiness СloudinessWeather, Precipitation PrecipitationWeather) { this.Name = Name; this.Date = Date; this.PressureMax = PressureMax; this.PressureMin = PressureMin; this.TemperatureMax = TemperatureMax; this.TemperatureMin = TemperatureMin; this.TemperatureMin = TemperatureMin; this.СloudinessWeather = СloudinessWeather; this.PrecipitationWeather = PrecipitationWeather; //this.RelWet = RelWet; }
/// <summary> /// Takes a time step /// </summary> /// <param name="Endtime"></param> public void MoveInTime(DateTime Endtime) { double output = 0; CurrentTime = Endtime; CurrentState = StateVariables.Rows.Find(new object[] { ID, CurrentTime }); if (CurrentState == null) { CurrentState = StateVariables.NewRow(); CurrentState["ID"] = ID; CurrentState["Time"] = CurrentTime; StateVariables.Rows.Add(CurrentState); } foreach (var S in SourceModels) { double value; if (S.Update) { value = S.GetValue(this, Endtime) * DateTime.DaysInMonth(Endtime.Year, Endtime.Month) * 86400.0; CurrentState[S.Name] = value; } if (!CurrentState.IsNull(S.Name)) { output += (double)CurrentState[S.Name]; } } foreach (var R in InternalReduction) { double value; if (R.Update) { value = R.GetReduction(this, output, Endtime) * DateTime.DaysInMonth(Endtime.Year, Endtime.Month) * 86400.0; CurrentState[R.Name] = value; } if (!CurrentState.IsNull(R.Name)) { output -= (double)CurrentState[R.Name]; } } foreach (var ups in UpstreamConnections) { output += ups.GetDownStreamOutput(Endtime); } //Do the global reductions foreach (var R in MainStreamReduction) { double value; if (R.Update) { value = R.GetReduction(this, output, Endtime) * DateTime.DaysInMonth(Endtime.Year, Endtime.Month) * 86400.0; CurrentState[R.Name] = value; } if (!CurrentState.IsNull(R.Name)) { output -= (double)CurrentState[R.Name]; } } if (Precipitation != null) { CurrentState["Precipitation"] = Precipitation.GetTs(TimeStepUnit.Month).GetValue(CurrentTime); } if (Temperature != null) { CurrentState["Air Temperature"] = Temperature.GetValue(CurrentTime, InterpolationMethods.DeleteValue); } if (M11Flow != null) { CurrentState["M11Flow"] = M11Flow.GetTs(TimeStepUnit.Month).GetValue(CurrentTime) * DateTime.DaysInMonth(CurrentTime.Year, CurrentTime.Month) * 86400; CurrentState["NetM11Flow"] = NetInflow.GetTs(TimeStepUnit.Month).GetValue(CurrentTime) * DateTime.DaysInMonth(CurrentTime.Year, CurrentTime.Month) * 86400; } if (Leaching != null) { CurrentState["Leaching"] = Leaching.GetValue(CurrentTime, InterpolationMethods.DeleteValue) * DateTime.DaysInMonth(CurrentTime.Year, CurrentTime.Month) * 86400; } if (Measurements != null) { CurrentState["ObservedFlow"] = Measurements.Flow.GetValue(CurrentTime, InterpolationMethods.DeleteValue); CurrentState["ObservedNitrate"] = Measurements.Nitrate.GetValue(CurrentTime, InterpolationMethods.DeleteValue); if (ObsNitrate == null) { ObsNitrate = new FixedTimeStepSeries() { TimeStepSize = TimeStepUnit.Month, StartTime = CurrentTime }; SimNitrate = new FixedTimeStepSeries() { TimeStepSize = TimeStepUnit.Month, StartTime = CurrentTime }; } ObsNitrate.Add(Measurements.Nitrate.GetValue(CurrentTime, InterpolationMethods.DeleteValue)); SimNitrate.Add(output); } CurrentState["DownStreamOutput"] = output; }