cansas1d binding IgorPro
canSAS 1-D SAS XML format binding to IgorPro
An import tool (binding) for IgorPro has been created (cansasXML.ipf). You can check out the IgorPro working directory from the SVN server (see instructions below).
To use the canSASxml.ipf procedure, you must have the XMLutils XOP IGOR plugin installed. See the Usage Notes below.
Note that the code described here is not a complete user interface. (See further comments below.) It is expected that this code will be called by a graphical user interface routine and that routine will handle the work of copying the loaded SAS data in IgorPro from the root:Packages:CS_XMLreader data folder to the destination of choice (including any renaming of waves as desired).
|author||Pete R. Jemian <email@example.com>|
|purpose||implement an IgorPro file reader to read the canSAS 1-D reduced SAS data in XML files |
adheres to the cansas1d/1.0 standard: http://www.smallangles.net/wgwiki/index.php/cansas1d_documentation
|URL||TRAC: http://svn.smallangles.net/trac/canSAS/browser/1dwg/trunk/IgorPro/cansasXML.ipf |
|requires||IgorPro: http://www.wavemetrics.com |
XMLutils - XOP: http://www.igorexchange.com/project/XMLutils
Checkout of support code in Subversion
Subversion (http://subversion.tigris.org/) is a program for managing software versions. There are command line and GUI clients for a variety of operating systems. We won't recommend any here but will show the command lines necessary.
The XMLutils XOP, written by Andrew Nelson (ANSTO), is hosted on the IgorExchange (http://www.igorexchange.com/).
One good location to place the checked out XMLutils directory is in the Wavemetrics directory, next to the Igor Pro Folder
In the future, to retrieve an updated version of this support, go into the XMLutils directory (created above) and type the command
This will check the repository and update files as needed. If the installer program was updated, you;ll need to run the new installer program. It is not necessary to uninstall first.
The installer executables contained in the download will do all the installation for you. They will place the XOP in the folder /User Procedures/motofit/XMLutils, and create a shortcut/alias to the plugin in /Igor Extensions. Packages from other facilities should place the XOP there as well.
Check out the canSAS 1d SAS XML reader from the subversion repository:
svn checkout http://svn.smallangles.net/svn/canSAS/1dwg/trunk cansas-1dwg
This will download lots of extra files. The file of interest is in the IgorPro directory and is called cansasXML.ipf
In the future, to retrieve an updated version of this support, go into the cansas-1dwg directory (created above) and type the command
This will check the repository and update files as needed.
- License and Install IgorPro (should have already been done by now)
- Quit IgorPro if it is running
- Download XMLutils XOP. Either checkout from subversion (see above) or, with a web browser, go to http://svn.igorexchange.com/viewvc/packages/XMLutils/trunk/
- Install XMLutils XOP by double-clicking the installer for you operating system.
- Download cansasXML.ipf. Either checkout from subversion (see above) or, with a web browser, copy cansasXML.ipf from on-line subversion repository: http://svn.smallangles.net/svn/canSAS/1dwg/trunk/IgorPro/cansasXML.ipf
- Copy cansasXML.ipf file to ...\Wavemetrics\Igor Pro Folder\User Procedures (or file system equivalent)
- Then, you should be able to restart IgorPro and progress from there
To use the canSASxml.ipf procedure, you must have the XMLutils XOP IGOR plugin installed. This may be downloaded from the IgorExchange Project site. There are installer executables contained in the download that will do all the installation for you. Each installer will place the XOP in the folder ...\Wavemetrics\Igor Pro Folder\User Procedures\motofit\XMLutils, and create a shortcut/alias to the plugin in ...\Wavemetrics\Igor Pro Folder\Igor Extensions.
List of Functions
These are (most of) the FUNCTIONS in the cansasXML.ipf code. The only functions of interest are CS_XmlReader(fileName) which reads the named XML file and and loads SAS data and the two demonstration functions prj_grabMyXmlData() and prjTest_cansas1d() that together show a usage example.
- open a canSAS 1-D reduced SAS XML data file
- input: fileName (string) name of canSAS XML file (can include file system path name to file)
- 0 successful
- -1: XML file not found
- -2: root element is not <SASroot>
- -3: <SASroot> version is not 1.0
- -4: no <SASentry> elements
- given a file ID returned from XMLOpenFile(), parses that file for SAS data and metadata
- CS_1i_collectMetadata(fileID, sasEntryPath)
- gathers metadata from the named SASentry (XPathStr)
- CS_appendMetaData(key, xpath, value)
- queries XML file for xpath. If value is not empty, appends it to metadata where last is the new last row: metadata[last]=key; metadata[last]=value
- looks for element index in structure W_ElementList returned from call to XmlElemList(fileID)
- Builds a table of all namespaces used in the XML file and appends W_ElementList with full namespace-xpath string for each element.
- this function adds namespace info as necessary to simpleStr (an XPath)
- CS_buildXpathStr(prefix, value)
- this function can be used only with very simple XPath constructions
- CS_XmlStrFmXpath(fileID, prefix, value)
- Calls XmlStrFmXpath() with proper namespace prefix attached. Trims the result string.
- CS_simpleXmlWaveFmXpath(fileID, prefix, value)
- Calls XMLwaveFmXpath() with proper namespace prefix attached.
- CS_simpleXmlListXpath(fileID, prefix, value)
- Calls XMLlistXpath() with proper namespace prefix attached.
- Calls TrimWSL(TrimWSR(str))
- Trims white space from left (leading) end of str
- Trims white space from right (trailing) end of str
- CS_updateWaveNote(wavName, key, value)
- adds (or replaces) definition of key=value in the wave note of wavName
- CS_1i_extractIdataColumn2Wave(fileID, basePath, colName, wavName)
- This function pulls one column of data from each <Idata> element. It is easier to write this as a single function than debug it all the times it is needed.
Avoid the use of the semicolon in anything that might make it into the IgorPro wavenote since the semicolon is a list delimiter. The import macro defends against this by converting all semicolons into the string " :semicolon: "
- CS_1i_extractSasData(fileID, SASdataPath, SASdata_folder)
- (1i in the function name signifies this is a function that supports INPUT from version 1.0 XML files)
- Demonstration function that moves loaded data from root:Packages:CS_XMLreader to a user's data folder. (In this example, that folder is root:PRJ_canSAS.)
- Demonstration function that calls CS_XmlReader(fileName) for many of the test data sets.