示例#1
0
        public void Run(string inputfile1, string inputfile2, double fac1, double fac2, string outputfile)
        {
            if (!File.Exists(inputfile1))
            {
                throw new Exception(String.Format("First input file {0} does not exist!", inputfile1));
            }
            if (!File.Exists(inputfile2))
            {
                throw new Exception(String.Format("Second input file {0} does not exist!", inputfile1));
            }

            try
            {
                _dfsInput1 = DfsFileFactory.DfsGenericOpen(inputfile1);
                _dfsInput2 = DfsFileFactory.DfsGenericOpen(inputfile2);
                _VerifyInputSimilarity(_dfsInput1, _dfsInput2);
                _dfsOutput = DfsOutput.CreateFromTemplate(_dfsInput1, outputfile);

                ProcessAllTimeSteps(_dfsOutput, (float)fac1, (float)fac2);
            }
            finally
            {
                _dfsInput1.Close();
                _dfsInput2.Close();
                _dfsOutput.Close();
            }
        }
示例#2
0
        public void Run(string inputfile, double fac, double constant, string outputfile)
        {
            if (!File.Exists(inputfile))
            {
                throw new Exception(String.Format("Input file {0} does not exist!", inputfile));
            }

            var ext1 = Path.GetExtension(inputfile).ToLower();
            var ext2 = Path.GetExtension(outputfile).ToLower();

            if (ext1 != ext2)
            {
                throw new Exception("Input and output files must have same extension!");
            }

            try
            {
                _dfsInput  = DfsFileFactory.DfsGenericOpen(inputfile);
                _dfsOutput = DfsOutput.CreateFromTemplate(_dfsInput, outputfile);

                ProcessAllTimeSteps(_dfsOutput, (float)fac, (float)constant);
            }
            finally
            {
                _dfsInput.Close();
                _dfsOutput.Close();
            }
        }
示例#3
0
        public void Run(string inputfile, string outputfile)
        {
            if (!File.Exists(inputfile))
            {
                throw new Exception(String.Format("Input file {0} does not exist!", inputfile));
            }

            try
            {
                _dfsInput  = DfsFileFactory.DfsGenericOpen(inputfile);
                _dfsOutput = DfsOutput.CreateFromTemplate(_dfsInput, outputfile);

                ProcessAllTimeSteps(_dfsOutput);
            }
            finally
            {
                _dfsInput.Close();
                _dfsOutput.Close();
            }
        }
示例#4
0
        public void Run(string inputfile1, string inputfile2, double fac1, double fac2, string outputfile)
        {
            if (!File.Exists(inputfile1))
            {
                throw new Exception(String.Format("First input file {0} does not exist!", inputfile1));
            }
            if (!File.Exists(inputfile2))
            {
                throw new Exception(String.Format("Second input file {0} does not exist!", inputfile1));
            }

            var ext1 = Path.GetExtension(inputfile1).ToLower();
            var ext2 = Path.GetExtension(inputfile2).ToLower();

            if (ext1 != ext2)
            {
                throw new Exception("Input files must have same extension!");
            }
            var ext_out = Path.GetExtension(outputfile).ToLower();

            if (ext1 != ext_out)
            {
                throw new Exception("Input and output files must have same extension!");
            }

            try
            {
                _dfsInput1 = DfsFileFactory.DfsGenericOpen(inputfile1);
                _dfsInput2 = DfsFileFactory.DfsGenericOpen(inputfile2);
                _VerifyInputSimilarity(_dfsInput1, _dfsInput2);
                _dfsOutput = DfsOutput.CreateFromTemplate(_dfsInput1, outputfile);

                ProcessAllTimeSteps(_dfsOutput, (float)fac1, (float)fac2);
            }
            finally
            {
                _dfsInput1.Close();
                _dfsInput2.Close();
                _dfsOutput.Close();
            }
        }
示例#5
0
        private DfsFile _CreateFromTemplate(IDfsFile dfsTemplate, string outputfile, IEnumerable <int> timesteps, int stride, List <int> items)
        {
            IDfsFileInfo fi = dfsTemplate.FileInfo;
            //this._AnalyzeDfsInputItems(dfsTemplate.ItemInfo);
            var builder = DfsBuilder.Create(fi.FileTitle, fi.ApplicationTitle, fi.ApplicationVersion);

            IDfsTemporalAxis timeAxis = _CorrectTimeAxis(fi.TimeAxis, timesteps.First(), stride);

            DfsOutput.CreateHeader(fi, builder, timeAxis);
            DfsOutput.CreateDynamicItems(builder, dfsTemplate.ItemInfo, items);

            builder.CreateFile(outputfile);

            IDfsStaticItem staticItem;

            while ((staticItem = dfsTemplate.ReadStaticItemNext()) != null)
            {
                builder.AddStaticItem(staticItem);
            }

            return(builder.GetFile());
        }
示例#6
0
        private DfsFile _CreateFromTemplate(IDfsFile dfsTemplate, string outputfile, IEnumerable <int> timesteps, int stride)
        {
            var items = Enumerable.Range(0, DfsOutput._NumberItems(dfsTemplate.ItemInfo)).ToList();

            return(_CreateFromTemplate(dfsTemplate, outputfile, timesteps, stride, items));
        }