Thursday 25 June 2009

pgfplots axis scaling error



The 10^{-2} scaling label is incorrect and unasked for. Turn it off by:

\begin{axis}[scaled y ticks=false, 

Sunday 21 June 2009

Converting gzips to png and maybe cropping

The following routine was used to batch convert all \verb".gz" files in a
directory to .png. The format of the file inside the zipfile doesn't matter
as the conversion takes place automatically.

The routine is in \verb"ms.py"


import Image, gzip, os, StringIO

def unzip_file(filename):
fileObj = gzip.GzipFile(filename, 'rb');
fileContent = fileObj.read()
fileObj.close()
return(fileContent)

def gz2png():
# get the directory listing
files = os.listdir('.')

for i in files:
# import the zipfile
if '.gz' in i:
print i,
data = unzip_file(i)
# Convert this data into an image object.
im = Image.open(StringIO.StringIO(data))

# Use pil to convert to .png and save it for external compilation.
f2 = i.split('.')[0] + '.png'
im.save(f2)
print ' -> ', f2



To use, perform \verb">>> import imageconv; imageconv.convert()" in the
directory containing the files. A similar routine for converting to gif
exists by the name \verb"gz2gif". This routine is now in \verb"ms.py".

\protect to \cite in \caption

\protect before the \cite, fixes the problem.

a better way to mount usb drives.

Don't just sudo mount /dev/sdb /media/tmp

This mounts with root ownership. Rather,

sudo mount -o uid=username /dev/sdb /media/tmp

------------

Or in fstab:

/dev/sdb1 /home/me/mountpoint vfat gid=mylogin,dmask=007,fmask=117,rw 0 3

-----------

Friday 19 June 2009

CFD Codes

Dolfyn: K-Epsilon only, but appears well integrated with gmsh.
OpenFoam: Appears to support many turbulence models, including RSM. Not so well integrated with Gmsh, but well integrated with ParaView (?).

Thursday 18 June 2009

Installing Latex packages inc circuitikz and siunitx




Not conforming to standards but simple:
mkdir ~/downloads/latex/circuitikz


Navigate to:
circuitikz

Save all the files to
 ~/downloads/latex/circuitikz 


Make sure .bashrc contains:

# for latex packages, installed to ~/latex/:
export TEXINPUTS=/home/login/downloads/latex//:


Open a terminal and run:
 sudo texhash 


Test:

\ctikzset{bipoles/length = 1.4 cm} % careful of whitespace here with /, and when using 5: NO WHITESPACE!
\begin{circuitikz}[scale = 1.2]
\draw (0, 0) node[anchor = east] {B}
to[short, o-*] (1,0)
to [R=20<\ohm>, *-*] (1,2)
to [R=10<\ohm>, v=$v_{x}$] (3,2) -- (4,2)
to [cI = $\frac{\siemens}{5} v_{x}$, *-*] (4,0) -- (3,0)
to [R = 5<\ohm>, *-*] (3,2) % no whitespace between 5 and
(3,0) -- (1,0)
(1,2) to [short, -o] (0,2) node[anchor = east] {A};
\end{circuitikz}


Beware whitespaces (as noted). Do not use them between numbers and units, or the following error will occur:

! Package siunitx Error: Invalid character `20 ' in numerical input.

See the siunitx package documentation for explanation.
Type H for immediate help.
...

l.44 to [R=20 <\ohm>, *-*] (1,2)
^^M


Turns out, circuitikz required siunitx also, and the manual wasn't so helpful in that
only a .pdf was present, and copy/paste from the .pdf changed the * and - characters.

So, check http://home.dei.polimi.it/mredaelli/circuitikz/examples.html
for real examples but consider also, siunitx - if you were wondering why 1*10^{5} looks
so crap in tex!

Sunday 7 June 2009

ubuntu hangs on shutdown due to windows shares

https://help.ubuntu.com/community/MountWindowsSharesPermanently

shows this should be fixed with:

sudo update-rc.d -f umountnfs.sh remove
sudo update-rc.d umountnfs.sh stop 15 0 6 .

and it was!

Thursday 4 June 2009

PGFplots limits / nan problems

Plotting big numbers (> 1E6), is ok, as long as the axis
limits are not specified. If nan errors start cropping up,
remove the axis limit definitions.

The second axis, if used, can be defined by plotting the
data again; but plot using [color = white, only marks]

Or, add a new plot(s) with a single point(s), color = white,
to force pgfplots to extend the axis. Add these plots last,
and don't give 'em a legend entry.