Modfies the selected DFSU file so that it begins at starttime and ends at endtime, with equally space timesteps inbetween INPUT starttime A MATLAB datetime vector endtime A MATLAB datetime vector OUTPUT NO OUTPUT AT CONSOLE. Modifies the timestep information of the selected DFSU file. USAGE mrg_dfsu_alter_time([2013 10 28 15 30 00], [2014 01 01 00 00 00]) REQUIREMENTS MIKE by DHI toolbox. Tested / developed with 20130222 REFERENCES Please list references here in a consistent, human readable format. AUTHORS Daniel Pritchard LICENCE Code distributed as part of the MRG toolbox from the Marine Research Group at Queens Univeristy Belfast (QUB) School of Planning Architecture and Civil Engineering (SPACE). Distributed under a creative commons CC BY-SA licence, retaining full copyright of the original authors. http://creativecommons.org/licenses/by-sa/3.0/ http://www.qub.ac.uk/space/ http://www.qub.ac.uk/research-centres/eerc/ DEVELOPMENT v 1.0 2013-10-28 First version. DP TODO Allow string input for filename % Function Begin!
0001 function mrg_dfsu_alter_time(starttime, endtime) 0002 % Modfies the selected DFSU file so that it begins at starttime and ends at 0003 % endtime, with equally space timesteps inbetween 0004 % 0005 % INPUT 0006 % starttime A MATLAB datetime vector 0007 % endtime A MATLAB datetime vector 0008 % 0009 % OUTPUT 0010 % NO OUTPUT AT CONSOLE. 0011 % Modifies the timestep information of the selected DFSU file. 0012 % 0013 % USAGE 0014 % mrg_dfsu_alter_time([2013 10 28 15 30 00], [2014 01 01 00 00 00]) 0015 % 0016 % REQUIREMENTS 0017 % MIKE by DHI toolbox. Tested / developed with 20130222 0018 % 0019 % REFERENCES 0020 % Please list references here in a consistent, human readable format. 0021 % 0022 % AUTHORS 0023 % Daniel Pritchard 0024 % 0025 % LICENCE 0026 % Code distributed as part of the MRG toolbox from the Marine Research 0027 % Group at Queens Univeristy Belfast (QUB) School of Planning 0028 % Architecture and Civil Engineering (SPACE). Distributed under a 0029 % creative commons CC BY-SA licence, retaining full copyright of the 0030 % original authors. 0031 % 0032 % http://creativecommons.org/licenses/by-sa/3.0/ 0033 % http://www.qub.ac.uk/space/ 0034 % http://www.qub.ac.uk/research-centres/eerc/ 0035 % 0036 % DEVELOPMENT 0037 % v 1.0 2013-10-28 0038 % First version. DP 0039 % 0040 % TODO 0041 % Allow string input for filename 0042 %% Function Begin! 0043 oldpath = cd; 0044 [infile, path] = uigetfile('.dfsu','Select a DFSU file to process'); 0045 cd(path); 0046 0047 % Load libraries 0048 NET.addAssembly('DHI.Generic.MikeZero.DFS'); 0049 NET.addAssembly('DHI.Generic.MikeZero.EUM'); 0050 import DHI.Generic.MikeZero.DFS.*; 0051 import DHI.Generic.MikeZero.DFS.dfsu.*; 0052 import DHI.Generic.MikeZero.* 0053 0054 % Caculate times 0055 timesec = (datenum(endtime)-datenum(starttime))*24*60*60; 0056 newstart = System.DateTime(starttime(1), starttime(2), starttime(3), starttime(4), starttime(5), starttime (6)); 0057 0058 % Write data 0059 dfsu_file = DfsFileFactory.DfsuFileOpenEdit(infile); 0060 dfsu_file.StartDateTime = newstart; 0061 dfsu_file.TimeStepInSeconds = timesec; 0062 0063 % Close 0064 dfsu_file.Close(); 0065 0066 % Return 0067 cd(oldpath); 0068 0069 end