/// <summary> /// Updates SAM WeatherYear from TBD WeatherYear /// </summary> /// <param name="weatherYear">Destination SAM WeatherYear</param> /// <param name="weatherYear_TBD">Source TBD WeatherYear</param> /// <returns>True if data Updated</returns> public static bool Update(this WeatherYear weatherYear, TBD.WeatherYear weatherYear_TBD) { if (weatherYear == null || weatherYear_TBD == null) { return(false); } weatherYear.Year = weatherYear_TBD.year; List <TBD.WeatherDay> weatherDays_TBD = weatherYear_TBD.WeatherDays(); for (int i = 0; i < weatherDays_TBD.Count; i++) { WeatherDay weatherDay = weatherYear[i]; if (weatherDay == null) { weatherDay = new WeatherDay(); } Update(weatherDay, weatherDays_TBD[i]); weatherYear[i] = weatherDay; } return(true); }
public static bool UpdateWeatherData(this TBD.Building building, WeatherData weatherData) { if (building == null || weatherData == null) { return(false); } TBD.WeatherYear weatherYear_TBD = building.GetWeatherYear(); if (weatherYear_TBD == null) { weatherYear_TBD = building.AddWeatherYear(); } building.latitude = System.Convert.ToSingle(weatherData.Latitude); building.longitude = System.Convert.ToSingle(weatherData.Longitude); building.maxBuildingAltitude = System.Convert.ToSingle(weatherData.Elevtion); if (weatherData.TryGetValue(WeatherDataParameter.TimeZone, out string timeZone)) { double @double = Core.Query.Double(Core.Query.UTC(timeZone)); if (!double.IsNaN(@double)) { building.timeZone = System.Convert.ToSingle(@double); } } weatherYear_TBD.latitude = building.latitude; weatherYear_TBD.longitude = building.longitude; weatherYear_TBD.name = weatherData.Name; weatherYear_TBD.description = weatherData.Description; weatherYear_TBD.altitude = System.Convert.ToSingle(weatherData.Elevtion); weatherYear_TBD.timeZone = building.timeZone; if (weatherData.TryGetValue(WeatherDataParameter.GroundTemperatures, out Core.SAMCollection <GroundTemperature> groundTemperatures) && groundTemperatures != null && groundTemperatures.Count != 0) { GroundTemperature groundTemperature = groundTemperatures.ToList().Find(x => System.Math.Abs(x.Depth - 2.0) < Core.Tolerance.MacroDistance); if (groundTemperature == null) { groundTemperature = groundTemperatures.FirstOrDefault(); } if (groundTemperature != null) { weatherYear_TBD.groundTemperature = System.Convert.ToSingle(groundTemperature.Temperatures.Sum() / 12.0); } } WeatherYear weatherYear = weatherData.WeatherYears?.FirstOrDefault(); if (weatherYear != null) { weatherYear_TBD.year = weatherYear.Year; } return(Update(weatherYear_TBD, weatherYear)); }
public static WeatherData ToSAM_WeatherData(this TSD.SimulationData simulationData, int year = 2018) { if (simulationData == null) { return(null); } WeatherYear weatherYear = simulationData.GetBuildingData().WeatherYear(year); WeatherData result = new WeatherData(); result.Add(weatherYear); return(result); }
public static WeatherYear WeatherYear(this string path_TSD, int year = 2018) { if (string.IsNullOrWhiteSpace(path_TSD)) { return(null); } WeatherYear result = null; using (SAMTSDDocument sAMTSDDocument = new SAMTSDDocument(path_TSD, true)) { result = WeatherYear(sAMTSDDocument, year); } return(result); }
public static WeatherData ToSAM_WeatherData(this TBD.WeatherYear weatherYear) { if (weatherYear == null) { return(null); } WeatherYear weatherYear_SAM = new WeatherYear(weatherYear.year); weatherYear_SAM.Update(weatherYear); WeatherData result = new WeatherData(weatherYear.name, weatherYear.description, weatherYear.latitude, weatherYear.longitude, weatherYear.altitude); result.SetValue(WeatherDataParameter.TimeZone, Core.Query.Description(Core.Query.UTC(weatherYear.timeZone))); result.Add(weatherYear_SAM); return(result); }
/// <summary> /// Updates TBD WeatherYear from SAM WeatherYear /// </summary> /// <param name="weatherYear_TBD">Destination TBD WeatherYear</param> /// <param name="weatherYear">Source SAM WeatherYear</param> /// <returns>True if data Updated</returns> public static bool Update(this TBD.WeatherYear weatherYear_TBD, WeatherYear weatherYear) { if (weatherYear_TBD == null || weatherYear == null) { return(false); } List <TBD.WeatherDay> weatherDays_TBD = weatherYear_TBD.WeatherDays(); if (weatherDays_TBD == null) { return(false); } for (int i = 0; i < weatherDays_TBD.Count; i++) { Update(weatherDays_TBD[i], weatherYear[i]); } return(true); }
/// <summary> /// This is the method that actually does the work. /// </summary> /// <param name="dataAccess">The DA object is used to retrieve from inputs and store in outputs.</param> protected override void SolveInstance(IGH_DataAccess dataAccess) { int index; bool run = false; index = Params.IndexOfInputParam("_run"); if (index == -1 || !dataAccess.GetData(index, ref run)) { run = false; } if (!run) { return; } index = Params.IndexOfInputParam("_pathTasTSD"); if (index == -1) { AddRuntimeMessage(GH_RuntimeMessageLevel.Error, "Invalid data"); return; } string path_TSD = null; if (!dataAccess.GetData(index, ref path_TSD) || string.IsNullOrWhiteSpace(path_TSD)) { AddRuntimeMessage(GH_RuntimeMessageLevel.Error, "Invalid data"); return; } WeatherYear weatherYear = Weather.Tas.Query.WeatherYear(path_TSD); index = Params.IndexOfOutputParam("weatherYear"); if (index != -1) { dataAccess.SetData(index, new GooWeatherYear(weatherYear)); } }