fujiisoup / sif_parser

A small package to read Andor Technology Multi-Channel files.
BSD 3-Clause "New" or "Revised" License
15 stars 5 forks source link

Addition of Raman laser wavelength to the metadata ordereddict #12

Closed DDuijnstee closed 2 years ago

DDuijnstee commented 2 years ago

Dear fujiisoup,

I have made use of your sifreader package on github, and I have a suggestion for a small addition.

The change I would suggest is reading out an additional line (if present) on the laser wavelength used in a Raman spectroscopy experiment. In this technique the unit used is usually wavenumber (calculated from the wavelength calibration and a manually entered laser wavelength).

From the way the package is written now, it seems the line in which this value is stored is normally supposed to be empty, and therefore your package skips over it. The proposed change is to have a check whether the line contains something different from the standard filling, and if so add the value stored there to the ordereddict your functions already return. This would constitute the addition of a few lines of code that should not interfere with any other part of your package.

Specifically, below I copied the altered lines corresponding to 155 to 157 in your original script:

fp.readline() # 0 1 0 0 newline
fp.readline() # 0 1 0 0 newline
#fp.readline() # 0 1 0 0 newline
try: info['RamanExWavelength'] = _read_float(fp)
except: pass

This is an example version written with limited experience in coding, so if a better solution that arrives at the same result is available that'd of course be great.

The last of these three fp.readline() lines should contain the laser wavelength if present. It has worked on all files I tried until now (from different machines, with a range of wavelength values stored in the line), but for some reason I haven't encountered any where the line actually corresponded to a 0 1 0 0 newline as the package says it should be, rather if 'empty' the line contained a standard value of 433, even when taken from a freshly installed version of andor solis.

Due to my inability to get a proper test case for it, I decided to just allow the program to skip the line if it wasn't able to read the value into a float, which effectively should do the same as what your third line does now.

Can this be integrated into the package?

Looking forward to your reply, DDuijnstee

DDuijnstee commented 2 years ago

example .sif files with raman laser wavelength = 785 and 364.67 respectively siffilesDDuijnstee.zip

fujiisoup commented 2 years ago

Thanks @DDuijnstee It would be a good addition. I'll work on that. Your file would also help.

DDuijnstee commented 2 years ago

the edited version of _sif_open.py newversion_sif_open.zip

fujiisoup commented 2 years ago

Solved by #13. Hoping it helps!