[kepler-dev] Re: [kepler-cvs] kepler/workflows/orb GnuplotSurfaceDemo.xml

Dan Higgins higgins at nceas.ucsb.edu
Thu Aug 5 08:33:08 PDT 2004


Tobin,
    Nice work!  (as is your image display workflow)

I ran into many of the same problems in creating the InteractiveExec 
actor (getting the process to stop!) and in getting R running inside 
Kepler. I also agree that it would be very useful if the expression 
language was extended to handle arrays and matrices more easily. If you 
haven't looked at the 'S' language (the language that 'R' uses) you 
might want to take a look at all the features it has for manipulating 
arrays of data. It's pretty extensive and is one example of things we 
might want to add to the PT expression language.

    Also, Bertam had sent out an email referencing a web page with much 
of your work. I managed to delete the email with that web reference. 
Could you send it to me.

Thanks,

Dan Higgins

Tobin Fricke wrote:

>fricke      04/08/04 23:03:02
>
>  Added:       workflows/orb GnuplotSurfaceDemo.xml
>  Log:
>  Plot a surface using gnuplot.  This model uses the Ptolemy expression language
>  to construct a sample grid of (x,y) points, and then evaluates a function at
>  those points.  The resulting array of records {{x=double,y=double,z=double}} is
>  formatted as a gnuplot command (using the Ptolemy expression language), and
>  sent to an instance of gnuplot using the Exec actor.
>  
>  Bugs: The slowest part is actually a massive string concatenation, which is
>  not too surprising considering how Java deals with strings.  The array
>  Each element of the array {{x,y,z}} is turned into a string "x y z\n" and
>  then these are concatenated -- this operation is prohibitively slow for
>  a reasonably dense sample grid.
>  
>  There is some trouble in stopping the instance of gnuplot, too.  If I use the
>  InteractiveExec actor, then the model gets 'stuck' after firing that actor. If
>  I use Exec, it closes immediately, but then the gnuplot display disappears. I
>  tried to put in a "pause 10;exit" command in the gnuplot command, but it's not
>  working 100% yet.
>  
>  Forming the sample grid involves a mess of Ptolemy II expressions which were
>  moderately to highly mind-boggling to develop.  A more complete set of
>  primitive functions might help this... but another approach would be to just
>  use the PythonScript actor.
>  
>  As part of forming the sample grid, I needed to convert {{general}} to
>  {general}, i.e. {{1,2,3},{4,5,6},{7,8,9}} --> {1,2,3,4,5,6,7,8,9}.  I
>  accomplished this via a hack (ArrayToSeq --> ArrayToSeq --> SeqToArray) but
>  I envision implementing concatenate({{general}}) that would do this.
>  
>  Revision  Changes    Path
>  1.1                  kepler/workflows/orb/GnuplotSurfaceDemo.xml
>  
>  Index: GnuplotSurfaceDemo.xml
>  ===================================================================
>  <?xml version="1.0" standalone="no"?>
>  <!DOCTYPE entity PUBLIC "-//UC Berkeley//DTD MoML 1//EN"
>      "http://ptolemy.eecs.berkeley.edu/xml/dtd/MoML_1.dtd">
>  <entity name="GnuplotSurfaceDemo" class="ptolemy.actor.TypedCompositeActor">
>      <property name="_createdBy" class="ptolemy.kernel.attributes.VersionAttribute" value="4.0">
>      </property>
>      <property name="SDF Director" class="ptolemy.domains.sdf.kernel.SDFDirector">
>          <property name="iterations" class="ptolemy.data.expr.Parameter" value="1">
>          </property>
>          <property name="_location" class="ptolemy.kernel.util.Location" value="[-170.0, -65.0]">
>          </property>
>      </property>
>      <property name="_windowProperties" class="ptolemy.actor.gui.WindowPropertiesAttribute" value="{bounds = {0, 0, 1024, 765}, maximized = true}">
>      </property>
>      <property name="_vergilSize" class="ptolemy.actor.gui.SizeAttribute" value="[785, 639]">
>      </property>
>      <property name="_vergilZoomFactor" class="ptolemy.data.expr.ExpertParameter" value="1.0">
>      </property>
>      <property name="_vergilCenter" class="ptolemy.data.expr.ExpertParameter" value="{158.4730113636364, 220.9680397727273}">
>      </property>
>      <property name="Annotation2" class="ptolemy.vergil.kernel.attributes.TextAttribute">
>          <property name="text" class="ptolemy.kernel.util.StringAttribute" value="This model computes a function at all points&#10;on a regular rectangular grid, and graphs the&#10;result as a surface plot using gnuplot.">
>          </property>
>          <property name="_location" class="ptolemy.kernel.util.Location" value="[150.0, -85.0]">
>          </property>
>      </property>
>      <property name="annotation" class="ptolemy.kernel.util.Attribute">
>          <property name="_hideName" class="ptolemy.kernel.util.SingletonAttribute">
>          </property>
>          <property name="_iconDescription" class="ptolemy.kernel.util.SingletonConfigurableAttribute">
>              <configure><svg><text x="20" y="20" style="font-size:14; font-family:SansSerif; fill:darkgray">Author: Tobin T. Fricke
>  University of California
>  2004-08-04
>  </text></svg></configure>
>          </property>
>          <property name="_smallIconDescription" class="ptolemy.kernel.util.SingletonConfigurableAttribute">
>              <configure>
>        <svg>
>          <text x="20" style="font-size:14; font-family:SansSerif; fill:blue" y="20">-A-</text>
>        </svg>
>      </configure>
>          </property>
>          <property name="_controllerFactory" class="ptolemy.vergil.basic.NodeControllerFactory">
>          </property>
>          <property name="_editorFactory" class="ptolemy.vergil.toolbox.AnnotationEditorFactory">
>          </property>
>          <property name="_location" class="ptolemy.kernel.util.Location" value="[295.0, -20.0]">
>          </property>
>      </property>
>      <property name="Annotation" class="ptolemy.vergil.kernel.attributes.TextAttribute">
>          <property name="text" class="ptolemy.kernel.util.StringAttribute" value="This is a terrible hack to get around&#10;not having array.concatenate({array})">
>          </property>
>          <property name="_location" class="ptolemy.kernel.util.Location" value="[-270.0, 365.0]">
>          </property>
>      </property>
>      <entity name="map" class="ptolemy.actor.lib.Expression">
>          <property name="expression" class="ptolemy.kernel.util.StringAttribute" value="map(f,x)">
>          </property>
>          <property name="_icon" class="ptolemy.vergil.icon.BoxedValueIcon">
>              <property name="attributeName" class="ptolemy.kernel.util.StringAttribute" value="expression">
>              </property>
>              <property name="displayWidth" class="ptolemy.data.expr.Parameter" value="60">
>              </property>
>          </property>
>          <property name="_location" class="ptolemy.kernel.util.Location" value="[145.0, 145.0]">
>          </property>
>          <port name="output" class="ptolemy.actor.TypedIOPort">
>              <property name="output"/>
>              <property name="_showName" class="ptolemy.kernel.util.SingletonAttribute">
>              </property>
>          </port>
>          <port name="f" class="ptolemy.actor.TypedIOPort">
>              <property name="input"/>
>              <property name="_type" class="ptolemy.actor.TypeAttribute" value="unknown">
>              </property>
>              <property name="_showName" class="ptolemy.kernel.util.SingletonAttribute">
>              </property>
>          </port>
>          <port name="x" class="ptolemy.actor.TypedIOPort">
>              <property name="input"/>
>              <property name="_type" class="ptolemy.actor.TypeAttribute" value="unknown">
>              </property>
>              <property name="_showName" class="ptolemy.kernel.util.SingletonAttribute">
>              </property>
>          </port>
>      </entity>
>      <entity name="make tuplized evaluator" class="ptolemy.actor.lib.Expression">
>          <property name="expression" class="ptolemy.kernel.util.StringAttribute" value="function(x:{x=double,y=double})({x=x.x, y=x.y, z=f(x)})">
>          </property>
>          <property name="_icon" class="ptolemy.vergil.icon.BoxedValueIcon">
>              <property name="attributeName" class="ptolemy.kernel.util.StringAttribute" value="expression">
>              </property>
>              <property name="displayWidth" class="ptolemy.data.expr.Parameter" value="60">
>              </property>
>          </property>
>          <property name="_location" class="ptolemy.kernel.util.Location" value="[285.0, 85.0]">
>          </property>
>          <port name="f" class="ptolemy.actor.TypedIOPort">
>              <property name="input"/>
>              <property name="_type" class="ptolemy.actor.TypeAttribute" value="unknown">
>              </property>
>              <property name="_showName" class="ptolemy.kernel.util.SingletonAttribute">
>              </property>
>          </port>
>      </entity>
>      <entity name="tuples to gnuplot" class="ptolemy.actor.lib.Expression">
>          <property name="expression" class="ptolemy.kernel.util.StringAttribute" value="&quot;set surface;set contour;splot '-'\n&quot; + sum(map(function(tuple:{x=double,y=double,z=double}) sum({tuple.x, &quot; &quot;, tuple.y, &quot; &quot;, tuple.z, &quot;\n&quot;}),x)) + &quot;e;pause 10;exit\n&quot;">
>          </property>
>          <property name="_icon" class="ptolemy.vergil.icon.BoxedValueIcon">
>              <property name="attributeName" class="ptolemy.kernel.util.StringAttribute" value="expression">
>              </property>
>              <property name="displayWidth" class="ptolemy.data.expr.Parameter" value="60">
>              </property>
>          </property>
>          <property name="_location" class="ptolemy.kernel.util.Location" value="[305.0, 220.0]">
>          </property>
>          <port name="output" class="ptolemy.actor.TypedIOPort">
>              <property name="output"/>
>              <property name="_type" class="ptolemy.actor.TypeAttribute" value="string">
>              </property>
>          </port>
>          <port name="x" class="ptolemy.actor.TypedIOPort">
>              <property name="input"/>
>              <property name="_type" class="ptolemy.actor.TypeAttribute" value="{{x=double,y=double,z=double}}">
>              </property>
>              <property name="_showName" class="ptolemy.kernel.util.SingletonAttribute">
>              </property>
>          </port>
>      </entity>
>      <entity name="sample range" class="ptolemy.actor.lib.Expression">
>          <property name="expression" class="ptolemy.kernel.util.StringAttribute" value="[-6.0:0.5:6.0].toArray">
>          </property>
>          <property name="_icon" class="ptolemy.vergil.icon.BoxedValueIcon">
>              <property name="attributeName" class="ptolemy.kernel.util.StringAttribute" value="expression">
>              </property>
>              <property name="displayWidth" class="ptolemy.data.expr.Parameter" value="60">
>              </property>
>          </property>
>          <property name="_location" class="ptolemy.kernel.util.Location" value="[-150.0, 45.0]">
>          </property>
>      </entity>
>      <entity name="make cartesian tuples" class="ptolemy.actor.lib.Expression">
>          <property name="expression" class="ptolemy.kernel.util.StringAttribute" value="map( (function(y:double)((function(F:{(function(x:general)general)},x:general) map(function(f:(function(x:general)general)) f(x), F)) (map((function (x:double) (function (y:double) {x=x, y=y})), xs), y))), ys ) ">
>          </property>
>          <property name="_icon" class="ptolemy.vergil.icon.BoxedValueIcon">
>              <property name="attributeName" class="ptolemy.kernel.util.StringAttribute" value="expression">
>              </property>
>              <property name="displayWidth" class="ptolemy.data.expr.Parameter" value="60">
>              </property>
>          </property>
>          <property name="_location" class="ptolemy.kernel.util.Location" value="[-45.0, 275.0]">
>          </property>
>          <port name="xs" class="ptolemy.actor.TypedIOPort">
>              <property name="input"/>
>              <property name="_type" class="ptolemy.actor.TypeAttribute" value="{double}">
>              </property>
>              <property name="_showName" class="ptolemy.kernel.util.SingletonAttribute">
>              </property>
>          </port>
>          <port name="ys" class="ptolemy.actor.TypedIOPort">
>              <property name="input"/>
>              <property name="_type" class="ptolemy.actor.TypeAttribute" value="{double}">
>              </property>
>              <property name="_showName" class="ptolemy.kernel.util.SingletonAttribute">
>              </property>
>          </port>
>      </entity>
>      <entity name="ArrayToSequence" class="ptolemy.domains.sdf.lib.ArrayToSequence">
>          <property name="arrayLength" class="ptolemy.data.expr.Parameter" value="25">
>          </property>
>          <property name="_location" class="ptolemy.kernel.util.Location" value="[-240.0, 345.0]">
>          </property>
>      </entity>
>      <entity name="ArrayToSequence2" class="ptolemy.domains.sdf.lib.ArrayToSequence">
>          <property name="arrayLength" class="ptolemy.data.expr.Parameter" value="25">
>          </property>
>          <property name="_location" class="ptolemy.kernel.util.Location" value="[-110.0, 345.0]">
>          </property>
>      </entity>
>      <entity name="SequenceToArray" class="ptolemy.domains.sdf.lib.SequenceToArray">
>          <property name="arrayLength" class="ptolemy.actor.parameters.PortParameter" value="25*25">
>          </property>
>          <property name="_location" class="ptolemy.kernel.util.Location" value="[30.0, 355.0]">
>          </property>
>      </entity>
>      <entity name="the function" class="ptolemy.actor.lib.Expression">
>          <property name="expression" class="ptolemy.kernel.util.StringAttribute" value="function(pt:{x=double,y=double}) ( (pt.x*pt.y == 0 ? 1 : sin(pt.x*pt.y)/(pt.x*pt.y)))">
>          </property>
>          <property name="_icon" class="ptolemy.vergil.icon.BoxedValueIcon">
>              <property name="attributeName" class="ptolemy.kernel.util.StringAttribute" value="expression">
>              </property>
>              <property name="displayWidth" class="ptolemy.data.expr.Parameter" value="60">
>              </property>
>          </property>
>          <property name="_location" class="ptolemy.kernel.util.Location" value="[-35.0, -10.0]">
>          </property>
>          <port name="output" class="ptolemy.actor.TypedIOPort">
>              <property name="output"/>
>              <property name="_type" class="ptolemy.actor.TypeAttribute" value="(function(x:{x=double,y=double}) double)">
>              </property>
>          </port>
>      </entity>
>      <entity name="gnuplot" class="ptolemy.actor.lib.Exec">
>          <property name="command" class="ptolemy.actor.parameters.PortParameter" value="gnuplot">
>          </property>
>          <property name="_location" class="ptolemy.kernel.util.Location" value="{375, 350}">
>          </property>
>      </entity>
>      <relation name="relation6" class="ptolemy.actor.TypedIORelation">
>      </relation>
>      <relation name="relation4" class="ptolemy.actor.TypedIORelation">
>      </relation>
>      <relation name="relation9" class="ptolemy.actor.TypedIORelation">
>          <vertex name="vertex1" value="[20.0, 155.0]">
>          </vertex>
>      </relation>
>      <relation name="relation5" class="ptolemy.actor.TypedIORelation">
>      </relation>
>      <relation name="relation8" class="ptolemy.actor.TypedIORelation">
>      </relation>
>      <relation name="relation10" class="ptolemy.actor.TypedIORelation">
>      </relation>
>      <relation name="relation11" class="ptolemy.actor.TypedIORelation">
>      </relation>
>      <relation name="relation" class="ptolemy.actor.TypedIORelation">
>      </relation>
>      <relation name="relation2" class="ptolemy.actor.TypedIORelation">
>      </relation>
>      <link port="map.output" relation="relation4"/>
>      <link port="map.f" relation="relation6"/>
>      <link port="map.x" relation="relation11"/>
>      <link port="make tuplized evaluator.output" relation="relation6"/>
>      <link port="make tuplized evaluator.f" relation="relation"/>
>      <link port="tuples to gnuplot.output" relation="relation2"/>
>      <link port="tuples to gnuplot.x" relation="relation4"/>
>      <link port="sample range.output" relation="relation9"/>
>      <link port="make cartesian tuples.output" relation="relation5"/>
>      <link port="make cartesian tuples.xs" relation="relation9"/>
>      <link port="make cartesian tuples.ys" relation="relation9"/>
>      <link port="ArrayToSequence.input" relation="relation5"/>
>      <link port="ArrayToSequence.output" relation="relation8"/>
>      <link port="ArrayToSequence2.input" relation="relation8"/>
>      <link port="ArrayToSequence2.output" relation="relation10"/>
>      <link port="SequenceToArray.input" relation="relation10"/>
>      <link port="SequenceToArray.output" relation="relation11"/>
>      <link port="the function.output" relation="relation"/>
>      <link port="gnuplot.input" relation="relation2"/>
>  </entity>
>  
>  
>  
>_______________________________________________
>kepler-cvs mailing list
>kepler-cvs at ecoinformatics.org
>http://www.ecoinformatics.org/mailman/listinfo/kepler-cvs
>  
>




More information about the Kepler-dev mailing list