-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #191 from h2020charisma/spc-multimap
Add support for SPC multidimentional maps
- Loading branch information
Showing
3 changed files
with
26 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
from .spc import read_map_spc |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
from collections import namedtuple | ||
from typing import Dict | ||
|
||
import spc_io | ||
|
||
from ...misc.types import SpeMetadataModel | ||
from ..spectrum import Spectrum | ||
|
||
SPCMapCoordinates = namedtuple('SPCMapCoordinates', ['z', 'w']) | ||
|
||
|
||
def read_map_spc(filename: str) -> Dict[SPCMapCoordinates, Spectrum]: | ||
spc = spc_io.SPC.from_bytes_io(open(filename, 'rb')) | ||
|
||
ret = dict() | ||
|
||
spc_meta = {k.strip(): v.strip() for k, v in spc.log_book.text.items()} | ||
for meas in spc: | ||
spe_meta = {} | ||
spe_meta.update(spc_meta) | ||
spe_meta.update(dict(w=meas.w, z=meas.z)) | ||
ret[SPCMapCoordinates(w=meas.w, z=meas.z)] = Spectrum(x=meas.xarray, y=meas.yarray, | ||
metadata=SpeMetadataModel.model_validate(spe_meta)) | ||
return ret |