mailRe: Implement handles for nmrglue in relax


Others Months | Index by Date | Thread Index
>>   [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Header


Content

Posted by Edward d'Auvergne on December 02, 2014 - 20:20:
Hi Jonathan,

Thank you for your reply to our public mailing list.  It can take a
while to appear (http://news.gmane.org/gmane.science.nmr.relax.devel),
as the mailing list maintainer, Chris MacRaild, is in a very different
time zone 
(http://www.monash.edu.au/pharm/research/researchers/profile.html?sid=47804&pid=5391).
Those not signed up to the list need to wait for the maintainer to
accept the message.  Anyway, I'm sure Troels will expand on this
relax-nmrglue topic in the nmrglue forums.  For your points, please
see below:


    A few points regarding nmrglue in this discussion.  The main nmrglue
website is www.nmrglue.com, links to that site are best in any documentation
or credits.  The source code and issue tracker are on GitHub at
https://github.com/jjhelmus/nmrglue.

The relax mailing lists (relax-announce, relax-users, relax-devel, and
relax-commits, see http://www.nmr-relax.com/communication.html) are
archived locally, with Gmane (http://gmane.org/), The Mail Archive
(https://www.mail-archive.com/), and MARC (http://marc.info/).  So the
nmrglue links will be amplified.  This should really help nmrglue pop
up higher in search engine results.  Crosslinking can further improve
the rankings.  Anyway, Troels is giving you plenty of links, see the
recent changes by Troels at
http://news.gmane.org/gmane.science.nmr.relax.scm
(http://article.gmane.org/gmane.science.nmr.relax.scm/24567 for
example).


    The representation of NMR data is in NumPy multi-dimenstional ndarray
objects [1].  These can be serialized to strings using the .tostring() or
.tobytes() methods.  Spectral metadata is stored in a Python dictionary,
there are a number of options for serializing these.  Also both objects can
be pickled.

Troels, the relax data store XML representation can handle numpy
ndarrays as is.  In relax, try:

relax> from numpy import array
relax> pipe.create('numpy_test', 'mf')
relax> cdp.test = array([[1, 2, 3.], [4, 5, 6]])
relax> state.save('test')

The 'test.bz2' XML file can then be loaded via state.load without
problem and cdp.test will be the correct numpy array.  Note there is a
truncation artefact present, as the XML looks like:

[snip]
    <pipe desc="The contents of a relax data pipe" name="numpy_test" 
type="mf">
        <global desc="Global data located in the top level of the data pipe">
            <test type="dtype('float64')">
                <value>
                    array([[ 1.,  2.,  3.],
       [ 4.,  5.,  6.]])
                </value>
            </test>
        </global>
[snip]

Ideally I would modify the data store to_xml() methods use the numpy
tobytes() methods and then store proper byte arrays using Gary
Thompson's float.py module to store the byte arrays, such as we
currently do with floats:

relax> pipe.create('numpy_test', 'mf')
relax> cdp.test = 1.23456
relax> state.save('test', force=True)

Which gives:

            <test type="float">
                <value>
                    1.23456
                </value>
                <ieee_754_byte_array>
                    [56, 50, 143, 252, 193, 192, 243, 63]
                </ieee_754_byte_array>
            </test>

The <value> is just there for users to read.  On the other hand, the
loading of the state file reads the data from the
<ieee_754_byte_array> XML tag.  Tell me if you have any truncation
artefact problems when saving states with spectral nmrglue data, and
I'll look into this full precision float support.  Due to horrible
compatibility problems, non-truncating pickling (Python or numpy) is
not an option.


    Python 3 support is available in the development version of nmrglue,
0.5-dev, available on GitHub.  There is an issue with installing the package
in a Python 3 environment which I need to work out but then I plan or
releasing version 0.5 which will be the first release to support Python 3.
Expect it out and available on PyPI by the end of the week.

I've been watching this.  There are still a lot of type() calls that
need to be replaced by isinstance().  And the unfortunate set()
function which rightfully no longer exists.  The following command
picks up a lot of the problems:

$ 2to3 -j 4 -w -f buffer -f idioms -f set_literal -f ws_comma -x
except -x import -x imports -x long -x numliterals -x xrange .

If you need help, have a look at the relax compat.py module
(http://svn.gna.org/viewcvs/relax/trunk/lib/compat.py?view=log,
http://svn.gna.org/viewcvs/*checkout*/relax/trunk/lib/compat.py?content-type=text%2Fplain).
This uses a lot of tricks for handling both Python 2 and 3.  For any
Python packages that have been renamed, we simply alias them in
lib.compat and import from lib.compat rather than from the Python
standard site-packages.  If their are any major headaches, just say
and I could play with it in a git fork.  Oh, we have a special
migration document:
http://svn.gna.org/viewcvs/relax/trunk/docs/devel/2to3_checklist?view=log,
or http://svn.gna.org/viewcvs/*checkout*/relax/trunk/docs/devel/2to3_checklist
.  These commands are used on the entire code base, but the fatal
changes to lib.compat are always reverted.  Now there is almost no
relax code, apart from lib.compat, that the 2to3 script touches.


    I have an SVG file of the nmrglue logo from which the small jpg was
created.  I'll need to find where it is stored on my computer at home but
I'll send it along with a higher resolution png/jpg once I locate it.

Cheers!  It'll be good to use the logo within relax's GUI, and maybe
one day in the manual if someone writes a chapter on this.  Have you
thought of adding it to the nmrglue sources and hence the distribution
archives?  We do that for relax, with all original graphics in
http://svn.gna.org/viewcvs/relax/trunk/graphics/.  I have seen the
relax graphics used by third parties at conferences on posters.  You
might have the same luck with nmrglue users - simply making the
original SVG icon easily available to PhD students and postdocs will
probably result in it being on more posters.  It could be good for
free advertising ;)


    Best of luck on getting relax to play nicely with nmrglue.  If there is
anything I can do to help on the nmrglue side feel free to ask.

Cheers, I'm sure this won't be a problem in Troels' capable hands.

 nmrglue is
BSD licensed and I would like to keep it that way, if you send any code my
way I'd appreciate if it could be licensed under the same terms.

No problems.  For the SVG file, could you put your copyright notice at
the top?  For example just after the comment:

<!-- Created with Inkscape (http://www.inkscape.org/) -->

wrapped in the "<!--" and "-->" elements.  This will be better for
then including with the relax sources.

Cheers,

Edward



Related Messages


Powered by MHonArc, Updated Tue Dec 02 23:20:10 2014