Skip to content

Commit 1491f3d

Browse files
committed
Consolidated instructions for saving figures
1 parent 2e617c0 commit 1491f3d

2 files changed

Lines changed: 4 additions & 3 deletions

File tree

src/climateclaw/prompt_library/baseline/examples.jsonl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@
131131
// Handlind daily data
132132
{"variant":"User","content":"Make a map plot of surface wind on 25.04.2010."}
133133
{"variant":"Assistant","content":"Here's how I will proceed:\n\n1. Query ERA5 surface wind (sfcWind) data for 25 April 2010 using freva-client.\n2. Load the data for that day using xarray.\n3. Create a global map plot (PlateCarree) of daily mean surface wind using matplotlib and cartopy.\n4. Add coastlines, borders, and a colorbar to the plot.\n\nLet's perform these steps now."}
134-
{"variant":"Code", "content":["{\"code\":\"import freva_client\\nimport xarray as xr\\nimport matplotlib.pyplot as plt\\nimport cartopy.crs as ccrs\\nimport cartopy.feature as cfeature\\nimport numpy as np\\n\\n# 1. Query ERA5 surface wind (sfcWind) data for 25 April 2010\\nerawind_files = freva_client.databrowser(\\n project='reanalysis',\\n experiment='era5',\\n variable='sfcwind',\\n time_frequency='day',\\n time='2010-04-25',\\n host='nextgems.dkrz.de')\\n\\n# 2. Load the data\\nds = xr.open_mfdataset(list(erawind_files), combine='by_coords')\\nwind = ds['sfcWind'].sel(time='2010-04-25').squeeze()\\n\\n# 3. Prepare lon/lat grid\\nd_lon = ds['lon']\\nd_lat = ds['lat']\\nlon2d, lat2d = np.meshgrid(d_lon, d_lat)\\n\\n# 4. Plotting\\nfig, ax = plt.subplots(figsize=(12,6), subplot_kw={'projection': ccrs.PlateCarree()})\\nlevels = np.linspace(np.nanmin(wind), np.nanmax(wind), 60)\\ncf = ax.contourf(lon2d, lat2d, wind, levels=levels, cmap='viridis', extend='both', transform=ccrs.PlateCarree())\\nax.add_feature(cfeature.COASTLINE)\\nax.add_feature(cfeature.BORDERS, linestyle=':')\\nplt.colorbar(cf, orientation='horizontal', pad=0.05, aspect=50, label='Surface Wind (m/s)')\\nplt.title('ERA5 Surface Wind on 2010-04-25')\\nplt.tight_layout()\\nplt.show()\"}","daily_wind_plot"]}
134+
{"variant":"Code", "content":["{\"code\":\"import freva_client\\nimport xarray as xr\\nimport matplotlib.pyplot as plt\\nimport cartopy.crs as ccrs\\nimport cartopy.feature as cfeature\\nimport numpy as np\\n\\n# 1. Query ERA5 surface wind (sfcWind) data for 25 April 2010\\nerawind_files = freva_client.databrowser(\\n project='reanalysis',\\n experiment='era5',\\n variable='sfcwind',\\n time_frequency='day',\\n time='2010-04-25',\\n host='nextgems.dkrz.de')\\n\\n# 2. Load the data\\nds = xr.open_mfdataset(list(erawind_files), combine='by_coords')\\nwind = ds['sfcWind'].sel(time='2010-04-25').squeeze()\\n\\n# 3. Prepare lon/lat grid\\nd_lon = ds['lon']\\nd_lat = ds['lat']\\nlon2d, lat2d = np.meshgrid(d_lon, d_lat)\\n\\n# 4. Plotting\\nfig, ax = plt.subplots(figsize=(12,6), subplot_kw={'projection': ccrs.PlateCarree()})\\nlevels = np.linspace(np.nanmin(wind), np.nanmax(wind), 60)\\ncf = ax.contourf(lon2d, lat2d, wind, levels=levels, cmap='viridis', extend='both', transform=ccrs.PlateCarree())\\nax.add_feature(cfeature.COASTLINE)\\nax.add_feature(cfeature.BORDERS, linestyle=':')\\nplt.colorbar(cf, orientation='horizontal', pad=0.05, aspect=50, label='Surface Wind (m/s)')\\nplt.title('ERA5 Surface Wind on 2010-04-25')\\nplt.tight_layout()\\nplt.savefig('era5_surface_wind_20100425.png')\"}","daily_wind_plot"]}
135135
{"variant":"CodeOutput","content":["","daily_wind_plot"]}
136136
{"variant":"Assistant","content":"Here is the global map plot of ERA5 surface wind (sfcWind, m/s) for 25 April 2010.\nThe map uses a PlateCarree projection, includes coastlines and country borders, and the colorbar shows the wind speed in meters per second. If you need any specific adjustments or a different region/projection, just let me know!"}
137137
// Weighting by area

src/climateclaw/prompt_library/baseline/starting_prompt.txt

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -112,8 +112,9 @@ G. FAILURE & TIMEOUT HANDLING
112112
H. FILE SAVING
113113

114114
1. When using code_interpreter to create a plot, chart, figure, image, map, or visualization for the user, always save it to a file in the current working directory.
115-
2. Use a descriptive filename with an appropriate extension, such as `.png`, `.jpg`, `.svg`, or `.pdf`.
116-
2. Only use `open` and do NOT `import os`.
115+
2. Instead of displaying figures inline, save every generated figure to disk, and close each figure after saving to avoid unnecessary inline rendering or memory use.
116+
3. Use a descriptive filename with an appropriate extension, such as `.png`, `.jpg`, `.svg`, or `.pdf`.
117+
4. Only use `open` and do NOT `import os`.
117118

118119
I. FORMATTING
119120

0 commit comments

Comments
 (0)