Skip to content

A plotting Script to aid in plotting outputs of NEMO5

Notifications You must be signed in to change notification settings

toro0/Plotting_Script

main
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Code

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Plotting GUI Application

Overview

This application provides a graphical user interface (GUI) for plotting data from .dat files or from specified directories Users can choose from different plot styles and customize various settings such as axis limits, titles, and legend inclusion.

Features

  • Select plot type (2D, 3D, or directory input).
  • Choose a plot style from available options.
  • Input custom x and y axis limits.
  • Set titles for axes and the plot.
  • Option to include a legend in the plot.

Installation

To run this application, make sure you have Python installed on your machine. You will also need the tkinter module, which comes with most Python installations.

  1. Clone this repository or download the source code.

  2. Ensure all required plot style modules (plot_style_<name>.py) are in the same directory as the main script.

  3. Navigate to the project directory in your terminal.

  4. Run the application using the command:

    python3 main.py
    
    

Adding More Plot Styles

  • To add a plot style create a new python file and define a function to take in the '.dat' files
  • Once defined implement the desired plotting logic, if you want to use the text box in the GUI the plot function needs to have the folowing parameters def plot(plot_type, dat_files, x_limits=None, y_limits=None, x_title='', y_title='', plot_title='', include_legend=False)
  • For the GUI to auto populate with the new plot style use the folowing naming convention plot_style_<name>.py
  • Use the provided test.py and .dat files as a guide (rename the test.py file to plot_style_sine.py

Current Known Issues

  • Directory input only useful for scattering rate
  • When GUI pops up there is no indication if user is selecting X or Y data
  • No 3D graph support yet

Function Descriptions

get_plot_styles()

This function scans the current directory for Python files that match the naming convention plot_style_<name>.py. It extracts the style names by removing the prefix and file extension, returning a list of available plot styles.

Returns:

  • list: A list of available plot style names (without the plot_style_ prefix and .py extension).

plot()

This function is executed when the user clicks the "Plot" button in the GUI. It handles the following tasks:

  1. Plot Type Determination: It checks whether the user selected "Directory Input" or specified .dat files for plotting.
  2. Directory/File Selection: If "Directory Input" is selected, it prompts the user to choose directories for real and complex scattering rate files. If .dat files are selected, it allows the user to choose the files to be plotted.
  3. Input Validation: It verifies that directories or files were selected; if not, it displays an error message.
  4. Retrieve User Inputs: It collects user inputs for x and y limits, axis titles, plot title, and whether to include a legend.
  5. Dynamic Module Import: It imports the selected plot style module using importlib.
  6. Plot Execution: It calls the plot function from the selected plot style module, passing the necessary parameters for plotting.
  7. Error Handling: It manages potential errors, displaying error messages if the selected plot style is not found or if any other exception occurs.

Returns:

  • None

Main GUI Components

  • Initialization: The main GUI window is initialized with the title "Plotting GUI".
  • Plot Type Selection: A dropdown menu allows users to select between different plot types (2D, 3D, or Directory Input).
  • Plot Style Selection: Another dropdown menu lets users choose from available plot styles fetched by get_plot_styles().
  • Axis Limit Inputs: Input fields are provided for users to specify x and y limits.
  • Axis Title Inputs: Users can enter titles for the x and y axes and the overall plot.
  • Legend Checkbox: A checkbox is available to include or exclude a legend in the plot.
  • Plot Button: A button labeled "Plot" triggers the user to select the files or folders for the desired pot once selected it calls the plot() function. When selecting files the order matters, select the x-axis values then control+click the y values.

About

A plotting Script to aid in plotting outputs of NEMO5

Resources

Stars

Watchers

Forks

Releases

No releases published

Languages