-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathplotting.py
More file actions
50 lines (41 loc) · 1.58 KB
/
plotting.py
File metadata and controls
50 lines (41 loc) · 1.58 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
import matplotlib.pyplot as plt
import numpy as np
def plot_dynamic_spectra(dynamic_spectra, title="Dynamic Spectra"):
"""
Plot a dynamic spectrum with horizontal time axis and reversed frequency axis.
Parameters:
dynamic_spectra (numpy.ndarray): The dynamic spectrum to plot.
title (str): The title for the plot (default is "Dynamic Spectra").
Returns:
None
"""
# Calculate the time step based on the number of time samples
num_time_samples = dynamic_spectra.shape[0]
time_step = 0.0000256 # Default time step in seconds
# Calculate the extent based on the number of frequency channels
extent = [0, num_time_samples * time_step * 1000, 1208, 1700]
plt.figure(figsize=(10, 6))
plt.imshow(dynamic_spectra.T, aspect="auto", cmap="viridis", extent=extent)
plt.xlabel("Time (ms)", size=14)
plt.ylabel("Frequency (MHz)", size=14)
plt.colorbar()
plt.title(title, size=16)
plt.show()
def plot_lightcurve(time_samples, lightcurve):
"""
Plot a lightcurve.
Parameters:
time_samples (numpy.ndarray): Array of time sample numbers.
lightcurve (numpy.ndarray): Array of intensity values.
Returns:
None
"""
# Calculate the time values based on the time step
time_values = time_samples * 0.0000256 * 1000 # Convert to milliseconds
plt.figure(figsize=(12, 6))
plt.plot(time_values, lightcurve, color='blue', lw=1)
plt.xlabel("Time (ms)", fontsize=12)
plt.ylabel("Intensity", fontsize=12)
plt.title("FRB Lightcurve", fontsize=14)
plt.grid(True)
plt.show()