Ignore:
Timestamp:
Oct 4, 2019 8:45:39 AM (3 years ago)
Author:
srkline
Message:

changes to NXcanSAS branch to allow each reduction package to compile correctly by having the proper files included.

Some checks have been added to the file loaders to catch errors where header fields are not present in the file (sometimes an issue with NSORTed files)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sans/Dev/branches/nxcansas_writer/NCNR_User_Procedures/Reduction/SANS/Write_SANS_NXcanSAS.ipf

    r1200 r1218  
    4242        destStr = "root:Packages:NIST:"+type 
    4343        //*****these waves MUST EXIST, or IGOR Pro will crash, with a type 2 error**** 
    44         WAVE intw = $(destStr + ":integersRead") 
     44//      WAVE intw = $(destStr + ":integersRead")                // SRK_0920 
    4545        WAVE rw = $(destStr + ":realsRead") 
    4646        WAVE/T textw=$(destStr + ":textRead") 
     
    453453End 
    454454 
    455 // 
    456 /////////////////////////////////////////////////////////////////////////// 
    457  
     455 
     456/////////////////////////////////////////////////////////////////////////// 
     457// 
     458// Methods related to NSORT 
     459 
     460 
     461//these canSANs NSORT files are only necessary for SANS reduction, not USANS or VSANS. as such,  
     462// move them to the SANS-specific NXcanSAS file. Conditional compilation did not work since I can't access 
     463// user-defined objects through #if 
     464// 
     465// SRK 092019 
     466// 
     467 
     468Function WriteNSORTedNXcanSASFile(qw,iw,sw,firstFileName,secondFileName,thirdFileName,fourthFileName,normTo,norm12,norm23,norm34,[res]) 
     469        Wave qw,iw,sw,res 
     470        String firstFileName,secondFileName,thirdFileName,fourthFileName,normTo 
     471        Variable norm12,norm23,norm34 
     472         
     473        Variable err=0,refNum,numCols,dialog=1,useRes=0 
     474        String fullPath="",formatStr="",process 
     475         
     476        //check each wave - else REALLY FATAL error when writing file 
     477        If(!(WaveExists(qw))) 
     478                err = 1 
     479                return err 
     480        Endif 
     481        If(!(WaveExists(iw))) 
     482                err = 1 
     483                return err 
     484        Endif 
     485        If(!(WaveExists(sw))) 
     486                err = 1 
     487                return err 
     488        Endif 
     489        if(WaveExists(res)) 
     490                useRes = 1 
     491        endif 
     492         
     493        NVAR/Z useTable = root:myGlobals:CombineTable:useTable 
     494        if(NVAR_Exists(useTable) && useTable==1) 
     495                SVAR str=root:myGlobals:CombineTable:SaveNameStr        //messy, but pass in as a global 
     496                fullPath = str 
     497                dialog=0 
     498        endif 
     499         
     500        NewDataFolder/O/S root:Packages:NIST:NSORT 
     501        SetDataFolder root:Packages:NIST:NSORT 
     502         
     503        process = CreateNSORTProcess(firstFileName,secondFileName,thirdFileName,fourthFileName,normTo,norm12,norm23,norm34) 
     504        Make/O/T/N=1 processNote = process 
     505         
     506        Variable pts = numpnts(qw) 
     507        Make/O/N=(pts) qval = qw 
     508        Make/O/N=(pts) aveint = iw 
     509        Make/O/N=(pts) sigave = sw 
     510        if (useRes) 
     511                Make/O/N=(dimsize(res,0)) SigmaQ = res[p][0] 
     512                Make/O/N=(dimsize(res,0)) QBar = res[p][1] 
     513                Make/O/N=(dimsize(res,0)) fSubS = res[p][2] 
     514        Else 
     515                Make/O/N=(pts) SigmaQ = 0 
     516                Make/O/N=(pts) QBar = 0 
     517                Make/O/N=(pts) fSubS = 0 
     518        EndIf 
     519         
     520        Make/O/T/N=11 textRead 
     521        textRead[6] = firstfileName 
     522        textRead[0] = "Combined data" 
     523         
     524        Make/O/N=52 realsRead = 0 
     525         
     526        WriteNxCanSAS1D("NSORT",fullpath,dialog) 
     527         
     528End 
     529 
     530 
     531Function/T CreateNSORTProcess(firstFileName,secondFileName,thirdFileName,fourthFileName,normTo,norm12,norm23,norm34) 
     532        String firstFileName,secondFileName,thirdFileName,fourthFileName,normTo 
     533        Variable norm12,norm23,norm34 
     534        String process 
     535        String processFormat = "COMBINED FILE CREATED: %s - NSORT-ed %s\t+ %s\t+ %s\t+%s, normalized to %s, multiplicative factor 1-2 = %12.8g\t multiplicative factor 2-3 = %12.8g\t multiplicative factor 3-4 = %12.8g" 
     536         
     537        sprintf process,processFormat,date(),firstFileName,secondFileName,thirdFileName,fourthFileName,normTo,norm12,norm23,norm34 
     538        return process 
     539End 
     540 
     541// 
     542 
     543 
     544// 
     545/////////////////////////////////////////////////////////////////////////// 
     546 
Note: See TracChangeset for help on using the changeset viewer.