Comments (5)
based on @sgnoohc's example, but only half-tested:
function make_fhist1d(th1::Dict{Symbol, Any}; overflow=false)
xmin = th1[:fXaxis_fXmin]
xmax = th1[:fXaxis_fXmax]
nbins = th1[:fXaxis_fNbins]
bins = isempty(th1[:fXaxis_fXbins]) ? range(xmin, xmax, length=nbins+1) : th1[:fXaxis_fXbins];
h = Hist1D(Float64; bins=bins, overflow=overflow) # so if we push more later, overflow is respected
counts = th1[:fN]
sumw2 = th1[:fSumw2]
if overflow
counts[2] += counts[1]
counts[end-1] += counts[end]
sumw2[2] += sumw2[1]
sumw2[end-1] += sumw2[end]
end
h.hist.weights .= counts[2:end-1]
h.sumw2 .= sumw2[2:end-1]
return h
end
and then 2D is to be done...
from fhist.jl.
I don't know how to get the bin edges directly rather than computing from xmin xmax and nbins.
I couldn't find the key in th1 from UnROOT.
(but must be there somewhere..?)
from fhist.jl.
I think we could use a method that returns ( edges counts and sumw2 ) in UnROOT.jl, since it's easy to construct histogram from those in either StatsBase or FHist and it doesn't bloat the dependency.
the individuals bin edges are indeed not stored when they are uniform, your observation is correct I think
from fhist.jl.
I agree with @Moelf. About the irregular binning, this is how to get it:
julia> using UnROOT, FHist
julia> f = ROOTFile("/Users/namin/.julia/dev/UnROOT/test/samples/histograms1d2d.root")
julia> th = f["myTH1D_nonuniform"];
julia> th[:fXaxis_fXmin], th[:fXaxis_fXmax], th[:fXaxis_fNbins], th[:fXaxis_fXbins]
(-2.0, 2.0, 2, [-2.0, 1.0, 2.0])
julia> th = f["myTH1D"];
julia> th[:fXaxis_fXmin], th[:fXaxis_fXmax], th[:fXaxis_fNbins], th[:fXaxis_fXbins]
(-2.0, 2.0, 2, Any[])
That is, :fXaxis_fXbins
is filled if the histogram has irregular binning, otherwise min/max/nbins is sufficient to construct the edges with range(min,max,length=nbins+1)
from fhist.jl.
Another thing to be careful about if we want a method that returns edges, counts, sumw2 in UnROOT.jl: what do we do with overflow bins? If we return the full arrays as-is, then the user still has to go through and do counts[2:end-1]
and sumw2[2:end-1]
from fhist.jl.
Related Issues (20)
- Number of entries not properly 'merged' HOT 8
- Make plot attributes histograms - direction HOT 5
- Extract ATLAS styling and utility function in another package HOT 1
- [Makie] `stephist` missing edges when some bins are empty in the middle of the histogram HOT 1
- Weird behavior HOT 1
- Naming of push/unsafe_push HOT 1
- unsafe_push when only 1 thread HOT 1
- implement Hist3D
- High precision bin edges make overfull display HOT 3
- Nonuniform weights? HOT 5
- FHist type-parameter (of eltype) is also used for the weights HOT 7
- Statbox not working on a normalized histogram
- integral should take into account binwidths HOT 4
- Normalize broken ? HOT 1
- normalize, width = true HOT 5
- Is normal that memory allocations happens when filling? HOT 16
- Problem with recipes HOT 15
- [RFC] `v0.11` breaking change to main API HOT 10
- FHistCairoMakieExt not found HOT 3
- Pushing `-Inf` and `Inf` HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from fhist.jl.