(ds, ds_name)
Plot all results from list of dictionaries

    Args:
        ds      : Dataset (list of dictionaries)
        ds_name : Dataset name
Plot all results from list of dictionaries
Plot all results from list of dictionaries
def _plot(ds, ds_name):
    """Plot all results from list of dictionaries

    Args:
        ds      : Dataset (list of dictionaries)
        ds_name : Dataset name

    """
    keys = set()
    for elem in ds:
        keys.update(list(ds[0].keys()))
    keys.remove("time")
    keys.remove("date")

    formatter = DateFormatter('%m/%d %H:%M')

    path = os.path.join("figs", ds_name)
    if not os.path.isdir(path):
        os.makedirs(path)

    for key in keys:
        logger.info("Plotting {}".format(key))

        x = [r[key] for r in ds if key in r]
        t = [r["date"] for r in ds if key in r]

        # Add unit to y-label
        if (key == "SNR"):
            ylabel = "SNR (dB)"
        elif (key == "Level"):
            ylabel = "Signal Level"
            # NOTE: the SDR logs positive signal levels rather than dBm.
            if (all([val < 0 for val in x])):
                ylabel += " (dBm)"
        else:
            ylabel = key

        fig, ax = plt.subplots()
        plt.plot_date(t, x, ms=2)
        plt.ylabel(ylabel)
        plt.xlabel("Time (UTC)")

        # Plot BER in log scale as it is not zero throughout the acquisition
        if (key == "BER" and any([val > 0 for val in x])):
            ax.set_yscale('log')

        ax.xaxis.set_major_formatter(formatter)
        ax.xaxis.set_tick_params(rotation=30, labelsize=10)
        plt.tight_layout()

        savepath = os.path.join(path, key.replace("/", "_").lower() + ".png")
        plt.savefig(savepath, dpi=300)
        plt.close()
def _plot ( ds , ds_name ) : keys = set ( ) for elem in ds : keys . update ( list ( ds [ 0 ] . keys ( ) ) ) keys . remove ( "time" ) keys . remove ( "date" ) formatter = DateFormatter ( '%m/%d %H:%M' ) path = os . path . join ( "figs" , ds_name ) if not os . path . isdir ( path ) : os . makedirs ( path ) for key in keys : logger . info ( "Plotting {}" . format ( key ) ) x = [ r [ key ] for r in ds if key in r ] t = [ r [ "date" ] for r in ds if key in r ] # Add unit to y-label if ( key == "SNR" ) : ylabel = "SNR (dB)" elif ( key == "Level" ) : ylabel = "Signal Level" # NOTE: the SDR logs positive signal levels rather than dBm. if ( all ( [ val < 0 for val in x ] ) ) : ylabel += " (dBm)" else : ylabel = key fig , ax = plt . subplots ( ) plt . plot_date ( t , x , ms = 2 ) plt . ylabel ( ylabel ) plt . xlabel ( "Time (UTC)" ) # Plot BER in log scale as it is not zero throughout the acquisition if ( key == "BER" and any ( [ val > 0 for val in x ] ) ) : ax . set_yscale ( 'log' ) ax . xaxis . set_major_formatter ( formatter ) ax . xaxis . set_tick_params ( rotation = 30 , labelsize = 10 ) plt . tight_layout ( ) savepath = os . path . join ( path , key . replace ( "/" , "_" ) . lower ( ) + ".png" ) plt . savefig ( savepath , dpi = 300 ) plt . close ( )