Hide keyboard shortcuts

Hot-keys on this page

r m x p   toggle line displays

j k   next/prev highlighted chunk

0   (zero) top of page

1   (one) first highlighted chunk

1# SPDX-FileCopyrightText: 2020 Jonathan Pieper <jpieper@stud.uni-frankfurt.de> 

2# 

3# SPDX-License-Identifier: GPL-3.0-or-later 

4 

5""" 

6Main parent class for all multiple measurements. 

7These Measurements are represent by one data variable. 

8 

9All multiple measurements have a variable called ``multi_info`` which contains 

10a pandas.DataFrame with parameter settings to single measurements. 

11 

12All single can be represented by 

13 

14 >>> m = ana.MultipleM() 

15 >>> m 

16 Nr. 0: Hloop 

17 Nr. 0: RAW 

18""" 

19 

20from .measurement import MeasurementClass 

21 

22import os 

23import pandas as pd 

24 

25class MultipleM(MeasurementClass): 

26 def __init__(self): 

27 """MultipleM: 

28 

29 Main parent class for all multiple measurements. These Measurements 

30 are represent by one data variable. 

31 

32 All multiple measurements have a variable called ``multi_info`` which 

33 contains a pandas.DataFrame with parameter settings to single 

34 measurements. 

35 

36 All multiple measurements can be represented by 

37 

38 >>> m = ana.MultipleM() 

39 >>> m 

40 Nr. 0: Hloop 

41 Nr. 0: RAW 

42 """ 

43 

44 super().__init__() 

45 self.multi_info = pd.DataFrame() 

46 if os.path.exists('data/mfn_info.csv'): 

47 self.read_csv('data/mfn_info.csv') 

48 

49 

50 query = lambda self, request: self.multi_info.query(request) 

51 

52 def get_lofm_sweeps(self, to_show, label, options={}): 

53 """Workaround to get list of measurements for sweeps. 

54 

55 Args: 

56 to_show (dict): Measurement Numbers pointing to label format 

57 variables: e.g. `` {nr: [-1, 1, 'Plusses', '2 mT/min']} 

58 label (str): Label to show in plots: e.g. "Show %s -> %s (%s) %s " 

59 -> will be formated using to_show 

60 options (dict, default: empty): Additional plotting options 

61 

62 Returns: 

63 dict: List of Measurements with description 

64 """ 

65 

66 return self.get_lofm(to_show, 

67 label, 

68 options) 

69 

70 def read_csv(self, *args, **kwargs): 

71 """Updates multi_info DataFrame. Reads csv and adds information to 

72 self.multi_info 

73 

74 Args: 

75 *args: 

76 **kwargs: 

77 

78 Returns: 

79 None 

80 """ 

81 

82 self.multi_info = pd.concat([self.multi_info, pd.read_csv(*args, **kwargs)]) 

83 

84 def get_lofm(self, to_show, label, options={}): 

85 """Returns the List of Measurements (lofm) for plot functions 

86 (see :meth:`ana.HandleM.plot`). 

87 

88 Args: 

89 to_show (dict): Measurement Numbers pointing to label format 

90 variables: e.g. ``{nr: [(-1, 1), 'Plusses', '5 mT/min']}`` 

91 label (str): Label to show in plots: e.g. 

92 ``"Show %s -> %s (%s) %s "`` -> will be string formated using 

93 to_show 

94 options (dict, optional, default: empty): Additional plotting 

95 parameters 

96 

97 Returns: 

98 dict: List of Measurements with description: ``{nr: [labels]}`` 

99 """ 

100 lofm = {} 

101 for nr, content in to_show.items(): 

102 if isinstance(content[0], tuple): 

103 form = content[0][0], content[0][1], content[1], content[2] 

104 # elif isinstance(content[0], str) or \ 

105 # isinstance(content[0], int) or \ 

106 # isinstance(content[0], float): 

107 # form = content[0], content[1], content[2] 

108 else: 

109 form = content 

110 

111 lofm[nr] = [label % form, options] 

112 

113 return lofm