Changeset 732 for sans/Dev/trunk/NCNR_User_Procedures
- Timestamp:
- Sep 10, 2010 5:50:17 PM (13 years ago)
- Location:
- sans/Dev/trunk/NCNR_User_Procedures/Common
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
sans/Dev/trunk/NCNR_User_Procedures/Common/DataSetHandling.ipf
r728 r732 363 363 Make/O/T/N=1 filewave="" 364 364 Make/O/N=1 selWave=0 365 Variable/G ind=0 365 Variable/G ind=0,gRadioVal=1 366 366 SetDataFolder root: 367 367 End … … 370 370 PauseUpdate; Silent 1 // building window... 371 371 NewPanel /W=(658,347,1018,737)/N=NCNRBatchConvertPanel/K=2 as "Batch Convert 1D Data" 372 // NewPanel /W=(658,347,1018,737)/N=NCNRBatchConvertPanel as "Batch Convert 1D Data" 372 373 ModifyPanel cbRGB=(40000,50000,32896) 373 374 ModifyPanel fixedSize=1 … … 383 384 384 385 GroupBox filterGroup,pos={13,200},size={206,60},title="Filter list by input file type" 386 CheckBox filterCheck_1,pos={24,220},size={36,14},title="XML",value= 1,mode=1, proc=BC_filterCheckProc 387 CheckBox filterCheck_2,pos={24,239},size={69,14},title="ABS or AVE",value= 0,mode=1, proc=BC_filterCheckProc 388 CheckBox filterCheck_3,pos={100,220},size={69,14},title="none",value= 0,mode=1, proc=BC_filterCheckProc 385 389 386 390 Button button8,pos={238,76},size={100,20},proc=NCNRBatchConvertHelpProc,title="Help" … … 389 393 390 394 GroupBox outputGroup,pos={13,270},size={206,60},title="Output File Type" 391 395 CheckBox outputCheck_1,pos={24,289},size={36,14},title="XML",value= 0,mode=1, proc=BC_outputCheckProc 396 CheckBox outputCheck_2,pos={24,309},size={69,14},title="ABS or AVE",value= 1,mode=1, proc=BC_outputCheckProc 392 397 393 398 Button button6,pos={13,350},size={206,20},proc=NCNRBatchConvertFiles,title="Convert File(s)" … … 398 403 End 399 404 405 Function BC_filterCheckProc(ctrlName,checked) : CheckBoxControl 406 String ctrlName 407 Variable checked 408 409 NVAR gRadioVal= root:Packages:NIST:BatchConvert:gRadioVal 410 411 strswitch (ctrlName) 412 case "filterCheck_1": 413 gRadioVal= 1 414 break 415 case "filterCheck_2": 416 gRadioVal= 2 417 break 418 case "filterCheck_3": 419 gRadioVal= 3 420 break 421 endswitch 422 CheckBox filterCheck_1,value= gRadioVal==1 423 CheckBox filterCheck_2,value= gRadioVal==2 424 CheckBox filterCheck_3,value= gRadioVal==3 425 426 NCNRBatchConvertGetList() 427 428 return(0) 429 End 430 431 Function BC_outputCheckProc(ctrlName,checked) : CheckBoxControl 432 String ctrlName 433 Variable checked 434 435 if(cmpstr("outputCheck_1",ctrlName)==0) 436 CheckBox outputCheck_1,value=checked 437 CheckBox outputCheck_2,value=!checked 438 else 439 CheckBox outputCheck_1,value=!checked 440 CheckBox outputCheck_2,value=checked 441 endif 442 443 return(0) 444 End 400 445 401 446 Function NCNRBatchConvertFiles(ba) : ButtonControl 402 447 STRUCT WMButtonAction &ba 403 448 449 404 450 switch (ba.eventCode) 405 451 case 2: 452 453 //check the input/output as best I can (none may be the input filter) 454 Variable inputType,outputType=1 455 NVAR gRadioVal= root:Packages:NIST:BatchConvert:gRadioVal 456 inputType = gRadioVal 457 ControlInfo outputCheck_1 458 if(V_value==1) 459 outputType = 1 //xml 460 else 461 outputType = 2 //6-col 462 endif 463 464 if(inputType==outputType) 465 DoAlert 0,"Input and output types are the same. Nothing will be converted" 466 return(0) 467 endif 468 469 470 // input and output are different, proceed 471 406 472 Wave/T fileWave=$"root:Packages:NIST:BatchConvert:fileWave" 407 Wave sel=$"root:BatchConvert:NIST:BatchConvert:selWave" 473 Wave sel=$"root:Packages:NIST:BatchConvert:selWave" 474 475 String fname="",pathStr="",newFileName="" 476 Variable ii,num 477 PathInfo catPathName //this is where the files are 478 pathStr=S_path 479 480 // process the selected items 481 num=numpnts(sel) 482 ii=0 483 do 484 if(sel[ii] == 1) 485 fname=pathStr + fileWave[ii] 486 487 if(outputType == 1) 488 convertNISTtoNISTXML(fname) 489 endif 490 491 if(outputType == 2) 492 convertNISTXMLtoNIST6Col(fname) 493 endif 494 endif 495 ii+=1 496 while(ii<num) 408 497 409 498 break … … 426 515 End 427 516 517 518 // filter is a bit harsh - will need to soften this by presenting an option to enter the suffix 519 // 428 520 Function NCNRBatchConvertGetList() 429 521 … … 434 526 Endif 435 527 436 String newList = A_ReducedDataFileList("") 528 String newList = A_ReducedDataFileList(""),tmpList="" 437 529 Variable num 530 531 NVAR gRadioVal= root:Packages:NIST:BatchConvert:gRadioVal 532 ControlInfo filterCheck_1 533 if(gRadioVal == 1) 534 //keep XML data 535 tmpList = ListMatch(newList, "*.ABSx" ,";") 536 tmpList += ListMatch(newList, "*.AVEx" ,";") 537 tmpList += ListMatch(newList, "*.xml" ,";") 538 else 539 if(gRadioVal ==2) 540 //keep ave, abs data 541 tmpList = ListMatch(newList, "*.ABS" ,";") 542 tmpList += ListMatch(newList, "*.AVE" ,";") 543 else 544 //return everything 545 tmpList = newList 546 endif 547 endif 548 newList = tmpList 438 549 439 550 num=ItemsInList(newlist,";") … … 444 555 fileWave = StringFromList(p,newlist,";") 445 556 Sort filewave,filewave 557 558 return 0 446 559 End 447 560 … … 1551 1664 1552 1665 1666 1667 // still need to get the header information, and possibly the SASprocessnote from the XML load into the 6-column header 1668 // 1669 // start by looking in: 1670 // String xmlReaderFolder = "root:Packages:CS_XMLreader:" 1671 // for Title and Title_folder strings -> then the metadata (but the processnote is still not there 1672 // 1673 // may need to get it directly using the filename 1674 Function convertNISTXMLtoNIST6Col(fname) 1675 String fname 1676 1677 String list, item,path 1678 Variable num,ii 1679 1680 //load the XML 1681 1682 LoadNISTXMLData(fname,"",0,0) //no plot, no force overwrite 1683 // Execute "A_LoadOneDDataWithName(\""+fname+"\",0)" //won't plot 1684 1685 // then rewrite what is in the data folder that was just loaded 1686 String basestr = ParseFilePath(0, fname, ":", 1, 0) 1687 baseStr = CleanupName(baseStr,0) 1688 print fname 1689 print basestr 1690 1691 fReWrite1DData_noPrompt(baseStr,"tab","CR") 1692 1693 return(0) 1694 End 1695 1696 1553 1697 ///////// SRK - VERY SIMPLE batch converter 1554 1698 // no header information is preserved -
sans/Dev/trunk/NCNR_User_Procedures/Common/NIST_XML_v40.ipf
r710 r732 565 565 end 566 566 567 // 568 // !!! nf.Sample_ID is not set correctly here, since it's not read in from the NIST 6-col data file 569 // and SASprocessnote does not get set either! 570 // 567 571 Function convertNISTtoNISTXML(fileStr) 568 572 String fileStr … … 639 643 640 644 endif 641 642 //Tidy up643 Variable i = 0644 do645 WAVE/Z wv= $(StringFromList(i,S_waveNames,";"))646 if( WaveExists(wv) == 0 )647 break648 endif649 KillWaves wv650 i += 1651 while (1) // exit is via break statement652 653 645 654 646 endif //6-col data … … 666 658 667 659 writeNISTXML(outfileName, nf) 660 661 //Tidy up AFTER we're all done, since STRUCT points to wave0,wave1, etc. 662 Variable i = 0 663 do 664 WAVE/Z wv= $(StringFromList(i,S_waveNames,";")) 665 if( WaveExists(wv) == 0 ) 666 break 667 endif 668 KillWaves wv 669 i += 1 670 while (1) // exit is via break statement 668 671 669 672 end … … 695 698 if (stringmatch(buffer,"*FIRST File LABEL:*") == 1) 696 699 NISTfile.title = TrimWS(StringFromList(1,buffer, ":")) 697 elseif(stringmatch(buffer,"*LABEL:*") == 1) 700 endif 701 if(stringmatch(buffer,"*LABEL:*") == 1) 698 702 NISTfile.title = TrimWS(StringFromList(1,buffer, ":")) 703 endif 704 if(stringmatch(buffer,"NSORT*") == 1) 705 NISTfile.title = buffer 699 706 endif 700 707
Note: See TracChangeset
for help on using the changeset viewer.