-
Notifications
You must be signed in to change notification settings - Fork 48
Command line interface
The usual call of pyrat functions looks approx. like module.function(parameters)
. Each function return the name of its output layer(s). Some examples:
lay1 = load.fsar(”/playground/14CROPXP/FL02/PS03/T01”, band="L", polarisation="HH")
lay2 = filter.reflee(looks=2)
Further examples can be found here.
Apart from calling the various PyRAT functions, there are a bunch of basic commands:
active()
:
Returns the names of the currently active layers.
activate(layer, silent=False)
:
Activates one or several layers, eventually without output (silent=True)
adddata(array, block='D')
:
Generates a new pyrat layer from a numpy ndarray. block="D" for normal data (default), "T" for tracks.
defreeze(filename)
:
Restores are previously session saved with 'freeze'. Example: var1, var2, var3 = defreeze("session.hd5")
delete(layer, silent=False)
:
Deletes one or several layers.
expose([layer], [layer=layer])
:
Expose the layer content for direct manipulation. The returned object should behave as a numpy array (but are of type hdf5). Manipulations of it are instantanously written to the layer. Do not change size or dtype of data! Attention: multidimensional arrays appear flattened!
Example usage:
var = expose('/L15') # Comment: '/L15' is the name of a layer
print(var.shape)
(16, 250, 250) # the data are exposed with their 'raw' shape, flattened over the channels
freeze(filename, *args)
:
Freezes the entire pyrat session (the layer structure) for later usage. A list of local variables can be saved together with the layers. Example: freeze("session.hd5", var1, var2, var3) :param filename: File where to save all the data (might get very large!) :param args: List of local variables to be saved together with the layer
getdata()
Copies the content of a layer into a numpy array
getmeta()
:
Returns the meta data of a layer as dict.
gui() / show()
:
Launches the PyRat GUI.
help()
:
[The help system](Help system)
listlayer()
/ info()
:
Outputs a list of all existing layers together with their names and sizes.
pyrat_reset()
:
Deletes all layers and totally resets PyRAT
query()
:
Queries the content / data structure of a layer. Returns a AttrDict object.
setmeta(meta)
:
Adds metadata to a layer. :param meta: meta data as dict
setlayername(name)
:
Sets the name of a layer. This will be shown when using info()/listlayer().
show() / gui()
:
Launches the PyRat GUI.
updatelayer(array)
:
Updates the content of a pyrat layer with the content of a provided ndarray. Warning: Do not change dimensions or dtype! Optional layer name to use as target (default: active layer)
Additionally, some commands exist to tweak some internal settings of PyRAT:
_debug = True
Switches on debug mode: More debugging output, no internal exception handling, no multiprocessing. Generally recommended when programming own routines. Debug mode can also enabled during startup: call PyRAT with the --debug
flag, or in your script, use pyrat_init(debug=True)
instead of just pyrat_init()
_nthreads = N
Sets the number (N) of parallel processes. Using _nthreads=1
switches off multiprocessing. Can also be set during initialisation by pyrat_init(nthreads=N)
. Generally, it doesn't make much sense to use more threads than CPU kernels on your machine.
Worker.blockprocess=False
Switch off blockprocessing
Worker.blocksize=N
Changes default blocksize (default=128).