Powerspectrum and averagedpowerspectrum#57
Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #57 +/- ##
==========================================
- Coverage 88.06% 87.78% -0.29%
==========================================
Files 5 6 +1
Lines 1081 1277 +196
==========================================
+ Hits 952 1121 +169
- Misses 129 156 +27 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
i have tested like : events = readevents("ni1200120104_0mpu7_cl.evt", load_gti=true, sort=true)
# Powerspectrum(events, dt, segment_size; norm="leahy")
ps_direct = Powerspectrum(events, 0.01, 1000, norm="frac")
# Events method with AveragedPowerspectrum - same as before
ps_events = AveragedPowerspectrum(events, 1000, norm="frac", dt=0.01)
# Compare with light curve method
lc = create_lightcurve(events, 0.01) # Using same dt=1.0 for fair comparison
ps_lc = AveragedPowerspectrum(lc, 1000, norm="frac")
# Check results
println("Direct method nphots: ", ps_direct.nphots)
println("Events method nphots: ", ps_events.nphots)
println("LC method nphots: ", ps_lc.nphots)
# All three should now have mean_rate since they're all AveragedPowerspectrum
println("\nMean rate comparison:")
println("Direct method mean_rate: ", ps_direct.mean_rate)
println("Events method mean_rate: ", ps_events.mean_rate)
println("LC method mean_rate: ", ps_lc.mean_rate)
# Additional comparisons
println("\nFrequency resolution comparison:")
println("Direct method df: ", ps_direct.df)
println("Events method df: ", ps_events.df)
println("LC method df: ", ps_lc.df)
println("\nNumber of segments:")
println("Direct method m: ", ps_direct.m)
println("Events method m: ", ps_events.m)
println("LC method m: ", ps_lc.m)
println("\nSegment size:")
println("Direct method segment_size: ", ps_direct.segment_size)
println("Events method segment_size: ", ps_events.segment_size)
println("LC method segment_size: ", ps_lc.segment_size)output : Found GTI data: 16 intervals
GTI time range: 1.3253976595089495e8 to 1.3261337476368216e8
Direct method nphots: 19163002
Events method nphots: 19163002
LC method nphots: 19497872
Mean rate comparison:
Direct method mean_rate: 2737.5717142857143
Events method mean_rate: 2737.5717142857143
LC method mean_rate: 2785.4102857142857
Frequency resolution comparison:
Direct method df: 0.001
Events method df: 0.001
LC method df: 0.001
Number of segments:
Direct method m: 7
Events method m: 7
LC method m: 7
Segment size:
Direct method segment_size: 1000.0
Events method segment_size: 1000.0
LC method segment_size: 1000.0The main problem lies in the number of photons. Using the events method and the light curve method should yield the same result, but they exhibit a ~1.3% difference. I am not sure about the numbers, but I have some doubts, like whether it is valid or not? tagging @matteobachetti |
|
|
||
| return LightCurve( | ||
| times, dt, counts, nothing, nothing, EventProperty{Float64}[], | ||
| times, dt, counts, nothing, fill(dt, length(times)), EventProperty{Float64}[], |
There was a problem hiding this comment.
Why this double definition of dt?
There was a problem hiding this comment.
So our constructor signature was like this
LightCurve(::Vector{T}, ::Union{Vector{T}, T}, ::Vector{Int64}, ::Union{Nothing, Vector{T}},
::Union{Nothing, Vector{T}}, ::Array{EventProperty{T}, 1}, ::LightCurveMetadata, ::Symbol)For exposure and count_error, we have the same struct data i.e:Union{Nothing, Vector{T}}
So, I have used this to create a vector where every element is dt for the previous test cases in #53, which we then concluded to remove. I forgot to remove it; by the way, nice catch! :)
There was a problem hiding this comment.
I have removed that redundant dt, you may review again
this pr contains the powerspectrum and averagepowerspectrum functions for light curve[binned edges] and event[unbinned edges]
Here are some examples with output :
events[unbinned]
output: data [ik redunddant :)]
lightcurve[binned]
output the same type as the above one:)
output:
output:
output:
output
output
output
tagging @fjebaker @matteobachetti @stefanocovino