Currently, we use the previously introduced UnitsDict class that is tailored to dictionaries (it inherits from a dict), and adds a units attribute.
It seems to work for cases like this:
for phidx in ephmat_dat.keys():
phdisp[phidx] = ephmat_dat[phidx].pop('phonon energy')
defpot[phidx] = np.array(ephmat_dat[phidx].pop('deformation potential')).reshape(N, M)
ephmat[phidx] = np.array(ephmat_dat[phidx].pop('e-ph matrix elements')).reshape(N, M)
self.phdisp = UnitsDict.from_dict(phdisp, phdisp_units)
self.defpot = UnitsDict.from_dict(defpot, defpot_units)
self.ephmat = UnitsDict.from_dict(ephmat, ephmat_units)
However, we do not have (to my knowledge) a way to store floats with units. The only workaround I found, would be
input_dict = {'pump_energy': 5}
self.pump_energy = UnitsDict.from_dict(input_dict, units='eV')
Then printing the attribute gives you:
print(self.pump_energy)
{'pump_energy': 1.5}
So, I first use the keyword pump_energy as the attribute name, then it apprears in the dict which is definitely redundant.
Another thing is that the data attribute is no in the UnitsDict, evethough it is specified so.
Currently, we use the previously introduced
UnitsDictclass that is tailored to dictionaries (it inherits from a dict), and adds a units attribute.It seems to work for cases like this:
However, we do not have (to my knowledge) a way to store floats with units. The only workaround I found, would be
Then printing the attribute gives you:
So, I first use the keyword
pump_energyas the attribute name, then it apprears in the dict which is definitely redundant.Another thing is that the
dataattribute is no in the UnitsDict, evethough it is specified so.