Scientific Computing

Python Launcher executable scripts Windows

Python programs can be launched by

python myprog.py

The Python Launcher, on Windows allows running by simply

myprog.py

based on the shebang

#!/usr/bin/env python

which works on Windows and Unix-like OS to search the user’s PATH for the desired Python executable.

Notes

Specific executables #!/usr/bin/python are only for specific situations like GNU Radio. Generally, please use #!/usr/bin/env python.

WROL 950 FM translator 100.3 FM

FM translator W262CV on 100.3 FM greatly expands the AM listening audience of WROL 950 Class D AM. WROL’s 5kW day signal from Rumney Marsh Reservation in Saugus is greatly attenuated to 90 watts at night to protect stations including:

  • WIBX Utica, NY
  • WKDN King of Prussia, PA
  • CKNB New Brunswick, Canada

This means WROL night coverage is weak in Boston and even core North Shore communities that are well within WROL day coverage.

FM translators for AM: AM Revitalization FM translators for AM stations attempt to provide the AM daytime coverage 24 hours a day via 250 watt or less transmissions in the FM broadcast band. Having an FM signal can be a boon for station advertising revenue–provided the FM coverage is not disrupted by unexpected factors such as illegal broadcasters. The Feb. 2017 R&O extended the 60 dBu (1 mV/m) FM translator contour to the greater of the AM 2 mV/m contour or 25 mile radius.

WROL W262CV 100.3 specifications

  • 45 watts
  • 42 21 46.35012 N 071 05 08.18621W (WGS84) Near the MIT Kendall MBTA stop, on the Marriott Hotel on Broadway (next to Microsoft NERD building).
  • height above ground: 90 meters

WROL FM translator interference: the 100.3 pirates changed frequency, but WROL 100.3 faces severe challenges from, and presents new challenges to other licensed stations. Listeners to these existing stations may object to the new WROL 100.3 translator.

Co-channel

50 kW WHEB is the primary limitation to coverage, particularly in the northeastern parts of Boston. However, one can merely switch to WROL 950 AM in northeast exurbs of Boston as per W262CV Exhibit 3 interference study.

Licensed co-channel interferers include:

  • WKIT Bangor, ME
  • WHEB Portsmouth, NH 50 kW station that interfered with Dorchester 100.3 pirate, sometimes overriding pirate down to at least Chinatown area.
  • W262CL Brattleboro, VT
  • WKKB Middletown, RI
  • WFFG Warrensburg, NY
  • W262AS Bridgehampton, NY

Adjacent channel

For most listeners, co-channel WHEB is more limiting than first adjacent WBRS.

  • WBRS 100.1 Brandeis Univ., Waltham (25 watts)

Add bookmark folder in Ubuntu Nautilus

Ubuntu Gnome 3-based desktop is even better than Unity. However, I was puzzled by the lack of a folder bookmark menu item in Nautilus, Ubuntu’s default “File Explorer”.

Fix: simply dragging and dropping a folder into the left sidebar adds a folder bookmark in Nautilus.

Improved Sondrestrom, Greenland internet speed

For many years, $45/GByte and 400 kbps with 200+ ms ping was the state of the art internet connection at Sondrestrom near Kangerlussuaq, Greenland. Recent Internet upgrades give nearly 1 Mbps upload and multiple Mbps download.

Speedtest results Greenland

Speedtest results for Greenland internet

Xauthority with VirtualBox on Wayland

Wayland desktop after install / upgrade a VirtualBox Extension Pack may get a “can’t find Xauthority”. The fix is to revert to X11 as recommended by Ubuntu.

Fix by logging out, and at the login screen select X11 login. Install the VirtualBox Expansion Pack Logout and switch back to the default login (with Wayland). VirtualBox will work in Wayland.

Recover macOS with no mouse, keyboard only

A recent macOS upgrade to High Sierra mysteriously broke the Apple mouse Bluetooth connection. Despite the computer showing the mouse as paired, no motion of the cursor or response to clicks. The keyboard alone can reconnect the mouse if no wired mouse was available.

The frequently used Apple key is equivalent to the key on a PC keyboard.

  1. open the Go To folder dialog with Cmd Shift g
  2. type /Applications
  3. highlight (select) System Preferences with the arrow keys
  4. Cmd o to open System Preferences
  5. Select Bluetooth. You may see your mouse already paired.
  6. Use Tab to select the “x” (it’s hard to see the highlight due to the flat color scheme.
  7. press Space to delete the mouse pairing
  8. Cmd n to setup new device. Flip mouse power switch off, then on again if it doesn’t show up.
  9. select the mouse and press Enter.

Best colormap for Matlab/Matplotlib plots

Much has been written on selecting best colormaps from among: sequential, divergingm and qualitative. Sequential colormaps are good for representing magnitude of data. How much flow, how much precipitation, how much weight, temperature, etc. Having a monotonic lightness factor is important for perceptual consistency. Non-linear lightness is used to emphasize certain ranges of data, perhaps where snow changes to ice or rain. Non-monotonic lightness can be used to emphasize different types of precipitation or phase changes, etc. Example sparse data plots with reversed sequential colormaps: colormap_white_min.py, colormap_white_min.m

Reversed sequential colormaps are useful for sparse data such as astronomical images or precipitation data where a lot of data is at or near zero relative to other data. The reversal leads to near-zero areas being white and higher intensities being darker. While any colormap can be reversed, typically sequential colormaps are used with/without reversal. Matplotlib colormaps are reversed by appending _r to the colormap name. For example:

cmap='cubehelix_r'

Matlab and GNU Octave colormaps are reversed by flipud() the colormap. Colormaps in .m code are represented as an (N,3) array, where N is the number of steps in the colormap (typically 64 or 256).

colormap(flipud(cubehelix()))

Matlab cubehelix.m is like Matplotlib.

Diverging colormaps are useful for positive or negative data where the sign is as important as the magnitude. For example, in/out flows, positive/negative charge. These colormaps are white near the zero point (which can be offset) and intensify as their absolute magnitude increases.

Qualitative colormaps emphasize difference between values, but without a particular sense of ordering. This can be useful for categories, say a histogram of salary vs. employee type.

Diagnosing SSH servers

This checklist helps rapidly diagnose SSH server issues, segmenting the problem into whether it’s network, firewall or SSH server configuration issues.

This checklist is OpenSSH + Debian/Ubuntu centric. Some systems (particularly embedded) may use iptables or nftables directly instead of high-level ufw.

Check if the SSH server is actually running. Errors in /etc/ssh/sshd_config can prevent the SSH server from running.

service ssh status

should show feedback including:

Active: active (running)

If not, try

service ssh restart

If restarting SSH server allows connections, be sure that after rebooting the server, the SSH server still works. This could help avoid a costly trip back to the site later.

From the laptop, error

Connection refused.

can simply mean the SSH server is not running.

Firewall: check port SSH server is supposed to be on in /etc/ssh/sshd_config. Look for Port 22 or whatever the SSH server is on. Although “security through obscurity” is not the goal of changing to a non-default SSH port, it can drastically reduce the amount of log flooding.

Check that firewall is open on the SSH server port.

ufw status

22/tcp ALLOW Anywhere

22/tcp (v6) ALLOW Anywhere (v6)

Check that packets are making it from the SSH client to the SSH server by on the server

tcpdump port 22 -n -Q inout

Specify the desired network interface as revealed by ip a with the tcpdump -i option. When the SSH client attempts to connect, the SSH server tcpdump should show packets coming in on the desired port with the client IP address also shown. If not, see if the network itself has a firewall that’s blocking your packets.

Logs: should see attempts to connect showing in /var/log/auth.log. Try

tail -f /var/log/auth.log

to see if new attempts show up.


Fail2ban might have the laptop IP address in “jail”. Check on the SSH server to see which IP addresses are banned:

fail2ban-client status sshd

Ubuntu Meltdown / Spectre patch

Ubuntu’s Meltdown/Spectre wiki as well as their Meltdown/Spectre press release indicate the versions of Ubuntu patched for this issue. Part of the general problem is servers that should be maintained in the cloud are instead running in a closet without maintenance.

A modern more robust approach:

  • Consider virtualization where possible, with remote staff dedicated to patches and maintenance
  • for long-term survivability of custom code assets, use OS-agnostic coding methods with modern build systems such as CMake.
  • Use continuous integration with unit tests and integration tests
  • common version control across code products

Registration tests are a first step on wrangling the dataflow lifecycle. Registration tests + continuous integration add meaningful testing across OS & compiler versions, monitoring edge cases that break. Driving toward unit tests incrementally as warranted allow minimal upfront expenditure.

Julia IDE

A popular IDE for Julia (syntax highlighting, linting) is via the Julia plugin for Visual Studio code.