Changes between Version 84 and Version 85 of Other/Summer/2025/mlCoexist


Ignore:
Timestamp:
Jul 16, 2025, 7:43:28 PM (13 days ago)
Author:
aw1086
Comment:

Legend:

Unmodified
Added
Removed
Modified
  • Other/Summer/2025/mlCoexist

    v84 v85  
    6363- In progress to generate all graphs for fc1, 2, 3 for both a) transition-band and b) out-of-band scenarios
    6464[[Image(https://www.orbit-lab.org/raw-attachment/wiki/Other/Summer/2025/mlCoexist/Frequency%20Band.png, 60%)]]
     65- Code used for generating spectrograms and converting them into np 2D arrays:
     66{{{#!python
     67def plot_spect(dataset, title,min_value,max_value,normalized=False, save=None):
     68    if normalized:
     69        global_maximum = np.amax(np.abs(dataset))
     70    else:
     71        global_maximum = 1
     72
     73    y_res = 20 * np.log10(np.abs(dataset) / global_maximum)
     74
     75    fig = plt.figure(figsize=(12, 8))
     76    im = plt.imshow(y_res, origin='lower', cmap='jet', aspect='auto', vmax=max_value, vmin=min_value)
     77    plt.colorbar(label='dB')
     78
     79    yaxis = np.ceil(np.linspace(-15, 15, 11))
     80    ylabel = np.linspace(0, len(y_res), 11)
     81    xaxis = np.linspace(0, .25, 5)
     82    xlabel = np.linspace(0, len(y_res[1]), 5)
     83
     84    plt.title(title)
     85    plt.yticks(ylabel, yaxis)
     86    plt.xticks(xlabel, xaxis)
     87    plt.xlabel('Time')
     88    plt.ylabel('Frequency')
     89    plt.tight_layout()
     90
     91    fig.canvas.draw()
     92    img_rgba = np.frombuffer(fig.canvas.tostring_argb(), dtype=np.uint8)
     93    img_rgba = img_rgba.reshape(fig.canvas.get_width_height()[::-1] + (4,))
     94    img_rgb = img_rgba[:, :, [1, 2, 3]]
     95
     96    return img_rgb
     97}}}
    6598\\
    6699\\