@@ -19,6 +19,7 @@ def __init__(self, name='', wavelength=None):
1919 self .on_tth = [np .empty (1 ), np .empty (1 )]
2020 self .on_d = [np .empty (1 ), np .empty (1 )]
2121 self ._all_arrays = [self .on_q , self .on_tth ]
22+ self .metadata = {}
2223
2324 def __add__ (self , other ):
2425 summed = deepcopy (self )
@@ -221,7 +222,8 @@ def get_angle_index(self, angle):
221222 if count >= len (self .angles ):
222223 raise IndexError (f"WARNING: no angle { angle } found in angles list" )
223224
224- def insert_scattering_quantity (self , xarray , yarray , xtype , metadata = {}):
225+ def insert_scattering_quantity (self , xarray , yarray , xtype , metadata = {},
226+ scat_quantity = None , name = None , wavelength = None ):
225227 f"""
226228 insert a new scattering quantity into the scattering object
227229
@@ -241,7 +243,12 @@ def insert_scattering_quantity(self, xarray, yarray, xtype, metadata={}):
241243
242244 """
243245 self .input_xtype = xtype
244- self .metadata = metadata
246+ # empty attributes have been defined in the __init__ method so only
247+ # set the attributes that are not empty to avoid emptying them by mistake
248+ if metadata : self .metadata = metadata
249+ if scat_quantity is not None : self .scat_quantity = scat_quantity
250+ if name is not None : self .name = name
251+ if wavelength is not None : self .wavelength = wavelength
245252 if xtype .lower () in QQUANTITIES :
246253 self .on_q = [np .array (xarray ),np .array (yarray )]
247254 elif xtype .lower () in ANGLEQUANTITIES :
@@ -284,7 +291,7 @@ def q_to_tth(self):
284291 q = np .asarray (q )
285292 wavelength = float (self .wavelength )
286293 pre_factor = wavelength / (4 * np .pi )
287- return np .rad2deg (2 * np .arcsin (q * pre_factor ))
294+ return np .rad2deg (2. * np .arcsin (q * pre_factor ))
288295
289296 def tth_to_q (self ):
290297 r"""
0 commit comments