<commit_before>#!/usr/bin/env python
"""Plot simulation results
"""

from __future__ import print_function

import sys

from matplotlib.pylab import *

from h5py import File

fname, _junk, gname = sys.argv[1].partition(':')

data = File(fname)
grp  = data[gname or '/']

simtype = grp.attrs['sim_type']

print('sim_type', simtype)

def show_vector(grp):
    'Show envelope size and angle as a function of s position'
    pos   = grp['pos']
    state = grp['state']

    subplot(2,1,1)
    plot(pos, state[:,0], '-b',
         pos, state[:,2], '-r',
         pos, state[:,4], '-g')
    xlabel('s')
    ylabel('size')
    legend(['x','y','z'])

    subplot(2,1,2)
    plot(pos, state[:,1], '-b',
         pos, state[:,3], '-r',
         pos, state[:,5], '-g')
    xlabel('s')
    ylabel('angle')

def show_generic(grp):
    print("Unknown sim_type")

showsim = {
  'Vector': show_vector
}

showsim.get(simtype)(grp)

show()<commit_msg>moment2: h5plot<commit_after>#!/usr/bin/env python
"""Plot simulation results
"""

from __future__ import print_function

import sys

from matplotlib.pylab import *

from h5py import File

fname, _junk, gname = sys.argv[1].partition(':')

data = File(fname)
grp  = data[gname or '/']

simtype = grp.attrs['sim_type']

print('sim_type', simtype)

def show_vector(grp, vector='state'):
    'Show envelope size and angle as a function of s position'
    pos   = grp['pos']
    state = grp[vector]

    subplot(2,1,1)
    plot(pos, state[:,0], '-b',
         pos, state[:,2], '-r',
         pos, state[:,4], '-g')
    xlabel('s')
    ylabel('size')
    legend(['x','y','z'])

    subplot(2,1,2)
    plot(pos, state[:,1], '-b',
         pos, state[:,3], '-r',
         pos, state[:,5], '-g')
    xlabel('s')
    ylabel('angle')

def show_generic(grp):
    print("Unknown sim_type")

showsim = {
  'Vector': show_vector,
  'MomentMatrix2': lambda x:show_vector(x,'moment0'),
}

showsim.get(simtype)(grp)

show()
{'fraction_non_alphanumeric': 0.19401444788441694, 'fraction_numerical': 0.016511867905056758, 'mean_word_length': 3.4068181818181817, 'pattern_counts': {'":': 0, '<': 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': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6300282', 'n_tokens_mistral': 735, 'n_tokens_neox': 744, 'n_words': 168}