analyseScript/ToolFunction/ToolFunction.py

48 lines
928 B
Python
Raw Normal View History

2023-05-04 19:16:35 +02:00
import numpy as np
import glob
from datetime import date
2023-05-04 18:32:17 +02:00
2023-05-04 19:16:35 +02:00
def get_mask(dataArray):
return np.ones(dataArray.shape, dtype=bool)
2023-05-04 18:32:17 +02:00
2023-05-04 19:16:35 +02:00
def remove_bad_shots(dataArray, **kwargs):
dataArray.loc[dict(kwargs)] = np.nan
2023-05-04 18:32:17 +02:00
2023-05-04 19:16:35 +02:00
def auto_rechunk(dataSet):
kwargs = {
key: "auto"
2023-05-05 18:25:03 +02:00
for key in dataSet.dims
2023-05-04 19:16:35 +02:00
}
return dataSet.chunk(**kwargs)
2023-05-04 18:32:17 +02:00
2023-05-06 11:23:38 +02:00
def copy_chunk(dataSet, dataChunk):
kwargs = {
key: dataChunk.chunksizes[key]
for key in dataChunk.chunksizes
if key in dataSet.dims
}
return dataSet.chunk(**kwargs)
2023-05-04 19:16:35 +02:00
def get_h5_file_path(folderpath, maxFileNum=None, filename='*.h5',):
filepath = np.sort(glob.glob(folderpath + filename))
if maxFileNum is None:
return filepath
else:
return filepath[:maxFileNum]
def get_date():
today = date.today()
2023-05-05 18:25:03 +02:00
return today.strftime("%y/%m/%d")
2023-05-06 11:23:38 +02:00
2023-05-05 18:25:03 +02:00
def resolve_fit_result(fitResult):
return