示例#1
0
        static void Run(Options options)
        {
            Dir.RequireDirectory(options.OutputDir);
            var floodVisOutput = $"{options.OutputDir}/flood_vis";

            Dir.RequireClearDirectory(floodVisOutput);
            var floodseries = FloodseriesZip.Read(options.FloodSeriesPath, options.StartDay, options.EndDay);
            var floodmap    = floodseries.CombineToFloodmap();

            DrawFloodSeries(floodseries, floodVisOutput);
            DrawFloodMap(floodmap, $"{options.OutputDir}/floodmap.png");
            Grd.Write($"{options.OutputDir}/floodmap.grd", floodmap);
        }
示例#2
0
 static void Main(string[] args)
 {
     Parser.Default.ParseArguments <Options>(args).WithParsed(o =>
     {
         var channels    = CgInteraction.ReadChannelsTreeFromCg(o.ChannelsGraphFile);
         var floodSeries = FloodseriesZip.Read(o.FloodSeriesFile, o.StartDay, o.EndDay);
         Dir.RequireClearDirectory(o.OutputDir);
         foreach (var day in floodSeries.Days)
         {
             var bitmap = DrawDirectionsBitmap(channels, day.VxMap, day.VyMap);
             bitmap.Save($"{o.OutputDir}/{day.T}.png");
         }
     });
     System.Console.WriteLine("Press any key to continue...");
     System.Console.ReadKey();
 }
示例#3
0
        private static void Run(Options options)
        {
            var relief      = Grd.Read(options.ReliefFile);
            var targetMap   = Grd.Read(options.TargetMapFile);
            var floodSeries = FloodseriesZip.Read(options.FloodSeriesFile, options.StartDay, options.EndDay);
            var channels    = CgInteraction.ReadChannelsTreeFromCg(options.ChannelsGraphFile);

            var drawingsDir = $"{options.OutputDir}/vis";
            var mapsDir     = $"{options.OutputDir}/maps";

            Dir.RequireClearDirectory(drawingsDir);
            Dir.RequireClearDirectory(mapsDir);

            var floodMap = DrawFloodMapWithTargets(floodSeries, targetMap, options.TargetValue);

            floodMap.Save($"{options.OutputDir}/floodmap.png");

            var strategies = new[]
示例#4
0
        private static void Run(Options options)
        {
            var graph = CgInteraction.ReadChannelsGraphFromCg(options.GraphPath);
            var flood = FloodseriesZip.Read(options.FloodPath, 20, 20);

            var hMap  = flood.Days[0].HMap;
            var vxMap = flood.Days[0].VxMap;
            var vyMap = flood.Days[0].VyMap;

            var channelById = new Dictionary <long, Channel>();
            var channels    = new List <Channel>();

            graph.BFS(channel =>
            {
                var direction      = GetChannelDirection(channel, flood.Days[0]);
                channel.Connecions = channel.Connecions.Where(child => {
                    var directionBetween = GetDirectionBetweenChannels(channel, child);
                    return(IsSodirected(direction, directionBetween));
                }).ToList();
                channelById[channel.Id] = channel;
                channels.Add(channel);
            });

            var interestingId = new List <long>()
            {
                74, 77, 87, 86, 90, 91, 109, 108, 151, 152, 103, 105, 104, 131, 130, 163, 164
            };

            var reportCsv = "id,q_entrance,q_exit,loss,is_source";

            foreach (var channel in channels)
            {
                var n = 3;

                var vxEntrance = 0d;
                var vyEntrance = 0d;
                var hEntrance  = 0d;

                for (var i = 0; i < n && i < channel.Points.Count; i++)
                {
                    var p = channel.Points[i];
                    vxEntrance += vxMap[p.X, p.Y - 1] / n;
                    vyEntrance += vyMap[p.X, p.Y - 1] / n;
                    hEntrance  += hMap[p.X, p.Y - 1] / n;
                }

                var qEntrance = Length(new Vec(vxEntrance, vyEntrance)) * 25 * hEntrance;

                var vxExit = 0d;
                var vyExit = 0d;
                var hExit  = 0d;

                for (var i = 0; i < n && i < channel.Points.Count; i++)
                {
                    var p = channel.Points[channel.Points.Count - i - 1];
                    vxExit += vxMap[p.X, p.Y - 1] / n;
                    vyExit += vyMap[p.X, p.Y - 1] / n;
                    hExit  += hMap[p.X, p.Y - 1] / n;
                }

                var qExit = Length(new Vec(vxExit, vyExit)) * 25 * hExit;

                reportCsv += $"\n{channel.Id},{qEntrance},{qExit},{qEntrance - qExit},{(channel.IsEntrance ? 1 : 0)}";
            }

            File.WriteAllText(options.ReportOutPath, reportCsv);
            CgInteraction.WriteChannelsGraphToCg(options.GraphOutPath, graph);
        }