Ignore:
Timestamp:
Mar 10, 2015 10:50:03 AM (8 years ago)
Author:
srkline
Message:

some minor changes to the FFT filling procedures to help out Abhiram

Replaced cansasXML.ipf v1.11 with v1.12 (current version)

some restructuring of the VSANS file names.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sans/Dev/trunk/NCNR_User_Procedures/Common/cansasXML.ipf

    r928 r953  
    1 #pragma rtGlobals=1             // Use modern global access method. 
    2 #pragma version=1.11 
    3 #pragma IgorVersion=6.1 
    4  
    5 // taken from smallangles.net on 02 APR 2010 
     1#pragma rtGlobals=1             // rtGlobals=3 requires IgorPro 6.3+ 
     2#pragma version=1.12 
     3 
     4// SRK 
     5// taken from smallangles.net on 10 MAR 2015 
    66// changed Function/T to Function/S on (unused) TrimWS functions 
     7// 
     8// 
    79 
    810// file:        cansasXML.ipf 
     
    1315// SVN ID:      $Id$ 
    1416// purpose:  implement an IgorPro file reader to read the canSAS 1-D reduced SAS data in XML files 
    15 //                      adheres to the cansas1d/1.0 standard 
    16 // readme:    http://www.smallangles.net/wgwiki/index.php/cansas1d_binding_IgorPro 
    17 // URL: http://www.smallangles.net/wgwiki/index.php/cansas1d_documentation 
     17//                      adhering to either the cansas1d/1.0 or cansas1d/1.1 standards 
     18// readme:    http://www.cansas.org/formats/canSAS1d/1.1/doc/binding-igorpro.html 
     19// URL: http://www.cansas.org/formats/canSAS1d/1.1/doc/ 
    1820// 
    1921// requires:    IgorPro (http://www.wavemetrics.com/) 
    2022//                              XMLutils - XOP (http://www.igorexchange.com/project/XMLutils) 
    21 // provides:  CS_CmlReader(String fileName) 
     23// provides:  CS_XmlReader(String fileName) 
    2224//                              all other functions in this file should not be relied upon 
    23  
    24 // ================================================================== 
    25 // CS_XmlReader("bimodal-test1.xml") 
    26 // CS_XmlReader("1998spheres.xml") 
    27 // CS_XmlReader("xg009036_001.xml") 
    28 // CS_XmlReader("s81-polyurea.xml") 
    29 // CS_XmlReader("cs_af1410.xml") 
     25// 
     26// Copyright (c) 2013, UChicago Argonne, LLC 
     27// This file is distributed subject to a Software License Agreement found 
     28// in the file LICENSE that is included with this distribution.  
     29 
     30 
     31//  ================  ================  =================  ========== 
     32//  #pragma version   canSAS1d version  namespace          released 
     33//  ================  ================  =================  ========== 
     34//  1.12              v1.1              urn:cansas1d:1.1   2013-04-01 
     35//  1.11              v1.0              cansas1d/1.0       2009-09-25 
     36//  ================  ================  =================  ========== 
     37 
     38 
     39// ================================================================== 
     40// CS_XmlReader("../examples/bimodal-test1.xml") 
     41// CS_XmlReader("../examples/1998spheres.xml") 
     42// CS_XmlReader("../examples/xg009036_001.xml") 
     43// CS_XmlReader("../examples/s81-polyurea.xml") 
     44// CS_XmlReader("../examples/cs_af1410.xml") 
    3045//  testCollette();  prjTest_cansas1d() 
    3146// ================================================================== 
    3247 
    3348 
    34 #if( Exists("XmlOpenFile") ) 
     49#if( ! Exists("XmlOpenFile") ) 
    3550        // BEFORE we do anything else, check that XMLutils XOP is available. 
    36  
     51        // No XMLutils XOP: provide dummy function so that IgorPro can compile dependent support code 
     52 
     53        FUNCTION CS_XmlReader(fileName) 
     54            String fileName 
     55                String msg 
     56                msg = "XML function provided by XMLutils XOP is not available," 
     57                msg += " get the XOP from : http://www.igorexchange.com/project/XMLutils" 
     58                msg += " (see http://www.cansas.org/formats/canSAS1d/1.1/doc/binding-igorpro.html for details)" 
     59            Abort  msg 
     60            RETURN(-6) 
     61        END 
     62 
     63#else   // if( Exists("XmlOpenFile") ) 
    3764 
    3865FUNCTION CS_XmlReader(fileName) 
     
    4370        //              -1: XML file not found 
    4471        //              -2: root element is not <SASroot> with valid canSAS namespace 
    45         //              -3: <SASroot> version  is not 1.0 
     72        //              -3: <SASroot> version  is not 1.0 or 1.1 
    4673        //              -4: no <SASentry> elements 
    4774        //              -5: XMLutils XOP needs upgrade 
     
    115142        STRSWITCH(ns)    
    116143        CASE "cansas1d/1.0":                                                    // version 1.0 of the canSAS 1-D reduced SAS data standard 
    117 //              PRINT fileName, "\t\t identified as: cansas1d/1.0 XML file" 
     144        CASE "urn:cansas1d:1.1":                                                // version 1.1 of the canSAS 1-D reduced SAS data standard 
     145                PRINT fileName, "\t\t identified as: " + ns + " XML file" 
    118146                returnCode = CS_1i_parseXml(fileID)                     //  This is where the action happens! 
    119147                IF (returnCode != 0) 
     
    154182        STRING ns = "", thisLocation 
    155183        VARIABLE i, item 
    156         MAKE/T/N=(1)/O nsList           // list of all possible namespaces 
     184        MAKE/T/N=(2)/O nsList           // list of all possible namespaces 
    157185        nsList[0] = "cansas1d/1.0"              // first version of canSAS 1-D reduced SAS 
     186        nsList[1] = "urn:cansas1d:1.1"  // second version of canSAS 1-D reduced SAS 
    158187 
    159188        FOR (item = 0; item < DimSize(nsList, 0); item += 1)            // loop over all possible namespaces 
     
    236265                        ENDFOR 
    237266                ENDIF 
     267 
     268                // TODO: process any transmission spectra 
     269                STRING/G ns = CS_getDefaultNamespace(fileID) 
     270                IF (cmpstr(ns,  "urn:cansas1d:1.1") == 0) 
     271                        XmlListXpath(fileID, SASentryPath + "//cs:SAStransmission_spectrum", nsStr) 
     272                        WAVE/T  M_listXPath 
     273                        print "Searching for SAStransmission_spectrum groups" 
     274                        print DimSize(M_listXPath, 0) , M_listXPath 
     275                        // ... 
     276                ENDIF 
     277                 
    238278                KillWaves/Z M_listXPath 
    239279        ENDFOR 
     
    613653                TitlePath = "" 
    614654        ENDIF 
    615 //      PRINT "\t Title:", Title 
     655        PRINT "\t Title:", Title 
    616656        RETURN(Title) 
    617657END 
     
    714754        fList = AddListItem("elmo.xml",                                 fList, ";", Inf)                // non-existent file 
    715755        fList = AddListItem("cansasXML.ipf",                    fList, ";", Inf)                // this file (should fail on XML parsing) 
    716         fList = AddListItem("book.xml",                                 fList, ";", Inf)                // good XML example file but not canSAS, not even close 
    717         fList = AddListItem("bimodal-test1.xml",                fList, ";", Inf)                // simple dataset 
    718         fList = AddListItem("bimodal-test2-vector.xml", fList, ";", Inf)                // version 2.0 file (no standard yet) 
    719         fList = AddListItem("test.xml",                                 fList, ";", Inf)                // cs_collagen.xml with no namespace 
    720         fList = AddListItem("test2.xml",                                fList, ";", Inf)                // version 2.0 file (no standard yet) 
    721         fList = AddListItem("ISIS_SANS_Example.xml",    fList, ";", Inf)                // from S. King, 2008-03-17 
    722         fList = AddListItem("W1W2.xml",                                 fList, ";", Inf)                // from S. King, 2008-03-17 
    723         fList = AddListItem("ill_sasxml_example.xml",   fList, ";", Inf)                // from canSAS 2007 meeting, reformatted 
    724         fList = AddListItem("isis_sasxml_example.xml",  fList, ";", Inf)                // from canSAS 2007 meeting, reformatted 
    725         fList = AddListItem("r586.xml",                                         fList, ";", Inf)                // from canSAS 2007 meeting, reformatted 
    726         fList = AddListItem("r597.xml",                                         fList, ";", Inf)                // from canSAS 2007 meeting, reformatted 
    727         fList = AddListItem("xg009036_001.xml",                 fList, ";", Inf)                // foreign elements with other namespaces 
    728         fList = AddListItem("cs_collagen.xml",                  fList, ";", Inf)                // another simple dataset, bare minimum info 
    729         fList = AddListItem("cs_collagen_full.xml",             fList, ";", Inf)                // more Q range than previous 
    730         fList = AddListItem("cs_af1410.xml",                    fList, ";", Inf)                // multiple SASentry and SASdata elements 
    731         fList = AddListItem("cansas1d-template.xml",    fList, ";", Inf)                // multiple SASentry and SASdata elements 
    732         fList = AddListItem("1998spheres.xml",                  fList, ";", Inf)                // 2 SASentry, few thousand data points each 
    733         fList = AddListItem("does-not-exist-file.xml",          fList, ";", Inf)                // non-existent file 
    734         fList = AddListItem("cs_rr_polymers.xml",               fList, ";", Inf)                // Round Robin polymer samples from John Barnes @ NIST 
    735         fList = AddListItem("s81-polyurea.xml",                         fList, ";", Inf)                // polyurea from APS/USAXS/Indra (with extra metadata) 
     756        fList = AddListItem("../examples/book.xml",                             fList, ";", Inf)                // good XML example file but not canSAS, not even close 
     757        fList = AddListItem("../examples/bimodal-test1.xml",            fList, ";", Inf)                // simple dataset 
     758        fList = AddListItem("../examples/testers/test3.xml",                                    fList, ";", Inf)                // no number provided for wavelength, others, too 
     759        fList = AddListItem("../examples/ISIS_SANS_Example.xml",        fList, ";", Inf)                // from S. King, 2008-03-17 
     760        fList = AddListItem("../examples/W1W2.xml",                             fList, ";", Inf)                // from S. King, 2008-03-17 
     761        fList = AddListItem("../examples/ill_sasxml_example.xml",       fList, ";", Inf)                // from canSAS 2007 meeting, reformatted 
     762        fList = AddListItem("../examples/isis_sasxml_example.xml",      fList, ";", Inf)                // from canSAS 2007 meeting, reformatted 
     763        fList = AddListItem("../examples/r586.xml",                                     fList, ";", Inf)                // from canSAS 2007 meeting, reformatted 
     764        fList = AddListItem("../examples/r597.xml",                                     fList, ";", Inf)                // from canSAS 2007 meeting, reformatted 
     765        fList = AddListItem("../examples/xg009036_001.xml",             fList, ";", Inf)                // foreign elements with other namespaces 
     766        fList = AddListItem("../examples/cs_collagen.xml",                      fList, ";", Inf)                // another simple dataset, bare minimum info 
     767        fList = AddListItem("../examples/cs_collagen_full.xml",                 fList, ";", Inf)                // more Q range than previous 
     768        fList = AddListItem("../examples/cs_af1410.xml",                        fList, ";", Inf)                // multiple SASentry and SASdata elements 
     769        fList = AddListItem("../examples/cs_rr_polymers.xml",           fList, ";", Inf)                // Round Robin polymer samples from John Barnes @ NIST 
     770        fList = AddListItem("../examples/cansas1d-template.xml",        fList, ";", Inf)                // multiple SASentry and SASdata elements 
     771        fList = AddListItem("../examples/1998spheres.xml",                      fList, ";", Inf)                // 2 SASentry, few thousand data points each 
     772        fList = AddListItem("../examples/does-not-exist-file.xml",              fList, ";", Inf)                // non-existent file 
     773        fList = AddListItem("../examples/s81-polyurea.xml",                     fList, ";", Inf)                // polyurea from APS/USAXS/Indra (with extra metadata) 
     774        fList = AddListItem("../examples/GLASSYC_C4G8G9_w_TL.xml",                      fList, ";", Inf)                // from S. King, with transmission spectra 
    736775         
    737776        // try to load each data set in the table 
     
    759798        // 3.   Loading actual data from LOQ caused some problems.  
    760799        //      Data created by Colette names files with run number.  
    761         //      When entering full path to load the data if you use "\example\31531.X" Igor will read \3 as a character.  
    762         //      A simple fix which has worked for this is to use / instead of \ e.g. "\example/31531.X". 
     800        //      When entering full path to load the data if you use " 
     801\example\31531.X" Igor will read \3 as a character.  
     802        //      A simple fix which has worked for this is to use / instead of \ e.g. " 
     803\example/31531.X". 
    763804         
    764805        //4.    Once data is loaded in Igor it is relatively easy to work with but would be nicer if the SASdata  
     
    769810        //Say, for Run=31531, then Qsas_31531 
    770811 
    771         CS_XmlReader("W1W2.XML") 
     812        CS_XmlReader("../examples/W1W2.XML") 
    772813        STRING srcDir = "root:Packages:CS_XMLreader" 
    773814        STRING destDir = "root", importFolder, target 
Note: See TracChangeset for help on using the changeset viewer.