| sim=pyLCSIM.Simulation() |
| sim.addModel('smoothbknpo', [1., 1, 2, 1]) |
| sim.addModel('lorentzian', [10., 1., 10, 2]) |
| |
| # Run the simulation |
| sim.run(dt, nbins, rate_src, rms=frms) |
| |
| # Add Poisson noise to the light curve |
| sim.poissonRandomize(dt, rate_bkg) |
| |
| # Get lightcurve and power spectrum as 1-D arrays |
| time, rate=sim.getLightCurve() |
| f, psd=sim.getPowerSpectrum() |
| pyLCSIM.saveFITSLC("myLC.fits", time, rate) |
| pyLCSIM.saveFITSPSD("myPSD.fits", f, psd) |
| fig0=plt.figure() |
| plt.plot(time, rate) |
| plt.xlabel("Time [s]") |
| plt.ylabel("Rate [counts/s]") |
| plt.title("Lightcurve") |
| fig1=plt.figure() |
| plt.loglog(f, psd, drawstyle='steps-mid', color='black') |
| plt.xlabel("Frequency [Hz]") |
| plt.ylabel("PSD [Leahy normalized]") |
| plt.title("Power spectrum density") |
| plt.show() |