Skip to content

Commit

Permalink
Merge pull request Quasars#751 from ngergihun/newneareader
Browse files Browse the repository at this point in the history
[ENH] Single NeaGSF reader with measurement.signaltype attribute
markotoplak authored Oct 3, 2024

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
2 parents c80bcca + 3a33a12 commit fce710e
Showing 1 changed file with 30 additions and 1 deletion.
31 changes: 30 additions & 1 deletion orangecontrib/spectroscopy/io/neaspec.py
Original file line number Diff line number Diff line change
@@ -8,7 +8,7 @@
from scipy.interpolate import interp1d

from orangecontrib.spectroscopy.io.gsf import reader_gsf
from orangecontrib.spectroscopy.io.util import SpectralFileFormat
from orangecontrib.spectroscopy.io.util import SpectralFileFormat, _spectra_from_image
from orangecontrib.spectroscopy.utils import MAP_X_VAR, MAP_Y_VAR

class NeaReader(FileFormat, SpectralFileFormat):
@@ -335,6 +335,35 @@ def _gsf_reader(self, path):
return np.asarray(X)


class NeaImageGSF(FileFormat, SpectralFileFormat):

EXTENSIONS = (".gsf",)
DESCRIPTION = 'Single NeaGSF image files'

def read_spectra(self):

channel_strings = ['M(.?)A', 'M(.?)P', 'O(.?)A', 'O(.?)P', 'Z C', 'Z raw']
for pattern in channel_strings:
if re.search(pattern, self.filename) is not None:
channel_name = re.search(pattern, self.filename)[0]

if 'P' in channel_name:
signal_type = "Phase"
elif 'A' in channel_name:
signal_type = "Amplitude"
elif 'Z' in channel_name:
signal_type = "Topography"
else:
signal_type = "None"

X, XRr, YRr = reader_gsf(self.filename)
features, final_data, meta_data = _spectra_from_image(X, np.array([1]), XRr, YRr)

meta_data.attributes["measurement.signaltype"] = signal_type

return features, final_data, meta_data


class NeaReaderMultiChannel(FileFormat, SpectralFileFormat):
EXTENSIONS = (".txt",)
DESCRIPTION = "NeaSPEC multichannel (raw) IFGs"

0 comments on commit fce710e

Please sign in to comment.