public static void GetHourlyLocationWind(UmiContext context)
        {
            RhinoApp.WriteLine("Calculating wind for location...");
            var a = new EPWeatherData();

            a.GetRawData(context.WeatherFilePath);
            var wind = a.HourlyWeatherDataRawList.Select(b => (double)b.WindSpeed);

            RhinoApp.WriteLine("Completed wind");
            WindSpeed = wind;
        }
        public static void GetHourlyLocationSolarRadiation(UmiContext context)
        {
            RhinoApp.WriteLine("Calculating Solar Radiation on horizontal surfaces...");
            var a = new EPWeatherData();

            a.GetRawData(context.WeatherFilePath);
            var radiation = a.HourlyWeatherDataRawList.Select(b => (double)b.GHorRadiation / 1000.0);

            RhinoApp.WriteLine("Completed Solar Radiation");
            SolarNormalRadiation = radiation;
            // return radiation; // from Wh to kWh
        }
Exemple #3
0
        protected override Result RunCommand(RhinoDoc doc, RunMode mode)
        {
            string        filepath = UmiContext.Current.WeatherFilePath;
            EPWeatherData epw      = new EPWeatherData();

            epw.GetRawData(filepath);
            string[] paramsOfInterest = new string[1];
            paramsOfInterest[0] = "DB";
            epw.GetWeatherStats(paramsOfInterest);
            var r = epw.GetHourlyListsTransformed(paramsOfInterest.ToList());

            //Write file
            // Create file and test if already exists
            string file_name = @"C:\UMI\temp\DryBulbData.csv";

            try
            {
                StreamWriter writer = File.CreateText(file_name);
                var          csv    = new CsvWriter(writer, CultureInfo.InvariantCulture);
                csv.WriteField("Hour");
                csv.WriteField("DB");
                csv.NextRecord();
                foreach (var item in r)
                {
                    DateTime time = new DateTime(2017, 1, 1, 0, 0, 0);
                    foreach (var line in item.Value)
                    {
                        csv.WriteField(time);
                        csv.WriteField(line);
                        csv.NextRecord();
                        time = time.AddHours(1);
                    }
                    //// these extra lines shouldn't exist but Brad's script needs a loop value (first of the year) at
                    //// the end of the file
                    //DateTime time2 = new DateTime(2017, 1, 1, 0, 0, 0);
                    //csv.WriteField(time2);
                    //csv.WriteField(item.Value[0]);
                    //csv.NextRecord();
                }

                writer.Close();
            }
            catch (IOException)
            {
                string mess = "Creation of file did not work";
                RhinoApp.WriteLine(mess);
                throw new ApplicationException("File can't be created");
            }
            return(Result.Success);
        }