Skip to content

Commit

Permalink
handle html and mp4 separately for dpi/embedded figure width in brows…
Browse files Browse the repository at this point in the history
…er issues.
  • Loading branch information
kbarnhart committed Mar 21, 2024
1 parent 94e2084 commit 57075b1
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 21 deletions.
4 changes: 3 additions & 1 deletion src/python/visclaw/data.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,9 @@ def __init__(self, controller=None):
self.add_attribute('html_index_title','Plot Index') # title at top of index page
self.add_attribute('html_homelink',None) # link to here from top of _PlotIndex.html
self.add_attribute('html_movie','JSAnimation') # make html with java script for movie
self.add_attribute('html_movie_width', 500) # width of movie
self.add_attribute('html_movie_width', 500) # width of movie (not used?)
self.add_attribute('html_movie_dpi', 100) # dpi of movie

self.add_attribute('html_eagle',False) # use EagleClaw titles on html pages?

self.add_attribute('kml',False) # make kml plots and a kml file for figures
Expand Down
46 changes: 26 additions & 20 deletions src/python/visclaw/plotpages.py
Original file line number Diff line number Diff line change
Expand Up @@ -3077,37 +3077,43 @@ def plotclaw_driver(plotdata, verbose=False, format='ascii'):
else:
png_prefix = plotdata.file_prefix

outputs = []
if plotdata.html_movie == "JSAnimation":
outputs.append('html')
if plotdata.mp4_movie:
outputs.append('mp4')

# get original dpi and fig shape, if
# this ensures that the resolution of the movie is the
# same as the frames.
# get original fig shape
figname = plotdata._figname_from_num[figno]
plotfigure = plotdata.plotfigure_dict[figname]

figkwargs = getattr(plotfigure, 'kwargs', {})
figsize = getattr(plotfigure, 'figsize', None)
if figsize is None:
figsize = figkwargs.get('figsize', None)
dpi = figkwargs.get('dpi', html_movie_dpi)

# make animations
animation_tools.make_anim_outputs_from_plotdir(plotdir=plotdir,
#file_name_prefix='movieframe_allframes',
file_name_prefix=plotdata.movie_name_prefix,
png_prefix=png_prefix,
figsize=figsize,
dpi=dpi,
fignos=[figno], outputs=outputs,
raw_html=raw_html)
if plotdata.mp4_movie:
# use default dpi or get from plotdata
# this ensures that if it was set, dpi of mp4 is same as frames.
dpi = figkwargs.get('dpi', html_movie_dpi)
animation_tools.make_anim_outputs_from_plotdir(plotdir=plotdir,
#file_name_prefix='movieframe_allframes',
file_name_prefix=plotdata.movie_name_prefix,
png_prefix=png_prefix,
figsize=figsize,
dpi=dpi,
fignos=[figno], outputs=['mp4'],
raw_html=raw_html)

if plotdata.html_movie == "JSAnimation":
# use different dpi so that plots do not take over browser width.
animation_tools.make_anim_outputs_from_plotdir(plotdir=plotdir,
#file_name_prefix='movieframe_allframes',
file_name_prefix=plotdata.movie_name_prefix,
png_prefix=png_prefix,
figsize=figsize,
dpi=plotdata.html_movie_dpi,
fignos=[figno], outputs=['html'],
raw_html=raw_html)

# Note: setting figsize=None above chooses figsize with aspect
# ratio based on .png files read in, may fit better on page
# 3/21/24 - For MP4 size and dpi are taken from plotdata for each figure.
# 3/21/24 - For MP4 size and dpi are taken from plotdata for
# each figure.


#-----------
Expand Down

0 comments on commit 57075b1

Please sign in to comment.