public void TestMethod1()
 {
   DFS0 df = new DFS0(@"C:\Users\Jacob\Downloads\gridKlima20148.dfs0");
   var monthly = TSTools.ChangeZoomLevel(df.GetTimeSpanSeries(1), TimeStepUnit.Month, true);
   using (System.IO.StreamWriter sw = new System.IO.StreamWriter(@"C:\Users\Jacob\Downloads\Monthly_20148.csv"))
   {
     sw.WriteLine("Year,Month,Precip");
   foreach(var v in monthly.Items)
     sw.WriteLine(v.Time.Year + ","+v.Time.Month+","+v.Value);
   }
 }
Esempio n. 2
0
    private void InitializeDetailedM11()
    {
      mike11Observations = new List<DetailedMike11>();

      DFS0 simdata = new DFS0(mshe.Files.DetailedTimeSeriesM11);
      Dictionary<string, DFS0> ObsCache= new Dictionary<string,DFS0>();


      foreach (var obs in mshe.Input.MIKESHE_FLOWMODEL.StoringOfResults.DetailedM11TimeseriesOutput.Item_1s)
      {
        var m = new DetailedMike11() { Chainage = obs.Chainage, Name = obs.Name };

        m.Branch = mshe.River.network.GetBranch(obs.BranchName, obs.Chainage);

        if (m.Branch != null)
        {
          m.Location = m.Branch.GetPointAtChainage(obs.Chainage);
          var item = simdata.Items.FirstOrDefault(i => i.Name == m.Name);

          if (item != null)
            m.Simulation = simdata.GetTimeSpanSeries(item.ItemNumber);


          if (obs.InclObserved == 1)
          {
            DFS0 obsdata;
            if (!ObsCache.TryGetValue(obs.TIME_SERIES_FILE.FILE_NAME, out obsdata))
            {
              obsdata = new DFS0(obs.TIME_SERIES_FILE.FILE_NAME);
              ObsCache.Add(obs.TIME_SERIES_FILE.FILE_NAME, obsdata);
            }
              m.Observation = obsdata.GetTimeSpanSeries(obs.TIME_SERIES_FILE.ITEM_NUMBERS);
          }
          mike11Observations.Add(m);
        }
      }
      simdata.Dispose();
      foreach (var obsdata in ObsCache.Values)
        obsdata.Dispose();
    }