@@ -106,9 +106,11 @@ def coil_model(sets, pars, cons):
106106# enforce_parameter_constraints() method for all parameters
107107class OptBayesExptLockinCleanParams (OptBayesExptNoiseParameter ):
108108
109- def __init__ (self , coil_model , sets , params , cons , ** kwargs ):
109+ def __init__ (self , coil_model , sets , params , cons ,
110+ cost_of_changing_setting = 1.0 , ** kwargs ):
110111 OptBayesExptNoiseParameter .__init__ (self , coil_model , sets , params ,
111112 cons , ** kwargs )
113+ self .cost_of_changing_setting = cost_of_changing_setting
112114
113115 def enforce_parameter_constraints (self ):
114116 """
@@ -129,6 +131,25 @@ def enforce_parameter_constraints(self):
129131 # rescale the particle weights
130132 self .particle_weights = self .particle_weights \
131133 / np .sum (self .particle_weights )
134+
135+ def cost_estimate (self ):
136+ """
137+ Estimate the cost of measurements, depending on settings
138+
139+ The denominator of the *utility* function allows measurement
140+ resources (e.g. setup time + data collection time) to be entered
141+ into the utility calculation.
142+
143+ Returns:
144+ :obj:`float`, otherwise an :obj:`ndarray` describing how
145+ measurement variance depends on settings.
146+ """
147+ setting = self .last_setting_index
148+ cost = np .ones_like (self .allsettings [0 ]) * \
149+ self .cost_of_changing_setting
150+ cost [setting ] = 1.0
151+
152+ return cost
132153 # End of class definition
133154
134155
@@ -166,14 +187,18 @@ def enforce_parameter_constraints(self):
166187cons = ()
167188
168189coil_obe = OptBayesExptLockinCleanParams (coil_model , sets , params , cons ,
169- scale = False )
190+ scale = False , noise_parameter_index = 3 ,
191+ cost_of_changing_setting = cost_of_moving )
170192# Here, scale=False is a keyword argument that the class definition lumps
171193# into **kwargs and passes to OptBayesExptNoiseParam, which passes it to
172194# OptBayesExpt, which passes it to ParticlePDF. ParticlePDF has a ``scale``
173195# argument that gets set to ``False``.
196+ # The noise_parameter_index parameter is passed to
197+ # OptBayesExptNoiseParameter to identify which parameter describes the
198+ # standard deviation of experimental noise.
199+
200+
174201
175- coil_obe .cost_of_changing_setting = cost_of_moving
176- coil_obe .noise_parameter_index = 3
177202
178203########################################################################
179204# MEASUREMENT LOOP
@@ -251,14 +276,14 @@ def enforce_parameter_constraints(self):
251276plt .semilogx (xvals , truecurve [1 ], 'g-' , label = "Imag" )
252277plt .legend ()
253278plt .xlabel ("Frequency (Hz)" )
254- plt .ylabel ("Impedance (Ohms )" )
279+ plt .ylabel ("Impedance ($\Omega$ )" )
255280
256281# (2) plot the setting behavior
257282ax = plt .subplot (222 )
258283plt .text (.02 , .9 , "(b)" , transform = ax .transAxes )
259284plt .semilogy (frequency_trace , '.' )
260- plt .ylabel ("settingss " )
261- plt .xlabel ("No. of measurements " )
285+ plt .ylabel ("Frequency Setting (Hz) " )
286+ plt .xlabel ("Measurement iteration " )
262287
263288ax = plt .subplot (223 )
264289plt .text (0.02 , .9 , "(c)" , transform = ax .transAxes )
@@ -277,23 +302,24 @@ def enforce_parameter_constraints(self):
277302plt .semilogx (xvals , truecurve [1 ], 'g-' , label = "Imag" )
278303plt .legend ()
279304plt .xlabel ("Frequency (Hz)" )
280- plt .ylabel ("Impedance (Ohms )" )
305+ plt .ylabel ("Impedance ($\Omega$ )" )
281306
282307thisaxes = plt .subplot (224 )
283308plt .xticks ([])
284309plt .yticks ([])
285310thisaxes .set_frame_on (False )
286311# printed outputs
287- names = ["L" , "R" , "C" , "sigma" ]
312+ names = ["L" , "R" , "C" , "$\ sigma$ " ]
288313scales = np .array ([1e-3 , 1 , 1e-6 , 1 ])
289- units = ["mH " , "Ohm " , "uF " , "Ohm " ]
314+ units = ["mH " , "$\Omega$ " , "$\mu$F " , "$\Omega$ " ]
290315means = coil_obe .mean () / scales
291316stds = coil_obe .std () / scales
292317trues = np .array (true_pars ) / scales
293318f_string = "{}: true = {:5.3f} {} <-> ({:5.3f} +/- {:5.3f}) {}"
294319top = .9
295320delta_y = .1
296- delta_x = - .25
321+ # delta_x = -.25
322+ delta_x = - .1
297323
298324for name , true , mean , std , unit in \
299325 zip (names , trues , means , stds , units ):
0 commit comments