Ignore:
Timestamp:
Sep 16, 2009 3:51:45 PM (13 years ago)
Author:
srkline
Message:

Added function to the SANSBeta menu for reduction to be able to re-write the filename to the header, correctly accounting for possible blank spaces caused by a prefix of less than 5 characters. VAX puts the spaces at the beginning of the field, ICE puts them at the end. As a result, the unique file suffix is not at the correct byte location.

ICE will be notified of the necessary change.

Location:
sans/Dev/trunk/NCNR_User_Procedures/Reduction/SANS
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • sans/Dev/trunk/NCNR_User_Procedures/Reduction/SANS/Includes_v520.ipf

    r544 r557  
    114114        "Read Detector Count" 
    115115        "-" 
     116        "PatchFileNameInHeader" 
     117        "ReadFileNameInHeader" 
     118        "-" 
    116119        "AddALLToLayout" 
    117120         
  • sans/Dev/trunk/NCNR_User_Procedures/Reduction/SANS/NCNR_DataReadWrite.ipf

    r544 r557  
    13181318End 
    13191319 
     1320// file name, starts at byte 2 
     1321// limit to 21 characters 
     1322// 
     1323// be sure that any white space to pad to 21 characters is at the front of the string 
     1324Function WriteFileNameToHeader(fname,str) 
     1325        String fname,str 
     1326         
     1327        Variable i 
     1328        String newStr="" 
     1329//      printf "\"%s\"\t%d\r",str,strlen(str) 
     1330 
     1331        //strip any white spaces from the end (from TrimWSR(str) in cansasXML.ipf) 
     1332        for (i=strlen(str)-1; char2num(str[i])<=32 && i>=0; i-=1)    // find last non-white space 
     1333        endfor 
     1334        str = str[0,i] 
     1335//      printf "\"%s\"\t%d\r",str,strlen(str) 
     1336 
     1337        // if the string is less than 21 characters, fix it with white space at the beginning 
     1338        if(strlen(str) < 21) 
     1339                newStr = PadString(newStr,21,0x20)              //pad with fortran-style spaces 
     1340                newStr[21-strlen(str),20] = str 
     1341        else 
     1342                newStr = str 
     1343        endif 
     1344//      printf "\"%s\"\t%d\r",newstr,strlen(newstr) 
     1345 
     1346        WriteTextToHeader(fname,newstr,2) 
     1347        return(0) 
     1348End 
     1349 
     1350 
    13201351//rewrite an integer field back to the header 
    13211352// fname is the full path:name 
     
    13961427         
    13971428        return(getStringFromHeader(fname,78,11)) 
     1429End 
     1430 
     1431// file name (21 characters @ byte 2) 
     1432Function/S getFileName(fname) 
     1433        String fname 
     1434         
     1435        return(getStringFromHeader(fname,2,21)) 
    13981436End 
    13991437 
     
    25172555End 
    25182556 
     2557 
     2558// Sept 2009 -SRK 
     2559// the ICE instrument control software is not correctly writing out the file name to the header in the specific 
     2560// case of a file prefix less than 5 characters. ICE is quite naturally putting the blanke space(s) at the end of 
     2561// the string. However, the VAX puts them at the beginning... 
     2562Proc PatchFileNameInHeader(firstFile,lastFile) 
     2563        Variable firstFile=1,lastFile=100 
     2564 
     2565        fPatchFileName(firstFile,lastFile) 
     2566 
     2567End 
     2568 
     2569Proc ReadFileNameInHeader(firstFile,lastFile) 
     2570        Variable firstFile=1,lastFile=100 
     2571         
     2572        fReadFileName(firstFile,lastFile) 
     2573End 
     2574 
     2575 
     2576// simple utility to patch the file name in the file headers 
     2577// lo is the first file number 
     2578// hi is the last file number (inclusive) 
     2579// 
     2580// will read the 21 character file name and put any spaces at the front of the string 
     2581// like the VAX does. Should have absolutely no effect if there are spaces at the 
     2582// beginning of the string, as the VAX does. 
     2583Function fPatchFileName(lo,hi) 
     2584        Variable lo,hi 
     2585         
     2586        Variable ii 
     2587        String file,fileName 
     2588         
     2589        //loop over all files 
     2590        for(ii=lo;ii<=hi;ii+=1) 
     2591                file = FindFileFromRunNumber(ii) 
     2592                if(strlen(file) != 0) 
     2593                        fileName = getFileName(file) 
     2594                        WriteFileNameToHeader(file,fileName) 
     2595                else 
     2596                        printf "run number %d not found\r",ii 
     2597                endif 
     2598        endfor 
     2599         
     2600        return(0) 
     2601End 
     2602 
     2603// simple utility to read the file name stored in the file header (and the suffix) 
     2604Function fReadFileName(lo,hi) 
     2605        Variable lo,hi 
     2606         
     2607        String file,fileName,suffix 
     2608        Variable ii 
     2609         
     2610        for(ii=lo;ii<=hi;ii+=1) 
     2611                file = FindFileFromRunNumber(ii) 
     2612                if(strlen(file) != 0) 
     2613                        fileName = getFileName(file) 
     2614                        suffix = getSuffix(file) 
     2615                        printf "File %d:  File name = %s\t\tSuffix = %s\r",ii,fileName,suffix 
     2616                else 
     2617                        printf "run number %d not found\r",ii 
     2618                endif 
     2619        endfor 
     2620         
     2621        return(0) 
     2622End 
     2623 
     2624 
     2625 
     2626 
    25192627// April 2009 - AJJ 
    25202628// The new ICE instrument control software was not correctly writing the run.defdir field 
Note: See TracChangeset for help on using the changeset viewer.