Difference between revisions of "How to visualize WRF-Fire output in Matlab"

From openwfm
Jump to navigation Jump to search
 
(11 intermediate revisions by the same user not shown)
Line 1: Line 1:
 +
{{users guide}}
 
==Prerequistes==
 
==Prerequistes==
  
* A computer for visualization with recent [[Matlab]] and memory at least 3 times the size of the '''wrfout''' file.
+
* A visualization computer with recent [[Matlab]] and memory at least 3 times the size of the '''wrfout''' file.
 
* [[How to run WRF-Fire|A working installation]] of [[WRF-Fire]], possibly on another computer or a cluster.
 
* [[How to run WRF-Fire|A working installation]] of [[WRF-Fire]], possibly on another computer or a cluster.
  
==Directions==
+
==Loading WRF-Fire files into [[Matlab]]==
 +
''Note that fire variables in WRF files have an extra strip the size of subgrid ratio at the end every spatial dimension. That is, each spatial dimension stored in WRF files is by the subgrid ratio larger. The functions provided here will hide that and manipulate the fire variables correctly.''
  
* [http://www.mmm.ucar.edu/wrf/users/docs/user_guide_V3/users_guide_chap5.htm#Nml Change in '''namelist.input'''] the line with '''history_interval''' to the desired frame interval in seconds, for example '''history_interval_s=1'''. Make sure '''frames_per_outfile''' is large enough so that only one '''wrfout''' file is produced.
+
* It is recommended to set in [http://www.mmm.ucar.edu/wrf/users/docs/user_guide_V3/users_guide_chap5.htm#Nml Change in '''namelist.input'''] the variable '''frames_per_outfile''' small, esp. for a large model, to avoid creating huge files.  
 
* Run WRF-Fire.
 
* Run WRF-Fire.
 
* If the visualization computer is different from the computer where you run WRF-Fire,
 
* If the visualization computer is different from the computer where you run WRF-Fire,
 
** [[How to get WRF-Fire|Download WRF-Fire]] on the visualization computer
 
** [[How to get WRF-Fire|Download WRF-Fire]] on the visualization computer
 
** Transfer the '''wrfout''' file to the visualization computer
 
** Transfer the '''wrfout''' file to the visualization computer
* Start Matlab on the visualization computer from the directory '''wrf-fire/WRFV3/test/em_fire'''. This is needed to set Matlab search path. Alternatively, '''cd''' in Matlab to this directory and run '''startup'''.  You can then '''cd''' to the directory where you put the '''wrfout''' file if you want.
+
* Start Matlab on the visualization computer from the directory '''wrf-fire/WRFV3/test/em_fire'''. This is needed to set Matlab search path. Alternatively, '''cd''' in Matlab to this directory and run '''startup'''.  You can then '''cd''' to the directory where you put the '''wrfout''' file. You can also '''cd''' to '''wrf-fire/other/Matlab''' and run '''startup''' there.
 +
* Use commands '''ncload''' to load all variables from a WRF file into matlab workspace, '''ncread''' to read a single variable into a matrix, '''nc2struct''' to read multiple variables as fields of a structure, and '''ncreplace''' to rewrite the value of a variable in the file.
 +
 
 +
==3D Visualization==
 +
 
 +
* Proceed as above, except change in  [http://www.mmm.ucar.edu/wrf/users/docs/user_guide_V3/users_guide_chap5.htm#Nml '''namelist.input'''] the line with '''history_interval''' to the desired frame interval in seconds, for example '''history_interval_s=1''' make sure '''frames_per_outfile''' is large enough so that only one '''wrfout''' file is produced.
 
* Type in Matlab '''wrfout2frame3d'''
 
* Type in Matlab '''wrfout2frame3d'''
 +
* Examine the variables loaded in the Matlab workspace for further education and entertainment.
  
 
The scripts are fairly straightforward and various options are controlled by editing the scripts in Matlab.
 
The scripts are fairly straightforward and various options are controlled by editing the scripts in Matlab.
 +
 +
==See also==
 +
 +
* [[How to interpret WRF-Fire variables]]
  
 
== Gallery ==
 
== Gallery ==
Line 20: Line 32:
 
[[File:Hill2-jan.png|200px]]
 
[[File:Hill2-jan.png|200px]]
 
[[File:WRF-Fire-walking-ignition-matlab.png|200px]]
 
[[File:WRF-Fire-walking-ignition-matlab.png|200px]]
 +
[[File:Harmanli.png|200px]]
  
 
==Works with==
 
==Works with==
* WRF-Fire commit 0098ec2f615bc598f829d551169424e6fd55f1c5 and later
+
* WRF-Fire {{WRF-Fire-commit|6cff9ae515e4830bb5042417d024e5c06b237eb7|Aug 7 2010}} and hopefully later
 
* Matlab 2008b and later
 
* Matlab 2008b and later
 
* Tested with Matlab 2010a on MacBook Pro 4GB OS X 10.6
 
* Tested with Matlab 2010a on MacBook Pro 4GB OS X 10.6
Line 28: Line 41:
 
[[Category:Howtos|Visualize WRF-Fire output in Matlab]]
 
[[Category:Howtos|Visualize WRF-Fire output in Matlab]]
 
[[Category:WRF-Fire]]
 
[[Category:WRF-Fire]]
[[Category:Visualizations]]
+
[[Category:Visualization]]

Latest revision as of 21:49, 19 May 2016

Back to the WRF-SFIRE user guide.

Prerequistes

Loading WRF-Fire files into Matlab

Note that fire variables in WRF files have an extra strip the size of subgrid ratio at the end every spatial dimension. That is, each spatial dimension stored in WRF files is by the subgrid ratio larger. The functions provided here will hide that and manipulate the fire variables correctly.

  • It is recommended to set in Change in namelist.input the variable frames_per_outfile small, esp. for a large model, to avoid creating huge files.
  • Run WRF-Fire.
  • If the visualization computer is different from the computer where you run WRF-Fire,
    • Download WRF-Fire on the visualization computer
    • Transfer the wrfout file to the visualization computer
  • Start Matlab on the visualization computer from the directory wrf-fire/WRFV3/test/em_fire. This is needed to set Matlab search path. Alternatively, cd in Matlab to this directory and run startup. You can then cd to the directory where you put the wrfout file. You can also cd to wrf-fire/other/Matlab and run startup there.
  • Use commands ncload to load all variables from a WRF file into matlab workspace, ncread to read a single variable into a matrix, nc2struct to read multiple variables as fields of a structure, and ncreplace to rewrite the value of a variable in the file.

3D Visualization

  • Proceed as above, except change in namelist.input the line with history_interval to the desired frame interval in seconds, for example history_interval_s=1 make sure frames_per_outfile is large enough so that only one wrfout file is produced.
  • Type in Matlab wrfout2frame3d
  • Examine the variables loaded in the Matlab workspace for further education and entertainment.

The scripts are fairly straightforward and various options are controlled by editing the scripts in Matlab.

See also

Gallery

Hill2-jan.png WRF-Fire-walking-ignition-matlab.png Harmanli.png

Works with

  • WRF-Fire Aug 7 2010 and hopefully later
  • Matlab 2008b and later
  • Tested with Matlab 2010a on MacBook Pro 4GB OS X 10.6