<commit_before>#!/usr/bin/env python

import numpy
import pylab
import sys
import mesh.patch as patch

# plot an output file using the solver's dovis script

def makeplot(myd, solverName):

    exec 'import ' + solverName + ' as solver'

    pylab.figure(num=1, figsize=(8,4.5), dpi=100, facecolor='w')

    solver.dovis(myd, 0)
    pylab.savefig("plot.png")
    pylab.savefig("plot.eps")
    pylab.show()


if __name__== "__main__":

    print sys.argv

    solver = sys.argv[1]
    file = sys.argv[2]

    myg, myd = patch.read(file)

    makeplot(myd, solver)



<commit_msg>add a -o option and some usage (-h) help<commit_after>#!/usr/bin/env python

import numpy
import pylab
import sys
import getopt

import mesh.patch as patch

# plot an output file using the solver's dovis script

def makeplot(myd, solverName, outfile):

    exec 'import ' + solverName + ' as solver'

    pylab.figure(num=1, figsize=(8,4.5), dpi=100, facecolor='w')

    solver.dovis(myd, 0)
    pylab.savefig(outfile)
    pylab.show()


def usage():
    usage="""
usage: plot.py [-h] [-o image.png] solver filename

positional arguments:
  solver        required inputs: solver name
  filename      required inputs: filename to read from

optional arguments:
  -h, --help    show this help message and exit
  -o image.png  output image name. The extension .png will generate a PNG
                file, .eps will generate an EPS file (default: plot.png).
"""
    print usage
    sys.exit()


if __name__== "__main__":

    try: opts, next = getopt.getopt(sys.argv[1:], "o:h")
    except getopt.GetoptError:
        sys.exit("invalid calling sequence")

    outfile = "plot.png"

    for o, a in opts:
        if o == "-h": usage()
        if o == "-o": outfile = a
                                    
    try: solver = next[0]
    except: usage()
        
    try: file = next[1]
    except: usage()

    myg, myd = patch.read(file)

    makeplot(myd, solver, outfile)




{'fraction_non_alphanumeric': 0.12346311475409837, 'fraction_numerical': 0.010758196721311475, 'mean_word_length': 2.630111524163569, 'pattern_counts': {'":': 4, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 1, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3148346', 'n_tokens_mistral': 714, 'n_tokens_neox': 663, 'n_words': 203}