Example #1
0
        public override void ReadConfiguration(System.Xml.Linq.XElement Configuration)
        {
            base.ReadConfiguration(Configuration);

            if (Include)
            {
                var pFiles = Configuration.Element("ParticleFiles");
                UseUnsatFilter        = pFiles.SafeParseBool("RemoveUnsatParticles") ?? false;
                DrainToBoundaryOption = pFiles.SafeParseBool("DrainToBoundaryCorrection") ?? false;

                ParticlesPrSquareMeter = Configuration.SafeParseDouble("ParticlesPrSquareMeter") ?? -1;

                foreach (var parfile in pFiles.Elements("ParticleFile"))
                {
                    ParticleFiles.Add(new SafeFile()
                    {
                        FileName = parfile.SafeParseString("ShapeFileName")
                    });
                }

                Start = new DateTime(Configuration.SafeParseInt("FromYear") ?? 2000, Configuration.SafeParseInt("FromMonth") ?? 1, 1);
                End   = new DateTime(Configuration.SafeParseInt("ToYear") ?? 2002, Configuration.SafeParseInt("ToMonth") ?? 1, 1);

                OutputFile = new SafeFile()
                {
                    CheckIfFileExists = false, FileName = Configuration.SafeParseString("ShapeFileName")
                };
            }
        }
Example #2
0
        public virtual void ReadConfiguration(XElement Configuration)
        {
            this.Configuration = Configuration;
            Update             = Configuration.SafeParseBool("Update") ?? _Update;
            Include            = Configuration.SafeParseBool("Include") ?? _Include;
            Name        = Configuration.SafeParseString("Name");
            ExtraOutput = Configuration.SafeParseBool("ExtraOutput") ?? _ExtraOutput;

            MultiplicationPar = Configuration.SafeParseDouble("MultiplicationPar") ?? _MultiplicationPar;
            AdditionPar       = Configuration.SafeParseDouble("AdditionPar") ?? _AdditionPar;

            var element = Configuration.Element("ExtraParameters");

            if (element != null)
            {
                ExtraParsShape = new SafeFile()
                {
                    FileName = element.SafeParseString("ShapeFileName")
                };
                ExtraParsShape.ColumnNames.Add(element.SafeParseString("IDColumn"));
                ExtraParsShape.ColumnNames.Add(element.SafeParseString("MultiplicationColumn"));
                ExtraParsShape.ColumnNames.Add(element.SafeParseString("AdditionColumn"));
            }

            NewMessage("Configuration read.");
        }
Example #3
0
    public override void ReadConfiguration(XElement Configuration)
    {
      base.ReadConfiguration(Configuration);
      if (Update)
      {
        var pars = Configuration.Element("Parameters");
        if (pars != null)
        {
          Par1 = pars.SafeParseDouble("p1") ?? _Par1;
          Par2 = pars.SafeParseDouble("p2") ?? _Par2;
          Par3 = pars.SafeParseDouble("p3") ?? _Par3;
          Par4 = pars.SafeParseDouble("p4") ?? _Par4;
          MaxConcentration = pars.SafeParseDouble("MaxConcentration") ?? _MaxConcentration;
        }

        Slope = new SafeFile() { FileName = Configuration.Element("SlopeFile").SafeParseString("DBFFileName") };
        Slope.ColumnNames.Add(Configuration.Element("SlopeFile").SafeParseString("IDColumn"));
        Slope.ColumnNames.Add(Configuration.Element("SlopeFile").SafeParseString("ValueColumn"));

        SoilTypeFile = new SafeFile() { FileName = Configuration.Element("SoilTypeFile").SafeParseString("DBFFileName") };
        SoilTypeFile.ColumnNames.Add(Configuration.Element("SoilTypeFile").SafeParseString("IDColumn"));
        SoilTypeFile.ColumnNames.Add(Configuration.Element("SoilTypeFile").SafeParseString("ValueColumn"));
        SoilTypeFile.ColumnNames.Add(Configuration.Element("SoilTypeFile").SafeParseString("SoilNameText"));

      }
    }
Example #4
0
        public override void ReadConfiguration(XElement Configuration)
        {
            base.ReadConfiguration(Configuration);

            if (Update)
            {
                MultiplicationFactor       = Configuration.SafeParseDouble("MultiplicationFactor") ?? _MultiplicationFactor;
                Exponent                   = Configuration.SafeParseDouble("Exponent") ?? _Exponent;
                ReachLengthReductionFactor = Configuration.SafeParseDouble("ReachLenghtReductionFactor") ?? _ReachLengthReductionFactor;
                FirstSummerMonth           = Configuration.SafeParseInt("FirstSummerMonth") ?? _FirstSummerMonth;
                LastSummerMonth            = Configuration.SafeParseInt("LastSummerMonth") ?? _LastSummerMonth;

                foreach (var v in Configuration.Element("StreamClasses").Elements("StreamClass"))
                {
                    StreamClassification sc = new StreamClassification();
                    sc.StreamType           = v.SafeParseString("Name");
                    sc.StreamDepthSummer    = v.SafeParseDouble("DepthSummer") ?? 0;
                    sc.StreamDepthWinter    = v.SafeParseDouble("DepthWinter") ?? 0;
                    sc.StreamVelocitySummer = v.SafeParseDouble("VelocitySummer") ?? 0;
                    sc.StreamVelocityWinter = v.SafeParseDouble("VelocityWinter") ?? 0;
                    StreamClasses.Add(sc.StreamType, sc);
                }
                foreach (var v in Configuration.Element("DBFFiles").Elements("DBFFile"))
                {
                    var dbf = new SafeFile();
                    dbf.FileName = v.SafeParseString("FileName");
                    dbf.ColumnNames.Add(v.SafeParseString("IDColumn"));
                    dbf.ColumnNames.Add(v.SafeParseString("NameColumn"));
                    dbf.ColumnNames.Add(v.SafeParseString("LengthColumn"));
                    dbf.ColumnNames.Add(v.SafeParseString("LRColumn"));
                    this.DBFFiles.Add(dbf);
                }
            }
        }
Example #5
0
        public override void ReadConfiguration(XElement Configuration)
        {
            base.ReadConfiguration(Configuration);
            if (Update)
            {
                var pars = Configuration.Element("Parameters");
                if (pars != null)
                {
                    Par1             = pars.SafeParseDouble("p1") ?? _Par1;
                    Par2             = pars.SafeParseDouble("p2") ?? _Par2;
                    Par3             = pars.SafeParseDouble("p3") ?? _Par3;
                    Par4             = pars.SafeParseDouble("p4") ?? _Par4;
                    MaxConcentration = pars.SafeParseDouble("MaxConcentration") ?? _MaxConcentration;
                }

                Slope = new SafeFile()
                {
                    FileName = Configuration.Element("SlopeFile").SafeParseString("DBFFileName")
                };
                Slope.ColumnNames.Add(Configuration.Element("SlopeFile").SafeParseString("IDColumn"));
                Slope.ColumnNames.Add(Configuration.Element("SlopeFile").SafeParseString("ValueColumn"));

                SoilTypeFile = new SafeFile()
                {
                    FileName = Configuration.Element("SoilTypeFile").SafeParseString("DBFFileName")
                };
                SoilTypeFile.ColumnNames.Add(Configuration.Element("SoilTypeFile").SafeParseString("IDColumn"));
                SoilTypeFile.ColumnNames.Add(Configuration.Element("SoilTypeFile").SafeParseString("ValueColumn"));
                SoilTypeFile.ColumnNames.Add(Configuration.Element("SoilTypeFile").SafeParseString("SoilNameText"));
            }
        }
 public override void ReadConfiguration(XElement Configuration)
 {
   base.ReadConfiguration(Configuration);
   if (Update)
   {
     Shapefile = new SafeFile() { FileName = Configuration.Element("LocationFile").SafeParseString("ShapeFileName") };
     ExcelFile = new SafeFile() { FileName = Configuration.Element("DataFile").SafeParseString("ExcelFileName") };
   }
 }
    public override void ReadConfiguration(System.Xml.Linq.XElement Configuration)
    {
      base.ReadConfiguration(Configuration);
      //Needs the source model name even if it does not update for the reduction map
      SourceModelName = (Configuration.SafeParseString("SourceModelName") ?? "").ToLower();

      if (Update)
      {
        ShapeFile = new SafeFile() { FileName = Configuration.SafeParseString("ShapeFileName") };
        ShapeFile.ColumnNames.Add(Configuration.SafeParseString("IDColumn"));
        ShapeFile.ColumnNames.Add(Configuration.SafeParseString("ValueColumn"));
      }
    }
 public override void ReadConfiguration(XElement Configuration)
 {
     base.ReadConfiguration(Configuration);
     if (Update)
     {
         Shapefile = new SafeFile()
         {
             FileName = Configuration.Element("LocationFile").SafeParseString("ShapeFileName")
         };
         ExcelFile = new SafeFile()
         {
             FileName = Configuration.Element("DataFile").SafeParseString("ExcelFileName")
         };
     }
 }
        public override void ReadConfiguration(System.Xml.Linq.XElement Configuration)
        {
            base.ReadConfiguration(Configuration);
            //Needs the source model name even if it does not update for the reduction map
            SourceModelName = (Configuration.SafeParseString("SourceModelName") ?? "").ToLower();

            if (Update)
            {
                ShapeFile = new SafeFile()
                {
                    FileName = Configuration.SafeParseString("ShapeFileName")
                };
                ShapeFile.ColumnNames.Add(Configuration.SafeParseString("IDColumn"));
                ShapeFile.ColumnNames.Add(Configuration.SafeParseString("ValueColumn"));
            }
        }
Example #10
0
    public override void ReadConfiguration(XElement Configuration)
    {
      base.ReadConfiguration(Configuration);

      if (Update)
      {
        Alpha = Configuration.SafeParseDouble("Alpha") ?? _Alpha;
        Beta = Configuration.SafeParseDouble("Beta") ?? _Beta;
        Par1 = Configuration.SafeParseDouble("Par1") ?? _Par1;
        ShapeFile = new SafeFile() { FileName = Configuration.SafeParseString("ShapeFileName") };
        ShapeFile.ColumnNames.Add(Configuration.SafeParseString("NameColumn") ?? "NAVN");
        ShapeFile.ColumnNames.Add(Configuration.SafeParseString("DepthColumn") ?? "Dybde");
        ShapeFile.ColumnNames.Add(Configuration.SafeParseString("InitNColumn") ?? "SoInitNmgL");
        ShapeFile.ColumnNames.Add(Configuration.SafeParseString("StartColumn") ?? "Aar_start");
        ShapeFile.ColumnNames.Add(Configuration.SafeParseString("EndColumn") ?? "Aar_slut");
      }
    }
Example #11
0
    public override void ReadConfiguration(XElement Configuration)
    {
      base.ReadConfiguration(Configuration);
      if (Update)
      {
        var shapeconf = Configuration.Element("LocationFile");
        ShapeFile = new SafeFile { FileName = shapeconf.SafeParseString("ShapeFileName") };
        ShapeFile.ColumnNames.Add(shapeconf.SafeParseString("IDColumn"));
        ShapeFile.ColumnNames.Add(shapeconf.SafeParseString("ZoneColumn"));

        var dbfconf = Configuration.Element("DataFile");
        DBFFile = new SafeFile { FileName = dbfconf.SafeParseString("DBFFileName") };
        DBFFile.ColumnNames.Add(dbfconf.SafeParseString("IDColumn"));
        DBFFile.ColumnNames.Add(dbfconf.SafeParseString("YearColumn"));
        DBFFile.ColumnNames.Add(dbfconf.SafeParseString("ValueColumn"));
      }
    }
Example #12
0
        public override void ReadConfiguration(XElement Configuration)
        {
            base.ReadConfiguration(Configuration);

            if (Update)
            {
                Alpha     = Configuration.SafeParseDouble("Alpha") ?? _Alpha;
                Beta      = Configuration.SafeParseDouble("Beta") ?? _Beta;
                Par1      = Configuration.SafeParseDouble("Par1") ?? _Par1;
                ShapeFile = new SafeFile()
                {
                    FileName = Configuration.SafeParseString("ShapeFileName")
                };
                ShapeFile.ColumnNames.Add(Configuration.SafeParseString("NameColumn") ?? "NAVN");
                ShapeFile.ColumnNames.Add(Configuration.SafeParseString("DepthColumn") ?? "Dybde");
                ShapeFile.ColumnNames.Add(Configuration.SafeParseString("InitNColumn") ?? "SoInitNmgL");
                ShapeFile.ColumnNames.Add(Configuration.SafeParseString("StartColumn") ?? "Aar_start");
                ShapeFile.ColumnNames.Add(Configuration.SafeParseString("EndColumn") ?? "Aar_slut");
            }
        }
    public override void ReadConfiguration(XElement Configuration)
    {
      base.ReadConfiguration(Configuration);

      if (Update)
      {
        ShapeFile = new SafeFile() { FileName = Configuration.SafeParseString("ShapeFileName") };
        ShapeFile.ColumnNames.Add(Configuration.SafeParseString("YearColumn"));
        ShapeFile.ColumnNames.Add(Configuration.SafeParseString("NameColumn"));
        Par1 = Configuration.SafeParseDouble("Par1")??_Par1;
        Par2 = Configuration.SafeParseDouble("Par2") ?? _Par2;

        foreach (var soileq in Configuration.Elements("Soil"))
        {
          WetLandsReducer wr = new WetLandsReducer();
          wr.ReadConfiguration(soileq);
          SoilEquations.Add(wr.Name, wr);
        }
      }
    }
Example #14
0
        public override void ReadConfiguration(XElement Configuration)
        {
            base.ReadConfiguration(Configuration);
            if (Update)
            {
                var shapeconf = Configuration.Element("LocationFile");
                ShapeFile = new SafeFile {
                    FileName = shapeconf.SafeParseString("ShapeFileName")
                };
                ShapeFile.ColumnNames.Add(shapeconf.SafeParseString("IDColumn"));
                ShapeFile.ColumnNames.Add(shapeconf.SafeParseString("ZoneColumn"));

                var dbfconf = Configuration.Element("DataFile");
                DBFFile = new SafeFile {
                    FileName = dbfconf.SafeParseString("DBFFileName")
                };
                DBFFile.ColumnNames.Add(dbfconf.SafeParseString("IDColumn"));
                DBFFile.ColumnNames.Add(dbfconf.SafeParseString("YearColumn"));
                DBFFile.ColumnNames.Add(dbfconf.SafeParseString("ValueColumn"));
            }
        }
Example #15
0
    public virtual void ReadConfiguration(XElement Configuration)
    {
      this.Configuration = Configuration;
      Update = Configuration.SafeParseBool("Update") ?? _Update;
      Include = Configuration.SafeParseBool("Include") ?? _Include;
      Name = Configuration.SafeParseString("Name");
      ExtraOutput = Configuration.SafeParseBool("ExtraOutput") ?? _ExtraOutput;
     
      MultiplicationPar = Configuration.SafeParseDouble("MultiplicationPar") ?? _MultiplicationPar;
      AdditionPar = Configuration.SafeParseDouble("AdditionPar") ?? _AdditionPar;

      var element = Configuration.Element("ExtraParameters");
      if (element != null)
      {
        ExtraParsShape = new SafeFile() { FileName = element.SafeParseString("ShapeFileName") };
        ExtraParsShape.ColumnNames.Add(element.SafeParseString("IDColumn"));
        ExtraParsShape.ColumnNames.Add(element.SafeParseString("MultiplicationColumn"));
        ExtraParsShape.ColumnNames.Add(element.SafeParseString("AdditionColumn"));
      }

      NewMessage("Configuration read.");
    }
Example #16
0
        public override void ReadConfiguration(XElement Configuration)
        {
            base.ReadConfiguration(Configuration);

            if (Update)
            {
                ShapeFile = new SafeFile()
                {
                    FileName = Configuration.SafeParseString("ShapeFileName")
                };
                ShapeFile.ColumnNames.Add(Configuration.SafeParseString("YearColumn"));
                ShapeFile.ColumnNames.Add(Configuration.SafeParseString("NameColumn"));
                Par1 = Configuration.SafeParseDouble("Par1") ?? _Par1;
                Par2 = Configuration.SafeParseDouble("Par2") ?? _Par2;

                foreach (var soileq in Configuration.Elements("Soil"))
                {
                    WetLandsReducer wr = new WetLandsReducer();
                    wr.ReadConfiguration(soileq);
                    SoilEquations.Add(wr.Name, wr);
                }
            }
        }
Example #17
0
    public void LoadStationData(SafeFile ShapeFileName, string StationData, DateTime Start, DateTime End)
    {

      StateVariables.ClearColumnValues("ObservedFlow");
      StateVariables.ClearColumnValues("ObservedNitrate");


      Dictionary<int, DMUStation> locatedStations = new Dictionary<int,DMUStation>();
      List<DMUStation> stations = new List<DMUStation>();
      LogThis("Reading stations from " + ShapeFileName.FileName);
      using (ShapeReader sr = new ShapeReader(ShapeFileName.FileName))
      {
        for (int i = 0; i < sr.Data.NoOfEntries; i++)
        {
          DMUStation dm = new DMUStation();
          dm.Location = sr.ReadNext(i) as XYPoint;
          dm.ID = sr.Data.ReadInt(i, ShapeFileName.ColumnNames[0]);
          dm.ODANummer = sr.Data.ReadInt(i, ShapeFileName.ColumnNames[1]);
          stations.Add(dm);
          if(dm.ODANummer!=0)
            locatedStations.Add(dm.ODANummer, dm);
          int id = sr.Data.ReadInt(i, ShapeFileName.ColumnNames[2]);
          if (id != 0 & AllCatchments.ContainsKey(id))
          {
            if (AllCatchments[id].Measurements != null)
            {
              int m = 0;
            }
            AllCatchments[id].Measurements = dm;
          }
        }
      }
      LogThis(stations.Count + " stations read. " + locatedStations.Count + " within catchments distributed on " + AllCatchments.Values.Count(ca => ca.Measurements != null) +" catchments.");

      using (StreamReader sr = new StreamReader(StationData))
      {
        sr.ReadLine();//HeadLine
        while (!sr.EndOfStream)
        {
          var data = sr.ReadLine().Split(';');
          DMUStation  station;

          if (locatedStations.TryGetValue(int.Parse(data[0]), out station))
          {
            var time = new DateTime(int.Parse(data[2]), int.Parse(data[3]), 1);
            if (time >= Start & time <= End)
            {
              station.Nitrate.Items.Add(new TimeStampValue(time, double.Parse(data[4])));
              station.Flow.Items.Add(new TimeStampValue(time, double.Parse(data[5]) * 1000));
            }
          }
        }
      }
    }
Example #18
0
    /// <summary>
    /// Reads and parses the configuration file
    /// </summary>
    /// <param name="xmlfilename"></param>
    public void ReadConfiguration(string xmlfilename)
    {
      string dir = Directory.GetCurrentDirectory();
      Directory.SetCurrentDirectory(Path.GetDirectoryName(xmlfilename));

      LogThis("Reading configfile: " + xmlfilename);

      XElement configuration = XDocument.Load(xmlfilename).Element("Configuration");

      var startxml =configuration.Element("SimulationStart");
      var endxml = configuration.Element("SimulationEnd");
      Start = new DateTime(int.Parse(startxml.Attribute("Year").Value), int.Parse(startxml.Attribute("Month").Value), 1);
      End = new DateTime(int.Parse(endxml.Attribute("Year").Value), int.Parse(endxml.Attribute("Month").Value), 1);
      CurrentTime = Start;

      LakeFile = new SafeFile() { FileName = configuration.Element("Lakes").SafeParseString("ShapeFileName") };

      SoilsShape = new SafeFile() { FileName = configuration.Element("SoilTypes").SafeParseString("ShapeFileName") };
      SoilsShape.ColumnNames.Add(configuration.Element("SoilTypes").SafeParseString("SoilTypeColumn"));

      var observar =configuration.Element("Observations");

      if (observar != null && (observar.SafeParseBool("Update") ?? true))
      {
        Stations = new SafeFile() { FileName = observar.SafeParseString("ShapeFileName") };
        Stations.ColumnNames.Add(observar.SafeParseString("DMUColumn"));
        Stations.ColumnNames.Add(observar.SafeParseString("ODAColumn"));
        Stations.ColumnNames.Add(observar.SafeParseString("ID15Column"));
        StationData = new SafeFile() { FileName = observar.SafeParseString("TransportFileName") };
      }
      //Read output section
      var output = configuration.Element("Output");
      var log = output.Element("Log");
      if(log!=null && (log.SafeParseBool("Include") ?? true))
        LogFileName = Path.GetFullPath( log.SafeParseString("FileName"));

      var csv = output.Element("AllData");
      if (csv != null && (csv.SafeParseBool("Include") ?? true))
      {
        AlldataFile = new SafeFile() { CheckIfFileExists = false, InitialDelete = true, FileName = csv.SafeParseString("CSVFileName") };
        MainModel.OutputDirectory = Path.GetDirectoryName(AlldataFile.FileName);
      }
      var excel = output.Element("Calibration");
      if (excel != null && (excel.SafeParseBool("Include") ?? true))
      {
        ExcelTemplate = new SafeFile() { FileName = excel.SafeParseString("ExcelTemplate") };
        ExcelTemplate.ColumnNames.Add(Path.GetFullPath(excel.SafeParseString("OutputFolder")));
      }

      var mapouts = output.Element("MapOutputs");
      if(mapouts !=null)
        foreach (var mapout in mapouts.Elements())
        {
          if (mapout.SafeParseBool("Include")??true)
          {
            SafeFile sf = new SafeFile() {CheckIfFileExists=false, FileName = mapout.SafeParseString("ShapeFileName") };
            sf.Parameters.Add(mapout.SafeParseInt("FromYear") ?? Start.Year);
            sf.Parameters.Add(mapout.SafeParseInt("ToYear") ?? End.Year);
            sf.Parameters.Add(mapout.SafeParseInt("FromMonth") ?? Start.Month);
            sf.Parameters.Add(mapout.SafeParseInt("ToMonth") ?? End.Month);
            sf.Flags.Add(mapout.SafeParseBool("AreaWeighted") ?? false);
            sf.Flags.Add(mapout.SafeParseBool("Accumulated") ?? false);
            MapOutputFiles.Add(sf);
          }
        }

      mapouts = output.Element("StatisticsMaps");
      if (mapouts != null)
      {
        foreach (var mapout in mapouts.Elements())
        {
          if (mapout.SafeParseBool("Include") ?? true)
          {
            SafeFile sf = new SafeFile() { CheckIfFileExists = false, FileName = mapout.SafeParseString("ShapeFileName") };
            sf.Parameters.Add(mapout.SafeParseInt("FromYear") ?? Start.Year);
            sf.Parameters.Add(mapout.SafeParseInt("ToYear") ?? End.Year);
            sf.Parameters.Add(mapout.SafeParseInt("FromMonth") ?? Start.Month);
            sf.Parameters.Add(mapout.SafeParseInt("ToMonth") ?? End.Month);
            sf.Flags.Add(mapout.SafeParseBool("Yearly") ?? false);
            sf.Flags.Add(mapout.SafeParseBool("BiasFactorUpstream") ?? false);
            sf.Flags.Add(mapout.SafeParseBool("Water") ?? false);
            StatisticsMap.Add(sf);
          }
        }
      }


      //Detailed parameter time series
        var detailed = output.Element("DetailedParameterTimeSeries");
        if (detailed != null)
        {
          foreach (var mapout in detailed.Elements())
          {
            if (mapout.SafeParseBool("Include") ?? true)
            {
              SafeFile sf = new SafeFile() { CheckIfFileExists = false, InitialDelete=true, FileName = mapout.SafeParseString("CSVFileName") };
              sf.ColumnNames.Add(mapout.SafeParseString("Parameter"));
              sf.Flags.Add(mapout.SafeParseBool("Accumulated") ?? false);
              DetailedParameterTimeSeries.Add(sf);
            }
          }
        }

      //Detailed catchment time series
        detailed = output.Element("DetailedCatchmentTimeSeries");
        if (detailed != null)
        {
          foreach (var mapout in detailed.Elements())
          {
            if (mapout.SafeParseBool("Include") ?? true)
            {
              SafeFile sf = new SafeFile() { CheckIfFileExists = false, InitialDelete=true, FileName = mapout.SafeParseString("CSVFileName") };
              sf.Parameters.Add(mapout.SafeParseInt("CatchmentID")??0);
              sf.Flags.Add(mapout.SafeParseBool("Accumulated") ?? false);
              DetailedCatchmentTimeSeries.Add(sf);
            }
          }
        }


      if (configuration.Element("InitialConditions").SafeParseBool("Include") ?? false)
      {
        InitialConditionsfile = new SafeFile() { FileName = configuration.Element("InitialConditions").SafeParseString("CSVFileName") };
        InitialConditionsfile.ColumnNames.Add(configuration.Element("InitialConditions").SafeParseString("DateFormat"));
      }

      foreach (var mshe in configuration.Element("MikeSheModels").Elements("MikeSheModel"))
      {
        if(mshe.SafeParseBool("Update") ?? true)
          MsheSetups.Add(new SafeFile(){ FileName = mshe.SafeParseString("SheFileName")});
      }

      var m11override = configuration.Element("M11FlowOverride");
      if (m11override != null && (m11override.SafeParseBool("Include") ?? true) && (m11override.SafeParseBool("Update") ?? true))
        M11FlowOverride = new SafeFile() { FileName = m11override.SafeParseString("DFS0FileName") };

      var m11bias = configuration.Element("M11Bias");
      if (m11bias != null && (m11bias.SafeParseBool("Include") ?? true) && (m11bias.SafeParseBool("Update") ?? true))
      {
        M11Base = new SafeFile() { FileName = m11bias.SafeParseString("ShapeFileName") };
        M11Base.ColumnNames.Add(m11bias.SafeParseString("MultiplyColumn"));
      }

      var coastal = configuration.Element("CoastalZone");
      if(coastal!=null && (coastal.SafeParseBool("Include")??true))
      {
        CoastalZone = new SafeFile(){FileName = coastal.SafeParseString("ShapeFileName")};
        CoastalZone.ColumnNames.Add(coastal.SafeParseString("Column") ?? "Kyst");
        foreach (var elem in coastal.Elements("KeepValue"))
          CoastalZone.ColumnNames.Add(elem.SafeParseString("AttributeValue"));

      }

      //Configuration of sourcemodels
      SourceModels = new List<ISource>();
      foreach (var sourcemodelXML in configuration.Element("SourceModels").Elements())
      {
        ISource NewModel= ModelFactory.GetSourceModel(sourcemodelXML.Name.LocalName);
        if (NewModel != null)
        {
          NewModel.ReadConfiguration(sourcemodelXML);
          if (NewModel.Include)
          {
            SourceModels.Add(NewModel);
            NewModel.MessageChanged += new NewMessageEventhandler(NewModel_MessageChanged);
          }
        }
      }

      LogThis("Source models created");


      InternalReductionModels = new List<ISink>();
      //Configuration of internal reduction models
      foreach (var sourcemodelXML in configuration.Element("InternalSinks").Elements())
      {
        ISink NewModel = ModelFactory.GetSinkModel(sourcemodelXML.Name.LocalName);
        if (NewModel != null)
        {
          NewModel.ReadConfiguration(sourcemodelXML);
          if (NewModel.Include)
          {
            InternalReductionModels.Add(NewModel);
            NewModel.MessageChanged += new NewMessageEventhandler(NewModel_MessageChanged);
          }
        }
      }

      LogThis("Internal sink models created");

      MainStreamRecutionModels = new List<ISink>();
      //Configuration of internal reduction models
      foreach (var sourcemodelXML in configuration.Element("MainStreamSinks").Elements())
      {
        ISink NewModel = ModelFactory.GetSinkModel(sourcemodelXML.Name.LocalName);
        if (NewModel != null)
        {
          NewModel.ReadConfiguration(sourcemodelXML);
          if (NewModel.Include)
          {
            MainStreamRecutionModels.Add(NewModel);
            NewModel.MessageChanged += new NewMessageEventhandler(NewModel_MessageChanged);
          }
        }
      }

      var calib = configuration.Element("Calibration");
      if (calib != null)
      {
        Calib = new Calibrator();
        Calib.ReadConfiguration(calib);
        Calib.MessageChanged += new NewMessageEventhandler(NewModel_MessageChanged);

      }

      var redmap = configuration.Element("ReductionMap");
      if(redmap!=null)
      {
        reductioncreator = new ReductionMap();
        reductioncreator.ReadConfiguration(redmap);
      }
      
      LogThis("Main stream sink models created");

      CatchmentFiles.Add(new SafeFile() { FileName = configuration.Element("Catchments").SafeParseString("ShapeFileName") });

      Directory.SetCurrentDirectory(dir);
    }
Example #19
0
    public override void ReadConfiguration(System.Xml.Linq.XElement Configuration)
    {
      base.ReadConfiguration(Configuration);

      if (Include)
      {
        var pFiles = Configuration.Element("ParticleFiles");
        UseUnsatFilter = pFiles.SafeParseBool("RemoveUnsatParticles") ?? false;
        DrainToBoundaryOption = pFiles.SafeParseBool("DrainToBoundaryCorrection") ?? false;

        ParticlesPrSquareMeter = Configuration.SafeParseDouble("ParticlesPrSquareMeter") ?? -1;

        foreach (var parfile in pFiles.Elements("ParticleFile"))
        {
          ParticleFiles.Add(new SafeFile() { FileName = parfile.SafeParseString("ShapeFileName") });
        }

        Start = new DateTime(Configuration.SafeParseInt("FromYear") ?? 2000, Configuration.SafeParseInt("FromMonth") ?? 1, 1);
        End = new DateTime(Configuration.SafeParseInt("ToYear") ?? 2002, Configuration.SafeParseInt("ToMonth") ?? 1, 1);

        OutputFile = new SafeFile() { CheckIfFileExists = false, FileName = Configuration.SafeParseString("ShapeFileName") };
      }
    }
Example #20
0
        /// <summary>
        /// Reads and parses the configuration element
        /// </summary>
        /// <param name="Configuration"></param>
        public override void ReadConfiguration(XElement Configuration)
        {
            base.ReadConfiguration(Configuration);
            if (Update)
            {
                var Unsatelement = Configuration.Element("UnsatFiles");
                if (Unsatelement != null)
                {
                    foreach (var parfile in Unsatelement.Elements("UnsatFile"))
                    {
                        UZAgeDefinition uzd = new UZAgeDefinition();
                        uzd.FileName = new SafeFile()
                        {
                            FileName = parfile.SafeParseString("DFS2FileName")
                        };
                        uzd.FileName.ColumnNames.Add(parfile.SafeParseString("ItemName"));
                        uzd.MinHorizontalTravelDistance = parfile.SafeParseDouble("MinHorizontalTravelDistance") ?? 0;
                        uzd.MinTravelTime = parfile.SafeParseDouble("MinTravelTime") ?? 0;

                        UnsatAgeFiles.Add(uzd);
                    }
                }


                var daisyelement = Configuration.Element("DaisyFiles");

                var startyear  = daisyelement.SafeParseInt("RecycleStartYear");
                int startmonth = daisyelement.SafeParseInt("RecycleStartMonth") ?? 1;

                if (startyear.HasValue)
                {
                    RecycleStart = new DateTime(startyear.Value, startmonth, 1);
                }

                var endyear  = daisyelement.SafeParseInt("RecycleEndYear");
                int endmonth = daisyelement.SafeParseInt("RecycleEndMonth") ?? 1;
                if (endyear.HasValue)
                {
                    RecycleEnd = new DateTime(endyear.Value, endmonth, 1);
                }
                RecycleScale = daisyelement.SafeParseDouble("RecycleScaleFactor") ?? 1;

                foreach (var parfile in daisyelement.Elements("DaisyFile"))
                {
                    DaisyFiles.Add(new SafeFile()
                    {
                        FileName = parfile.SafeParseString("FileName")
                    });
                }

                var pFiles = Configuration.Element("ParticleFiles");
                UseUnsatFilter        = pFiles.SafeParseBool("RemoveUnsatParticles") ?? false;
                DrainToBoundaryOption = pFiles.SafeParseBool("DrainToBoundaryCorrection") ?? false;


                foreach (var parfile in pFiles.Elements("ParticleFile"))
                {
                    ParticleFiles.Add(new SafeFile()
                    {
                        FileName = parfile.SafeParseString("ShapeFileName")
                    });
                }

                SoilCodes = new SafeFile()
                {
                    FileName = Configuration.Element("SoilCodes").SafeParseString("ShapeFileName")
                };
            }
        }
    /// <summary>
    /// Reads and parses the configuration element
    /// </summary>
    /// <param name="Configuration"></param>
    public override void ReadConfiguration(XElement Configuration)
    {
      base.ReadConfiguration(Configuration);
      if (Update)
      {
        var Unsatelement = Configuration.Element("UnsatFiles");
        if (Unsatelement != null)
        {
          foreach (var parfile in Unsatelement.Elements("UnsatFile"))
          {
            UZAgeDefinition uzd = new UZAgeDefinition();
            uzd.FileName = new SafeFile() { FileName = parfile.SafeParseString("DFS2FileName") };
            uzd.FileName.ColumnNames.Add(parfile.SafeParseString("ItemName"));
            uzd.MinHorizontalTravelDistance =parfile.SafeParseDouble("MinHorizontalTravelDistance") ?? 0;
            uzd.MinTravelTime = parfile.SafeParseDouble("MinTravelTime") ?? 0;

            UnsatAgeFiles.Add(uzd);
          }
        }

        
        var daisyelement =Configuration.Element("DaisyFiles");

        var startyear = daisyelement.SafeParseInt("RecycleStartYear");
        int startmonth = daisyelement.SafeParseInt("RecycleStartMonth") ??1;

        if (startyear.HasValue)
          RecycleStart = new DateTime(startyear.Value, startmonth, 1);

        var endyear = daisyelement.SafeParseInt("RecycleEndYear");
        int endmonth = daisyelement.SafeParseInt("RecycleEndMonth") ?? 1;
        if (endyear.HasValue)
          RecycleEnd = new DateTime(endyear.Value, endmonth, 1);
        RecycleScale = daisyelement.SafeParseDouble("RecycleScaleFactor") ?? 1;

        foreach (var parfile in daisyelement.Elements("DaisyFile"))
        {
          DaisyFiles.Add(new SafeFile() { FileName = parfile.SafeParseString("FileName") });
        }

        var pFiles =Configuration.Element("ParticleFiles");
        UseUnsatFilter = pFiles.SafeParseBool("RemoveUnsatParticles") ?? false;
        DrainToBoundaryOption = pFiles.SafeParseBool("DrainToBoundaryCorrection") ?? false;


        foreach (var parfile in pFiles.Elements("ParticleFile"))
        {
          ParticleFiles.Add(new SafeFile() { FileName = parfile.SafeParseString("ShapeFileName") });
        }

        SoilCodes = new SafeFile() { FileName = Configuration.Element("SoilCodes").SafeParseString("ShapeFileName") };
      }
    }
Example #22
0
    public override void ReadConfiguration(XElement Configuration)
    {
      base.ReadConfiguration(Configuration);

      if (Update)
      {

        MultiplicationFactor = Configuration.SafeParseDouble("MultiplicationFactor") ?? _MultiplicationFactor;
        Exponent = Configuration.SafeParseDouble( "Exponent") ?? _Exponent;
        ReachLengthReductionFactor = Configuration.SafeParseDouble("ReachLenghtReductionFactor") ?? _ReachLengthReductionFactor;
        FirstSummerMonth = Configuration.SafeParseInt("FirstSummerMonth") ?? _FirstSummerMonth;
        LastSummerMonth = Configuration.SafeParseInt("LastSummerMonth") ?? _LastSummerMonth;

        foreach (var v in Configuration.Element("StreamClasses").Elements("StreamClass"))
        {
          StreamClassification sc = new StreamClassification();
          sc.StreamType = v.SafeParseString("Name");
          sc.StreamDepthSummer = v.SafeParseDouble("DepthSummer") ?? 0;
          sc.StreamDepthWinter = v.SafeParseDouble("DepthWinter") ?? 0;
          sc.StreamVelocitySummer = v.SafeParseDouble("VelocitySummer") ?? 0;
          sc.StreamVelocityWinter = v.SafeParseDouble( "VelocityWinter") ?? 0;
          StreamClasses.Add(sc.StreamType, sc);
        }
        foreach (var v in Configuration.Element("DBFFiles").Elements("DBFFile"))
        {
          var dbf = new SafeFile();
          dbf.FileName = v.SafeParseString("FileName");
          dbf.ColumnNames.Add(v.SafeParseString("IDColumn"));
          dbf.ColumnNames.Add(v.SafeParseString("NameColumn"));
          dbf.ColumnNames.Add(v.SafeParseString("LengthColumn"));
          dbf.ColumnNames.Add(v.SafeParseString("LRColumn"));
          this.DBFFiles.Add(dbf);
        }
      }

    }