Changeset 2812 in lmdz_wrf


Ignore:
Timestamp:
Apr 11, 2020, 1:27:16 AM (5 years ago)
Author:
lfita
Message:

Adding `pdf-eps' and instructions to resize by number of pixels

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tools/drawing_tools.py

    r2780 r2812  
    27032703    return colorvc
    27042704
    2705 def output_kind(kindf, namef, close):
     2705def output_kind(kindf, namef, close, quality=90):
    27062706    """ Function to generate the output of the figure
    27072707      kindf= kind of the output
     
    27102710      namef= name of the figure (without extension)
    27112711      close= if the graph has to be close or not [True/False]
     2712      quality= quality of the plot for 'convert' (90, default)
    27122713    """
     2714    # resizing by number of pixels: http://www.imagemagick.org/Usage/resize/#pixel
     2715    # convert topo_10k.png -resize 3300000@ topo_10k.eps
    27132716    import subprocess as sub
    27142717    fname = 'output_kind'
    27152718
    2716     availkindf = ['eps', 'gif', 'jpg', 'png', 'pdf-png', 'ps']
     2719    qS = str(quality)
     2720
     2721    availkindf = ['eps', 'gif', 'jpg', 'png', 'pdf-eps', 'pdf-png', 'ps']
    27172722
    27182723    if kindf == 'h':
     
    27402745            plt.savefig(namef + ".png")
    27412746            if close: print "Successfully generation of figure '" + namef + ".png' !!!"
     2747        elif kindf == 'pdf-eps':
     2748            plt.savefig(namef + ".pdf")
     2749            sub.call('convert -trim -density 300 ' + namef + '.pdf -quality '+ qS +  \
     2750              ' '+ namef+'.eps', shell=True)
     2751            sub.call('rm ' + namef + '.pdf', shell=True)
     2752            if close: print "Successfully generation of figure '" + namef + ".png' !!!"
    27422753        elif kindf == 'pdf-png':
    27432754            plt.savefig(namef + ".pdf")
    2744             sub.call('convert -trim -density 300 ' + namef + '.pdf -quality 90 '+  \
    2745               namef+'.png', shell=True)
     2755            sub.call('convert -trim -density 300 ' + namef + '.pdf -quality ' + qS + \
     2756              ' ' + namef+'.png', shell=True)
    27462757            sub.call('rm ' + namef + '.pdf', shell=True)
    27472758            if close: print "Successfully generation of figure '" + namef + ".png' !!!"
     
    1490614917
    1490714918    if kfig == 'pdf-png': kfigS = 'png'
     14919    elif kfig == 'pdf-eps': kfigS = 'eps'
    1490814920    else: kfigS = kfig
    1490914921
Note: See TracChangeset for help on using the changeset viewer.