source: 1dwg/trunk/doc/source/casestudy_collagen.rst @ 271

Last change on this file since 271 was 271, checked in by prjemian, 8 years ago

remove last vestiges of from documentation (except two instances referring to previous work)

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision URL
File size: 4.9 KB

Case Study: Dry Chick Collagen

.. index:: ! case study; dry chick collagen SAXS

To demonstrate how to get SAS data into the XML standard format, consider this set of SAXS data collected at the National Synchrotron Light Source, Brookhaven National Laboratory, using a SAXS camera set up temporarily at beam line X6B (operated by the Materials Science Division, Argonne National Lab).

The sample was dry chick collagen. (Thanks to Malcolm Capel, NSLS beam line X12C for the sample.)


collagen SAXS in Excel table


collagen SAXS in Excel chart (log-log)

The raw data was collected on a linear position-sensitive detector and reduced to columns of Q , I , and Idev (estimated standard deviation of I ).

The only :index:`metadata` available for this data (without resorting to digging through piles of old notebooks) was obtained from the headers of two files:


raw data file

The header lines from collagen.asc:

.. code-block:: text
        Sep 19 1994     01:41:02 am     Elt: 00090 Seconds
        ID: No spectrum identifier defined
        Memory Size: 8192 Chls  Conversion Gain: 1024  Adc Offset: 0000 Chls

raw data file

The header lines from collagen.saxs:

.. code-block:: text
        dry chick collagen, d = 673 A
        6531 eV, X6B

There is enough information to fulfill the minimum requirements of the 1D standard file format and also make an excellent example of a minimal canSAS reduced 1-D SAS data file in XML.

Create the XML data file

The procedure to create the XML data file by hand is described next.

Make the basic XML file

It is easiest to copy a template rather than start from an empty file. Copy the :download:`cansas1d.xml <../../cansas1d.xml>` file ( into your working directory and rename it to collagen.xml.


Modify collagen.xml

It is easier to see the metadata in the XML file before you enter the SAXS data into the file. With the brief metadata available, most of the other lines in cansas1d.xml can be eliminated. This will result in a file that looks like the next example.

collagen.xml with metadata but before data lines are added

.. literalinclude:: examples/example-collagen-predata.xml
   :language: xml

Prepare the SAXS data

Microsoft Excel is used here to convert the table of SAXS data into the required lines of XML for the standard. Some may prefer to use a cell formula but here, we develop a bit of Excel Macro code to clarify our procedure.

Using Excel macros to reformat the SAXS data

.. index:: binding; Microsoft Excel

Within Excel, with the SAXS data in columns as shown in the Excel table above, let's define the macros for our use. In Excel, type <alt><F11> to open the macro editing window.

Microsoft Excel macro to format the Idata lines

.. literalinclude:: examples/example-excel-macro.txt
   :language: text

Your window will look similar to this one when you copy/paste the above example code: (Yes, my spreadsheet is called MyFirstMacro.xls)


case study: Collagen, SAXS data in Excel chart

Now close the macro editing window and return to the SAXS data in the spreadsheet.

construct the Idata lines in XML

Move to spreadsheet cell E5 and enter this formula:


Copy it down all rows in column E through cell E335.

Select cells E5:E335 and copy to clipboard, then paste into collagen.xml document inside the SASdata element where you see the XML comment.

Final Result

A nicely-formatted display version of the final result can be viewed through the TRAC repository:

Validate the file

So you think you have an XML file? Let's validate it using the procedure from the documentation. All the instructions are in the :ref:`validate` section. No sense in repeating them here.

Note: See TracBrowser for help on using the repository browser.