Nipun Claude commited on
Commit
4038c51
·
1 Parent(s): e939a33

Fix code generation errors for complex meteorological analysis

Browse files

- Add specific guidance for wind rose diagrams with polar projections
- Improve correlation analysis error handling and data validation
- Add statistical analysis patterns for wind speed thresholds
- Fix data validation with proper early exits and error messages
- Prevent common plotting errors for complex visualizations

Addresses failures in:
- Wind direction vs pollution rose diagrams
- Meteorological factor correlation analysis
- Wind speed threshold analysis
- Unicode column name handling

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <[email protected]>

Files changed (1) hide show
  1. new_system_prompt.txt +21 -2
new_system_prompt.txt CHANGED
@@ -69,13 +69,32 @@ PLOT GENERATION (MANDATORY FOR PLOTS):
69
  CRITICAL CODING PRACTICES:
70
 
71
  DATA VALIDATION & SAFETY:
72
- - Always check if DataFrames/Series are empty before operations: if df.empty: return
73
  - Use .dropna() to handle missing values or .fillna() with appropriate defaults
74
- - Validate column names exist before accessing: if 'column' in df.columns
75
  - Check data types before operations: df['col'].dtype, isinstance() checks
76
  - Handle edge cases: empty results, single row/column DataFrames, all NaN columns
77
  - Use .copy() when modifying DataFrames to avoid SettingWithCopyWarning
78
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
79
  VARIABLE & TYPE HANDLING:
80
  - Use descriptive variable names (avoid single letters in complex operations)
81
  - Ensure all variables are defined before use - initialize with defaults
 
69
  CRITICAL CODING PRACTICES:
70
 
71
  DATA VALIDATION & SAFETY:
72
+ - Always check if DataFrames/Series are empty before operations: if df.empty: answer = "No data available"; exit()
73
  - Use .dropna() to handle missing values or .fillna() with appropriate defaults
74
+ - Validate column names exist before accessing: if 'column' in df.columns: else: answer = "Column not found"
75
  - Check data types before operations: df['col'].dtype, isinstance() checks
76
  - Handle edge cases: empty results, single row/column DataFrames, all NaN columns
77
  - Use .copy() when modifying DataFrames to avoid SettingWithCopyWarning
78
 
79
+ SPECIFIC PLOT TYPE REQUIREMENTS:
80
+
81
+ WIND ROSE DIAGRAMS:
82
+ - Use matplotlib polar projection: fig, ax = plt.subplots(subplot_kw=dict(projection='polar'))
83
+ - Create proper wind direction bins: wind_bins = np.arange(0, 361, 30)
84
+ - Handle wind direction (0-360 degrees): convert to radians with np.radians()
85
+ - Group by wind direction bins and calculate statistics properly
86
+
87
+ CORRELATION ANALYSIS:
88
+ - Always use .dropna() before correlation: df_clean = df.dropna(subset=[col1, col2])
89
+ - Handle correlation matrices properly: corr = df_clean.corr()
90
+ - Check for sufficient data: if len(df_clean) < 10: answer = "Insufficient data"
91
+ - Use .abs() on Series, not float values: corr_series.abs() not float_value.abs()
92
+
93
+ STATISTICAL ANALYSIS:
94
+ - For wind speed thresholds: use boolean indexing df[df['WS (m/s)'] > 5.0]
95
+ - For meteorological factors: handle missing weather data gracefully
96
+ - For time-based analysis: ensure proper datetime conversion and filtering
97
+
98
  VARIABLE & TYPE HANDLING:
99
  - Use descriptive variable names (avoid single letters in complex operations)
100
  - Ensure all variables are defined before use - initialize with defaults