Changeset 69 for sans/SANSReduction/branches/kline_29MAR07/Put in User Procedures/SANS_Reduction_v5.00/RawDataReader.ipf
- Timestamp:
- Mar 29, 2007 1:45:45 PM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
sans/SANSReduction/branches/kline_29MAR07/Put in User Procedures/SANS_Reduction_v5.00/RawDataReader.ipf
r41 r69 3 3 #pragma IgorVersion=4.0 4 4 5 //**************************6 //7 // Vers. 1.2 0921018 //9 // functions for reading raw data files from the VAX10 // - RAW data files are read into the RAW folder - integer data from the detector11 // is decompressed and given the proper orientation12 // - header information is placed into real,integer, or text waves in the order they appear13 // in the file header14 //15 // Work data (DIV File) is read into the DIV folder16 //17 //*****************************18 5 19 //simple, main entry procedure that will load a RAW sans data file (not a work file)20 //into the RAW dataFolder21 //(typically called from main panel button)22 //23 Proc LoadSANSData()24 String msgStr = "Select a SANS data file"25 26 Variable err27 err = ReadBinarySANS(msgStr) //will prompt for file28 //ignore the error here29 End30 31 //function that does the guts of reading the binary data file32 //fname is the full path:name;vers required to open the file33 //VAX record markers are skipped as needed34 //the data as read in is in compressed I*2 format, and is decompressed35 //immediately after being read in. The final root:RAW:data wave is the real36 //neutron counts and can be directly operated on37 //header information is put into three wave, integers,reals, and text38 //logicals in the header are currently skipped, since they are no use in the39 //data reduction process. the logicals, however are left untouched.40 //41 Function ReadHeaderAndData(fname)42 String fname43 //this function is for reading in RAW data only, so it will always put data in RAW folder44 String curPath = "root:RAW"45 SetDataFolder curPath //use the full path, so it will always work46 Variable/G root:RAW:gIsLogScale = 0 //initial state is linear, keep this in RAW folder47 48 Variable refNum,integer,realval49 String sansfname,textstr50 51 Make/O/N=23 $"root:RAW:IntegersRead"52 Make/O/N=52 $"root:RAW:RealsRead"53 Make/O/T/N=11 $"root:RAW:TextRead"54 55 Wave intw=$"root:RAW:IntegersRead"56 Wave realw=$"root:RAW:RealsRead"57 Wave/T textw=$"root:RAW:TextRead"58 59 //***NOTE ****60 // the "current path" gets mysteriously reset to "root:" after the SECOND pass through61 // this read routine, after the open dialog is presented62 // the "--read" waves end up in the correct folder, but the data does not! Why?63 //must re-set data folder before writing data array (done below)64 65 //full filename and path is now passed in...66 //actually open the file67 Open/R refNum as fname68 //skip first two bytes (VAX record length markers, not needed here)69 FSetPos refNum, 270 //read the next 21 bytes as characters (fname)71 FReadLine/N=21 refNum,textstr72 textw[0]= textstr73 //read four i*4 values /F=3 flag, B=3 flag74 FBinRead/F=3/B=3 refNum, integer75 intw[0] = integer76 //77 FBinRead/F=3/B=3 refNum, integer78 intw[1] = integer79 //80 FBinRead/F=3/B=3 refNum, integer81 intw[2] = integer82 //83 FBinRead/F=3/B=3 refNum, integer84 intw[3] = integer85 // 6 text fields86 FSetPos refNum,55 //will start reading at byte 5687 FReadLine/N=20 refNum,textstr88 textw[1]= textstr89 FReadLine/N=3 refNum,textstr90 textw[2]= textstr91 FReadLine/N=11 refNum,textstr92 textw[3]= textstr93 FReadLine/N=1 refNum,textstr94 textw[4]= textstr95 FReadLine/N=8 refNum,textstr96 textw[5]= textstr97 FReadLine/N=60 refNum,textstr98 textw[6]= textstr99 100 //3 integers101 FSetPos refNum,174102 FBinRead/F=3/B=3 refNum, integer103 intw[4] = integer104 FBinRead/F=3/B=3 refNum, integer105 intw[5] = integer106 FBinRead/F=3/B=3 refNum, integer107 intw[6] = integer108 109 //2 integers, 3 text fields110 FSetPos refNum,194111 FBinRead/F=3/B=3 refNum, integer112 intw[7] = integer113 FBinRead/F=3/B=3 refNum, integer114 intw[8] = integer115 FReadLine/N=6 refNum,textstr116 textw[7]= textstr117 FReadLine/N=6 refNum,textstr118 textw[8]= textstr119 FReadLine/N=6 refNum,textstr120 textw[9]= textstr121 122 //2 integers123 FSetPos refNum,244124 FBinRead/F=3/B=3 refNum, integer125 intw[9] = integer126 FBinRead/F=3/B=3 refNum, integer127 intw[10] = integer128 129 //2 integers130 FSetPos refNum,308131 FBinRead/F=3/B=3 refNum, integer132 intw[11] = integer133 FBinRead/F=3/B=3 refNum, integer134 intw[12] = integer135 136 //2 integers137 FSetPos refNum,332138 FBinRead/F=3/B=3 refNum, integer139 intw[13] = integer140 FBinRead/F=3/B=3 refNum, integer141 intw[14] = integer142 143 //3 integers144 FSetPos refNum,376145 FBinRead/F=3/B=3 refNum, integer146 intw[15] = integer147 FBinRead/F=3/B=3 refNum, integer148 intw[16] = integer149 FBinRead/F=3/B=3 refNum, integer150 intw[17] = integer151 152 //1 text field153 FSetPos refNum,404154 FReadLine/N=42 refNum,textstr155 textw[10]= textstr156 157 //1 integer158 FSetPos refNum,458159 FBinRead/F=3/B=3 refNum, integer160 intw[18] = integer161 162 //4 integers163 FSetPos refNum,478164 FBinRead/F=3/B=3 refNum, integer165 intw[19] = integer166 FBinRead/F=3/B=3 refNum, integer167 intw[20] = integer168 FBinRead/F=3/B=3 refNum, integer169 intw[21] = integer170 FBinRead/F=3/B=3 refNum, integer171 intw[22] = integer172 173 Close refNum174 175 //now get all of the reals176 //177 //Do all the GBLoadWaves at the end178 //179 //FBinRead Cannot handle 32 bit VAX floating point180 //GBLoadWave, however, can properly read it181 String GBLoadStr="GBLoadWave/O/N=tempGBwave/T={2,2}/J=2/W=1/Q"182 String strToExecute183 //append "/S=offset/U=numofreals" to control the read184 // then append fname to give the full file path185 // then execute186 187 Variable a=0,b=0188 189 SetDataFolder curPath190 191 // 4 R*4 values192 strToExecute = GBLoadStr + "/S=39/U=4" + "\"" + fname + "\""193 Execute strToExecute194 Wave w=$"root:RAW:tempGBWave0"195 b=4 //num of reals read196 realw[a,a+b-1] = w[p-a]197 a+=b198 199 // 4 R*4 values200 SetDataFolder curPath201 strToExecute = GBLoadStr + "/S=158/U=4" + "\"" + fname + "\""202 Execute strToExecute203 b=4204 realw[a,a+b-1] = w[p-a]205 a+=b206 207 ///////////208 // 2 R*4 values209 SetDataFolder curPath210 strToExecute = GBLoadStr + "/S=186/U=2" + "\"" + fname + "\""211 Execute strToExecute212 b=2213 realw[a,a+b-1] = w[p-a]214 a+=b215 216 // 6 R*4 values217 SetDataFolder curPath218 strToExecute = GBLoadStr + "/S=220/U=6" + "\"" + fname + "\""219 Execute strToExecute220 b=6221 realw[a,a+b-1] = w[p-a]222 a+=b223 224 // 13 R*4 values225 SetDataFolder curPath226 strToExecute = GBLoadStr + "/S=252/U=13" + "\"" + fname + "\""227 Execute strToExecute228 b=13229 realw[a,a+b-1] = w[p-a]230 a+=b231 232 // 3 R*4 values233 SetDataFolder curPath234 strToExecute = GBLoadStr + "/S=320/U=3" + "\"" + fname + "\""235 Execute strToExecute236 b=3237 realw[a,a+b-1] = w[p-a]238 a+=b239 240 // 7 R*4 values241 SetDataFolder curPath242 strToExecute = GBLoadStr + "/S=348/U=7" + "\"" + fname + "\""243 Execute strToExecute244 b=7245 realw[a,a+b-1] = w[p-a]246 a+=b247 248 // 4 R*4 values249 SetDataFolder curPath250 strToExecute = GBLoadStr + "/S=388/U=4" + "\"" + fname + "\""251 Execute strToExecute252 b=4253 realw[a,a+b-1] = w[p-a]254 a+=b255 256 // 2 R*4 values257 SetDataFolder curPath258 strToExecute = GBLoadStr + "/S=450/U=2" + "\"" + fname + "\""259 Execute strToExecute260 b=2261 realw[a,a+b-1] = w[p-a]262 a+=b263 264 // 2 R*4 values265 SetDataFolder curPath266 strToExecute = GBLoadStr + "/S=470/U=2" + "\"" + fname + "\""267 Execute strToExecute268 b=2269 realw[a,a+b-1] = w[p-a]270 a+=b271 272 // 5 R*4 values273 SetDataFolder curPath274 strToExecute = GBLoadStr + "/S=494/U=5" + "\"" + fname + "\""275 Execute strToExecute276 b=5277 realw[a,a+b-1] = w[p-a]278 279 //if the binary VAX data ws transferred to a MAC, all is OK280 //if the data was trasnferred to an Intel machine (IBM), all the real values must be281 //divided by 4 to get the correct floating point values282 // I can't find any combination of settings in GBLoadWave or FBinRead to read data in correctly283 // on an Intel machine.284 //With the corrected version of GBLoadWave XOP (v. 1.43 or higher) Mac and PC both read285 //VAX reals correctly, and no checking is necessary 12 APR 99286 //if(cmpstr("Macintosh",IgorInfo(2)) == 0)287 //do nothing288 //else289 //either Windows or Windows NT290 //realw /= 4291 //endif292 293 SetDataFolder curPath294 //read in the data295 strToExecute = "GBLoadWave/O/N=tempGBwave/B/T={16,2}/S=514/Q" + "\"" + fname + "\""296 Execute strToExecute297 298 SetDataFolder curPath //use the full path, so it will always work299 300 Make/O/N=16384 $"root:RAW:data"301 WAVE data=$"root:RAW:data"302 SkipAndDecompressVAX(w,data)303 Redimension/N=(128,128) data //NIST raw data is 128x128 - do not generalize304 305 //keep a string with the filename in the RAW folder306 String/G root:RAW:fileList = textw[0]307 308 //set the globals to the detector dimensions (pixels)309 Variable/G root:myGlobals:gNPixelsX=128 //default for Ordela data (also set in Initialize.ipf)310 Variable/G root:myGlobals:gNPixelsY=128311 // if(cmpstr(textW[9],"ILL ")==0) //override if OLD Cerca data312 // Variable/G root:myGlobals:gNPixelsX=64313 // Variable/G root:myGlobals:gNPixelsY=64314 // endif315 316 //clean up - get rid of w = $"root:RAW:tempGBWave0"317 KillWaves/Z w318 319 //return the data folder to root320 SetDataFolder root:321 322 Return 0323 324 End325 326 //function called by the main entry procedure327 //sets global display variable, reads in the data, and displays it328 //displays alert, and returns error if no file was selected329 //330 // calling routine must decide whether to abort the execution or not...331 Function ReadBinarySANS(msgStr)332 String msgStr333 334 String filename=""335 336 //each routine is responsible for checking the current (displayed) data folder337 //selecting it, and returning to root when done338 PathInfo/S catPathName //should set the next dialog to the proper path...339 //get the filename, then read it in340 filename = PromptForPath(msgStr)341 //check for cancel from dialog342 if(strlen(filename)==0)343 //user cancelled, abort344 SetDataFolder root:345 DoAlert 0, "No file selected, action aborted"346 return(1)347 Endif348 //Print "GetFileNameFromPath(filename) = " + GetFileNameFromPathNoSemi(filename)349 ReadHeaderAndData(filename) //this is the full Path+file350 351 //the calling macro must change the display type352 String/G root:myGlobals:gDataDisplayType="RAW" //displayed data type is raw353 354 //data is displayed here355 fRawWindowHook()356 357 Return(0)358 End359 360 //function to take the I*2 data that was read in, in VAX format361 //where the integers are "normal", but there are 2-byte record markers362 //sprinkled evenly through the data363 //there are skipped, leaving 128x128=16384 data values364 //the input array (in) is larger than 16384365 //(out) is 128x128 data (single precision) as defined in ReadHeaderAndData()366 //367 Function SkipAndDecompressVAX(in,out)368 Wave in,out369 370 Variable skip,ii371 372 ii=0373 skip=0374 do375 if(mod(ii+skip,1022)==0)376 skip+=1377 endif378 out[ii] = Decompress(in[ii+skip])379 ii+=1380 while(ii<16384)381 return(0)382 End383 384 //decompresses each I*2 data value to its real I*4 value385 //using the decompression routine written by Jim Ryhne, many moons ago386 //387 // the compression routine (not shown here, contained in the VAX fortran RW_DATAFILE.FOR) maps I4 to I2 values.388 // (back in the days where disk space *really* mattered). the I4toI2 function spit out:389 // I4toI2 = I4 when I4 in [0,32767]390 // I4toI2 = -777 when I4 in [2,767,000,...]391 // I4toI2 mapped to -13277 to -32768 otherwise392 //393 // the mapped values [-776,-1] and [-13276,-778] are not used.394 // in this compression scheme, only 4 significant digits are retained (to allow room for the exponent)395 // technically, the maximum value should be 2,768,499 since this maps to -32768. But this is of396 // little consequence. If you have individual pixel values on the detector that are that large, you need397 // to re-think your experiment.398 Function Decompress(val)399 Variable val400 401 Variable i4,npw,ipw,ib,nd402 403 ib=10404 nd=4405 ipw=ib^nd406 i4=val407 408 if (i4 <= -ipw)409 npw=trunc(-i4/ipw)410 i4=mod(-i4,ipw)*(ib^npw)411 return i4412 else413 return i4414 endif415 End416 417 //****************418 //main entry procedure for reading a "WORK.DIV" file419 //displays a quick image of the file, to check that it's correct420 //data is deposited in root:DIV data folder421 //422 Proc ReadWork_DIV()423 // Silent 1424 425 String fname = PromptForPath("Select detector sensitivity file")426 ReadHeaderAndWork("DIV",fname) //puts what is read in work.div427 428 String waveStr = "root:DIV:data"429 NewImage/F/K=1/S=2 $waveStr //this is an experimental IGOR operation430 ModifyImage '' ctab= {*,*,YellowHot,0}431 //Display;AppendImage $waveStr432 433 //change the title string to WORK.DIV, rather than PLEXnnn_TST_asdfa garbage434 String/G root:DIV:fileList = "WORK.DIV"435 436 SetDataFolder root: //(redundant)437 // Silent 0438 End439 440 //testing procedure that is not called anymore and is out-of-date441 //with the new data structures. update before re-implementing442 Proc ReadBinaryWork() //this procedure is not called anymore443 444 // Silent 1445 446 //make sure the globals are reset properly447 Variable/G root:myGlobals:gIsLogScale=0 //image is linearly scaled to begin with448 String/G root:myGlobals:gDataDisplayType="RAW" //displayed data type is raw449 450 //each routine is responsible for checking the current (displayed) data folder451 //selecting it, and returning to root when done452 453 ReadHeaderAndWork()454 455 SetDataFolder root:RAW456 //data is displayed here457 Display;AppendImage data458 459 // Silent 0460 461 //data folder was changed from root in this macro462 SetDataFolder root:463 End464 465 //this function is the guts of reading a rinary VAX file of real (4-byte) values466 // (i.e. a WORK.aaa file)467 // work files have the same header structure as RAW SANS data, just with468 //different data (real, rather than compressed integer data)469 //470 //************471 //this routine incorrectly reads in several data values where the VAX record472 //marker splits the 4-byte real (at alternating record markers)473 //this error seems to not be severe, but shoud be corrected (at great pain)474 //************475 //476 Function ReadHeaderAndWork(type,fname)477 String type,fname478 479 //type is the desired folder to read the workfile to480 //this data will NOT be automatically displayed gDataDisplayType is unchanged481 482 // SVAR cur_folder=root:myGlobals:gDataDisplayType483 String cur_folder = type484 String curPath = "root:"+cur_folder485 SetDataFolder curPath //use the full path, so it will always work486 487 Variable refNum,integer,realval488 String sansfname,textstr489 Variable/G $(curPath + ":gIsLogScale") = 0 //initial state is linear, keep this in DIV folder490 491 Make/O/N=23 $(curPath + ":IntegersRead")492 Make/O/N=52 $(curPath + ":RealsRead")493 Make/O/T/N=11 $(curPath + ":TextRead")494 495 WAVE intw=$(curPath + ":IntegersRead")496 WAVE realw=$(curPath + ":RealsRead")497 WAVE/T textw=$(curPath + ":TextRead")498 499 //***NOTE ****500 // the "current path" gets mysteriously reset to "root:" after the SECOND pass through501 // this read routine, after the open dialog is presented502 // the "--read" waves end up in the correct folder, but the data does not! Why?503 //must re-set data folder before writing data array (done below)504 505 SetDataFolder curPath506 507 //actually open the file508 Open/R refNum as fname509 //skip first two bytes510 FSetPos refNum, 2511 //read the next 21 bytes as characters (fname)512 FReadLine/N=21 refNum,textstr513 textw[0]= textstr514 //read four i*4 values /F=3 flag, B=3 flag515 FBinRead/F=3/B=3 refNum, integer516 intw[0] = integer517 //518 FBinRead/F=3/B=3 refNum, integer519 intw[1] = integer520 //521 FBinRead/F=3/B=3 refNum, integer522 intw[2] = integer523 //524 FBinRead/F=3/B=3 refNum, integer525 intw[3] = integer526 // 6 text fields527 FSetPos refNum,55 //will start reading at byte 56528 FReadLine/N=20 refNum,textstr529 textw[1]= textstr530 FReadLine/N=3 refNum,textstr531 textw[2]= textstr532 FReadLine/N=11 refNum,textstr533 textw[3]= textstr534 FReadLine/N=1 refNum,textstr535 textw[4]= textstr536 FReadLine/N=8 refNum,textstr537 textw[5]= textstr538 FReadLine/N=60 refNum,textstr539 textw[6]= textstr540 541 //3 integers542 FSetPos refNum,174543 FBinRead/F=3/B=3 refNum, integer544 intw[4] = integer545 FBinRead/F=3/B=3 refNum, integer546 intw[5] = integer547 FBinRead/F=3/B=3 refNum, integer548 intw[6] = integer549 550 //2 integers, 3 text fields551 FSetPos refNum,194552 FBinRead/F=3/B=3 refNum, integer553 intw[7] = integer554 FBinRead/F=3/B=3 refNum, integer555 intw[8] = integer556 FReadLine/N=6 refNum,textstr557 textw[7]= textstr558 FReadLine/N=6 refNum,textstr559 textw[8]= textstr560 FReadLine/N=6 refNum,textstr561 textw[9]= textstr562 563 //2 integers564 FSetPos refNum,244565 FBinRead/F=3/B=3 refNum, integer566 intw[9] = integer567 FBinRead/F=3/B=3 refNum, integer568 intw[10] = integer569 570 //2 integers571 FSetPos refNum,308572 FBinRead/F=3/B=3 refNum, integer573 intw[11] = integer574 FBinRead/F=3/B=3 refNum, integer575 intw[12] = integer576 577 //2 integers578 FSetPos refNum,332579 FBinRead/F=3/B=3 refNum, integer580 intw[13] = integer581 FBinRead/F=3/B=3 refNum, integer582 intw[14] = integer583 584 //3 integers585 FSetPos refNum,376586 FBinRead/F=3/B=3 refNum, integer587 intw[15] = integer588 FBinRead/F=3/B=3 refNum, integer589 intw[16] = integer590 FBinRead/F=3/B=3 refNum, integer591 intw[17] = integer592 593 //1 text field594 FSetPos refNum,404595 FReadLine/N=42 refNum,textstr596 textw[10]= textstr597 598 //1 integer599 FSetPos refNum,458600 FBinRead/F=3/B=3 refNum, integer601 intw[18] = integer602 603 //4 integers604 FSetPos refNum,478605 FBinRead/F=3/B=3 refNum, integer606 intw[19] = integer607 FBinRead/F=3/B=3 refNum, integer608 intw[20] = integer609 FBinRead/F=3/B=3 refNum, integer610 intw[21] = integer611 FBinRead/F=3/B=3 refNum, integer612 intw[22] = integer613 614 Close refNum615 616 //now get all of the reals617 //618 //Do all the GBLoadWaves at the end619 //620 //FBinRead Cannot handle 32 bit VAX floating point621 //GBLoadWave, however, can properly read it622 String GBLoadStr="GBLoadWave/O/N=tempGBwave/T={2,2}/J=2/W=1/Q"623 String strToExecute624 //append "/S=offset/U=numofreals" to control the read625 // then append fname to give the full file path626 // then execute627 628 Variable a=0,b=0629 630 SetDataFolder curPath631 // 4 R*4 values632 strToExecute = GBLoadStr + "/S=39/U=4" + "\"" + fname + "\""633 Execute strToExecute634 635 SetDataFolder curPath636 Wave w=$(curPath + ":tempGBWave0")637 b=4 //num of reals read638 realw[a,a+b-1] = w[p-a]639 a+=b640 641 // 4 R*4 values642 SetDataFolder curPath643 strToExecute = GBLoadStr + "/S=158/U=4" + "\"" + fname + "\""644 Execute strToExecute645 b=4646 realw[a,a+b-1] = w[p-a]647 a+=b648 649 ///////////650 // 2 R*4 values651 SetDataFolder curPath652 strToExecute = GBLoadStr + "/S=186/U=2" + "\"" + fname + "\""653 Execute strToExecute654 b=2655 realw[a,a+b-1] = w[p-a]656 a+=b657 658 // 6 R*4 values659 SetDataFolder curPath660 strToExecute = GBLoadStr + "/S=220/U=6" + "\"" + fname + "\""661 Execute strToExecute662 b=6663 realw[a,a+b-1] = w[p-a]664 a+=b665 666 // 13 R*4 values667 SetDataFolder curPath668 strToExecute = GBLoadStr + "/S=252/U=13" + "\"" + fname + "\""669 Execute strToExecute670 b=13671 realw[a,a+b-1] = w[p-a]672 a+=b673 674 // 3 R*4 values675 SetDataFolder curPath676 strToExecute = GBLoadStr + "/S=320/U=3" + "\"" + fname + "\""677 Execute strToExecute678 b=3679 realw[a,a+b-1] = w[p-a]680 a+=b681 682 // 7 R*4 values683 SetDataFolder curPath684 strToExecute = GBLoadStr + "/S=348/U=7" + "\"" + fname + "\""685 Execute strToExecute686 b=7687 realw[a,a+b-1] = w[p-a]688 a+=b689 690 // 4 R*4 values691 SetDataFolder curPath692 strToExecute = GBLoadStr + "/S=388/U=4" + "\"" + fname + "\""693 Execute strToExecute694 b=4695 realw[a,a+b-1] = w[p-a]696 a+=b697 698 // 2 R*4 values699 SetDataFolder curPath700 strToExecute = GBLoadStr + "/S=450/U=2" + "\"" + fname + "\""701 Execute strToExecute702 b=2703 realw[a,a+b-1] = w[p-a]704 a+=b705 706 // 2 R*4 values707 SetDataFolder curPath708 strToExecute = GBLoadStr + "/S=470/U=2" + "\"" + fname + "\""709 Execute strToExecute710 b=2711 realw[a,a+b-1] = w[p-a]712 a+=b713 714 // 5 R*4 values715 SetDataFolder curPath716 strToExecute = GBLoadStr + "/S=494/U=5" + "\"" + fname + "\""717 Execute strToExecute718 b=5719 realw[a,a+b-1] = w[p-a]720 721 //if the binary VAX data ws transferred to a MAC, all is OK722 //if the data was trasnferred to an Intel machine (IBM), all the real values must be723 //divided by 4 to get the correct floating point values724 // I can't find any combination of settings in GBLoadWave or FBinRead to read data in correctly725 // on an Intel machine.726 //With the corrected version of GBLoadWave XOP (v. 1.43 or higher) Mac and PC both read727 //VAX reals correctly, and no checking is necessary 12 APR 99728 //if(cmpstr("Macintosh",IgorInfo(2)) == 0)729 //do nothing730 //else731 //either Windows or Windows NT732 //realw /= 4733 //endif734 735 //read in the data736 GBLoadStr="GBLoadWave/O/N=tempGBwave/T={2,2}/J=2/W=1/Q"737 738 curPath = "root:"+cur_folder739 SetDataFolder curPath //use the full path, so it will always work740 741 Make/O/N=16384 $(curPath + ":data")742 WAVE data = $(curPath + ":data")743 744 Variable skip,ii,offset745 746 //read in a total of 16384 values (ii)747 //as follows :748 // skip first 2 bytes749 // skip 512 byte header750 // skip first 2 bytes of data751 //(read 511 reals, skip 2b, 510 reals, skip 2b) -16 times = 16336 values752 // read the final 48 values in seperately to avoid EOF error753 754 /////////////755 SetDataFolder curPath756 skip = 0757 ii=0758 offset = 514 +2759 a=0760 do761 SetDataFolder curPath762 763 strToExecute = GBLoadStr + "/S="+num2str(offset)+"/U=511" + "\"" + fname + "\""764 Execute strToExecute765 //Print strToExecute766 b=511767 data[a,a+b-1] = w[p-a]768 a+=b769 770 offset += 511*4 +2771 772 strToExecute = GBLoadStr + "/S="+num2str(offset)+"/U=510" + "\"" + fname + "\""773 SetDataFolder curPath774 Execute strToExecute775 //Print strToExecute776 b=510777 data[a,a+b-1] = w[p-a]778 a+=b779 780 offset += 510*4 +2781 782 ii+=1783 //Print "inside do, data[2] =",data[2]784 //Print "inside do, tempGBwave0[0] = ",w[0]785 while(ii<16)786 787 // 16336 values have been read in --788 //read in last 64 values789 strToExecute = GBLoadStr + "/S="+num2str(offset)+"/U=48" + "\"" + fname + "\""790 791 SetDataFolder curPath792 Execute strToExecute793 b=48794 data[a,a+b-1] = w[p-a]795 a+=b796 //797 /// done reading in raw data798 //799 //Print "in workdatareader , data = ", data[1][1]800 801 Redimension/n=(128,128) data802 803 //clean up - get rid of w = $"tempGBWave0"804 KillWaves w805 806 //divide the FP data by 4 if read from a PC (not since GBLoadWave update)807 //if(cmpstr("Macintosh",IgorInfo(2)) == 0)808 //do nothing809 //else810 //either Windows or Windows NT811 //data /= 4812 //endif813 814 //keep a string with the filename in the DIV folder815 String/G $(curPath + ":fileList") = textw[0]816 817 //return the data folder to root818 SetDataFolder root:819 820 Return(0)821 End822 823 //returns the path to the file, or null if cancel824 Function/S DoOpenFileDialog(msg)825 String msg826 827 Variable refNum828 // String message = "Select a file"829 String outputPath830 831 Open/D/R/T="????"/M=msg refNum832 outputPath = S_fileName833 834 return outputPath835 End836 837 // returns the path to the file, or null if the user cancelled838 Function/S DoSaveFileDialog(msg)839 String msg840 Variable refNum841 // String message = "Save the file as"842 String outputPath843 844 Open/D/M=msg refNum845 outputPath = S_fileName846 847 return outputPath848 End
Note: See TracChangeset
for help on using the changeset viewer.