The Origin Forum
File Exchange
Try Origin for Free
The Origin Forum
Home | Profile | Register | Active Topics | Members | Search | FAQ | Send File to Tech support
Username:
Password:
Save Password
Forgot your Password? | Admin Options

 All Forums
 Origin Forum for Programming
 Forum for Origin C
 Binary import of spectra in .spe format!
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic

osohr

Germany
4 Posts

Posted - 03/01/2007 :  08:01:29 AM  Show Profile  Edit Topic  Reply with Quote  View user's IP address  Delete Topic
Origin Version 7.5 SR6 german:
Operating System: win 2000

Hi,

I can import the pixel intensities of my spectra with the princeton instruments (*.spe) import filter. the x-axis can be calculated with some parameters from the header. The filter writes the complete header (more than 100 lines) into the notes window.
How can i modify the OC- filter to drop the following parameters into LT
variables for x-axis calculation:
....
calib_xpolynom_coeff0 = 538.197893442706
calib_xpolynom_coeff1 = 0.102408269881526
calib_xpolynom_coeff2 = -1.53844343185115e-006
calib_xpolynom_coeff3 = 0.
calib_xpolynom_coeff4 = 0.
calib_xpolynom_coeff5 = 0.
calib_xlaser_position = 532.
....

Maybe the calculation of the x-axis could be done by OC much quicker, but basically the transfer of these specific parameters to LT would be sufficient.

There was a topic with the same problem in 2004, a solution wasn´t documented.

Thanks to all,

Oliver

Mike Buess

USA
3037 Posts

Posted - 03/01/2007 :  09:49:37 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hi Oliver,

This OC function reads the named Notes window and converts all lines that start with "calib_" to LabTalk variables. I don't know what your import filter looks like now but you might be able to run this function from advanced filter options.
void get_calib_info(string strNote)
{
Note note(strNote);
string str1,str2,str = note.Text;
StringArray sa;
str.GetTokens(sa,'\n');
for(int i=0;i<sa.GetSize();i++)
{
if( sa[i].Find("calib_")==0 )
{
str1 = sa[i].GetToken(0,'=');
str2 = sa[i].GetToken(1,'=');
LT_set_var(str1,atof(str2));
}
}
}


Mike Buess
Origin WebRing Member
Go to Top of Page

osohr

Germany
4 Posts

Posted - 03/01/2007 :  11:38:20 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hi Mike,

I get two runtime errors when i call this function. It compiled without errors. Do i have to include anything.
For the Import of the intensities I use the Import Filter Script:
princetoninstruments.c that you can find in originlabs download area.
I think the relevant part of the script is this:

..

//--------------------------------------------------------------------------
// ImportFileToPage
//
// Imports an SPE file into the specified page.
//--------------------------------------------------------------------------
static int ImportFileToPage(Page& pgTarget, LPCSTR lpcszFile, int nFile)
{
// Open data file
file filSrc;
if( !filSrc.Open(lpcszFile, file::modeRead | file::typeBinary | file::shareDenyWrite) )
return SPE_ERR_FILE_OPEN;

// Read header
SPEHEADER spehdr;
int iRet = filSrc.Read(&spehdr, sizeof(SPEHEADER));
if( sizeof(SPEHEADER) == iRet )
{
// Read data into page
if( 1 == spehdr.ydim )
iRet = Import1DimToPage(pgTarget, filSrc, spehdr);
else
iRet = Import2DimToPage(pgTarget, filSrc, spehdr);

spe_SetPageNameAndLabel(pgTarget, spehdr, lpcszFile);

// Output header to Notes window
if( !iRet )
iRet = spe_HeaderToNotes(spehdr, lpcszFile);
}
else
iRet = SPE_ERR_READ_HEADER;

// Close data file
filSrc.Close();

return iRet;
}
...


maybe its easier to modify the original OC script, because with every import of a *.spe file into one project creates another notes window called "Notes".

Thank you for your quick response!

oliver
Go to Top of Page

osohr

Germany
4 Posts

Posted - 03/01/2007 :  11:52:02 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
..OK now your function runs smooth. The specific names(filename) of the notes windows were just hidden.

But how can i find the variables in LT? They should be num var with the identical names from the header !? list v in LT doesn´t show them.

Thanks again

oliver
Go to Top of Page

Mike Buess

USA
3037 Posts

Posted - 03/01/2007 :  12:46:44 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
I copied your original list of header lines to a notes window, ran the function and then 'list v'...

...
45 CALIB_XPOLYNOM_COEFF0 1 538.19789
46 CALIB_XPOLYNOM_COEFF1 1 0.10241
47 CALIB_XPOLYNOM_COEFF2 1 -0
48 CALIB_XPOLYNOM_COEFF3 1 0
49 CALIB_XPOLYNOM_COEFF4 1 0
50 CALIB_XPOLYNOM_COEFF5 1 0
51 CALIB_XLASER_POSITION 1 532

Possibly the lines start with # or some other character?

Mike Buess
Origin WebRing Member
Go to Top of Page

osohr

Germany
4 Posts

Posted - 03/01/2007 :  1:18:01 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
...yessss!!

two spaces in front of every new line!
now it works!

Thanks a lot!
Go to Top of Page
  Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
The Origin Forum © 2020 Originlab Corporation Go To Top Of Page
Snitz Forums 2000