- Timestamp:
- Jun 16, 2010 2:10:47 PM (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
sans/Dev/trunk/NCNR_User_Procedures/Common/DataSetHandling.ipf
r681 r708 1 1 #pragma rtGlobals=1 // Use modern global access method. 2 3 4 ///////// SRK - VERY SIMPLE batch converter has been added: see 5 // 6 // Function batchXML26ColConvert() 7 // 8 9 2 10 3 11 // Functions and interfaces to manage datasets now that they are in data folders … … 1509 1517 // 1510 1518 //End 1519 1520 1521 1522 ///////// SRK - VERY SIMPLE batch converter 1523 // no header information is preserved 1524 // file names are partially preserved 1525 // 1526 1527 /// to use this: 1528 // -open the Plot Manager and set the path 1529 // -run this function 1530 // 1531 // it doesn't matter if the XML ouput flag is set - this overrides. 1532 Function batchXML26ColConvert() 1533 1534 String list, item,path,fname 1535 Variable num,ii 1536 1537 PathInfo CatPathName 1538 path = S_Path 1539 1540 list = A_ReducedDataFileList("") 1541 num = itemsInList(list) 1542 Print num 1543 for(ii=0;ii<num;ii+=1) 1544 item = StringFromList(ii, list ,";") 1545 fname=path + item 1546 Execute "A_LoadOneDDataWithName(\""+fname+"\",0)" //won't plot 1547 // easier to load all, then write out, since the name will be changed 1548 endfor 1549 1550 1551 list = DM_DataSetPopupList() 1552 1553 num = itemsInList(list) 1554 Print num 1555 for(ii=0;ii<num;ii+=1) 1556 item = StringFromList(ii, list ,";") 1557 fReWrite1DData_noPrompt(item,"tab","CR") 1558 endfor 1559 1560 End 1561 1562 // quick version (copied from fReWrite1DData() that NEVER asks for a new fileName 1563 // - and right now, always expect 6-column data, either SANS or USANS (re-writes -dQv) 1564 // - AJJ Nov 2009 : better make sure we always fake 6 columns on reading then.... 1565 Function fReWrite1DData_noPrompt(folderStr,delim,term) 1566 String folderStr,delim,term 1567 1568 String formatStr="",fullpath="" 1569 Variable refnum,dialog=1 1570 1571 String dataSetFolderParent,basestr 1572 1573 //setup delimeter and terminator choices 1574 If(cmpstr(delim,"tab")==0) 1575 //tab-delimeted 1576 formatStr="%15.8g\t%15.8g\t%15.8g\t%15.8g\t%15.8g\t%15.8g" 1577 else 1578 //use 3 spaces 1579 formatStr="%15.8g %15.8g %15.8g %15.8g %15.8g %15.8g" 1580 Endif 1581 If(cmpstr(term,"CR")==0) 1582 formatStr += "\r" 1583 Endif 1584 If(cmpstr(term,"LF")==0) 1585 formatStr += "\n" 1586 Endif 1587 If(cmpstr(term,"CRLF")==0) 1588 formatStr += "\r\n" 1589 Endif 1590 1591 //Abuse ParseFilePath to get path without folder name 1592 dataSetFolderParent = ParseFilePath(1,folderStr,":",1,0) 1593 //Abuse ParseFilePath to get basestr 1594 basestr = ParseFilePath(0,folderStr,":",1,0) 1595 1596 //make sure the waves exist 1597 SetDataFolder $(dataSetFolderParent+basestr) 1598 WAVE/Z qw = $(baseStr+"_q") 1599 WAVE/Z iw = $(baseStr+"_i") 1600 WAVE/Z sw = $(baseStr+"_s") 1601 WAVE/Z resw = $(baseStr+"_res") 1602 1603 if(WaveExists(qw) == 0) 1604 Abort "q is missing" 1605 endif 1606 if(WaveExists(iw) == 0) 1607 Abort "i is missing" 1608 endif 1609 if(WaveExists(sw) == 0) 1610 Abort "s is missing" 1611 endif 1612 if(WaveExists(resw) == 0) 1613 Abort "Resolution information is missing." 1614 endif 1615 1616 Duplicate/O qw qbar,sigQ,fs 1617 if(dimsize(resW,1) > 4) 1618 //it's USANS put -dQv back in the last 3 columns 1619 NVAR/Z dQv = USANS_dQv 1620 if(NVAR_Exists(dQv) == 0) 1621 Abort "It's USANS data, and I don't know what the slit height is." 1622 endif 1623 sigQ = -dQv 1624 qbar = -dQv 1625 fs = -dQv 1626 else 1627 //it's SANS 1628 sigQ = resw[p][0] 1629 qbar = resw[p][1] 1630 fs = resw[p][2] 1631 endif 1632 1633 dialog=0 1634 if(dialog) 1635 PathInfo/S catPathName 1636 // fullPath = DoSaveFileDialog("Save data as",fname=baseStr+".txt") 1637 fullPath = DoSaveFileDialog("Save data as",fname=baseStr[0,strlen(BaseStr)-2]) 1638 Print fullPath 1639 If(cmpstr(fullPath,"")==0) 1640 //user cancel, don't write out a file 1641 Close/A 1642 Abort "no data file was written" 1643 Endif 1644 //Print "dialog fullpath = ",fullpath 1645 Endif 1646 PathInfo catPathName 1647 fullPath = S_Path + baseStr[0,strlen(BaseStr)-2] 1648 1649 Open refnum as fullpath 1650 1651 fprintf refnum,"Modified data written from folder %s on %s\r\n",baseStr,(date()+" "+time()) 1652 wfprintf refnum,formatStr,qw,iw,sw,sigQ,qbar,fs 1653 Close refnum 1654 1655 KillWaves/Z sigQ,qbar,fs 1656 1657 SetDataFolder root: 1658 return(0) 1659 End 1660 1661 ///////////end SRK
Note: See TracChangeset
for help on using the changeset viewer.