开发者

How to read data from a Nicolet FTIR spectral file with extension of *.spa

开发者 https://www.devze.com 2023-01-01 04:02 出处:网络
Is the *.spa binary file format trade 开发者_JS百科secret? But Perkin Elmer released *.sp format to public;
  1. Is the *.spa binary file format trade 开发者_JS百科secret? But Perkin Elmer released *.sp format to public;

  2. how to read?


I know this thread is a bit old now, but I needed to read SPA files recently, and would like to share how I managed to cope with them.
As stated by cooooldog, 0x41c offset is not standard. However, this offset is coded in the spa file itself.
When editing a spa file, there is a short header at the beginning, then many zeros. From 0x11e are non-zero values.
Here is how I managed to find the correct offset for my spectral files:
Starting from 0x11e, I start reading int32 values. It appears that the data offset is coded just before this value : 54 18 00 00 (which is 6228 in decimal).
Edit : I've received new set of spa files where the searched pattern is no longer 54 18 00 00 but 40 61 00 00 (24896), so this might not be standard as well. In fact it appears that starting address is either coded at 172h or 182h in the spa file. I do still need a way to find it out.
So by looking for 6228, the offset needed to find data later in the file is the integer found just before this value of 6228.
If you continue editing your spa file, you should find floating point values, 32-bit coded, placed just after a bunch of text.
From now, reading those values is possible, by just replacing 0x41c by the address found.
If this may help anyone...

function address = getStart(filename)  
    try  
        % Open the file  
        fid=fopen(filename,'r');  
        % Jump where the values become interesting  
        fseek(fid,hex2dec('11e'),'bof');  
        % Pattern we're looking for  
        pattern = 6228;  
        suspect = 0;  
        while suspect~=pattern  
            oldSuspect = suspect;  
            suspect    = fread(fid,1,'int32');  
        end  
        % The correct address is just before our current suspect  
        address = oldSuspect;  
        % Close the file  
        fclose(fid);  
    catch ex  
        address = 0;  
        disp(ex)  
end  


I found where the spectral offset is set, it is on position 386:

fseek(fid,386,'bof'); 
spectral_offset = fread(fid,1,'int32')

fseek(fid,spectral_offset,'bof'); 
spectrum=fread(fid,Number_of_DataPoints,'single');


Matlab implementation

https://cn.mathworks.com/matlabcentral/fileexchange/57904-loadspectra

You need to import the spectrum files in order to analyze FTIR and NIR absorbance data. This function loads data from .SPA format files into matrices with the spectra organized into columns.

C/C++ implemetation:

There is a small open source project on Github:

https://github.com/aitap/spa2txt

The program reads Nicolet FTIR spectral files (*.spa extension) and produces text files with the first line corresponding to the title, and every other line being in the format: wavenumber, tab, absorbance, newline.

Usage: feed *.spa files as command line arguments. Files with names *.spa.txt will be created.


'how to deal with.spa (spectrum analyzer output files ) usnig matlab' well i think the best way to deal with reading .spa files is first to convert it to txt using 'notepad' file and then import it to matlab using the importing tool which gives you a huge amount of functions starting from tab delimited and ending with custom delimited after that you select the frequencies and the received power you need to extrat from .spa file for more details you can check

https://nl.mathworks.com/videos/importing-data-from-text-files-interactively-71076.html

it was a great help for me dealing with .spa spectrum analyzer output files

:)

0

精彩评论

暂无评论...
验证码 换一张
取 消