Skip to content

Repository files navigation

WindRose Chart Generator

WindRose.py generates one or more high-quality wind rose charts from a CSV file by plotting measured variable values against a directional column (e.g., wave height vs. direction). The script is now significantly enhanced with modular architecture, improved robustness, and command-line argument support for advanced usage.

✨ New Features & Improvements

  • CLI Arguments (argparse): Run the script non-interactively by specifying file paths and binning parameters directly via the command line.
    • Example: python WindRose.py input.csv --columns 'HS,DIRM;TP,DIR' --var-width 5 --dir-width 10
  • Robustness: Improved validation for CSV column count, bin boundaries, and non-negative/positive width inputs.
  • Modular Codebase: The core logic is refactored into smaller, testable functions (load_csv, configure_binning, etc.).
  • Logging: Switched from standard print() statements to Python's logging module for better output control.

📋 CLI Usage Guide

Basic Interactive Mode

Run the script without arguments to be guided through the process:

python WindRose.py

The script will prompt you for:

  1. CSV File Path: Select the input data file.
  2. Column Pairs: Specify variables and directions (e.g., HS,DIRM;TP,DIRM).
  3. Binning Parameters: Configure min/max range and bin width for each variable and direction.
  4. Plot Details: Set the title and output filename.

Advanced Non-Interactive Mode

Use flags to automate the process:

Flag Description Example Usage
--columns COLUMNS Specify column pairs (e.g., '1, 3;2, 3' or 'HS,DIRM'). Required for automation. ... --columns '1,3'
--var-min/max/width Set fixed boundaries for the variable axis. --var-min 1.0 --var-max 10.0 --var-width 2.5
--dir-width WIDTH Set a specific width for direction sectors (default: 22.5). --dir-width 10
--title TITLE Override the default plot title. --title "Wave Analysis"
--output NAME Specify the desired output filename. --output "final_report_plot"
--skip-prompts Runs entirely non-interactively using all provided flags and defaults. ... --skip-prompts

Example: To process a file, forcing the plot to use 5-degree direction sectors and skipping prompts:

python WindRose.py data/my_data.csv \
    --columns 'var_col_name,dir_col_name' \
    --dir-width 5 \
    --skip-prompts

⚙️ Installation & Dependencies

The script requires the following packages:

pip install numpy matplotlib windrose pandas

💾 Input Data Requirements

  • CSV Structure: The input CSV must contain at least two numeric columns (one variable, one direction).
  • Direction Column: Must represent angles in degrees (°).

🖼️ Output Details

Each successful run generates a high-resolution PNG chart (dpi=300) saved in the same directory as the input CSV. The filename will follow the pattern: <input_stem>_<var_col>_vs_<dir_col>.png.

The plot includes interactive legend handling and displays key statistics for clarity.

About

Wind rose of selected variable

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages