Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Fixed directory structure naming using os.path.join instead of appending separation characters manually
  • Loading branch information
daminton committed Feb 23, 2022
1 parent a3d78a9 commit 769ed17
Showing 1 changed file with 4 additions and 28 deletions.
32 changes: 4 additions & 28 deletions python/ctem/ctem/io.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,30 +8,6 @@
# Set pixel scaling common for image writing, at 1 pixel/ array element
dpi = 72.0

def copy_dists(user, output_filenames, distlist):
# Save copies of distribution files

orig_list = ['odistribution', 'ocumulative', 'pdistribution', 'tdistribution']
dest_list = ['odist', 'ocum', 'pdist', 'tdist']

for index in range(len(orig_list)):
forig = user['workingdir'] + orig_list[index] + '.dat'
fdest = user['workingdir'] + 'dist' + os.sep + dest_list[index] + "_%06d.dat" % user['ncount']
shutil.copy2(forig, fdest)

forig = user['workingdir'] + 'impactmass.dat'
fdest = user['workingdir'] + 'misc' + os.sep + "mass_%06d.dat" % user['ncount']
shutil.copy2(forig, fdest)

if (user['savetruelist'].upper() == 'T'):
forig = user['workingdir'] + 'tcumulative.dat'
fdest = user['workingdir'] + 'dist' + os.sep + "tcum_%06d.dat" % user['ncount']
shutil.copy2(forig, fdest)

return



def create_dir_structure(user):
# Create directories for various output files if they do not already exist
directories = ['dist', 'misc', 'rego', 'rplot', 'surf', 'shaded']
Expand Down Expand Up @@ -95,7 +71,7 @@ def create_rplot(user, odist, pdist, tdist, ph1):
timelabel = 'Time = ' + r'${}$ x 10$^{}$'.format(tlabel[0], texp) + ' yrs'

# Save image to file
filename = user['workingdir'] + 'rplot' + os.sep + "rplot%06d.png" % user['ncount']
filename = os.path.join(user['workingdir'],'rplot',"rplot%06d.png" % user['ncount'])
height = user['gridsize'] / dpi
width = height
fig = plt.figure(figsize=(width, height), dpi=dpi)
Expand Down Expand Up @@ -151,7 +127,7 @@ def image_dem(user, DEM):
ax.imshow(dem_img, interpolation="nearest", cmap='gray', vmin=0.0, vmax=1.0)
plt.axis('off')
# Save image to file
filename = user['workingdir'] + 'surf' + os.sep + "surf%06d.png" % user['ncount']
filename = os.path.join(user['workingdir'],'surf',"surf%06d.png" % user['ncount'])
plt.savefig(filename, dpi=dpi, bbox_inches=0)

return
Expand All @@ -170,7 +146,7 @@ def image_regolith(user, regolith):
(np.log(regolith_scaled) - np.log(minreg)) / (np.log(maxreg) - np.log(minreg)))

# Save image to file
filename = user['workingdir'] + 'rego' + os.sep + "rego%06d.png" % user['ncount']
filename = os.path.join(user['workingdir'],'rego', "rego%06d.png" % user['ncount'])
height = user['gridsize'] / dpi
width = height
fig = plt.figure(figsize=(width, height), dpi=dpi)
Expand Down Expand Up @@ -223,7 +199,7 @@ def image_shaded_relief(user, DEM):
ax.imshow(dem_img, interpolation="nearest", vmin=0.0, vmax=1.0)
plt.axis('off')
# Save image to file
filename = user['workingdir'] + 'shaded' + os.sep + "shaded%06d.png" % user['ncount']
filename = os.path.join(user['workingdir'],'shaded',"shaded%06d.png" % user['ncount'])
plt.savefig(filename, dpi=dpi, bbox_inches=0)
return user

Expand Down

0 comments on commit 769ed17

Please sign in to comment.