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
addToSearchPath( PyList syspath, String path, String docPath, 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.
docPath - the path containing javadocs, useful programmatically for completions.
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. which shows example use.
findJavaPathRoots(org.das2.util.filesystem.FileSystem)
[search for examples]
[view on GitHub]
[view on old javadoc]
[view source]
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
applyLambda( QDataSet ds1, QDataSet ds2, PyFunction f ) → QDataSet
Apply the Python function, typically a two-argument lambda function, to each
element of the dataset. For example:
xx= dindgen( 6 )
yy= ones( 6 )
yy= applyLambda( xx, yy, lambda x,y : x+y )
plot( xx, yy )
Parameters
ds1 - the dataset to which the function is applied
ds2 - 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
applyLambda( QDataSet ds1, QDataSet ds2, QDataSet ds3, PyFunction f ) → QDataSet
Apply the Python function, typically a three-argument lambda function, to each
element of the dataset. For example:
xx= dindgen( 6 )
yy= ones( 6 )
yy= applyLambda( xx, yy, lambda x,y : x+y )
plot( xx, yy )
Parameters
ds1 - the dataset to which the function is applied
ds2 - the dataset to which the function is applied
ds3 - 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]
coerceToDs
Deprecated: use dataset command.
color
color( PyObject val ) → java.awt.Color
get the color from the python object, for example:
- Color.RED
- 16711680 (int for red)
- 16711680. (float from QDataSet)
- (255,0,0)
- (1.0,0,0)
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
dataset( PyObject arg0, Units u ) → QDataSet
coerce Python objects like arrays Lists and Arrays into a QDataSet.
Parameters
arg0 - a PyQDataSet, PyList, PyArray, PyTuple, PyInteger, PyLong, PyFloat, Datum, DatumRange, or String.
u - unit context
Returns:
the dataset
See Also:
Ops#dataset(java.lang.Object, org.das2.datum.Units)
[search for examples]
[view on GitHub]
[view on old javadoc]
[view source]
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:
- 2-element rank 1 QDataSet
- Strings like ("5 to 15 s" or "2014-01-01")
- 2-element arrays and lists
Parameters
arg0 - PyQDataSet, String, array or List.
Returns:
DatumRange
[search for examples]
[view on GitHub]
[view on old javadoc]
[view source]
datumRange
datumRange( PyObject arg0, PyObject arg1 ) → DatumRange
coerce two python objects to DatumRange
Parameters
arg0 - Python object, one of rank 0 dataset, int, float, or String.
arg1 - Python object, one of rank 0 dataset, int, float, or String.
Returns:
DatumRange
[search for examples]
[view on GitHub]
[view on old javadoc]
[view source]
datumRange
datumRange( PyObject arg0, Units context ) → DatumRange
coerce python objects to DatumRange, when the units are known.
Parameters
arg0 - PyQDataSet, String, array or List.
context - the units.
Returns:
range with the same magnitude, but context units.
[search for examples]
[view on GitHub]
[view on old javadoc]
[view source]
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
invokeSometime( PyObject func, PyObject arg ) → void
run the function on a different thread
Parameters
func - a jython callable.
arg - an object to pass to the callable as an argument
Returns:
void (returns nothing)
[search for examples]
[view on GitHub]
[view on old javadoc]
[view source]
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]
validateParam
validateParam( String name, Object v, java.util.List constraint ) → Object
validate the parameter value against the constraint. This will
raise an exception when the constraint is not met, or returns a modified
value conforming (with format). See https://github.com/autoplot/dev/blob/master/demos/2025/20250108/getParamsValidation.jy
Parameters
name - a String
v - an Object
constraint - a java.util.List
Returns:
java.lang.Object
See Also:
validateParam(java.lang.String, java.lang.Object, java.util.Map)
[search for examples]
[view on GitHub]
[view on old javadoc]
[view source]
validateParam
validateParam( String name, Object v, java.util.Map constraint ) → Object
validate the parameter, possibly modifying it to match constraints. For example,
a double less than the minimum would throw an IllegalArgumentException. However a
time range is reformatted to match the format, and a double can be formatted to
limit resolution.
Constraints include:
- regex -- regular expression which must be matched.
- min -- minimum value allowed, and for timerange parameter this is interpretted as time range.
- max -- maximum value allowed, and for timerange parameter this is interpretted as time range.
- format -- if URI template with $Y etc, then reformat with this, if starts with % then reformat double.
- values -- list/array of allowed values
Parameters
name - the parameter name or null (None), where "timerange" is special.
v - the value
constraint - the constraint map.
Returns:
the parameter, possibly modified to match constraints.
See Also:
https://github.com/autoplot/dev/blob/master/demos/2025/20250108/getParamsValidation.jy
[search for examples]
[view on GitHub]
[view on old javadoc]
[view source]
validateParam
validateParam( String name, Object v, PyDictionary constraint ) → Object
validate the parameter value against the constraint. This will
raise an exception when the constraint is not met, or returns a modified
value conforming (with format).
Parameters
name - the parameter name or null (None), where "timerange" is special.
v - the value
constraint - the constraint map.
Returns:
the parameter, possibly modified to match constraints.
See Also:
https://github.com/autoplot/dev/blob/master/demos/2025/20250108/getParamsValidation.jy
validateParam(java.lang.String, java.lang.Object, java.util.Map)
[search for examples]
[view on GitHub]
[view on old javadoc]
[view source]