Changeset 313


Ignore:
Timestamp:
Mar 29, 2013 1:00:46 AM (6 years ago)
Author:
prjemian
Message:
  • refs #23
  • applied license text
  • cleaned up the Python binding documentation
  • added list of authors and contributors
  • for each binding, show how to get I(Q)
  • retrieve CanSas1dType.java from repository (example in the Java binding documentation calls for it)
Location:
1dwg/trunk
Files:
4 added
42 edited
2 moved

Legend:

Unmodified
Added
Removed
  • 1dwg/trunk/CHANGES.txt

    r300 r313  
    77=============== 
    88 
    9 :v1.1: 
    10         2012-08-16, tagged version canSAS1d/1.1 
     9v1.1 
     10================ 
     11 
     122013-03-28: 
     13 
     14  moved v1.1 branch back to trunk (replacement) 
     15 
     16* TRAC #13: using the Argonne Open Source License 
     17 
     182013-03-27: 
     19 
     20  finishing up the bindings before moving back to trunk 
     21 
     22* removed java/maven-eclipse directory as indicated by java/README.txt file 
     23* TRAC #25: PHP code updated to generate v1.1 data files 
     24* TRAC #26: Python binding complete, reads both v1.0 and v1.1 
     25* TRAC #28: IgorPro binding needs updating, should read both v1.0 and v1.1 
     26* TRAC #29: FORTRAN binding needs to be updated (or withdrawn) 
     27* TRAC #30: Can't easily allow arbitrary order of data columns in Idata group 
     28* TRAC #31: began work on Java binding 
     29 
     302013-03-15: 
     31 
     32  identified that v1.1 is a branch, not yet ready for release 
     33 
     34* cleanup XSLT and reduce to just one XSLT 
     35* clean up the examples, remove unnecessary material 
     36* remove the mediawiki directory, we are done with it now 
     37 
     382012-10-31: 
     39 
     40* TRAC #17: wontfix: clean up rules 
     41* TRAC #18: added timestamp attribute to SASdata and SAStransmission_spectrum 
     42* TRAC #20: slight change in format of namespace string and URL 
     43* TRAC #21: added {any} element at end of SASdata and SAStransmission_spectrum 
     44* TRAC #22: added SAStransmission_spectrum 
     45* TRAC #27: rebrand from smallangles.net to cansas.org 
     46 
     47* slight changes in documentation of units (Angstrom and Celsius) 
     48* restriction against using UNICODE is lifted 
     49* removed the Glossary 
    1150         
    12         2012-10-31, still some more changes, need to retag 
    13          
    14         * TRAC #17: wontfix: clean up rules 
    15         * TRAC #18: added timestamp attribute to SASdata and SAStransmission_spectrum 
    16         * TRAC #20: slight change in format of namespace string and URL 
    17         * TRAC #21: added {any} element at end of SASdata and SAStransmission_spectrum 
    18         * TRAC #22: added SAStransmission_spectrum 
    19         * TRAC #27: rebrand from smallangles.net to cansas.org 
    20          
    21         * slight changes in documentation of units (Angstrom and Celsius) 
    22         * restriction against using UNICODE is lifted 
    23         * removed the Glossary 
    24          
    25         2013-03-15, identified that v1.1 is a branch, not yet ready for release 
    26          
    27         * cleanup XSLT and reduce to just one XSLT 
    28         * clean up the examples, remove unnecessary material 
    29         * remove the mediawiki directory, we are done with it now 
    30          
    31         2013-03-27, finishing up the bindings before moving back to trunk 
     51v1.0 
     52================ 
    3253 
    33     * removed java/maven-eclipse directory as indicated by java/README.txt file 
    34     * TRAC #13: Need to pick a license model  <<<<<<<<<<<<< MUST DO THIS ! 
    35     * TRAC #25: PHP code updated to generate v1.1 data files 
    36     * TRAC #26: Python binding complete, reads both v1.0 and v1.1 
    37     * TRAC #28: IgorPro binding needs updating, should read both v1.0 and v1.1 
    38     * TRAC #29: FORTRAN binding needs to be updated (or withdrawn) 
    39     * TRAC #30: Won't allow arbitrary order of data columns in Idata group 
    40     * TRAC #31: began work on Java binding 
    41  
    42 :v1.0: 
    4354        2009-05-12, tagged version canSAS1d/1.0 
  • 1dwg/trunk/IgorPro/cansasXML.ipf

    r310 r313  
    1717// provides:  CS_XmlReader(String fileName) 
    1818//                              all other functions in this file should not be relied upon 
     19// 
     20// Copyright (c) 2013, UChicago Argonne, LLC 
     21// This file is distributed subject to a Software License Agreement found 
     22// in the file LICENSE that is included with this distribution.  
     23 
    1924 
    2025//  ================  ================  =================  ========== 
  • 1dwg/trunk/cansas1d.xsd

    r271 r313  
    77        elementFormDefault="qualified"> 
    88 
     9<!--  
     10Copyright (c) 2013, UChicago Argonne, LLC 
     11This file is distributed subject to a Software License Agreement found 
     12in the file LICENSE that is included with this distribution.  
     13 --> 
     14  
    915<!-- JAXB: http://java.sun.com/developer/technicalArticles/WebServices/jaxb/ --> 
    1016 
  • 1dwg/trunk/doc/source/binding-fortran.rst

    r271 r313  
    3737 
    3838 
    39 canSAS 1-D SAS XML v1.0 support 
    40 ====================================== 
     39canSAS 1-D SAS XML v1.0 and v1.1 support 
     40========================================== 
    4141 
    42 .. sidebar:: Needs update to v1.1 
    43  
    44         This update is expected to follow soon on the release of v1.1 
    45  
    46 Steve King[mailto:stephen.king@stfc.ac.uk] (ISIS) has provided a F77 routine  
    47 that will read cansas1d/1.0 XML files. 
     42Steve King `<stephen.king@stfc.ac.uk>` (ISIS) has provided a F77 routine  
     43that will read cansas1d v1.0 and v1.1 XML files. 
    4844 
    4945http://www.cansas.org/trac/browser/1dwg/trunk/fortran/SASXML_G77.F  
  • 1dwg/trunk/doc/source/binding-java-jaxb.rst

    r284 r313  
    88Java JAXB 
    99================ 
     10 
     11.. note:: FIX THIS into a how-to use the JAR file to read canSAS data files 
    1012 
    1113A Java binding for the cansas1d:1.1 standard has been auto-created using the JAXB tools 
     
    123125         
    124126        Qsas[i] = sdt.getIdata().get(i).getQ().getValue(); 
     127        Isas[i] = sdt.getIdata().get(i).getI().getValue(); 
    125128 
    126129to see the operations that unwind the data into usable *double[]* 
  • 1dwg/trunk/doc/source/binding-php.rst

    r284 r313  
    77================ 
    88 
    9 .. sidebar:: Not much is written here.   
     9.. 
     10        .. sidebar:: Not much is written here.   
     11         
     12                Needs work. 
    1013 
    11         Needs work. 
     14 
    1215 
    1316A demonstration of writing the cansas1d:1.1 XML data format can be 
  • 1dwg/trunk/doc/source/binding-python.rst

    r289 r313  
    66 
    77================ 
    8 Python 
     8Python  
    99================ 
    1010 
    11 Specific support for the cansas1d:1.1 data standard in Python (http://danse.us/trac/sans) 
    12 is being developed by NIST/NCNR (http://www.ncnr.nist.gov) 
    13 as part of their contribution to the  
    14 DANSE project (http://wiki.cacr.caltech.edu/danse). 
     11The Python binding to read canSAS 1-D data files 
     12has been implemented using the :ref:`gnosis`. 
     13It is very easy to use, once you have the `gnosis utils` installed. 
     14XML files are read by the :meth:`readCanSasFile` routine 
     15from the `cansas1d` support file.  
    1516 
    16 Here are some extremely terse instructions (circa 2008) to get you started on a UNIX or Linux system: 
     17=======  ==================== 
     18version  namespace 
     19=======  ==================== 
     201.0      `cansas1d/1.0` 
     211.1      `urn:cansas1d:1.1` 
     22=======  ==================== 
    1723 
    18 .. code-block:: guess 
    19         :linenos: 
    20          
    21         svn co http://danse.us/trac/sans/browser/trunk/DataLoader DataLoader 
    22         cd DataLoader 
    23         python setup.py install 
     24If either namespace or version don't match, an exception is raised. 
    2425 
    25 The release notes (http://danse.us/trac/sans/browser/trunk/DataLoader/release_notes.txt) 
    26 have a list of the dependencies. 
     26If the version and namespace match this table, the data from the file is mapped 
     27into Python objects, as shown by the examples below.  Otherwise, an 
     28appropriate exception is raised. 
    2729 
    2830 
    29 .. rubric:: Comments 
     31Interactive example using `cansas1d` 
     32============================================= 
    3033 
    31 Other constructive suggestions (that predate the NIST/NCNR support) have been gathered on this page. 
    32   
    33   
    34 *gnosis.xml.objectify* 
    35 ========================= 
    36   
    37 The *GnosisUtils* (http://freecode.com/projects/gnosisxml/) 
    38 offer a method to read any XML file into Python data structures. This utility  
    39 does not validate the XML against a specific XML Schema which can be both good  
    40 (flexible, especially when XML Foreign Namespace elements are used) and not  
    41 so good (XML content not guaranteed to be valid *by the rules*). 
     34Here is an interactive example showing how to read a canSAS 1D  
     35data file using the canSAS 1D Python binding: 
    4236 
    43 A quick test of this turned up an acceptable result in that it was able to read  
    44 several of the canSAS test XML files, including those with foreign namespaces.   
    45 And **it was very easy**.  
    46 (Especially with some help from http://www.xml.com/pub/a/2003/07/02/py-xml.html) 
    47  
    48 Here is a quick example. 
    49  
    50 Installation 
    51 ------------ 
    52  
    53 Here is the condensed *GnosisUtils* installation (without all that output) steps.  
    54 Your system may have *gnosis* already installed.  
    55 You may also need sysAdmin privileges.  
    56 You may need ... 
    57  
    58         .. code-block:: guess 
    59                 :linenos: 
    60                  
    61                 cd /tmp 
    62                 wget http://freshmeat.net/redir/gnosisxml/22028/url_tgz/Gnosis_Utils-1.2.2.tar.gz 
    63                 tar xzf Gnosis_Utils-1.2.2.tar.gz  
    64                 cd Gnosis_Utils-1.2.2/ 
    65                 python setup.py install_all 
    66  
    67 Alternatively, it *is* much simpler to install (or update) from the PyPI 
    68 repository (http://pypi.python.org/pypi/Gnosis%20Utilities): 
    69  
    70         .. code-block:: guess 
    71                 :linenos: 
    72                  
    73                 easy_install -U gnosis 
    74  
    75 .. index:: Python file; python-test.py 
    76  
    77 Quick test in Python 
    78 ------------------------ 
    79  
    80 .. sidebar:: Conclusion: OK 
    81  
    82         The *GnosisUtils* have the promise of being a useful tool to support  
    83         reading this format in Python.  Now, how to write back out... ? 
    84         From the website, it appears the development of GnosisUtils  
    85         has stagnated in 2007 at v1.2.2. 
    86  
    87 Here is the Python code (without all that output) (called *python-test.py*): 
    88  
    89         .. rubric:: *python-test.py* 
    90          
    91         .. code-block:: python 
    92                 :linenos: 
    93                  
    94                 import gnosis.xml.objectify 
    95                  
    96                 sasxml = gnosis.xml.objectify.XML_Objectify('bimodal-test1.xml').make_instance()   
    97                 print sasxml.SASentry.Title.PCDATA 
    98                 print sasxml.SASentry.Run.PCDATA 
    99                 print sasxml.SASentry.SASinstrument.name.PCDATA 
    100                 data0 = sasxml.SASentry.SASdata.Idata[0] 
    101                 print data0.Q.unit,  data0.I.unit 
    102                 print data0.Q.PCDATA,  data0.I.PCDATA,  data0.Idev.PCDATA 
    103  
    104         .. rubric:: Output from *python-test.py* 
    105                  
    106         .. code-block:: guess 
    107                 :linenos: 
    108                  
    109                 [Pete@ubuntu,2441,cansas1dwg]$ ./python-test.py  
    110                 SAS bimodal test1 
    111                 1992 
    112                 simulated SAS calculation 
    113                 1/A 1/cm 
    114                 0.0040157139 3497.473 90.72816 
    115  
    116         .. rubric:: Full session output 
    117                  
    118         .. code-block:: guess 
    119                 :linenos: 
    120                  
    121                 [Pete@ubuntu,2429,/tmp]$ cd /tmp 
    122                 /tmp 
    123                 [Pete@ubuntu,2430,/tmp]$ wget http://freshmeat.net/redir/gnosisxml/22028/url_tgz/Gnosis_Utils-1.2.2.tar.gz 
    124                 --11:43:16--  http://freshmeat.net/redir/gnosisxml/22028/url_tgz/Gnosis_Utils-1.2.2.tar.gz 
    125                            => `Gnosis_Utils-1.2.2.tar.gz' 
    126                 Resolving freshmeat.net... 66.35.250.168 
    127                 Connecting to freshmeat.net|66.35.250.168|:80... connected. 
    128                 HTTP request sent, awaiting response... 302 Found 
    129                 Location: http://www.gnosis.cx/download/Gnosis_Utils.More/Gnosis_Utils-1.2.2.tar.gz [following] 
    130                 --11:43:16--  http://www.gnosis.cx/download/Gnosis_Utils.More/Gnosis_Utils-1.2.2.tar.gz 
    131                            => `Gnosis_Utils-1.2.2.tar.gz' 
    132                 Resolving www.gnosis.cx... 64.41.64.172 
    133                 Connecting to www.gnosis.cx|64.41.64.172|:80... connected. 
    134                 HTTP request sent, awaiting response... 200 OK 
    135                 Length: 287,989 (281K) [application/x-tar] 
    136                  
    137                 100%[==============================================================================>] 287,989       --.--K/s              
    138                  
    139                 11:43:16 (2.47 MB/s) - `Gnosis_Utils-1.2.2.tar.gz' saved [287989/287989] 
    140                  
    141                 [Pete@ubuntu,2431,/tmp]$ tar xzf Gnosis_Utils-1.2.2.tar.gz  
    142                 [Pete@ubuntu,2432,/tmp]$ cd Gnosis_Utils-1.2.2/ 
    143                 /tmp/Gnosis_Utils-1.2.2 
    144                 [Pete@ubuntu,2433,Gnosis_Utils-1.2.2]$ python setup.py install_all 
    145                 [Pete@ubuntu,2434,Gnosis_Utils-1.2.2]$ cd ~/workspace/cansas1dwg-regitte 
    146                 [Pete@ubuntu,2435,cansas1dwg-regitte]$ python 
    147                 Python 2.5.1 (r251:54863, May 18 2007, 16:56:43)  
    148                 [GCC 3.4.4 (cygming special, gdc 0.12, using dmd 0.125)] on cygwin 
    149                 Type "help", "copyright", "credits" or "license" for more information. 
    150                 >>> import gnosis.xml.objectify 
    151                 >>> sasxml = gnosis.xml.objectify.XML_Objectify('bimodal-test1.xml').make_instance()   
    152                 >>> print sasxml.SASentry.Title.PCDATA 
    153                 SAS bimodal test1 
    154                 >>> print sasxml.SASentry.Run.PCDATA 
    155                 1992 
    156                 >>> print sasxml.SASentry.SASinstrument.name.PCDATA 
    157                 simulated SAS calculation 
    158                 >>> data0 = sasxml.SASentry.SASdata.Idata[0] 
    159                 >>> print data0.Q.unit 
    160                 1/A 
    161                 >>> print data0.I.unit 
    162                 1/cm 
    163                 >>> print data0.Q.PCDATA,  data0.I.PCDATA,  data0.Idev.PCDATA 
    164                 0.0040157139 3497.473 90.72816 
     37>>> from cansas1d import readCanSasFile 
     38>>> sasxml = readCanSasFile('bimodal-test1.xml') 
     39>>> print sasxml.SASentry.Title 
     40<Title id="34b0470" > 
     41>>> print sasxml.SASentry.Title.PCDATA 
     42SAS bimodal test1 
     43>>> print len(sasxml.SASentry.SASdata.Idata) 
     4491 
     45>>> print sasxml.SASentry.SASsample.ID.PCDATA 
     46bimodal-test1 
     47>>> source = sasxml.SASentry.SASinstrument.SASsource 
     48>>> print source.radiation.PCDATA, source.wavelength.PCDATA, source.wavelength.unit 
     49artificial 1.00 A 
    16550 
    16651 
    167              
    168 *generateDS.py* 
    169 =============== 
     52Interactive Example using `gnosis.xml.objectify` 
     53================================================ 
    17054 
    171 .. sidebar:: Conclusion: not ready yet (2008-05-16) 
     55Here is an interactive example showing how to read a canSAS 1D  
     56data file using `gnosis.xml.objectify`: 
    17257 
    173         Either the canSAS standard (by means of the cansas1d.xsd XML Schema)  
    174         is not ready or *generateDS.py* does not cover the  
    175         XML Schema requirements we have at this time. Either way,  
    176         this is not a viable tool to use now. 
    177  
    178 *generateDS.py*  
    179 (http://www.rexx.com/~dkuhlman/, http://www.rexx.com/~dkuhlman/generateDS.html)  
    180 can build a binding (map the structure of the XML file directly into a  
    181 Python data structure) for Python from an XML Schema. 
    182 However, the cansas1d:1.1 XML schema (cansas1d.xsd) does not seem to  
    183 fit the model.It seems, for now, that *generateDS-1.12a*  
    184 fails on a certain *annotate* line. 
    185  
    186 .. code-block:: guess 
    187         :linenos: 
    188          
    189         [Pete@ubuntu,2402,cansas1dwg]$ python  \ 
    190                         ~/generateDS-1.12a/generateDS.py  \ 
    191                         -p CS1D_  \ 
    192                         -o cansas1d.py  \ 
    193                         -s cansas1dsubs.py  \ 
    194                         cansas1d.xsd 
    195         Traceback (most recent call last): 
    196           File "/home/Pete/generateDS-1.12a/generateDS.py", line 3997, in &lt;module> 
    197             main() 
    198           File "/home/Pete/generateDS-1.12a/generateDS.py", line 3993, in main 
    199             processIncludes, superModule=superModule) 
    200           File "/home/Pete/generateDS-1.12a/generateDS.py", line 3909, in parseAndGenerate 
    201             root.annotate() 
    202         AttributeError: 'NoneType' object has no attribute 'annotate' 
     58>>> from gnosis.xml.objectify import XML_Objectify 
     59>>> sasxml = XML_Objectify('bimodal-test1.xml').make_instance() 
     60>>> print sasxml.SASentry.Title.PCDATA 
     61SAS bimodal test1 
     62>>> sasxml.SASentry.Run.PCDATA 
     631992 
     64>>> sasxml.SASentry.SASinstrument.name.PCDATA 
     65simulated SAS calculation 
     66>>> data0 = sasxml.SASentry.SASdata.Idata[0] 
     67>>> print data0.Q.unit,  data0.I.unit 
     681/A 1/cm 
     69>>> print data0.Q.PCDATA,  data0.I.PCDATA,  data0.Idev.PCDATA 
     700.0040157139 3497.473 90.72816 
    20371 
    20472 
    205 Other possibilities 
    206 ===================== 
     73example: how to retrieve :math:`I(Q)` 
     74================================================ 
    20775 
    208 * http://www.devx.com/ibm/Article/20261 
    209 * http://mail.python.org/pipermail/xml-sig/2002-April/007559.html 
    210 * http://pywebsvcs.sourceforge.net/ 
     76briefly (ignoring any exception handling): 
     77 
     78>>> from cansas1d import readCanSasFile 
     79>>> sasxml = readCanSasFile('bimodal-test1.xml') 
     80>>> Q = [float(i.Q.PCDATA) for i in sasxml.SASentry.SASdata.Idata] 
     81>>> I = [float(i.I.PCDATA) for i in sasxml.SASentry.SASdata.Idata] 
     82 
     83 
     84.. _cansas1d.py: 
     85 
     86`cansas1d.py` source code documentation 
     87=========================================== 
     88 
     89Here is the source code and documentation of the 
     90`cansas1d.py` Python binding. 
     91This file (and an example that calls this file and prints  
     92more data from the file) may be found in the canSAS  
     93:ref:`subversion <repository>` repository. 
     94 
     95.. automodule:: cansas1d 
     96    :members: 
     97    :undoc-members: 
     98    :show-inheritance: 
     99 
     100 
     101.. _gnosis: 
     102 
     103gnosis utils 
     104================= 
     105 
     106The Python binding to read canSAS 1-D data files 
     107has been implemented using the gnosis utilities. [#]_ 
     108Specifically, the `gnosis.xml.objectify` package turns  
     109arbitrary XML documents into Python objects. 
     110Since `gnosis.xml.objectify` is not aware of the XML Schema, 
     111it is necessary to check that the file read is a canSAS 1D file. 
     112Matching of the namespace and version should be sufficient 
     113to accept a canSAS 1D file.  Appropriate exceptions 
     114are raised if the file does not pass these tests. 
     115 
     116.. [#] gnosis utilities: http://freecode.com/projects/gnosisxml/ 
     117 
     118You can install the gnosis utilities if you have the `distutils` package using:: 
     119 
     120    easy_install -U gnosis 
     121    
  • 1dwg/trunk/doc/source/bindings.rst

    r271 r313  
    1212language or software environment. 
    1313 
     14.. keep this list alphabetical 
     15 
    1416.. toctree:: 
    1517   :maxdepth: 2 
  • 1dwg/trunk/doc/source/conf.py

    r271 r313  
    1818# documentation root, use os.path.abspath to make it absolute, like shown here. 
    1919#sys.path.insert(0, os.path.abspath('.')) 
     20sys.path.insert(0, os.path.abspath(os.path.join('..', '..', 'python'))) 
    2021 
    2122# -- General configuration ----------------------------------------------------- 
     
    2627# Add any Sphinx extension module names here, as strings. They can be extensions 
    2728# coming with Sphinx (named 'sphinx.ext.*') or your custom ones. 
    28 extensions = ['sphinx.ext.pngmath',] 
     29#extensions = ['sphinx.ext.pngmath',] 
    2930extensions = ['sphinx.ext.mathjax',] 
    3031extensions.append('sphinx.ext.todo') 
     32extensions.append('sphinx.ext.autodoc') 
     33extensions.append('sphinx.ext.viewcode') 
    3134todo_include_todos = True 
    3235 
     
    4548# General information about the project. 
    4649project = u'canSAS1d' 
    47 copyright = u'2012, canSAS' 
     50copyright = u'2013, canSAS' 
    4851 
    4952# The version info for the project you're documenting, acts as replacement for 
     
    254257epub_author = u'canSAS' 
    255258epub_publisher = u'canSAS' 
    256 epub_copyright = u'2012, canSAS' 
     259epub_copyright = u'2013, canSAS' 
    257260 
    258261# The language of the text. It defaults to the language option 
  • 1dwg/trunk/doc/source/contents.rst

    r271 r313  
    1616   xml-help 
    1717   downloads 
     18   license 
     19   authors 
  • 1dwg/trunk/doc/source/downloads.rst

    r262 r313  
    1010 
    1111:Version 1.1: 
    12         released !imminent! including changes indicated on the TRAC site.  
    13         Tickets closed: 17, 18, 20, 21, 22. 
     12        expected release 2013-04-01 including changes indicated on the TRAC site.  
     13        See :ref:`changes` below. 
    1414         
    1515        See http://www.cansas.org/trac/report/6?sort=ticket&asc=1 
  • 1dwg/trunk/doc/source/examples/Example_canSAS_Reader.java

    r310 r313  
    2525/** 
    2626 * Demonstrate how to use the Java binding for the  
    27  * cansas1d/1.0 standard XML format for reduced  
     27 * cansas1d/1.1 standard XML format for reduced  
    2828 * small-angle scattering data. 
    2929 *  
  • 1dwg/trunk/doc/source/index.rst

    r284 r313  
    3737.. rubric::  Brief Contents 
    3838 
    39  
    4039.. toctree:: 
    4140   :hidden: 
     
    4342   contents 
    4443 
    45  
    46 * :ref:`Preface` 
    47 * :ref:`Specification` 
    48 * :ref:`Examples` 
    49 * :ref:`case.studies` 
    50 * :ref:`Tutorial` 
    51 * :ref:`bindings` 
    52 * :ref:`downloads` 
    53 * :ref:`changes` 
     44+-------------------------+----------------------+ 
     45| * :ref:`Preface`        + * :ref:`bindings`    | 
     46| * :ref:`Specification`  + * :ref:`downloads`   | 
     47| * :ref:`Examples`       + * :ref:`changes`     | 
     48| * :ref:`case.studies`   + * :ref:`license`     | 
     49| * :ref:`Tutorial`       + * :ref:`authors`     | 
     50+-------------------------+----------------------+ 
  • 1dwg/trunk/doc/source/intensity-problem.rst

    • Property svn:keywords set to Author Date Id Revision URL
    r242 r313  
    1 .. $Id: validation.rst 241 2012-08-27 07:15:24Z prjemian $ 
     1.. $Id$ 
    22 
    33.. index:: 
  • 1dwg/trunk/doc/source/overview.rst

    r284 r313  
    556556        :ref:`Example.XML.Stylesheets` section. 
    557557 
     558.. _repository: 
    558559 
    559560Software repositories (for cansas1d:1.1 standard) 
    560561========================================================= 
     562 
     563.. index:: TRAC 
    561564 
    562565:TRAC: 
     
    564567        http://www.cansas.org/trac/browser/1dwg/tags/v1.1 
    565568 
     569.. index:: subversion, svn 
     570 
    566571:SVN: 
    567572        (*subversion* revision control system) 
  • 1dwg/trunk/examples/cansas1d.xsl

    r285 r313  
    2020        (or include it as indicated at the documentation site 
    2121        http://www.cansas.org/wgwiki/index.php/cansas1d_documentation) 
     22 
     23Copyright (c) 2013, UChicago Argonne, LLC 
     24This file is distributed subject to a Software License Agreement found 
     25in the file LICENSE that is included with this distribution.  
    2226--> 
    2327 
  • 1dwg/trunk/java/ant-eclipse/LICENSES/cansas1d/LICENSE.txt

    r305 r313  
    1 Copyright ï¿œ 2013, UChicago Argonne, LLC 
     1Copyright (c) 2013, UChicago Argonne, LLC 
    22 
    33All Rights Reserved 
    44 
    5 cansas1d-1.1 (Java binding for the canSAS 1D XML standard for SAS data) 
     5cansas1d (The canSAS 1D XML standard v1.1 for SAS data) 
     6 
     7canSAS, http://www.cansas.org 
    68 
    79OPEN SOURCE LICENSE 
     
    1315this list of conditions and the following disclaimer.  Software changes,  
    1416modifications, or derivative works, should be noted with comments and the  
    15 author and organizationï¿œs name. 
     17author and organization's name. 
    1618  
    17192. Redistributions in binary form must reproduce the above copyright  
  • 1dwg/trunk/java/ant-eclipse/LICENSES/cansas1d/README.txt

    r183 r313  
    11 
    2 Java (JAXB 2.1) binding for canSAS1d/1.0 XML standard  
     2Java (JAXB 2.1) binding for canSAS1d/1.1 XML standard  
    33for reduced small-angle scattering data. 
    44 
     
    1515To use the Java (JAXB 2.1) binding, all you need are  
    1616the JAR files in the releases directory. 
    17         http://svn.smallangles.net/svn/canSAS/1dwg/tags/v1.0/java 
     17        http://svn.smallangles.net/svn/canSAS/1dwg/tags/v1.1/java 
    1818 
    1919These are the files to download: 
    20         cansas1d-1.0.jar 
    21         cansas1d-1.0-javadoc.jar (optional) 
    22         cansas1d-1.0-sources.jar (optional) 
     20        cansas1d-1.1.jar 
     21        cansas1d-1.1-javadoc.jar (optional) 
     22        cansas1d-1.1-sources.jar (optional) 
    2323 
    2424 
    2525DOCUMENTATION 
    2626 
    27 This is the Java binding for the cansas1d/1.0 XML  
     27This is the Java binding for the cansas1d/1.1 XML  
    2828standard for small-angle scattering data. 
    2929 
    3030The code has been auto-generated using the JAXB v2.1 
    31 reference implementation from the cansas1d/1.0 XML schema. 
     31reference implementation from the cansas1d/1.1 XML schema. 
    3232 
    3333The documentation for the code is available either: 
    3434* JAVADOC in JAR:  see above 
    3535* JAVADOC in HTML:  
    36 **  The complete HTML is contained within the cansas1d-1.0-javadoc.jar above.  It can be extracted with any program that can extract a ZIP file. 
     36**  The complete HTML is contained within the cansas1d-1.1-javadoc.jar above.   
     37    It can be extracted with any program that can extract a ZIP file. 
    3738 
    3839 
     
    4344need to contact someone on the development team who understands this code. 
    4445 
    45 svn co http://svn.smallangles.net/svn/canSAS/1dwg/trunk/java/ant-eclipse ./cansas1d-JAXB-ant-eclipse 
     46svn co http://www.cansas.org/svn/1dwg/trunk/java/ant-eclipse ./cansas1d-java 
    4647 
    4748 
    4849REFERENCES 
    4950 
    50 canSAS:  
    51 http://www.smallangles.net/wgwiki/index.php/1D_Data_Formats_Working_Group 
     51:canSAS:  
     52    http://www.cansas.org 
    5253 
    53 cansas1d/1.0 documentation: 
    54 http://svn.smallangles.net/trac/canSAS/browser/1dwg/tags/v1.0/doc/cansas-1d-1_0-manual.pdf?format=raw 
     54:canSAS 1D: 
     55    XML data file format documentation: 
     56    http://www.cansas.org/formats/canSAS1d/1.1/doc/ 
    5557 
    56 cansas1d/1.0 Java binding: 
    57 http://svn.smallangles.net/svn/canSAS/1dwg/tags/v1.0/java/ 
    58  
    59 JAXB reference implementation is version 2.1 
    60 See the README.txt file in the LICENSES/JAXB folder. 
    61  
    62  
    63 DEPRECATED 
    64  
    65 The code from previous versions of the packaging and distribution 
    66 (both cansas1d and maven-eclipse branches) is now deprecated and  
    67 has been removed from the SVN repository as of about revision 179. 
     58:JAXB: 
     59    reference implementation is version 2.1 
     60    See the README.txt file in the LICENSES/JAXB folder. 
  • 1dwg/trunk/java/ant-eclipse/README.txt

    r183 r313  
    11 
    2 Java (JAXB 2.1) binding for canSAS1d/1.0 XML standard  
     2Java (JAXB 2.1) binding for canSAS1d/1.1 XML standard  
    33for reduced small-angle scattering data. 
    44 
     
    1515To use the Java (JAXB 2.1) binding, all you need are  
    1616the JAR files in the releases directory. 
    17         http://svn.smallangles.net/svn/canSAS/1dwg/tags/v1.0/java 
     17        http://svn.smallangles.net/svn/canSAS/1dwg/tags/v1.1/java 
    1818 
    1919These are the files to download: 
    20         cansas1d-1.0.jar 
    21         cansas1d-1.0-javadoc.jar (optional) 
    22         cansas1d-1.0-sources.jar (optional) 
     20        cansas1d-1.1.jar 
     21        cansas1d-1.1-javadoc.jar (optional) 
     22        cansas1d-1.1-sources.jar (optional) 
    2323 
    2424 
    2525DOCUMENTATION 
    2626 
    27 This is the Java binding for the cansas1d/1.0 XML  
     27This is the Java binding for the cansas1d/1.1 XML  
    2828standard for small-angle scattering data. 
    2929 
    3030The code has been auto-generated using the JAXB v2.1 
    31 reference implementation from the cansas1d/1.0 XML schema. 
     31reference implementation from the cansas1d/1.1 XML schema. 
    3232 
    3333The documentation for the code is available either: 
    3434* JAVADOC in JAR:  see above 
    3535* JAVADOC in HTML:  
    36 **  The complete HTML is contained within the cansas1d-1.0-javadoc.jar above.  It can be extracted with any program that can extract a ZIP file. 
     36**  The complete HTML is contained within the cansas1d-1.1-javadoc.jar above.   
     37    It can be extracted with any program that can extract a ZIP file. 
    3738 
    3839 
     
    4344need to contact someone on the development team who understands this code. 
    4445 
    45 svn co http://svn.smallangles.net/svn/canSAS/1dwg/trunk/java/ant-eclipse ./cansas1d-JAXB-ant-eclipse 
     46svn co http://www.cansas.org/svn/1dwg/trunk/java/ant-eclipse ./cansas1d-java 
    4647 
    4748 
    4849REFERENCES 
    4950 
    50 canSAS:  
    51 http://www.smallangles.net/wgwiki/index.php/1D_Data_Formats_Working_Group 
     51:canSAS:  
     52    http://www.cansas.org 
    5253 
    53 cansas1d/1.0 documentation: 
    54 http://svn.smallangles.net/trac/canSAS/browser/1dwg/tags/v1.0/doc/cansas-1d-1_0-manual.pdf?format=raw 
     54:canSAS 1D: 
     55    XML data file format documentation: 
     56    http://www.cansas.org/formats/canSAS1d/1.1/doc/ 
    5557 
    56 cansas1d/1.0 Java binding: 
    57 http://svn.smallangles.net/svn/canSAS/1dwg/tags/v1.0/java/ 
    58  
    59 JAXB reference implementation is version 2.1 
    60 See the README.txt file in the LICENSES/JAXB folder. 
    61  
    62  
    63 DEPRECATED 
    64  
    65 The code from previous versions of the packaging and distribution 
    66 (both cansas1d and maven-eclipse branches) is now deprecated and  
    67 has been removed from the SVN repository as of about revision 179. 
     58:JAXB: 
     59    reference implementation is version 2.1 
     60    See the README.txt file in the LICENSES/JAXB folder. 
  • 1dwg/trunk/java/ant-eclipse/build.number

    r305 r313  
    1 #Thu, 28 Mar 2013 00:03:47 -0500 
     1#Thu, 28 Mar 2013 23:58:13 -0500 
     2 
    23#Build Number for ANT. Do not edit! 
    3 #Thu Mar 28 00:03:47 CDT 2013 
    4 build.number=30 
     4#Thu Mar 28 23:58:13 CDT 2013 
     5build.number=32 
  • 1dwg/trunk/java/ant-eclipse/resources/cansas1d/cansas1d.xsl

    r305 r313  
    2020        (or include it as indicated at the documentation site 
    2121        http://www.cansas.org/wgwiki/index.php/cansas1d_documentation) 
     22 
     23Copyright (c) 2013, UChicago Argonne, LLC 
     24This file is distributed subject to a Software License Agreement found 
     25in the file LICENSE that is included with this distribution.  
    2226--> 
    2327 
  • 1dwg/trunk/java/ant-eclipse/src/org/cansas/cansas1d/FloatUnitType.java

    • Property svn:keywords set to Author Date Id Revision URL
    r302 r313  
     1// Copyright (c) 2013, UChicago Argonne, LLC 
     2// This file is distributed subject to a Software License Agreement found 
     3// in the file LICENSE that is included with this distribution.  
     4 
    15// 
    26// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, vJAXB 2.1.10 in JDK 6  
  • 1dwg/trunk/java/ant-eclipse/src/org/cansas/cansas1d/IdataType.java

    r302 r313  
    11// 
     2// Copyright (c) 2013, UChicago Argonne, LLC 
     3// This file is distributed subject to a Software License Agreement found 
     4// in the file LICENSE that is included with this distribution.  
     5 
    26// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, vJAXB 2.1.10 in JDK 6  
    37// See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a>  
  • 1dwg/trunk/java/ant-eclipse/src/org/cansas/cansas1d/ObjectFactory.java

    r302 r313  
    11// 
     2// Copyright (c) 2013, UChicago Argonne, LLC 
     3// This file is distributed subject to a Software License Agreement found 
     4// in the file LICENSE that is included with this distribution.  
     5 
    26// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, vJAXB 2.1.10 in JDK 6  
    37// See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a>  
  • 1dwg/trunk/java/ant-eclipse/src/org/cansas/cansas1d/OrientationType.java

    r302 r313  
    11// 
     2// Copyright (c) 2013, UChicago Argonne, LLC 
     3// This file is distributed subject to a Software License Agreement found 
     4// in the file LICENSE that is included with this distribution.  
     5 
    26// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, vJAXB 2.1.10 in JDK 6  
    37// See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a>  
  • 1dwg/trunk/java/ant-eclipse/src/org/cansas/cansas1d/PositionType.java

    r302 r313  
    11// 
     2// Copyright (c) 2013, UChicago Argonne, LLC 
     3// This file is distributed subject to a Software License Agreement found 
     4// in the file LICENSE that is included with this distribution.  
     5 
    26// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, vJAXB 2.1.10 in JDK 6  
    37// See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a>  
  • 1dwg/trunk/java/ant-eclipse/src/org/cansas/cansas1d/SAScollimationType.java

    r302 r313  
    11// 
     2// Copyright (c) 2013, UChicago Argonne, LLC 
     3// This file is distributed subject to a Software License Agreement found 
     4// in the file LICENSE that is included with this distribution.  
     5 
    26// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, vJAXB 2.1.10 in JDK 6  
    37// See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a>  
  • 1dwg/trunk/java/ant-eclipse/src/org/cansas/cansas1d/SASdataType.java

    r302 r313  
    11// 
     2// Copyright (c) 2013, UChicago Argonne, LLC 
     3// This file is distributed subject to a Software License Agreement found 
     4// in the file LICENSE that is included with this distribution.  
     5 
    26// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, vJAXB 2.1.10 in JDK 6  
    37// See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a>  
  • 1dwg/trunk/java/ant-eclipse/src/org/cansas/cansas1d/SASdetectorType.java

    r302 r313  
    11// 
     2// Copyright (c) 2013, UChicago Argonne, LLC 
     3// This file is distributed subject to a Software License Agreement found 
     4// in the file LICENSE that is included with this distribution.  
     5 
    26// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, vJAXB 2.1.10 in JDK 6  
    37// See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a>  
  • 1dwg/trunk/java/ant-eclipse/src/org/cansas/cansas1d/SASentryType.java

    r302 r313  
    11// 
     2// Copyright (c) 2013, UChicago Argonne, LLC 
     3// This file is distributed subject to a Software License Agreement found 
     4// in the file LICENSE that is included with this distribution.  
     5 
    26// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, vJAXB 2.1.10 in JDK 6  
    37// See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a>  
  • 1dwg/trunk/java/ant-eclipse/src/org/cansas/cansas1d/SASinstrumentType.java

    r302 r313  
    11// 
     2// Copyright (c) 2013, UChicago Argonne, LLC 
     3// This file is distributed subject to a Software License Agreement found 
     4// in the file LICENSE that is included with this distribution.  
     5 
    26// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, vJAXB 2.1.10 in JDK 6  
    37// See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a>  
  • 1dwg/trunk/java/ant-eclipse/src/org/cansas/cansas1d/SASprocessType.java

    r302 r313  
    11// 
     2// Copyright (c) 2013, UChicago Argonne, LLC 
     3// This file is distributed subject to a Software License Agreement found 
     4// in the file LICENSE that is included with this distribution.  
     5 
    26// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, vJAXB 2.1.10 in JDK 6  
    37// See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a>  
  • 1dwg/trunk/java/ant-eclipse/src/org/cansas/cansas1d/SASrootType.java

    r302 r313  
    11// 
     2// Copyright (c) 2013, UChicago Argonne, LLC 
     3// This file is distributed subject to a Software License Agreement found 
     4// in the file LICENSE that is included with this distribution.  
     5 
    26// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, vJAXB 2.1.10 in JDK 6  
    37// See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a>  
  • 1dwg/trunk/java/ant-eclipse/src/org/cansas/cansas1d/SASsampleType.java

    r302 r313  
    11// 
     2// Copyright (c) 2013, UChicago Argonne, LLC 
     3// This file is distributed subject to a Software License Agreement found 
     4// in the file LICENSE that is included with this distribution.  
     5 
    26// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, vJAXB 2.1.10 in JDK 6  
    37// See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a>  
  • 1dwg/trunk/java/ant-eclipse/src/org/cansas/cansas1d/SASsourceType.java

    r302 r313  
    11// 
     2// Copyright (c) 2013, UChicago Argonne, LLC 
     3// This file is distributed subject to a Software License Agreement found 
     4// in the file LICENSE that is included with this distribution.  
     5 
    26// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, vJAXB 2.1.10 in JDK 6  
    37// See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a>  
  • 1dwg/trunk/java/ant-eclipse/src/org/cansas/cansas1d/SAStransmissionSpectrumType.java

    r302 r313  
    11// 
     2// Copyright (c) 2013, UChicago Argonne, LLC 
     3// This file is distributed subject to a Software License Agreement found 
     4// in the file LICENSE that is included with this distribution.  
     5 
    26// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, vJAXB 2.1.10 in JDK 6  
    37// See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a>  
  • 1dwg/trunk/java/ant-eclipse/src/org/cansas/cansas1d/TdataType.java

    r302 r313  
    11// 
     2// Copyright (c) 2013, UChicago Argonne, LLC 
     3// This file is distributed subject to a Software License Agreement found 
     4// in the file LICENSE that is included with this distribution.  
     5 
    26// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, vJAXB 2.1.10 in JDK 6  
    37// See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a>  
  • 1dwg/trunk/java/ant-eclipse/src/org/cansas/cansas1d/TermType.java

    r302 r313  
     1// Copyright (c) 2013, UChicago Argonne, LLC 
     2// This file is distributed subject to a Software License Agreement found 
     3// in the file LICENSE that is included with this distribution.  
     4 
    15// 
    26// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, vJAXB 2.1.10 in JDK 6  
  • 1dwg/trunk/java/ant-eclipse/src/org/cansas/cansas1d/package-info.java

    r302 r313  
     1// Copyright (c) 2013, UChicago Argonne, LLC 
     2// This file is distributed subject to a Software License Agreement found 
     3// in the file LICENSE that is included with this distribution.  
     4 
    15// 
    26// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, vJAXB 2.1.10 in JDK 6  
  • 1dwg/trunk/php/xmlWriter/cansas1d.xsl

    r287 r313  
    2020        (or include it as indicated at the documentation site 
    2121        http://www.cansas.org/wgwiki/index.php/cansas1d_documentation) 
     22 
     23Copyright (c) 2013, UChicago Argonne, LLC 
     24This file is distributed subject to a Software License Agreement found 
     25in the file LICENSE that is included with this distribution.  
    2226--> 
    2327 
  • 1dwg/trunk/php/xmlWriter/index.php

    r287 r313  
    88# $Id$ 
    99########### SVN repository information ################### 
     10 
     11# Copyright (c) 2013, UChicago Argonne, LLC 
     12# This file is distributed subject to a Software License Agreement found 
     13# in the file LICENSE that is included with this distribution.  
     14 
    1015 
    1116##### GLOBALS ##################################################################### 
  • 1dwg/trunk/php/xmlWriter/www/style.xsl

    r287 r313  
    1313        This stylesheet is used to display the cansas1d:1.1 
    1414        xmlWriter surveillance log.. 
     15 
     16Copyright (c) 2013, UChicago Argonne, LLC 
     17This file is distributed subject to a Software License Agreement found 
     18in the file LICENSE that is included with this distribution.  
    1519--> 
    1620 
  • 1dwg/trunk/python/cansas1d.py

    • Property svn:keywords changed from Author Date Id Revision URL Header to Author Date Id Revision URL
    r310 r313  
    11#!/usr/bin/env python 
     2 
    23'''  
    3 Example use of Gnosis_utils to read both cansas1d:1.1  
    4 and cansas1d/1.0 files 
     4read canSAS 1-D XML data files (either v1.0 or v1.1) 
    55 
    6 This demonstrates full access to the contents of  
    7 the XML file using a single line to open the file:: 
     6:requires:  
     7    gnosis.xml.objectify     # easy_install -U gnosis 
    88 
    9     sasxml = readCanSasFile(xmlFile) 
     9basic use in a program:: 
    1010 
    11 .. note:: Since :meth:`readCanSasFile` raises exceptions  
    12    if the namespace or version does not match, it is best 
    13    to wrap this call in ``try ... except``` block, 
    14    as shown in :meth:`demo`. 
     11    import cansas1d 
     12    try: 
     13        sasxml = cansas1d.readCanSasFile(xmlFile) 
     14    except cansas1d.Exception_canSAS_namespace, answer: 
     15        print "wrong XML namespace:", answer 
     16        return 
     17    except cansas1d.Exception_canSAS_version, answer: 
     18        print "wrong version string:", answer 
     19        return 
    1520 
     21Copyright (c) 2013, UChicago Argonne, LLC 
     22This file is distributed subject to a Software License Agreement found 
     23in the file LICENSE that is included with this distribution.  
    1624''' 
    1725 
     
    4351    open a canSAS XML data file as a gnosis file object 
    4452     
    45     usage:: 
    46      
    47         try: 
    48             sasxml = readCanSasFile(xmlFile) 
    49         except (Exception_canSAS_namespace, Exception_canSAS_version), answer: 
    50             print answer 
    51             return 
    52         print 'namespace:', sasxml.xmlns 
    53         print 'version:', sasxml.version 
    54         SASentry = sasxml.SASentry                  # just the first one 
    55         # ... 
    56      
     53    :param str xmlFile: name of canSAS 1D XML data file 
     54    :returns: gnosis object with XML data structure 
     55    :raises Exception_canSAS_namespace: if namespace does not match 
     56    :raises Exception_canSAS_version: if version does not match 
    5757    ''' 
    5858    # read in the XML file 
    5959    sasxml = gnosis.xml.objectify.XML_Objectify(xmlFile).make_instance() 
     60     
    6061    # namespace check to accept file as canSAS XML 
    6162    if sasxml.xmlns not in CANSAS_NAMESPACES.values(): 
    62         msg = "Not a canSAS data file (namespace found: %s)" % sasxml.xmlns 
    63         raise Exception_canSAS_namespace, msg 
     63        raise Exception_canSAS_namespace, str(sasxml.xmlns) 
     64     
     65    # version check 
    6466    if sasxml.version not in CANSAS_NAMESPACES.keys(): 
    65         msg = "Not v1.1 file (found: %s)" % msg 
    66         raise Exception_canSAS_version, msg 
     67        raise Exception_canSAS_version, str(sasxml.version) 
     68     
    6769    return sasxml 
    68  
    6970 
    7071class Exception_canSAS_namespace(Exception): 
     
    7677    pass 
    7778 
    78  
    79 def indra_metadata(SASentry): 
    80     '''print metadata from APS/USAXS Indra package''' 
    81     if 'metadata' in SASentry.__dict__: 
    82         for metadata in SASentry.metadata: 
    83             '''loop through the USAXS metadata''' 
    84             print metadata.xmlns 
    85             for index in metadata.usaxs: 
    86                 '''multiple invocations of the usaxs element''' 
    87                 for item in dir(index): 
    88                     '''discover the element names''' 
    89                     if item[0] == '_':    # sift out data structure management terms 
    90                         continue 
    91                     if item in ('PCDATA', 'name', 'xmlns'):  # sift this out 
    92                         continue 
    93                     s = '' 
    94                     s += '('+index.xmlns+') ' 
    95                     s += '('+index.name+') ' 
    96                     s += item + ': ' 
    97                     s += index.__dict__[item].PCDATA 
    98                     print s 
    99  
    100  
    101 def print_SASdata(sd): 
    102     '''print the contents of the SASdata element''' 
    103     numPts = len(sd.Idata) 
    104     if 'name' in sd.__dict__: 
    105         print 'SASdata name:', sd.name 
    106     print '# points:', numPts 
    107     columns = [ 
    108         ['Q ('+sd.Idata[0].Q.unit+')'], 
    109         ['I ('+sd.Idata[0].I.unit+')'], 
    110         ['Idev ('+sd.Idata[0].Idev.unit+')'], 
    111     ] 
    112     for Idata in sd.Idata: 
    113         values = (Idata.Q.PCDATA, Idata.I.PCDATA, Idata.Idev.PCDATA) 
    114         for item, value in enumerate(values): 
    115             columns[item].append(str(value)) 
    116     print columnsToText(columns) 
    117  
    118  
    119 def print_optional_item(title, parent, item): 
    120     ''' this item is optional and may not be present''' 
    121     if item in parent.__dict__: 
    122         #print item, item in parent.__dict__ 
    123         obj = parent.__dict__[item] 
    124         s = title+':\t' 
    125         s += obj.PCDATA 
    126         if 'unit' in obj.__dict__: 
    127             s += ' (' + obj.unit + ')' 
    128         print s 
    129  
    130  
    131 def columnsToText(columns): 
    132     ''' 
    133     convert a list of column lists into rows of text 
    134      
    135     column widths will be chosen from the maximum character width of each column 
    136      
    137     :param [[str]] columns: list of column lists (all same length) 
    138     :returns str: text block, with line separators 
    139      
    140     Example:: 
    141      
    142         >>> columns = [ ['1A', '2A'], ['1B is long', '2B'], ['1C', '2C'] ] 
    143         >>> print columnsToText( columns ) 
    144         1A  1B is long  1C 
    145         2A  2B          2C 
    146      
    147     ''' 
    148     # get the largest width for each column 
    149     widths = [max(map(len, item)) for item in columns] 
    150     # left-align each column 
    151     sep = ' '*2 
    152     fmt = sep.join(['%%-%ds' % item for item in widths]) 
    153     # rows = zip(*columns) : matrix transpose 
    154     result = [fmt % tuple(row) for row in zip(*columns)] 
    155     return '\n'.join(result) 
    156  
    157  
    158 def demo(xmlFile): 
    159     print '#---------------------------------------------------' 
    160     print 'XML:', xmlFile 
    161     # read in the XML file 
    162     try: 
    163         sasxml = readCanSasFile(xmlFile) 
    164     except (Exception_canSAS_namespace, Exception_canSAS_version), answer: 
    165         print answer 
    166         return 
    167     print 'namespace:', sasxml.xmlns 
    168     print 'version:', sasxml.version 
    169     SASentry = sasxml.SASentry                  # just the first one 
    170     print 'title:', SASentry.Title.PCDATA 
    171     print 'run:', SASentry.Run.PCDATA 
    172     print_optional_item('instrument', SASentry.SASinstrument, 'name') 
    173     indra_metadata(SASentry)        # foreign XML elements from APS/USAXS 
    174     print_optional_item('sample ID', SASentry.SASsample, 'ID') 
    175     print_optional_item('sample thickness', SASentry.SASsample, 'thickness') 
    176     print_optional_item('sample transmission', SASentry.SASsample, 'transmission') 
    177     if 'position' in SASentry.SASsample.__dict__: 
    178         print_optional_item('sample X', SASentry.SASsample.position, 'x') 
    179         print_optional_item('sample Y', SASentry.SASsample.position, 'y') 
    180     print_SASdata(SASentry.SASdata) 
    181  
    182  
    18379if __name__ == "__main__": 
    184     if len(sys.argv) == 2: 
    185         demo(sys.argv[1]) 
    186     else: 
    187         demo(os.path.join('..', 'examples', 'bimodal-test1.xml')) 
    188         demo(os.path.join('..', 'examples', 's81-polyurea.xml')) 
     80    '''just for demonstration using example data files''' 
     81    for xmlFile in ('bimodal-test1', 's81-polyurea'): 
     82        path = os.path.abspath(os.path.join('..', 'examples', xmlFile+'.xml')) 
     83        if not os.path.exists(path): 
     84            continue 
     85        try: 
     86            sasxml = readCanSasFile(path) 
     87        except Exception_canSAS_namespace, answer: 
     88            print xmlFile, "wrong XML namespace:", answer 
     89            continue 
     90        except Exception_canSAS_version, answer: 
     91            print xmlFile, "wrong version string:", answer 
     92            continue 
     93        print '%s has %d data points' % (xmlFile, len(sasxml.SASentry.SASdata.Idata)) 
     94         
Note: See TracChangeset for help on using the changeset viewer.