Python random seed init

Most programming languages have a built-in random number generator. Using an a priori random seed can be useful in testing simulations using randomness. In simulations with non-linear growth, small differences at the beginning of the simulations can result in significantly different time evolution of the outputs. To help test such simulations as compared against known-good reference data, it can be useful to set a known random seed to see that expected outputs result.

In Python Numpy, the random seed can be set:

import numpy.random

r = numpy.random.default_rng(seed=0)

x = r.standard_normal(3)

Observe that “x” will always be

[ 0.12573022 -0.13210486 0.64042265]

using different seed values result in a different set of repeatable pseudorandom numbers.

NOTE: the default RNG is not guaranteed to be stable over Numpy releases. The user may wish to specify a specific RNG like:

r = numpy.random.Generator(numpy.random.PCG64(seed=0))

MATLAB GCC version compatibility fix

Matlab with GCC / Gfortran needs compatible libc and libgfortran libraries. On non-officially-supported systems (too new Linux version), libc or libgfortran may be incompatible with Matlab.

Fortran

MATLAB/sys/os/glnxa64/libgfortran.so.5: version ‘GFORTRAN_1.4’ not found (required by /usr/lib/liblapack.so.3) MATLAB/sys/os/glnxa64/libgfortran.so.5: version `GFORTRAN_1.4' not found (required by /usr/lib/libblas.so.3)

Workaround: let the system default dynamic shared libraries take priority by renaming the Matlab libraries like:

cd $(matlab -batch "disp(matlabroot)")/sys/os/glnxa64

mv libgfortran.so.5 libgfortran.so.5.bak

C++

MATLAB/sys/os/glnxa64/libstdc++.so.6: version ‘GLIBCXX_3.4’ not found

Workaround: let the system default dynamic shared libraries take priority by renaming the Matlab libraries like:

cd $(matlab -batch "disp(matlabroot)")/sys/os/glnxa64

mv libstdc++.so.6 libstdc++.so.6.bak

Fix

If Matlab won’t startup, another way to do this from the system Terminal is:

cd $(dirname $(realpath $(which matlab)))/../sys/os/glnxa64/

mv libstdc++.so.6 libstdc++.so.6.bak

Use modern compilers in RHEL

Often we need a more modern compiler than is included in Red Hat / CentOS for HPC systems. Once an admin sets up GCC Toolset they can be loaded by any user thereafter.

To install and use a recent GFortran version, have the system admin do like:

yum install gcc-toolset-11-gcc-gfortran

Thereafter, users without sudo use the new Gfortran version for that Terminal session only by:

scl enable gcc-toolset-11 bash

Prior to CentOS / RHEL 8, this was known as Developer Toolset devtoolset.

Anker Soundcore Life P2 earbuds

The Anker Soundcore Life P2 has excellent sound quality. For use with more than one device, consider instead earbuds that have multipoint Blueooth (the Soundcore Life P2 earbuds do not have multipoint). The FCC ID is “2AOKB-A3919RT”.

In general for Bluetooth earbuds of any brand, it’s best to carry the charging container with you to protect and charge the earbuds when not in use. You may need to manually select “headset” or “stereo” mode in your operating system. Windows for example allows per-app defaults, or switch by clicking on Windows toolbar speaker icon.

The “pros” or upsides of these earbuds:

  • Excellent stereo sound quality including aptX
  • Works well with single earbud (left or right) and auto-enables stereo if 2nd earbud turned on (or mono if 2nd earbud turned off).
  • four microphones (two per ear) give excellent quality on two-way audio e.g. videoconferencing
  • holds in ear well with several earmold sizes–comfortable used several hours per day
  • USB-C charging jack on container, which fits well in pocket

The “cons” or downsides of these earbuds include negative characteristics that are serious enough to consider buying a different model earbud.

  • no multipoint Bluetooth–switching devices effectively requires repairing each time.
  • flashing status light annoyingly bright, particularly at night. They are like a “mug me” beacon if walking outside at night.

Re-pair both earbuds

Sometimes the earbuds lose sync with each other, so that they only function individually not as a stereo pair. The procedure for resetting / recovering stereo sync is from Soundcore support:

  • “Forget” the pairing with both Soundcore earbuds on your device
  • Place the earbuds into the charging case and ensure they are being charged (white light steady)
  • Press and hold the button on both earbuds for 3 seconds. The LED indicators will flash red 3 times and then turn white briefly. Release the buttons when the light turns white.

Now wait for about a minute.

  • Take both earbuds out of the charging case, and lay them where you can see each earbuds' light.
  • after a few seconds, the white light on one (usually right) earbud will flash quickly, which means it enters pairing mode.
  • On the phone, add device named “Soundcore” or “Soundcore-L” on the Bluetooth list. The white light will flash slowly, which means it paired successfully.
  • A few seconds later, there will pop out a screen with “Bluetooth Pairing Request”, just click “Pair” (this step is very important)

In the bluetooth pairing list the Soundcore is displayed as “connected”, and the Soundcore-L is displayed as “not connected”. In fact, the earbuds are normally TWS paired to work

GitHub Actions Windows MSYS2 MS-MPI

On Windows the most commonly used MPI libraries are MS-MPI and Intel MPI. MSYS2 is a popular choice to use GCC, Clang and many other developer tools from the Windows Command Prompt, PowerShell or the MSYS Terminal itself.

Continuous Integration for Windows MPI applications on GitHub Actions is accomplished using a workflow as below. This would be in a .github/workflows/ci_cmake.yml file.

Set inter-step environment variables using GitHub Actions environment files

Eton Elite Executive review

The Eton Elite Executive is the latest iteration of a fine entry-level SSB-enabled shortwave receiver. Others have noted its positive aspects that I generally agree with.

Here are a few downsides and limitations.

  • No computer connection. 700 memories, but they are manually entered.
  • Airband (118-136 MHz) suffers from overloading from FM broadcast (100 MHz). Manifests as broadband white noise and scratchy distorted voice-like sounds up to full-scale strength covering nearly all airband transmission. This happens when within a couple miles of an FM broadcast station.
  • The synchronous AM has a too-short time constant on tracking the carrier frequency. Music or tones like WWV break the frequency sync and sound wobbly.
  • backlight stays on in battery mode. This consumes a lot of battery if you forget to shut it off overnight. If you plug the radio in but have a master bench power shutoff, either remove the batteries or turn off the backlight.
  • several second delay when switching from AM to SSB or sync AM.

Some benefits:

  • The SSB receive has good audio quality for voice communications.
  • The selectable bandwidth generally works well. 3 kHz, 4kHz and 6 kHz are commonly used on AM, with narrower bandwidths available.
  • MW (530-1700 kHz) sensitivity is good, along with FM (100 MHz).
  • longwave NDB beacon sensitivity also seems good. Longwave uses the internal coil bar antenna like MW.
  • An external wire antenna (even if just clipped to the extendable antenna) makes a great improvement in many cases for shortwave.
  • The power adapter usually doesn’t cause interference. If you get a hum try running on battery instead to see if conducted or ground loop interference.

In general as with any shortwave radio, if there is too much noise, try turning off as many lights and unplugging as many items from wall mains power as possible. Then plug in / turn on one by one. When the noise is heard, take the radio around and see if the noise increases when near an offending object.

PowerShell command substitution

Linux / Unix / MacOS users are often familiar with using shell command substition. PowerShell command substitution works similarly. On any of these systems, command substitution works by enclosing the first command in “$()” like:

echo $(whoami)

To use additional strings adjacent to the command output, like when wanting to change directory relative to command output, enclose in quotes like:

cd "$(my_command)/rel/to/"