Hello,
I have just put new releases on the CCPN website (http://www.ccpn.ac.uk).
For Analysis this is mainly bug fixes. But there is also a new "shift
difference" dialog (under the Data Analysis menu). And the installation
script has been added to, mainly to get the OSX Framework glut to work.
(So OpenGL now works on a local OSX machine, but not it seems, on a remote
OSX machine.)
There is also some new functionality to let you create a new spectrum and
assign data to it. This is experimental so might not quite work the way
people want, so modifications can be suggested. (Also, it has not been
tested extensively so there are probably interesting bugs to be found.)
The module to do this is python/ccpnmr/analysis/UserSpectrum.py. Because
it does graphics, as well as the data, you have to pass the "top" object
in, which is accessible from the Python prompt, and also from the
argumentServer (in macros) via "parent" (i.e. argumentServer.parent). The
way you might use this from the Python prompt:
>>> from ccpnmr.analysis.UserSpectrum import UserSpectrum
>>> u = UserSpectrum(top, experiment, name, numPoints, sw, refppm, refpt,
file)
where top is as described above (so is available from the Python prompt),
experiment is an NMR experiment (spectra, i.e. dataSources, have
experiments as the parent in the data model), name is the name for this
spectrum (this is just for the benefit of the user, it doesn't really mean
anything), and numPoints, sw, refppm, refpt are tuples or lists of
referencing information, and file is the file name for the data (absolute
path).
This constructor actually creates a data model object (a DataSource).
Be warned that the data file is created from scratch (and zeroed to start
with), so be careful not to delete an existing data file that you want
preserved.
You can then do something like:
>>> u.getValue(point) # gets value at point
>>> u.getValues(boxMin, boxMax) # get values inside a box
>>> u.setValue(point, value) # set value at a point
>>> u.setValues(boxMin, boxMax, values) # set values in a box
>>> levels = u.getContourLevels # get the contour levels
>>> u.setContourLevels(levels) # set contour levels
>>> u.save() # save the changes to disk
Above, point, boxMin, boxMax, values, levels can be tuples or lists.
Obviously point, boxMin, boxMax must have the right length (to match the
dimension of the spectrum). The box is defined by
boxMin <= x < boxMax
The values are a 1D (not ND) array, of size the total number of points in
the box. There are routines to help you get back and forth from the 1D to
the ND form in python/memops/universal/BlockData.py (so you would "import
memops.universal.BlockData" or some equivalent).
The way Analysis works the initial contour level is set to of order
1/global_contour_scale (relative to the global_contour_scale), which is
almost certainly wrong (it implies that the values in the spectrum are of
order 1), so that is why there is a setContourLevels function. The save()
can be done explicitly or (in theory) happens automatically when the
UserSpectrum object is garbage collected (that has not been tested yet).
All the blocks that are "touched" are kept in memory, so for now I would
try this for 2D data sets, for 3D data sets you will either need to keep
them small or have a lot of memory.
Wayne
|