Skip to content

Conversation

kashish2210
Copy link
Member

this includes various methods of plotting: [powerspectrum and avg power spectrum]

basis setup:

using Plots
events = readevents("ni1200120104_0mpu7_cl.evt", sort=true)
lc = create_lightcurve(events, 0.1)

plotting :

plot(events, segment_size=256.0, dt=0.01, norm="frac", show_noise=true)
image
plot(events, segment_size=256.0, show_noise=true, axis_limits=[1,1/10])
image
# Create the power spectra objects
ps2 = AveragedPowerspectrum(events, 256.0; dt=0.01, norm="frac") 
ps3 = AveragedPowerspectrum(events, 256.0; dt=0.01, norm="leahy")
ps4 = AveragedPowerspectrum(events, 256.0; dt=0.01, norm="abs")
plot([ps2, ps3, ps4], 
     labels=[ "Fractional", "Leahy", "Absolute"], 
     colors=[ :red, :green, :orange], 
     linewidth=2.0,
     show_noise=true)
image
plot(events, segment_size=256.0, dt=0.01, norm="frac", show_noise=true, show_errors=true, freq_mult=true)
image
plot(events, segment_size=256.0, dt=0.01, norm="frac", show_noise=true, log_scale=false)
image
# you can use drawstyle if u want like
plot(events, segment_size=256.0, dt=0.01, norm="frac", drawstyle=:scatter)
image
plot(lc, segment_size=256, norm="frac", show_noise=true)
image
plot(lc, segment_size=128, norm="frac", show_noise=true, show_errors=true, freq_mult=true, log_scale=true, drawstyle=:steppost)
image
ps = AveragedPowerspectrum(events, 256.0, norm="frac")
plot(ps, show_noise=true, meanrate=ps.mean_rate)
image
plot(ps, show_noise=true, show_errors=true, subtract_noise=true, meanrate=ps.mean_rate)
plot(ps, freq_mult=true, show_noise=true, meanrate=ps.mean_rate)
image image
ps1 = AveragedPowerspectrum(events, 128.0, norm="frac")
ps2 = AveragedPowerspectrum(events, 256.0, norm="frac") 
ps3 = AveragedPowerspectrum(events, 512.0, norm="frac")

plot([ps1, ps2, ps3], labels=["128s", "256s", "512s"])
image
ps_orig = Powerspectrum(lc, norm="frac")
lc_rebinned = rebin(lc, 100)
ps_rebin = Powerspectrum(lc_rebinned, norm="frac")

# Use vector syntax
plot([ps_orig, ps_rebin], 
     labels=["Original", "Rebinned"], 
     colors=[:blue, :red],
     show_noise=true)
image
plot(events,segment_size=256.0, norm="frac", freq_mult=true)
image
events_soft = filter_energy(e -> 30 <= e <= 200, events)    # ~0.3-2 keV
events_medium = filter_energy(e -> 200 <= e <= 800, events) # ~2-8 keV  
events_hard = filter_energy(e -> 800 <= e <= 1200, events)  # ~8-12 keV

# Now this should work:
ps_soft = AveragedPowerspectrum(events_soft, 256.0, norm="frac", dt=0.1)
ps_medium = AveragedPowerspectrum(events_medium, 256.0, norm="frac", dt=0.1)
ps_hard = AveragedPowerspectrum(events_hard, 256.0, norm="frac", dt=0.1)

plot([ps_soft, ps_medium, ps_hard], 
     labels=["Soft", "Medium", "Hard"], 
     colors=[:blue, :green, :red])
plot([ps_soft, ps_medium, ps_hard], segment_size=256.0, norm="frac",
     colors=[:blue, :green, :red], freq_mult=true)
image image
powerlaw_model(f) = 100.0 * f^(-2.0) + 2.0
plot(ps, powerlaw_model, freq_mult=true, log_scale=true)
image
plot(ps, Val(:qpo), qpo_range=(0.1, 50), significance_level=5.0)
image

tagin @matteobachetti @stefanocovino @fjebaker for review

#33

@codecov-commenter
Copy link

codecov-commenter commented Jul 29, 2025

Codecov Report

❌ Patch coverage is 14.56311% with 440 lines in your changes missing coverage. Please review.
✅ Project coverage is 63.55%. Comparing base (98935ce) to head (c86ff8d).
⚠️ Report is 8 commits behind head on main.

Files with missing lines Patch % Lines
src/plotting/plots_recipes_powerspectrum.jl 0.00% 201 Missing ⚠️
src/powerspectrum.jl 0.00% 190 Missing ⚠️
src/fourier.jl 33.33% 40 Missing ⚠️
src/gti.jl 87.50% 5 Missing ⚠️
src/lightcurve.jl 83.33% 4 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff             @@
##             main      #59       +/-   ##
===========================================
- Coverage   89.26%   63.55%   -25.71%     
===========================================
  Files           5        7        +2     
  Lines        1025     1534      +509     
===========================================
+ Hits          915      975       +60     
- Misses        110      559      +449     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@matteobachetti
Copy link
Member

When freq_multi is true, the Poisson noise level should always be subtracted

removing if condition from that variable
@kashish2210
Copy link
Member Author

kashish2210 commented Aug 6, 2025

Member

yup I have removed the if condition @matteobachetti

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants