[kepler-dev] [kepler-cvs] kepler/workflows/test UnitConversion.xml
Shawn Bowers
sbowers at ucdavis.edu
Wed May 11 10:37:14 PDT 2005
Dan,
This is great. I think the "dynamic" unit system is older. And the
static unit type system was added to give more control at "design-time".
It sounds like the two systems don't really work together, except to
use the same unit definitions.
The becquerel/hertz example is a good one.
shawn
Dan Higgins wrote:
> Hi Shawn,
> Things are a little more complicated than I indicated. There are
> static and dynamic unit treatments, as indicated in the referenced
> sections of the documentation. The example uses the dynamic unit
> treatment which doesn't set units on the ports at all! [The static unit
> compatibility uses the port settings, as I understand it.] The
> interesting thing is that the unit conversion apparently uses an
> agebraic parser so that new combined units can be used. This is a
> capability you may need to add to your semantic engine.
>
> BTW, I think Rich's original example was the 'becquerel ' and the
> 'hertz'. Both have units of inverse time (1/seconds), but the becquerel
> is designed to measure radioactivity while the hertz is a unit of
> frequency. To my thinking this is an example of mixing semantics and
> units (like count/(1.6 m2)) where the area of the test (1.6 m2) has been
> mixed in with the unit.
>
> I didn't mean to imply that we shouldn't check unit compatibility; I
> just wanted to point out what Kepler does now.
>
> Dan
>
> ----
>
> Shawn Bowers wrote:
>
>> It's not clear from your log message Dan, but it sounds like you are
>> saying that when you run a workflow with connected ports having
>> different units, the unit system (sitting in the background)
>> automatically does the unit conversions.
>>
>> I wonder if this is the way we want to do it in Kepler from a UI
>> perspective, i.e., I think we probably want to (a) notify users when
>> units are incompatible prior to running the workflow (which can be
>> done now in Ptolemy but only by running the "constraint solver"), and
>> (b) offer to "resolve" the incompatibility via a set of choices (for
>> units, the choices are probably pretty limitted). In general, as Matt
>> and Rich have pointed out, there are cases where you can convert the
>> units, but semantically the conversion is incorrect.
>>
>>
>> shawn
>>
>>
>>
>>
>> Daniel Higgins wrote:
>>
>>> higgins 05/05/11 09:53:30
>>>
>>> Added: workflows/test UnitConversion.xml
>>> Log:
>>> An example of how unit conversions can be automatically carried out
>>> by Kepler/PTII.
>>> Revision Changes Path
>>> 1.1 kepler/workflows/test/UnitConversion.xml
>>> Index: UnitConversion.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="UnitConversion"
>>> class="ptolemy.actor.TypedCompositeActor">
>>> <property name="_createdBy"
>>> class="ptolemy.kernel.attributes.VersionAttribute" value="5.0-beta">
>>> </property>
>>> <property name="SDF Director"
>>> class="ptolemy.domains.sdf.kernel.SDFDirector">
>>> <property name="iterations"
>>> class="ptolemy.data.expr.Parameter" value="1">
>>> </property>
>>> <property name="entityId"
>>> class="org.ecoinformatics.seek.util.NamedObjId"
>>> value="urn:lsid:ecoinformatics.org:kepler.300.1">
>>> </property>
>>> <property name="_location"
>>> class="ptolemy.kernel.util.Location" value="[265.0, 115.0]">
>>> </property>
>>> </property>
>>> <property name="BasicUnits" class="ptolemy.data.unit.UnitSystem">
>>> <property name="entityId"
>>> class="org.ecoinformatics.seek.util.NamedObjId"
>>> value="urn:lsid:ecoinformatics.org:kepler.234.1">
>>> </property>
>>> <property name="meters" class="ptolemy.data.unit.BaseUnit"
>>> value="1.0">
>>> <property name="Length"
>>> class="ptolemy.data.unit.UnitCategory">
>>> </property>
>>> </property>
>>> <property name="meter" class="ptolemy.data.expr.Parameter"
>>> value="meters">
>>> </property>
>>> <property name="m" class="ptolemy.data.expr.Parameter"
>>> value="meters">
>>> </property>
>>> <property name="cm" class="ptolemy.data.expr.Parameter"
>>> value="0.01*meters">
>>> </property>
>>> <property name="centimeters"
>>> class="ptolemy.data.expr.Parameter" value="cm">
>>> </property>
>>> <property name="centimeter"
>>> class="ptolemy.data.expr.Parameter" value="cm">
>>> </property>
>>> <property name="mm" class="ptolemy.data.expr.Parameter"
>>> value="0.001*meters">
>>> </property>
>>> <property name="millimeter"
>>> class="ptolemy.data.expr.Parameter" value="mm">
>>> </property>
>>> <property name="millimeters"
>>> class="ptolemy.data.expr.Parameter" value="mm">
>>> </property>
>>> <property name="in" class="ptolemy.data.expr.Parameter"
>>> value="2.54*cm">
>>> </property>
>>> <property name="inch" class="ptolemy.data.expr.Parameter"
>>> value="in">
>>> </property>
>>> <property name="inches" class="ptolemy.data.expr.Parameter"
>>> value="in">
>>> </property>
>>> <property name="seconds" class="ptolemy.data.unit.BaseUnit"
>>> value="1.0">
>>> <property name="Time"
>>> class="ptolemy.data.unit.UnitCategory">
>>> </property>
>>> </property>
>>> <property name="sec" class="ptolemy.data.expr.Parameter"
>>> value="seconds">
>>> </property>
>>> <property name="second" class="ptolemy.data.expr.Parameter"
>>> value="seconds">
>>> </property>
>>> <property name="ms" class="ptolemy.data.expr.Parameter"
>>> value="0.001*seconds">
>>> </property>
>>> <property name="millisecond"
>>> class="ptolemy.data.expr.Parameter" value="ms">
>>> </property>
>>> <property name="milliseconds"
>>> class="ptolemy.data.expr.Parameter" value="ms">
>>> </property>
>>> <property name="_iconDescription"
>>> class="ptolemy.kernel.util.SingletonConfigurableAttribute">
>>> <configure>
>>> <svg>
>>> <rect x="-30" y="-15" width="60" height="30"
>>> style="fill:grey"></rect>
>>> </svg>
>>> </configure>
>>> </property>
>>> <property name="_location"
>>> class="ptolemy.kernel.util.Location" value="[275.0, 175.0]">
>>> </property>
>>> </property>
>>> <property name="Annotation"
>>> class="ptolemy.vergil.kernel.attributes.TextAttribute">
>>> <property name="text"
>>> class="ptolemy.kernel.util.StringAttribute" value="This is an example
>>> of unit conversion in Kepler, as supplied by PtolemyII. First,
>>> add a Unit System ('Basics Units' in this example). Then you can
>>> use expressions of units as indicated in this example and unit
>>> conversion will be automatically carried out. Note that the
>>> results of adding these 4 velocities is "12.0254 * meters /
>>> seconds" Dan Higgins - May 11, 2005">
>>> </property>
>>> <property name="entityId"
>>> class="org.ecoinformatics.seek.util.NamedObjId"
>>> value="urn:lsid:ecoinformatics.org:kepler.233.1">
>>> </property>
>>> <property name="_location"
>>> class="ptolemy.kernel.util.Location" value="{65, 430}">
>>> </property>
>>> </property>
>>> <property name="_windowProperties"
>>> class="ptolemy.actor.gui.WindowPropertiesAttribute"
>>> value="{bounds={222, 118, 836, 787}, maximized=false}">
>>> </property>
>>> <property name="_vergilSize"
>>> class="ptolemy.actor.gui.SizeAttribute" value="[600, 660]">
>>> </property>
>>> <property name="_vergilZoomFactor"
>>> class="ptolemy.data.expr.ExpertParameter" value="1.0">
>>> </property>
>>> <property name="_vergilCenter"
>>> class="ptolemy.data.expr.ExpertParameter" value="{300.0, 330.0}">
>>> </property>
>>> <entity name="Display" class="ptolemy.actor.lib.gui.Display">
>>> <property name="_windowProperties"
>>> class="ptolemy.actor.gui.WindowPropertiesAttribute"
>>> value="{bounds={953, 800, 292, 224}, maximized=false}">
>>> </property>
>>> <property name="entityId"
>>> class="org.ecoinformatics.seek.util.NamedObjId"
>>> value="urn:lsid:ecoinformatics.org:kepler.7.1">
>>> </property>
>>> <property name="_location"
>>> class="ptolemy.kernel.util.Location" value="{420, 270}">
>>> </property>
>>> </entity>
>>> <entity name="Constant" class="ptolemy.actor.lib.Const">
>>> <property name="value" class="ptolemy.data.expr.Parameter"
>>> value="1*m/sec">
>>> </property>
>>> <property name="entityId"
>>> class="org.ecoinformatics.seek.util.NamedObjId"
>>> value="urn:lsid:ecoinformatics.org:kepler.1.1">
>>> </property>
>>> <property name="_icon"
>>> class="ptolemy.vergil.icon.BoxedValueIcon">
>>> <property name="attributeName"
>>> class="ptolemy.kernel.util.StringAttribute" value="value">
>>> </property>
>>> <property name="displayWidth"
>>> class="ptolemy.data.expr.Parameter" value="40">
>>> </property>
>>> </property>
>>> <property name="_location"
>>> class="ptolemy.kernel.util.Location" value="{90, 235}">
>>> </property>
>>> </entity>
>>> <entity name="Constant2" class="ptolemy.actor.lib.Const">
>>> <property name="value" class="ptolemy.data.expr.Parameter"
>>> value="1*cm/ms">
>>> </property>
>>> <property name="entityId"
>>> class="org.ecoinformatics.seek.util.NamedObjId"
>>> value="urn:lsid:ecoinformatics.org:kepler.1.1">
>>> </property>
>>> <property name="_icon"
>>> class="ptolemy.vergil.icon.BoxedValueIcon">
>>> <property name="attributeName"
>>> class="ptolemy.kernel.util.StringAttribute" value="value">
>>> </property>
>>> <property name="displayWidth"
>>> class="ptolemy.data.expr.Parameter" value="40">
>>> </property>
>>> </property>
>>> <property name="_location"
>>> class="ptolemy.kernel.util.Location" value="{90, 280}">
>>> </property>
>>> </entity>
>>> <entity name="Constant3" class="ptolemy.actor.lib.Const">
>>> <property name="value" class="ptolemy.data.expr.Parameter"
>>> value="1000*mm/sec">
>>> </property>
>>> <property name="entityId"
>>> class="org.ecoinformatics.seek.util.NamedObjId"
>>> value="urn:lsid:ecoinformatics.org:kepler.1.1">
>>> </property>
>>> <property name="_icon"
>>> class="ptolemy.vergil.icon.BoxedValueIcon">
>>> <property name="attributeName"
>>> class="ptolemy.kernel.util.StringAttribute" value="value">
>>> </property>
>>> <property name="displayWidth"
>>> class="ptolemy.data.expr.Parameter" value="40">
>>> </property>
>>> </property>
>>> <property name="_location"
>>> class="ptolemy.kernel.util.Location" value="{90, 325}">
>>> </property>
>>> </entity>
>>> <entity name="Constant4" class="ptolemy.actor.lib.Const">
>>> <property name="value" class="ptolemy.data.expr.Parameter"
>>> value="1*inches/sec">
>>> </property>
>>> <property name="entityId"
>>> class="org.ecoinformatics.seek.util.NamedObjId"
>>> value="urn:lsid:ecoinformatics.org:kepler.1.1">
>>> </property>
>>> <property name="_icon"
>>> class="ptolemy.vergil.icon.BoxedValueIcon">
>>> <property name="attributeName"
>>> class="ptolemy.kernel.util.StringAttribute" value="value">
>>> </property>
>>> <property name="displayWidth"
>>> class="ptolemy.data.expr.Parameter" value="40">
>>> </property>
>>> </property>
>>> <property name="_location"
>>> class="ptolemy.kernel.util.Location" value="{90, 375}">
>>> </property>
>>> </entity>
>>> <entity name="Add or Subtract"
>>> class="ptolemy.actor.lib.AddSubtract">
>>> <property name="entityId"
>>> class="org.ecoinformatics.seek.util.NamedObjId"
>>> value="urn:lsid:ecoinformatics.org:kepler.69.1">
>>> </property>
>>> <property name="_location"
>>> class="ptolemy.kernel.util.Location" value="[245.0, 290.0]">
>>> </property>
>>> </entity>
>>> <relation name="relation" class="ptolemy.actor.TypedIORelation">
>>> </relation>
>>> <relation name="relation2" class="ptolemy.actor.TypedIORelation">
>>> </relation>
>>> <relation name="relation3" class="ptolemy.actor.TypedIORelation">
>>> </relation>
>>> <relation name="relation4" class="ptolemy.actor.TypedIORelation">
>>> </relation>
>>> <relation name="relation5" class="ptolemy.actor.TypedIORelation">
>>> </relation>
>>> <link port="Display.input" relation="relation5"/>
>>> <link port="Constant.output" relation="relation2"/>
>>> <link port="Constant2.output" relation="relation3"/>
>>> <link port="Constant3.output" relation="relation4"/>
>>> <link port="Constant4.output" relation="relation"/>
>>> <link port="Add or Subtract.plus" relation="relation"/>
>>> <link port="Add or Subtract.plus" relation="relation2"/>
>>> <link port="Add or Subtract.plus" relation="relation3"/>
>>> <link port="Add or Subtract.plus" relation="relation4"/>
>>> <link port="Add or Subtract.output" relation="relation5"/>
>>> </entity>
>>> _______________________________________________
>>> Kepler-cvs mailing list
>>> Kepler-cvs at ecoinformatics.org
>>> http://mercury.nceas.ucsb.edu/ecoinformatics/mailman/listinfo/kepler-cvs
>>
>>
>
>
More information about the Kepler-dev
mailing list