|
[Rivet] rebinning histogramsViesturs Veckalns viesturs.veckalns at cern.chSun Jun 12 12:53:18 BST 2016
Hello, It appears this recipe works with yoda 1.5.5 (CMSSW_7_6_3) but not with yoda 1.3.1-eccfad (CMSSW_7_5_0) Cheers, Viesturs ________________________________________ From: Andy Buckley Sent: 12 April 2016 21:12 To: Viesturs Veckalns; rivet at projects.hepforge.org Subject: Re: [Rivet] rebinning histograms I forgot an extra argument to yoda.read(): it returns a dict by default so the string you are seeing is the path of the first histo used as the dictionary key. Either rewrite the loop to use hists.values() or rewrite the first operation as: hists = yoda.read("myfile.yoda", asdict=False) Sorry, I realised this shortly after sending the snippet, then forgot to alert you! Cheers, Andy On 12/04/16 18:25, Viesturs Veckalns wrote: > Dear Andy, > I have a problem with the script you sent: h is considered as str and no methods of histo1D are applicable. > > AttributeError: 'str' object has no attribute 'rebin' > > Cheers, > Viesturs > ________________________________________ > From: Andy Buckley > Sent: 03 April 2016 23:22 > To: Viesturs Veckalns; rivet at projects.hepforge.org > Subject: Re: [Rivet] rebinning histograms > > Hi Viesturs, > > Yes, histograms have several rebinning methods. You can use a Python > script for simple rebinning like this: > > import yoda > hists = yoda.read("myfile.yoda") > for h in hists: > h.rebin(3) #< factor of 3 rebinning > yoda.write(hists, "newfile.yoda") > > Not tested, but it should work: see http://yoda.hepforge.org/pydoc/ and > search for "rebin" to get documentation. You can also pass a list of > explicit new bin edges to rebin() or use explicit rebinBy & rebinTo methods. > > Andy > > > On 01/04/16 19:31, Viesturs Veckalns wrote: >> Dear Rivet team, >> Is it possible to rebin yoda histograms? >> Cheers, >> Viesturs >> >> >> _______________________________________________ >> Rivet mailing list >> Rivet at projects.hepforge.org >> https://www.hepforge.org/lists/listinfo/rivet >> > > > -- > Dr Andy Buckley, Lecturer / Royal Society University Research Fellow > Particle Physics Expt Group, University of Glasgow > -- Dr Andy Buckley, Lecturer / Royal Society University Research Fellow Particle Physics Expt Group, University of Glasgow
More information about the Rivet mailing list |