Scientific Computing

REGEX formatted date from string

This is a regular expression string to get YYYY-MM-DD string from arbitrary length string:

(19|20)dd([- /.])(0[1-9]|1[012])2(0[1-9]|[12][0-9]|3[01])

With Matlab/Octave regex for dates works like:

input = '09av8joj23oit2pojiijo/20398/vj89/2012-10-15/0298f9082j23'; %random stuff with date in it

regStr = '(19|20)dd([- /.])(0[1-9]|1[012])2(0[1-9]|[12][0-9]|3[01])';

[startIndex,endIndex] = regexp(input,regStr,'start','end')

myDate = input(startIndex:endIndex);

Making a 2D pyramid in MATLAB

Make a square-base 2D data pyramid in Matlab, where:

N
number of pixels per side (e.g. 512)
MinVal
minimum data value (e.g. 0)
MaxVal
maximum data value (e.g. 65535)
N = 256;
MinVal = 0;
MaxVal = 2^16 - 1;

data = nan(N);
temp = uint16(MinVal:round((MaxVal-MinVal)/(N/2)):MaxVal);

for i = 1:N/2
  data(i,i:end-i+1) = temp(i);
  data(i:end-i+1,i) = temp(i);
  data(end-i+1,i:end-i+1) = temp(i);
  data(i:end-i+1,end-i+1) = temp(i);
end

figure, mesh(data)

The values at the “base” of the pyramid are zero, and increase linearly on each side to 65,535. This sort of figure might be useful when testing an optical flow algorithm.

Making hdparm setting permanent in Ubuntu

Some Linux distros in the past set the APM default very aggressively, leading your hard drive to hundreds and thousands of load/unload cycles in too short period of time. Typically HDD are only rated for 600,000 load/unload cycles, so it might be beneficial to reduce this cycling, at the expense of some additional power consumption.

The procedure below is informational, and may or may not provide benefit.

You can slow down the cycling manually, but the system will FORGET this setting upon reboot.

Make HDParm setting semi-permanent:

make line hdparm -B 250 /dev/sda, where /dev/sda is the HDD you’re wanting to stop cycling.

geany /etc/pm/power.d/90_hdparm

type

chmod +x /etc/pm/power.d/90_hdparm

cp /etc/pm/power.d/90_hdparm /etc/pm/sleep.d

Reboot, and check that your setting “stayed”

hdparm -B /dev/sda

This setting allows the drive to unload after an extended period without use, perhaps helping the HDD run a bit cooler without excessive wear. Instead of 250 you could use 254, which is thought to disallow unloading altogether. Try 254 and monitor HDD temperature–100 degrees Fahrenheit is possible.

To check how many load/unload cycles you’re using, go into Disk Utility, SMART data, and scroll down to Load/Unload cycle count.

similar procedure

Fix WINE reading JPEG

WINE users may experience:

Failed reading JPEG because unable to find libjpeg.so.62

Fix by installing the Windows codecs:

winetricks windowscodecs

Benchmark Seagate Momentus XT 500GB hybrid HDD

The Seagate Momentus XT 500GB hybrid hard drive (4GB SSD, 500GB HDD) is a useful way to speedup system boot and execution. However, on brand new files the speed is the same as a typical hard drive. A USB 3.0 drive adapter shows what the drive could do over a USB 3.0 link, using Disk Utility on Ubuntu.

Average read speed: 90MB/sec. Average write speed: 97MB/sec.

HDD speed test

Narrow auroral arc notes

magnetic bottle: pitch angle distribution vs. mirror height equipotential lines -> parallel E-field (Stephen Knight 1970) -> Large scale, dull auroral arc

  • inertial alfven wave connection to parallel E-field

fine scale arcs assosciated with Farley-Buneman instabilities, GPS scintillation

energy to produce electron-ion pair ionization potential ~ 18 eV takes on average ~ 35 eV

energy deposition physics

single particle motion, 3 adiabatic invariants, Debye length, two fluid vector potential

Alfven wave can couple to whistler mode

Auroral emissions: Bohr model of atom. have to release energy gap between orbitals (work function). Vibrational modes

Ions: closure current electrons: field aligned current

Inertial alfven wave: electron mass matters due to phase speed > speed of light F=ma inertial limit inerital lag – prevents group velocity from exceeding speed of light

λe = c / ωpe electron skin depth confines wave

Auroral emissions:

Björn Gustavsson Ph.D. thesis discusses briefly specifics of four major auroral emission lines.

Thesis on kinetic reactions resulting in auroral emissions.

Auroral width:

  • Borovsky 1993 “Auroral arc thicknesses as predicted by various theories”, JGR: Space Physics.
  • Chaston 2003 “Width and brightness of auroral arcs driven by inertial Alfven waves”, JGR: Space Physics.

Books:

  • Chen
  • Kivelson and Russell
  • Cravens
  • Nagey