org.autoplot.jythonsupport.JythonOps

Contains operations that are only available to Jython code, and is dependent on the jython libraries.

JythonOps( )


addToSearchPath

addToSearchPath( PyList syspath, String path, ProgressMonitor mon ) → String

download the jar file resource, unpack it, and add it to the search path. Note such scripts will not work with Webstart releases! The code is only loaded once per session, so Autoplot must be restarted if the library is updated. Here is an example use:


import sys
addToSearchPath( sys.path, 'http://www-us.apache.org/dist//commons/math/binaries/commons-math3-3.6.1-bin.zip/commons-math3-3.6.1/commons-math3-3.6.1.jar', monitor )
from org.apache.commons.math3.distribution import BetaDistribution
beta= BetaDistribution(2,5)

xx= linspace(0,1.0,100)
yy= zeros(100)
for i in indgen(100):
    yy[i]= beta.density(xx[i].value())
#yy= map( xx, beta.density )
plot( xx, yy )

Parameters

syspath - the list of folders to search, should be sys.path.
path - the path to add, which should be a jar file, possibly contained within a zip on an http site.
mon - monitor for the download.

Returns:

the name of the folder or jar file added.

See Also:

https://sourceforge.net/p/autoplot/feature-requests/584/, which shows example use.
findJavaPathRoots(org.das2.util.filesystem.FileSystem)


[search for examples] [view on GitHub] [view on old javadoc] [view source]

addToSearchPath( PyList syspath, String path, String docPath, ProgressMonitor mon ) → String

applyLambda

applyLambda( QDataSet ds, PyFunction f ) → QDataSet

Apply the Python function, typically a lambda function, to each element of the dataset. For example:


 xx= dindgen( 6 ) 
 yy= applyLambda( xx, lambda x : x**2 )
 plot( xx, yy )

Parameters

ds - the dataset to which the function is applied
f - the function

Returns:

the dataset with the function applied

[search for examples] [view on GitHub] [view on old javadoc] [view source]

applyLambda( QDataSet ds1, QDataSet ds2, PyFunction f ) → QDataSet
applyLambda( QDataSet ds1, QDataSet ds2, QDataSet ds3, PyFunction f ) → QDataSet

coerceToDs

Deprecated: use dataset command.

color

color( PyObject val ) → java.awt.Color

get the color from the python object, for example:

Parameters

val - the value

Returns:

java.awt.Color

[search for examples] [view on GitHub] [view on old javadoc] [view source]


currentLine

currentLine( ) → String

return the current line in the Jython script as <filename>:<linenum> or ??? if this cannot be done. Note calls to this will collect a stack trace and will affect performance.

Returns:

the current line or ???

See Also:

QubeDataSetIterator#currentJythonLine()


[search for examples] [view on GitHub] [view on old javadoc] [view source]


dataset

dataset( PyObject arg0 ) → QDataSet

coerce a python array or list into a QDataSet.

Parameters

arg0 - Python object or Datum

Returns:

QDataSet

See Also:

org.das2.qds.ops.Ops#dataset(java.lang.Object)


[search for examples] [view on GitHub] [view on old javadoc] [view source]

dataset( PyObject arg0, Units u ) → QDataSet

datum

datum( PyObject arg0 ) → Datum

coerce python objects to Datum

Parameters

arg0 - Python object, one of rank 0 dataset, int, float, or String.

Returns:

Datum

See Also:

org.das2.qds.ops.Ops#datum(java.lang.Object)


[search for examples] [view on GitHub] [view on old javadoc] [view source]


datumRange

datumRange( PyObject arg0 ) → DatumRange

coerce python objects to DatumRange See http://jfaden.net:8080/hudson/job/autoplot-test029/ This supports:

Parameters

arg0 - PyQDataSet, String, array or List.

Returns:

DatumRange

[search for examples] [view on GitHub] [view on old javadoc] [view source]

datumRange( PyObject arg0, PyObject arg1 ) → DatumRange
datumRange( PyObject arg0, Units context ) → DatumRange

findJavaPathRoots

findJavaPathRoots( org.das2.util.filesystem.FileSystem destDir ) → java.util.List

search the folder for the names of packages. This could trivially return "org", but instead navigate to find a more precise name, or names like "org.autoplot" and "org.das2". Note this is a bit like a recursive find command, but note that some Java assumptions like classnames being capitalized and packages being lower case are encoded.

Parameters

destDir - root to start the search.

Returns:

list of packages.

See Also:

addToSearchPath(org.python.core.PyList, java.lang.String, org.das2.util.monitor.ProgressMonitor)


[search for examples] [view on GitHub] [view on old javadoc] [view source]


formUri

formUri( String vapScheme, String resourceUri, Object args ) → String

convenience method for creating URIs.

Parameters

vapScheme - null or the data source scheme, such as "vap+das2server" or "vap+cdaweb"
resourceUri - null or the resource uri, such as "http://www-pw.physics.uiowa.edu/das/das2Server"
args - null or a map/dictionary of arguments, including "arg_0" for a positional argument.

Returns:

the URI. If vapScheme is null, then the URI will be implicit.

[search for examples] [view on GitHub] [view on old javadoc] [view source]


invokeSometime

invokeSometime( PyObject func ) → void

run the function on a different thread

Parameters

func - a jython callable.

Returns:

void (returns nothing)

[search for examples] [view on GitHub] [view on old javadoc] [view source]

invokeSometime( PyObject func, PyObject arg ) → void

putProperty

putProperty( QDataSet ds, String name, Object value ) → org.das2.qds.MutablePropertyDataSet

converts types often seen in Jython codes to the correct type. For example, ds= putProperty( ds, 'UNITS', 'seconds since 2012-01-01'). Note USER_PROPERTIES can be a Python dictionary and it will be converted to a Java Map.

Parameters

ds - the dataset
name - the name of the property, such as UNITS or USER_PROPERTIES
value - the value of the property

Returns:

the dataset, possibly converted to a mutable dataset.

[search for examples] [view on GitHub] [view on old javadoc] [view source]