Thursday 17 January 2013

PAFEC transient with WEE, 3D structure and 3D acoustic


CONTROL
c SKIP.COLLAPSE
FRONTAL.TRANSIENT
PHASE=2
 PHASE=4
 ADD.IN.CD:
 R09890 149 1 1
 END.OF.ADD.IN.CD
PHASE=7
CONTROL.END

NODES
NODE X Y Z
 1   0 0 0
 2   1 0 0
 3   0 1 0
 4   1 1 0

 5   0 0 1
 6   1 0 1
 7   0 1 1
 8   1 1 1

 9   0 0 2
10   1 0 2
11   0 1 2
12   1 1 2

13   0 0 3
14   1 0 3
15   0 1 3
16   1 1 3

ELEMENTS
NUMBER GROUP ELEMENT PROP TOPO
c 1st order
  1    1      37100   11  1 2 3 4 5 6 7 8
  2    2      29700   12  5 6 7 8 9 10 11 12
  3    3      29520   12  9 10 11 12 13 14 15 16

c 2nd order
c  1    1      37110   11  1 2 3 4 5 6 7 8
c  2    2      29620   12  5 6 7 8 9 10 11 12
c  3    3      29540   12  9 10 11 12 13 14 15 16   c corner nodes complaint
c  3    3      29520   12  9 10 11 12 13 14 15 16   c corner nodes complaint



MATERIALS
MATERIAL E NU RO
   11   100E9 0.33 1E-10
MATERIALS
MATERIAL BULK.MO RO
   12    <344> 1.18

DEFINE.RESPONSE
TIME LIST.OF.TYPES.NODES.DIRECTIONS.AND.VALUES
 0    1 1 2 0
 1    1 1 2 1

FULL.DYNAMICS.OUTPUT
TYPE   START  FINISH  STEP
  2       1    100    1

RESPONSE
TYPE TIME.STEP BETA FINISH LIST.OF.NODES.AND.DIRECTIONS
 2       4E-6   0.25 10E-3   1 2

MODES.AND.FREQUENCIES
AUTO MODES
 0   0


C separate structure and acoustic nodes
COLLAPSE
COUP GR1 GR2
 3    1   2   c new nodes on the acoustic at the interface with structure.

END.OF.DATA

Friday 11 January 2013

numpy with pip?

sudo apt-get install python-pip
sudo apt-get install python-dev    # after prompting from the following
sudo pip install numpy
sudo pip install scipy

Seems to be working on Chaos...  Ah, numpy was ok.  Scipy fell over due to lack of BLAS.

sudo apt-get install python-scipy

got it in there; presumably without BLAS setup.

Thursday 10 January 2013

kindle latex preamble


%{{{
% tables using \textwidth should sum to 0.84\textwidth.

\documentclass[oneside, 10pt]{scrbook}

% I spent some time establishing the bottom=2.5mm.  Change it with care.
\usepackage[verbose,paperwidth=9cm,paperheight=12.2cm,margin=0.5mm, bottom=2.5mm]{geometry}  
% do this first, as other packages use the page dims

\usepackage{microtype}  % reduces hyphenation
\usepackage{fancyhdr}   % headers and footers
\pagestyle{fancy}
\fancyhead{}            % clear page header
\fancyfoot{}            % clear page footer

% The following have not been optimised yet.
\setlength{\abovecaptionskip}{2pt} % space above captions
\setlength{\belowcaptionskip}{0pt} % space below captions
\setlength{\textfloatsep}{2pt}     % space between last top float / first bottom float text
\setlength{\floatsep}{2pt}         % space left between floats
\setlength{\intextsep}{2pt}        % space left on top and bottom of an in-text float
%
\pagestyle{empty}      % suppress page number.  Repeat after every chapter.
\usepackage{ifthen}    % logic programming
\usepackage{booktabs}  % top, mid, bottomrule in tables
\usepackage{longtable} % essential for small kindle display
\usepackage{color}     % Colour is used though this kindle is b/w
\usepackage{expdlist}  % long description items

\title{Notes}
\author{Mark St.}

% from https://www.cl.cam.ac.uk/~rf10/pstex/latexcommands.htm
% this sets the default font to be the system default sans-serif font.
% I'm adopting this for kindle as the serifs are problematic for
% low resolution display.  It is computer modern sans serif.

\renewcommand{\familydefault}{\sfdefault}

\renewcommand{\small}{\fontsize{4}{6}\selectfont}

\renewcommand{\normalsize}{\fontsize{6}{8}\selectfont}

\begin{document}%}}}

ipython video!


from IPython.display import HTML
video = open("animation.m4v", "rb").read()
video_encoded = video.encode("base64")
video_tag = '.format(video_encoded)
HTML(data=video_tag)

from http://nbviewer.ipython.org/urls/raw.github.com/ipython/ipython/master/docs/examples/notebooks/00_notebook_tour.ipynb

Thursday 3 January 2013

pandas notes

Extracting f0

x = store['spl20130409_107-6']
f0 = x.Freq[(x.SPL == max(x.SPL))]

:)

Extracting a results set by frequency range and node number from a store object (a dataFrame)

storeName = root + '20121205-WEEaxisymConstDispSettleTimes.h5'

store = pd.HDFStore(storeName)
x = store['ball70_p']
f = x.Freq[(x.Node == 32) & (x.Freq > fmin) & (x.Freq < fmax)].values
p = abs(x.Pressure[(x.Node == 32) & (x.Freq > fmin) & (x.Freq < fmax)]).values
store.close()

My observations suggest the store is volatile:  it should be closed when not in use to prevent database failure in case of, say,
power failure.  So it seems an open and close should be used in each ipython cell.  Wrap with, the open and close functions.

This seems clunky.  :(


Creating a dataFrame with column based data and appending new results without new columns,  with sort based on one of the columns.


for i in [4]:
    a = mfile.File(root2 + '1_hw%i.O07' % i); a.load()
    b = pd.DataFrame(a.pressures, columns = ['Freq', 'Node', 'Pressure'])
    c = store['v22_1_p'].append(b)
    c = c.sort_index(by = 'Freq')
    store['v22_1_p'] = c


Creating a multicolumn dataFrame with labels.


b = pd.DataFrame(array([x0[0, 1:], x0[1, 1:], x0[2, 1:], x0[3, 1:], x0[4, 1:]]).transpose(), 
        columns = ['Time', 'pNode4', 'pNode31', 'pNode32', 'pNode11', 'dNode35'])



Deleting an item in the store:

store.remove(keyName)

Adding a column to a dataFrame: (this does not work with the store)

b = pd.DataFrame(Q, columns = ['f0', 'DisplacementAtF0', 'Q'])  # create
b['newCol'] = listVariable   # append column



Printing a whole dataframe or specific columns

print melamine5cm.to_string()


    uMinMeas  uMaxMeas  uMeanMeas  dpMeas  uMeanSample  uErrorSample   resistivity       RError
0       0.03      0.03      0.030     5.4     0.003140      0.000000  17196.694215     0.000000
1       0.30      0.30      0.300    12.7     0.031401      0.000000   4044.407713     0.000000
2       0.15      0.19      0.170    19.7     0.017794      0.002093  11071.074380  1165.376251
3       0.54      0.68      0.610    27.1     0.063849      0.007327   4244.357133   436.919117
4       0.84      1.01      0.925    37.8     0.096821      0.008897   3904.114362   328.564080
5       0.97      1.01      0.990    46.0     0.103625      0.002093   4439.101761    87.903005
6       1.04      1.09      1.065    52.5     0.111475      0.002617   4709.579793   108.017885
7       1.24      1.31      1.275    61.7     0.133456      0.003663   4623.250689   123.521965
8       1.49      1.52      1.505    70.4     0.157530      0.001570   4468.982181    44.101798
9       1.61      1.68      1.645    78.1     0.172184      0.003663   4535.838629    94.496638
10      1.85      1.86      1.855    87.6     0.194165      0.000523   4511.621483    12.128015
11      1.89      1.95      1.920    94.6     0.200969      0.003140   4707.196970    72.418415
12      2.06      2.14      2.100   103.3     0.219810      0.004187   4699.519874    87.841493
13      2.29      2.34      2.315   111.9     0.242314      0.002617   4617.974760    49.337337


print melamine5cm.take([4, 5, 6, 7], axis=1)

    uMeanSample  uErrorSample   resistivity       RError
0      0.003140      0.000000  17196.694215     0.000000
1      0.031401      0.000000   4044.407713     0.000000
2      0.017794      0.002093  11071.074380  1165.376251
3      0.063849      0.007327   4244.357133   436.919117
4      0.096821      0.008897   3904.114362   328.564080
5      0.103625      0.002093   4439.101761    87.903005
6      0.111475      0.002617   4709.579793   108.017885
7      0.133456      0.003663   4623.250689   123.521965
8      0.157530      0.001570   4468.982181    44.101798
9      0.172184      0.003663   4535.838629    94.496638
10     0.194165      0.000523   4511.621483    12.128015
11     0.200969      0.003140   4707.196970    72.418415
12     0.219810      0.004187   4699.519874    87.841493
13     0.242314      0.002617   4617.974760    49.337337

Why that's double spaced I don't know!

Adjusting number of columns printed
pandas.set_option('display.max_columns', 50)