Skip to main content

Datasets

Standard Dataset

Code to import PSCAD data into Python (Spyder)

Citation Author(s):
Franz Guzman ( School of Electrical and Computing Engineering at the University of Campinas (UNICAMP))
Submitted by:
Franz Guzman Llanos
Last updated:
DOI:
10.21227/thm2-6322
Data Format:
9 views
Categories:
Keywords:
No Ratings Yet

Abstract

This Python script is designed to simplify the processing of PSCAD simulation outputs. Instead of manually handling PSCAD-generated data, the tool automatically converts output files into structured formats and generates ready-to-use plots and curves. It significantly reduces manual effort, minimizes errors, and provides a standardized workflow for data analysis.

Key Features:

  • Reads PSCAD output files and organizes data for analysis.
  • Generates plots for voltages, currents, power, and other variables.
  • Exports processed data in formats like CSV or Excel.
  • Allows optional adjustments for file names, plot types, and axis ranges.

Requirements:

  • Python 3.10+
  • Libraries: pandas, numpy, matplotlib, scipy
  • PSCAD output files to process.

Usage:

  1. Place PSCAD output files in a folder accessible to the script.
  2. Adjust parameters if needed (file names, variables, plot settings).
  3. Run the script with python process_pscad.py.
  4. Obtain processed data and graphical plots in the output folder.

Notes:

  • Minor adjustments may be needed depending on the PSCAD output format.
  • The script is designed to streamline analysis, saving time compared to manual processing.

Instructions:

User Manual: PSCAD Data Processing Tool (Python)

  1. Overview and Requirements
    This Python script is designed to simplify the processing of PSCAD simulation results.
    It allows you to:
  • Directly read and convert PSCAD data from the simulation case name.
  • Extract key variables (voltages, currents, powers, etc.).
  • Automatically generate plots.
  • Export processed data to CSV files for further analysis.

The main goal is to automate tasks that are usually done manually, reducing human error and saving time.

Requirements:

  • Python 3.10 or higher
  • Required libraries: pandas, numpy, matplotlib, scipy (optional)
  • PSCAD simulation case names to specify which simulation to process
  • Basic familiarity with Python to configure parameters and run the script
  1. Environment Setup and Input
  2. Ensure Python and the required libraries are installed.
  3. Create a working folder to store the processed data results.
  4. Organize PSCAD simulation case names consistently.
    • Example: Case1, Case2, etc.

Unlike other tools, you do not need an output file from PSCAD—the script reads data directly from the simulation case.

  1. Script Configuration
    Before running the script, configure these parameters:
  2. Simulation case name
    • Variable: case_name
    • Specifies which PSCAD simulation case to process.
    • Example: case_name = "Case1"
  3. Output folder
    • Variable: output_folder
    • Folder where processed results (plots and CSV files) will be saved.
    • Example: output_folder = "Processed_Case1"
    • The script can create this folder automatically if it does not exist.
  4. Variables to process
    • Variable: variables_to_extract
    • List of variables from the PSCAD simulation to extract and plot.
    • Example: variables_to_extract = ["V_bus1", "I_line2", "P_load"]
    • Ensure these match the variable names in your PSCAD case.
  5. Plot parameters
    • Adjust figure size, axis labels, titles, and colors.
    • Example: plot_settings = {
      "figsize": (10,6),
      "xlabel": "Time [s]",
      "ylabel": "Voltage [kV]",
      "title": "Bus 1 Voltage",
      "color": "blue",
      "grid": True
      }
    • You can plot multiple variables in a single figure or separate figures.
  6. Data adjustments (optional)
    • Optional adjustments such as smoothing, scaling, or filtering.
    • Example: data["V_bus1"] = data["V_bus1"] * 0.001 # Convert V to kV
  7. Running the Script
  8. Update the script with the parameters above (case name, variables, output folder).
  9. Run the script in Python (terminal, IDE, or Jupyter Notebook).
  10. The script will automatically:
    • Read data from the PSCAD simulation case.
    • Extract the specified variables.
    • Apply optional adjustments if defined.
    • Generate plots for each variable or group of variables.
    • Save plots and CSV files in the output folder.
  11. Expected Results
    After execution, you will get:
  • CSV files with the processed data.
  • PNG plots showing the evolution of each variable over time.
  • Optional combined plots for comparing multiple variables or cases.