User Guide 024: Difference between revisions

From CIRPwiki
Jump to navigation Jump to search
No edit summary
No edit summary
Line 15: Line 15:
‎In this example, 4 cases or alternatives (Figure 5.11.1) are set up using the Matlab script below. The script copies the base setup files into subfolders and then modifies specific CMS-Flow cards in the *.cmcards file. The set-tings for each case are setup using a structure variable with field names corresponding to each CMS-Flow card (e.g. <span style="color:#0000FF"> TIME_SERIES_INCREMENT)</span>. Separating each case into its own subfolder keeps the input and output separate and also allows for the different cases to be run at the same time.  
‎In this example, 4 cases or alternatives (Figure 5.11.1) are set up using the Matlab script below. The script copies the base setup files into subfolders and then modifies specific CMS-Flow cards in the *.cmcards file. The set-tings for each case are setup using a structure variable with field names corresponding to each CMS-Flow card (e.g. <span style="color:#0000FF"> TIME_SERIES_INCREMENT)</span>. Separating each case into its own subfolder keeps the input and output separate and also allows for the different cases to be run at the same time.  


figure d-1
[[File:fig_d-1.png]]
 
Figure D-1. Example of scripting showing the files used.
 


matlab example
matlab example
Line 23: Line 26:
matlab script
matlab script


Creating a Batch File  
=Creating a Batch File=
Although it is possible to launch CMS from Matlab a batch file is prefera-ble to use a batch file because it allows running all of the cases without opening Matlab.  
Although it is possible to launch CMS from Matlab a batch file is prefera-ble to use a batch file because it allows running all of the cases without opening Matlab.  


Line 33: Line 37:


To run the batch file, simply double click on the file and each case will launch separately in its own MS-DOS window.  
To run the batch file, simply double click on the file and each case will launch separately in its own MS-DOS window.  
Plotting  
 
=Plotting =
 
The following example reads the Observation Point time series output file (*_eta.txt) and plots the 3rd column corresponding to the second observation point.  
The following example reads the Observation Point time series output file (*_eta.txt) and plots the 3rd column corresponding to the second observation point.  


example
example

Revision as of 20:10, 2 May 2015

13 Appendix C: Matlab Scripting

Scipting refers to the automation of running multiple CMS runs with dif-ferent parameters, without manually having to create and edit each alter-native. The scripting process can include the following steps:

1. Setting up alternatives
2. Creating batch file
3. Plotting and analyzing results

Scripting can be done using a variety of software programs. The examples shown here were written in Matlab because it is widely used, easy to read and convenient for plotting and analyzing results.

Setting Up Alternatives

‎In this example, 4 cases or alternatives (Figure 5.11.1) are set up using the Matlab script below. The script copies the base setup files into subfolders and then modifies specific CMS-Flow cards in the *.cmcards file. The set-tings for each case are setup using a structure variable with field names corresponding to each CMS-Flow card (e.g. TIME_SERIES_INCREMENT). Separating each case into its own subfolder keeps the input and output separate and also allows for the different cases to be run at the same time.

File:Fig d-1.png

Figure D-1. Example of scripting showing the files used.


matlab example

The script above requires the subroutine below.

matlab script

Creating a Batch File

Although it is possible to launch CMS from Matlab a batch file is prefera-ble to use a batch file because it allows running all of the cases without opening Matlab.

matlab script

The following text shows what the resulting batch file (*.bat) looks like

example

To run the batch file, simply double click on the file and each case will launch separately in its own MS-DOS window.

Plotting

The following example reads the Observation Point time series output file (*_eta.txt) and plots the 3rd column corresponding to the second observation point.

example