https://visitusers.org/api.php?action=feedcontributions&user=Sisneros&feedformat=atomVisItusers.org - User contributions [en]2023-10-03T10:31:42ZUser contributionsMediaWiki 1.31.15https://visitusers.org/index.php?title=Model_Fit_Operator&diff=6752Model Fit Operator2012-04-28T12:06:26Z<p>Sisneros: Changed size of final image.</p>
<hr />
<div>The ModelFit operator allows for the definition of multiple high-dimensional models for the purpose of the classification of data. Models are specified in a space created by selected variables, e.g. for a model specified over variables [v1, v2, v3] a model is a collection of 3-dimensional points each component corresponding to one of the three variables. Once all models are defined, the distance from each model to every spatial location of the data is calculated as the distance of one representative point from each model to that location (whichever point is closest). The model with the shortest distance is a spatial location's classifying model. The operator creates two variables, one containing the integer tag of the classifying model and another containing the actual calculated distance.<br />
<br />
= Parts of the Operator =<br />
<br />
[[Image:Modefit parts.png]]<br />
<br />
# '''Add Model''': Any number of models may be added/renamed and each appears in the left table of the operator GUI. The right side of the interface is specific to a single model and updates on the selection of any model in the left table. <br />
# '''Add Variable/Add Point''': Models are defined by selecting variables (i.e. a variable space) and specifying some number of points in that space. The buttons for these additions affect the table on the right for any selected model. <br />
# '''Input Values''': The actual values of the points may be inputted into the right table at any time during the definition process.<br />
# '''Select Input Space''': Distance metrics may be calculated in a variety of spaces. Currently there is support for 4 spaces. The input values may be input in any of these spaces and this is specified here:<br />
## ''Variable'' – the original space of the dataset.<br />
## ''0-1'' – the data is normalized to be in the range [0, 1].<br />
## ''Log'' – the base 2 log is taken of the data.<br />
## ''Probability'' – the data is converted using its cumulative density function, distance in this space corresponds to an area under a density curve.<br />
# '''Select Calculation Space''': In which space should the distance metrics be calculated.<br />
# '''Select Distance Metric''': Choose one of 3 implemented distance metrics: Euclidean (2-norm), Manhattan (1-norm) and Maximum (infinity-norm). From the 1-norm to infinity-norm these distance metrics are least to most, respectively, sensitive to a single component in the calculation. Each of 4, 5, and 6 are specific to each defined model, and must be set for each.<br />
<br />
= Example Use =<br />
<br />
# Open sresa1b_ncar_ccsm3_0_run1_200001.nc (http://www.unidata.ucar.edu/software/netcdf/examples/files.html) linked to from: (https://wci.llnl.gov/codes/visit/datafiles.html). We'll be looking at two variables from this dataset, pr and tas. Pseudocolor plots of these variables follow: <br>[[Image:Modelfit pr.png|400px]] [[Image:Modelfit tas.png|400px]]<br />
# Add a Pseudocolor plot of operators->ModelFit->model <br>[[Image:Modelfit graph.png|500px]]<br />
# Add a model, and rename the model to “Max pr” <br>[[Image:Modelfit model added.png|500px]]<br />
# Add a variable to the model, choose pr from the “Scalars” menu. Then input the maximum value for pr (0.0003) into the model definition table. <br>[[Image:Modelfit var added.png|500px]]<br />
# Press the “Apply” button. Now, draw the plot. Make sure the Pseudocolor plot range is form min: 0 to max: 1. The model variable will contain a 1 everywhere that the model classifies the data, and a 0 where no model does. With the default (Hot) color table, the resulting image should be all red. This is because with only one model, it is trivially true that the one model is the closest of all defined models to each point in the data.<br />
# There is a way, however, to define a range at any input value, forcing models to be good fits. In the table, replace the input value with the following: 0.00015-0.00030. This lets the operator know that unless a points value falls within that range, a model should not even be considered a reasonable classifier. Notice the resulting image contains 3 colors now. The blue is everywhere the model is not the classifier and the red is where it is. The green is an interpolation error caused by the fact that we have discrete data and a continuous color scale. The following image has a 2 color discrete color scale and this problem is resolved. As a sanity check, compare this image with a Pseudocolor plot of the pr variable, and use the Threshold operator to look at only the values between 0.00015 and 0.00030. <br>[[Image:Modelfit var added 2.png|500px]] [[Image:Modelfit first image.png|500px]]<br />
# Revert to the original Max pr (value input is 0.0003), and add a second model. For this second model, name it Max tas, add the tas variable, and input its max value (309). <br>[[Image:Modelfit second model.png||500px]]<br />
# Make sure the Pseudocolor plot range is now at least [0, 2], to allow for the new integer tag for the second specified model (Max tas). Draw this plot. Again, assuming default Hot colors, the graph is all green. This is because the two variables are on different scales. Also, 309, is the approximate max value, and is actually farther away from the maximum value (.1) than the two farthest points in the pr variable.<br />
# To normalize scales, change for both models the Calculation Space to 0-1. Now the plot is overwhelmingly red, but both models are classifying some of the data. This tells us that once scales are removed, that the overall range of temperature is much smaller than that of pressure. <br>[[Image:Modelfit second 01.png|500px]] [[Image:Modelfit 0 1.png|500px]]<br />
# To achieve maximum representation in the output of all models, let's normalize both scales and distributions: change the Calculation Space to Probability. Here is the output: <br>[[Image:Modelfit second prob.png|500px]] [[Image:Modelfit probability space.png|500px]]<br />
# Finally, let's look at the distance variable. Remember, the classifying model at a point is based on a minimum distance. The actual distance is stored in the distance variable. The following is the resulting image from changing variables from ModelFit->model to ModelFit->distance with the same two models. The colors have been changed to an inverted grayscale. This is the “Gray” choice in the Pseudocolor plot attributes menu, and is inverted (with a checkbox) since lowest distances are the best fits. These are the distances classification in step 10. <br>[[Image:Modelfit distances.png|500px]]<br />
<br />
[[Category: User Documentation]]</div>Sisneroshttps://visitusers.org/index.php?title=VisIt-tutorial-in-situ&diff=6439VisIt-tutorial-in-situ2012-01-09T21:26:46Z<p>Sisneros: Typo</p>
<hr />
<div>VisIt provides a library for in-situ visualization and analysis that we call libsim. Libsim lets you instrument your simulation code so VisIt can connect to it and access its data directly as though the simulation was a VisIt compute engine. Trends show that as computers get faster, I/O cannot keep pace. This makes in-situ's properties appealing:<br />
<br />
*Adds visualization capabilities inside the simulation so it can visualize the data<br />
*Visualize the data using the same level of resources as are being used to calculate the data (vis often gets 1/10th the resources)<br />
*Writing plot dump files not required so plot images can be saved at greater frequency<br />
*Visualization routines get direct access to the simulation’s memory<br />
*Good for making canned movies<br />
<br />
This tutorial section will consist of:<br />
# Presentation slides ([[Media:SC2010-in-situ.pdf|pdf]]) ([http://portal.nersc.gov/svn/visit/trunk/docs/Presentations/SC2010-in-situ.pptx powerpoint])<br />
# Demonstration<br />
<br />
=Resources=<br />
Here are some resources for in-situ visualization with VisIt. The best reference is the [https://wci.llnl.gov/codes/visit/2.0.0/GettingDataIntoVisIt2.0.0.pdf Getting Data Into VisIt manual].<br />
<br />
*In-situ presentation slides ([[Media:SC2010-in-situ.pdf|pdf]]) ([http://portal.nersc.gov/svn/visit/trunk/docs/Presentations/SC2010-in-situ.pptx powerpoint])<br />
*[https://wci.llnl.gov/codes/visit/2.0.0/GettingDataIntoVisIt2.0.0.pdf Getting Data Into VisIt manual] chapter 5<br />
*[http://portal.nersc.gov/svn/visit/branches/2.1RC/src/tools/DataManualExamples/Simulations/ Simulation code example programs]<br />
*[[Simulation Control Interface]]<br />
*Development roadmaps [[SimV2 reader]], [[Additional in-situ work]]<br />
<br />
=Example=<br />
While VisIt provides many [http://portal.nersc.gov/svn/visit/branches/2.1RC/src/tools/DataManualExamples/Simulations example programs] for in-situ visualization, we will focus on the Mandelbrot set example. This example uses adaptive mesh refinement to more finely resolve the Mandelbrot set where it provides more detail.<br />
<br />
{| align="center" border="1"<br />
!align=center|[[Image:MandelbrotAMR.png|200px]]<br />
|-<br />
| Mandelbrot set<br />
|}<br />
<br />
Other links:<br />
*[http://portal.nersc.gov/svn/visit/branches/2.1RC/src/tools/DataManualExamples/Simulations/life.c Game of Life simulation example]<br />
*[http://portal.nersc.gov/svn/visit/trunk/src/tools/DataManualExamples/Simulations/contrib/pjacobi/ Parallel Jacobi solver for the Laplacian equation in 2D simulation example]<br />
*Find out more about the [http://en.wikipedia.org/wiki/Mandelbrot_set Mandelbrot set]<br />
*Find out more about [http://en.wikipedia.org/wiki/Adaptive_mesh_refinement Adaptive Mesh Refinement]<br />
<br />
<br />
<br />
==Building the example==<br />
# Get the source code for the Mandelbrot simulation example: [http://portal.nersc.gov/svn/visit/branches/2.1RC/src/tools/DataManualExamples/Simulations/mandelbrot.C mandelbrot.C],[http://portal.nersc.gov/svn/visit/branches/2.1RC/src/tools/DataManualExamples/Simulations/patch.C patch.C],[http://portal.nersc.gov/svn/visit/branches/2.1RC/src/tools/DataManualExamples/Simulations/patch.h patch.h],[http://portal.nersc.gov/svn/visit/branches/2.1RC/src/tools/DataManualExamples/Simulations/SimulationExample.h SimulationExample.h].<br />
# Make a '''simulation''' directory on your Desktop and copy the source code files to it<br />
# Copy the Makefile below to the '''simulation''' directory, adjusting the contents to provide the correct location of VisIt's SimV2 library.<br />
# Type ''make''<br />
<br />
<code><pre><br />
############## Makefile for building the simulation using libsim. ###############<br />
<br />
############################## USER EDIT SECTION ################################<br />
<br />
# Fill in the Path to the VisIt installation. This is the directory that contains <br />
# VisIt's 2.0.0, 2.0.1, 2.1.0, 2.1.1 directories<br />
VISITHOME=/path/to/visit<br />
<br />
# Set this to the version of VisIt that you use<br />
VISITVERSION=2.1.1<br />
<br />
# Choose one, depending on your system architecture<br />
#VISITARCH=linux-intel<br />
#VISITARCH=linux-x86_64<br />
VISITARCH=darwin-i386<br />
<br />
# Edit your compiler and its settings<br />
CXX=g++<br />
CPPFLAGS=<br />
CXXFLAGS=-O3<br />
LDFLAGS=<br />
LIBS=<br />
<br />
#################################################################################<br />
SIMDIR=$(VISITHOME)/$(VISITVERSION)/$(VISITARCH)/libsim/V2<br />
<br />
SIM_CXXFLAGS=-I$(SIMDIR)/include<br />
SIM_LDFLAGS=-L$(SIMDIR)/lib<br />
SIM_LIBS=-lsimV2<br />
<br />
SRC=mandelbrot.C patch.C<br />
OBJ=$(SRC:.C=.o)<br />
<br />
all: mandelbrot<br />
<br />
clean:<br />
rm -f mandelbrot $(OBJ)<br />
<br />
mandelbrot: $(OBJ)<br />
$(CXX) -o mandelbrot $(OBJ) $(LDFLAGS) $(SIM_LDFLAGS) $(SIM_LIBS) $(LIBS)<br />
<br />
.C.o:<br />
$(CXX) $(CXXFLAGS) $(SIM_CXXFLAGS) $(CPPFLAGS) -c $<<br />
</pre></code><br />
<br />
*''Note: if you build and make complains about missing separators, replace the spaces before $(CXX) with a tab''<br />
<br />
===Additional step for MacOS X===<br />
VisIt relinks its libraries during installation so its libraries are positioned relative to ''@executable_path/../lib''. Unfortunately, this means that when the VisIt libraries are dynamically loaded into your MacOS X simulation by libsim, it expects to find dependent libraries in ''../lib'' relative to your application. For the time being, you will need to create a ''lib'' symbolic link to VisIt's libraries.<br />
# cd ~/Desktop<br />
# ln -s /path/to/visit/2.1.1/darwin-i386/lib .<br />
<br />
==Running the example==<br />
You will need 2 terminal/shell windows. In the first window you will run the simulation. In the second window, you will launch VisIt and connect to the simulation.<br />
<br />
'''Terminal 1 (Run the simulation)'''<br />
# cd ~/Desktop/simulation<br />
# ./mandelbrot -trace trace.txt <br />
<br />
'''Terminal 2 (Run VisIt)'''<br />
# Run '''visit -small'''<br />
# Open ''~/.visit/simulations'' in the File Open window<br />
# There should be a file ######.mandelbrot.sim2 that you'll want to open. If there are multiple files that match that pattern then open the most recent one.<br />
# VisIt will try connecting to the simulation<br />
# Look at terminal 1 to see if it contains ''VisIt connected''<br />
# Add a Pseudocolor plot of the ''mandelbrot'' variable<br />
# Click Draw<br />
# Go back to terminal 1<br />
<br />
'''Terminal 1'''<br />
# Type ''step'' at the simulation's ''command>'' prompt<br />
# Type ''update'' at the simulation's ''command>'' prompt and watch the VisIt window update its plots with a different portion of the Mandelbrot set.<br />
<br />
'''Within VisIt'''<br />
# Open up VisIt's '''File'''->'''Simulations''' window <br />
# Note the command buttons: ''halt, step, run, update''<br />
# The command buttons provide a limited way for VisIt to drive the simulation<br />
# Click the '''run''' button and watch terminal 1 for messages<br />
# Click the '''update''' button and watch VisIt recalculate the plots<br />
# Click the '''halt''' button to halt the simulation<br />
# Add a Subset plot of levels<br />
# Open the Subset plot attributes and turn on ''single-color''. Make it black.<br />
# Turn on wireframe<br />
# Click Apply and Dismiss the window<br />
# Click Draw to draw the plot<br />
# Click the '''toggleupdates''' button<br />
# Click the '''run''' button and watch VisIt recalculate the plots as the simulation runs<br />
<br />
[[Category: VisIt Tutorial]]</div>Sisneros