-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ref: restructure file_format submodule
- Loading branch information
1 parent
8aac6c0
commit a356df0
Showing
16 changed files
with
95 additions
and
85 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
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
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
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
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
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
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,48 @@ | ||
import abc | ||
|
||
from .series_base import SeriesData | ||
|
||
|
||
class SingleData(SeriesData): | ||
"""Single data file format base class | ||
Parameters | ||
---------- | ||
path: str or pathlib.Path | ||
Path to the experimental data file. | ||
meta_data: dict | ||
Dictionary containing meta data. | ||
see :py:class:`qpimage.META_KEYS`. | ||
as_type: str | ||
Defines the data type that the input data is casted to. | ||
The default is "float32" which saves memory. If high | ||
numerical accuracy is required (does not apply for a | ||
simple 2D phase analysis), set this to double precision | ||
("float64"). | ||
""" | ||
__meta__ = abc.ABCMeta | ||
is_series = False | ||
|
||
def __len__(self): | ||
return 1 | ||
|
||
def get_identifier(self, idx=0): | ||
return self.identifier | ||
|
||
def get_name(self, idx=0): | ||
return super(SingleData, self).get_name(idx=0) | ||
|
||
def get_qpimage(self, idx=0): | ||
return super(SingleData, self).get_qpimage(idx=0) | ||
|
||
@abc.abstractmethod | ||
def get_qpimage_raw(self, idx=0): | ||
"""QPImage without background correction""" | ||
|
||
def get_time(self, idx=0): | ||
"""Time of the data | ||
Returns nan if the time is not defined | ||
""" | ||
thetime = super(SingleData, self).get_time(idx=0) | ||
return thetime |
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,29 @@ | ||
import hashlib | ||
|
||
import numpy as np | ||
|
||
|
||
def hash_obj(data, maxlen=5): | ||
hasher = hashlib.md5() | ||
tohash = obj2bytes(data) | ||
hasher.update(tohash) | ||
return hasher.hexdigest()[:maxlen] | ||
|
||
|
||
def obj2bytes(data): | ||
tohash = [] | ||
if isinstance(data, (tuple, list)): | ||
for item in data: | ||
tohash.append(obj2bytes(item)) | ||
elif isinstance(data, str): | ||
tohash.append(data.encode("utf-8")) | ||
elif isinstance(data, bytes): | ||
tohash.append(data) | ||
elif isinstance(data, np.ndarray): | ||
tohash.append(data.tobytes()) | ||
elif isinstance(data, int): | ||
tohash.append(bytes(data)) | ||
else: | ||
msg = "No rule to convert to bytes: {}".format(data) | ||
raise NotImplementedError(msg) | ||
return b"".join(tohash) |
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 @@ | ||
pytest |