Skip to content

Refactor: Fix missing imports, scope issues, and remove hardcoded weather data in plotting script - #199

Open
lavjeetrai wants to merge 1 commit into
52North:mainfrom
lavjeetrai:compare-rute
Open

Refactor: Fix missing imports, scope issues, and remove hardcoded weather data in plotting script#199
lavjeetrai wants to merge 1 commit into
52North:mainfrom
lavjeetrai:compare-rute

Conversation

@lavjeetrai

Copy link
Copy Markdown

Summary:

This PR refactors the route visualization script to resolve runtime errors and improve its flexibility as a command-line tool.

Before: The script failed to execute due to missing matplotlib and graphics imports. It also relied heavily on global variables (like figurefile) inside the plotting functions, which broke modularity. Furthermore, weather data and map bounding boxes were hardcoded in the __main__ block, limiting the tool's reusability. It also contained redundant if/else logic in the plot_power_vs_dist_ratios function that executed the same code regardless of the condition.

After: * Imports & Scope Fixes: Added missing imports and refactored plotting functions to accept figurefile as an explicit argument, eliminating NameError exceptions and global scope reliance.

  • CLI Enhancements: Replaced hardcoded timestamps and map coordinates with optional argparse parameters (--departure-time, --plot-time, --time-forecast, --bbox), preserving the original values as defaults. Users can now define these dynamically without modifying the script.
  • Code Cleanup: Removed the redundant code block in the ratio plotting function.

Dependencies:

No new external dependencies were introduced, though matplotlib.pyplot is now explicitly imported and required for this script to run.

PR Checklist:

In the context of this PR, I:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant