Ejemplo n.º 1
0
def plot():
    # Define filenames.

    # `save_folder` is the full path to the directory containing the Pickle (.pkl) log files from the optimization.
    save_folder = os.path.join(os.getcwd(), 'phc_test')
    spec_folder = os.getcwd()

    # Load the logged monitor data and monitor spec information.

    # `df` is a pandas dataframe containing all the data loaded from the log Pickle (.pkl) files.
    df = log_tools.create_log_data_frame(log_tools.load_all_logs(save_folder))

    # `monitor_spec_filename` is the full path to the monitor spec yml file.
    monitor_spec_filename = os.path.join(spec_folder,
                                         "monitor_spec_dynamic.yml")

    # `monitor_descriptions` now contains the information from the monitor_spec.yml file. It follows the format of
    # the schema found in `log_tools.monitor_spec`.
    monitor_descriptions = log_tools.load_from_yml(monitor_spec_filename)

    # Plot all monitor data and save into a pdf file in the project folder.

    # `summary_out_name` is the full path to the pdf that will be generated containing plots of all the log data.
    summary_out_name = os.path.join(save_folder, "summary.pdf")

    # This command plots all the monitor data contained in the log files, saves it to the specified pdf file, and
    # displays to the screen.
    log_tools.plot_monitor_data(df, monitor_descriptions, None)
Ejemplo n.º 2
0
def view_opt(save_folder: str) -> None:
    """Shows the result of the optimization.

    This runs the auto-plotter to plot all the relevant data.
    See `examples/wdm2` IPython notebook for more details on how to process
    the optimization logs.

    Args:
        save_folder: Location where the log files are saved.
    """
    log_df = log_tools.create_log_data_frame(
        log_tools.load_all_logs(save_folder))
    monitor_descriptions = log_tools.load_from_yml(
        os.path.join(os.path.dirname(__file__), "monitor_spec.yml"))
    log_tools.plot_monitor_data(log_df, monitor_descriptions)
Ejemplo n.º 3
0
def view_opt(save_folder: str) -> None:
    """Shows the result of the optimization.

    This runs the auto-plotter to plot all the relevant data.
    See `examples/wdm2` IPython notebook for more details on how to process
    the optimization logs.

    Args:
        save_folder: Location where the log files are saved.
    """
    log_df = log_tools.create_log_data_frame(log_tools.load_all_logs(save_folder))
    monitor_descriptions = log_tools.load_from_yml(os.path.join(os.path.dirname(__file__), "monitor_spec_dual.yml"))

    log_tools.plot_monitor_data(log_df, monitor_descriptions, show=False)
    log_tools.plot_power_vs_wlen(log_df, monitor_descriptions, "port1_out", show=False)
    log_tools.plot_power_vs_wlen(log_df, monitor_descriptions, "port2_out", show=False)

    import matplotlib.pyplot as plt
    wlen_goal, s11_fn, s21_fn = load_s_param_goal()
    plt.plot(wlen_goal, 20*np.log10(s21_fn(wlen_goal)), ':r')
    plt.show()