Scientific Computing

Asus P8Z77-M boot device choice

I found that there was no known special hotkey that will allow one to choose which device to boot when powering-up the PC.

What I found was to keep pressing Delete key upon booting, which brings you into BIOS setup. Under the Boot tab, scroll to the bottom, where you will see “force boot” choices. Click the one you want and the PC will do a one-time boot from that device.

Safely eject USB drives

Data drive write caching can lead to data loss upon unplugging an external flash drive or hard drive. Inexpensive USB flash drives may write data slowly. Operating systems use RAM to cache write data, making the copy/write operation appear done while the final data writing is actually still underway. If the drive is removed before the writing is done, that file or even the whole disk can become corrupted and unreadable.

For example, a drive writing at 10 MByte / second for a 1 GByte file could take 1000 / 10 = 100 seconds, despite the file copy operation appearing done in less than 10 seconds.

On macOS or Linux, verify writing to a flash drive is completed with sync and then click the Eject icon next to the drive’s name in Finder or File Manager.

Monitor macOS or Linux file write progress with iotop.

For Windows, use the Safely Remove Hardware icon in the system tray. Monitor Windows file write progress with Task Manager or Process Explorer.

Convert AVI to grayscale PNG

Large pixel-count or frame-count AVIs can be converted frame-by-frame to PNG. One can then use Irfanview or other common image browser to flick back and forth between movie frames.

The conversion uses ImageMagick, which calls FFmpeg.

magick -verbose CMOSvideoshorter_halfspeed.avi -type Grayscale CMOSvideo_%03d.png

Kenwood TS-2000 RS-232 remote baud rate change

Change the baud rate of the Kenwood TS-2000 over the RS-232 serial COM port locally or remotely. Faster rates are less reliable but enable quick parameter changes. 57600 has been reliable for me with the Kenwood TS-2000 for many years, but if you have high stakes operation or a noisy environment, in general slower serial speeds are more robust.

Local baud rate change

  1. menu 56
  2. select baud rate. Hamlib/rigctl recommends using the highest possible baud rate i.e. 57600 baud.
  3. power cycle the radio.

Remote baud rate change

  1. CAT EX menu item 56.

  2. Read the current baud rate by sending

     EX0560000;
    
  3. The radio will answer back

     EX05600004;
    

    which implies 57600 baud since the last digit is 4.

The last digit to baud is:

0: 4800
1: 9600
2: 19200
3: 38400
4: 57600

To set baud rate remotely, send the corresponding command. E.g. to set 57600 send:

EX05600004;

and turn off the TS-2000 by sending

PS0;

Now disconnect, and reconnect at the new baud rate (here, 57600) and turn the radio on by sending:

PS1;

Note: Lost communication with the TS-2000 requires a site visit. Be prepared.

MATLAB high CPU usage from Help browser

NOTE: Matlab R2024b and newer no longer use the internal Help browser for doc, instead referring “doc” commands to the system web browser.


After opening the Matlab Help Browser, Matlab might use 100% of one CPU core at about 25% duty cycle. Even after closing just the Help Browser while keeping Matlab itself open, this problem may persist.

Workaround: a one-time persistent setting.

Type in Matlab:

com.mathworks.mlwidgets.html.HtmlComponentFactory.setDefaultType('HTMLRENDERER');

Restart Matlab, reopen and close Matlab Help Browser. The CPU is no longer hanging at 100% after closing the Help Browser. However, this simpler Help Browser is not as graphically nice as the default Help Browser. Clickable links won’t work in the help files.

Undo workaround: revert back to the default Help Browser with this one-time persistent setting. Type in Matlab:

com.mathworks.mlwidgets.html.HtmlComponentFactory.setDefaultType('HTMLPANEL');

then restart Matlab.

Disable Beaglebone Black flashing heartbeat LED

Disable the Beaglebone Black flashing LEDs temporarily or permanently:

Persistently (permanently) disable: add to /etc/rc.local

echo none > /sys/class/leds/beaglebone\:green\:usr0/trigger
echo none > /sys/class/leds/beaglebone\:green\:usr1/trigger
echo none > /sys/class/leds/beaglebone\:green\:usr2/trigger
echo none > /sys/class/leds/beaglebone\:green\:usr3/trigger

Reference


Temporary disable (till reboot):

echo none > /sys/class/leds/beaglebone:green:usr0/trigger

Setting up GCX Linux astrometry program

Alternative: apt install astrometry.net


Install GCX

apt install gcx

GSC ACT catalog

there are a lot of directories with lots of ~50KB files, so it will take a while even with a very fast internet connection.

mkdir ~/gsc-act
cd ~/gsc-act

wget -r -nH --cut-dirs=5 ftp://cdsarc.u-strasbg.fr/pub/cats/I/255/GSC_ACT/

set File → File and Device Options/GSC to /home/username/gsc-act

username
your linux login

Tycho2 star catalog

mkdir ~/tycho2 && cd ~/tycho2

wget -r -nH --cut-dirs=5 ftp://cdsarc.u-strasbg.fr/pub/cats/I/259/

Once you see that they’ve downloaded correctly, do:

zcat tyc2.dat.??.gz > tycho2.dat

set File → File and Device Options/Tycho2 to /home/username/tycho2

username
your linux login