Skip to content

Commit

Permalink
create directory containing output file if it does not already exist
Browse files Browse the repository at this point in the history
  • Loading branch information
georgemccabe committed Oct 7, 2024
1 parent 951f8cd commit 4147b73
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion use_cases/Hurricane_Matthew/Visualization/map_funcs.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
"""

import sys
import os
import numpy as np
import datetime as dt
import wrf
Expand Down Expand Up @@ -517,6 +518,9 @@ def map_plot(opts):
if lg_text is not None:
ax.legend(loc=lg_loc, fontsize=lg_fontsize).set_zorder(15)

# create output directory if it does not already exist
os.makedirs(os.path.dirname(fname), exist_ok=True)

# Save and close the figure
plt.savefig(fname)
plt.close()
plt.close()

0 comments on commit 4147b73

Please sign in to comment.