<commit_before>#!/usr/bin/env python
"""
Load and display Array data file, or raw SD-card-dumped disparate dumps.

...the latter is "raw" in the sense that it is not in the standard
file container for Array data as described in the technical manual.

Use the command-line flag -l to get a figure with an informative title
(at the possible cost of screen real estate).

Internal notes: There are some internal constants that should either
be dynamically determined from the given data or set by the User.


<NAME>  <<EMAIL>>
Jun, Sep-Oct 2010.
"""


import sys
import math
from os import getcwd

import numpy as np
import matplotlib as mpl
import matplotlib.pyplot as plt

import batstack


Ts = 3.75e-6

# Before everything, look for and extract -l and -s arguments
try:
    ind = sys.argv.index('-l')
    verbose_title = True
    sys.argv.pop(ind) # Pull it out
except ValueError:
    verbose_title = False
try:
    ind = sys.argv.index('-s')
    mk_specgram = True
    sys.argv.pop(ind) # Pull it out
except ValueError:
    mk_specgram = False

# Now usual command-line argument processing
if '-h' in sys.argv or len(sys.argv) == 1:
#or (len(sys.argv) != 2 and len(sys.argv) < 4) or not (len(sys.argv)%2 == 0 or (len(sys.argv) >= 7 and sys.argv[-3] == '-t')):
    ind = sys.argv[0].rfind('/')
    if ind != -1:
        progname = sys.argv[0][ind+1:]
    else:
        progname = sys.argv[0]
    print 'Usage: %s $Array-data-file [-l] [-s]\nUsage: %s $basename ($addr $trial)^? [-t $t_start $t_stop] [-l] [-s]' % (progname, progname)
    exit(1)

# Handle case of reading an Array data file (rather than disparate SD-card-dumped shit).
if len(sys.argv) == 2 or (len(sys.argv) == 5 and '.bin' in sys.argv[1]):
    using_Arr_datafile = True # To help with verbose_title
    bsaf = batstack.BSArrayFile(sys.argv[1])
    bsaf.printparams()
    if len(bsaf.data) < 1:
        print 'Error reading Array data file (or its empty).'
        exit(-1)
    x = bsaf.export_chandata()
    
    try:
        ind = sys.argv.index('-t')
        if len(sys.argv)-ind > 2:
            t_win = [float(sys.argv[ind+1]), float(sys.argv[ind+2])]
        else:
            print 'Invalid time spec.'
            exit(-1)
    except ValueError:<commit_msg>Update usage notes for loadtrial.py.<commit_after>#!/usr/bin/env python
"""
Load and display Array data file, or raw SD-card-dumped disparate dumps.

...the latter is "raw" in the sense that it is not in the standard
file container for Array data as described in the technical manual.

Use the command-line flag -l to get a figure with an informative title
(at the possible cost of screen real estate).

Internal notes: There are some internal constants that should either
be dynamically determined from the given data or set by the User.


<NAME>  <<EMAIL>>
Jun, Sep-Oct 2010; Jan 2011.
"""


import sys
import math
from os import getcwd

import numpy as np
import matplotlib as mpl
import matplotlib.pyplot as plt

import batstack


Ts = 3.75e-6

# Before everything, look for and extract -l and -s arguments
try:
    ind = sys.argv.index('-l')
    verbose_title = True
    sys.argv.pop(ind) # Pull it out
except ValueError:
    verbose_title = False
try:
    ind = sys.argv.index('-s')
    mk_specgram = True
    sys.argv.pop(ind) # Pull it out
except ValueError:
    mk_specgram = False

# Now usual command-line argument processing
if '-h' in sys.argv or len(sys.argv) == 1:
    ind = sys.argv[0].rfind('/')
    if ind != -1:
        progname = sys.argv[0][ind+1:]
    else:
        progname = sys.argv[0]
    print 'Usage: %s $Array-data-file [-l] [-s] [-t $t_start $t_stop]\nUsage: %s $basename ($addr $trial)^? [-t $t_start $t_stop] [-l] [-s]' % (progname, progname)
    exit(1)

# Handle case of reading an Array data file (rather than disparate SD-card-dumped shit).
if len(sys.argv) == 2 or (len(sys.argv) == 5 and '.bin' in sys.argv[1]):
    using_Arr_datafile = True # To help with verbose_title
    bsaf = batstack.BSArrayFile(sys.argv[1])
    bsaf.printparams()
    if len(bsaf.data) < 1:
        print 'Error reading Array data file (or its empty).'
        exit(-1)
    x = bsaf.export_chandata()
    
    try:
        ind = sys.argv.index('-t')
        if len(sys.argv)-ind > 2:
            t_win = [float(sys.argv[ind+1]), float(sys.argv[ind+2])]
        else:
            print 'Invalid time spec.'
            exit(-1)
    except ValueError:
{'fraction_non_alphanumeric': 0.12579617834394904, 'fraction_numerical': 0.01364877161055505, 'mean_word_length': 2.90150842945874, 'pattern_counts': {'":': 0, '<': 12, '<?xml version=': 0, '>': 12, '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': '741533', 'n_tokens_mistral': 1532, 'n_tokens_neox': 1458, 'n_words': 524}