Modifying creation date of a wave
hiller
My waves are taken from an oscilloscope, so I'd like to put the trigger time stamp into the creation time. This could then be retrieved by creationdate(wave), and remain a fixed value despite other operations on the wave. The trigger time may differ from the wave creation time if the trace is not downloaded from the scope immediately.
Note <waveName>,"CREATIONDATE="+<your date here>+";"
and extracting with stringByKey("CREATIONDATE",note(<waveName>),"=",";") at any later time. The KEY=VALUE; approach allows you to put any number of data points in any order, as a bonus.
Regards,
Patrick.
May 18, 2009 at 09:36 pm - Permalink
I have written a function which lets you set the creation date of a igor binary wave. It requires that the wave is saved to disk as .ibw file. You can't process a wave which is part of a Igor experiment, but temporarily write a wave do disk, change the creation date, load the wave back in and then delete the file shouldn't be so difficult.
Here comes the code:
function modifyCreationDate(year,month,day,hour,minute,second)
variable year,month,day,hour,minute,second
string oldDF=getdatafolder(1)
string newDF=uniquename("newDF",11,0)
newdatafolder/s $newDF
variable creationDateMOD=date2secs(year,month,day)+hour*3600+minute*60+second
variable refnum,version,creationDatePos,headerlenAsWords,checksumPos
open/t=".ibw"/m="choose ibw file"/z=2/a refnum
// print V_flag
if(V_flag!=0)
setdatafolder $oldDF
killdatafolder $newDF
return V_flag
endif
fstatus refnum
// get igor binary version:
fsetpos refnum,0
fbinread/f=2 refnum,version
switch(version)
case 2:
creationDatePos=112
checksumPos=14
headerlenAsWords=142/2
break
case 5:
creationDatePos=68
checksumPos=2
headerlenAsWords=384/2
break
default:
print "Couldn't determine Igor binary version!"
fsetpos refnum,V_logEOF
close refnum
setdatafolder $oldDF
killdatafolder $newDF
return version
endswitch
// print version
// write new creation date:
fsetpos refnum,creationDatePos
fbinwrite/f=3/u refnum,creationDateMOD
// calculate checksum:
make/o/n=(headerlenAsWords)/w W_header
fsetpos refnum,0
fbinread refnum,W_header
W_header[checksumPos/2]=0
make/o/n=1/w W_checksum= -sum(W_header)
// write ckecksum:
fsetpos refnum,checksumPos
fbinwrite refnum,W_checksum
// clean up:
fsetpos refnum,V_logEOF
close refnum
setdatafolder $oldDF
killdatafolder $newDF
return creationDateMOD
end
May 19, 2009 at 04:50 am - Permalink