Takes the first step from a DFSU file and apends it to the end of the file INPUT OUTPUT NO OUTPUT AT CONSOLE Copys the selected DFSU file with a '_ts_added' suffix. REQUIREMENTS MIKE by DHI toolbox. Tested / developed with 20130222 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 Modify to allow copying of timestep n to the end? Allow string input for filename % Function Begin!
0001 function mrg_dfsu_duplicate_ts 0002 % Takes the first step from a DFSU file and apends it to the end of the 0003 % file 0004 % 0005 % INPUT 0006 % 0007 % OUTPUT 0008 % NO OUTPUT AT CONSOLE 0009 % Copys the selected DFSU file with a '_ts_added' suffix. 0010 % 0011 % REQUIREMENTS 0012 % MIKE by DHI toolbox. Tested / developed with 20130222 0013 % 0014 % AUTHORS 0015 % Daniel Pritchard 0016 % 0017 % LICENCE 0018 % Code distributed as part of the MRG toolbox from the Marine Research 0019 % Group at Queens Univeristy Belfast (QUB) School of Planning 0020 % Architecture and Civil Engineering (SPACE). Distributed under a 0021 % creative commons CC BY-SA licence, retaining full copyright of the 0022 % original authors. 0023 % 0024 % http://creativecommons.org/licenses/by-sa/3.0/ 0025 % http://www.qub.ac.uk/space/ 0026 % http://www.qub.ac.uk/research-centres/eerc/ 0027 % 0028 % DEVELOPMENT 0029 % v 1.0 2013-10-28 0030 % First version. DP 0031 % 0032 % TODO 0033 % Modify to allow copying of timestep n to the end? 0034 % Allow string input for filename 0035 % 0036 % 0037 %% Function Begin! 0038 oldpath = cd; 0039 [filename, path] = uigetfile('.dfsu','Select a DFSU file to process'); 0040 cd(path); 0041 new_file = [filename(1:end-5), '_ts_added.dfsu']; 0042 copyfile(filename, new_file); 0043 0044 % Load libraries 0045 NET.addAssembly('DHI.Generic.MikeZero.DFS'); 0046 NET.addAssembly('DHI.Generic.MikeZero.EUM'); 0047 import DHI.Generic.MikeZero.DFS.*; 0048 import DHI.Generic.MikeZero.DFS.dfsu.*; 0049 import DHI.Generic.MikeZero.* 0050 0051 % Get file 0052 dfsu_file = DfsFileFactory.DfsuFileOpenEdit(new_file); 0053 % Get data from first timestep 0054 itemData = dfsu_file.ReadItemTimeStep(1,0); 0055 data = double(itemData.Data)'; 0056 % Write data to a new appended timestep 0057 dfsu_file.WriteItemTimeStepNext(0, NET.convertArray(single(data))); 0058 % Close file 0059 dfsu_file.Close(); 0060 0061 % Return 0062 cd(oldpath); 0063 0064 0065 end