Scientific Computing

LaTeX with GitLab/GitHub and Dropbox backup

The examples show GitLab but of course work equally well with GitHub/Bitbucket/etc. Do not simply drag and drop the LaTeX directory into Dropbox–syncing errors will result.

Git is designed to make simultaneous pushes to multiple remotes. Backup to several sources at once such as LaTeX with Dropbox as backup to GitHub / GitLab, OneDrive or Google Drive with the syncing clients installed.

Given a LaTeX document connected to a GitLab repo, cloned to the computer, backup the LaTeX document folder somewhere else now as a precaution.

git LaTeX repo ↔ Dropbox: git push will go to both simultaneously.

Check current LaTeX repo

cd ~/Dissertation
git remote -v
origin  https://gitlab.com/username/MyDiss (fetch)
origin  https://gitlab.com/username/MyDiss (push)

To create a directory in the Dropbox folder specifically for LaTeX Git repositories, multiple LaTeX projects can be kept in one Dropbox directory. This directory will be referred to as Git.

mkdir ~/Dropbox/Git

Next, set up the Dropbox/Git directory as a second push-only remote. The files will not be visible in this directory because it is a “bare” Git repository, but the history of all files will be recoverable from it in case the LaTeX Git history becomes corrupted.

cd ~/Dropbox/Git
git clone --bare https://gitlab.com/username/MyDiss

cd ~/Dissertation
git remote set-url origin --push --add ~/Dropbox/Git/Dissertation.git
git remote set-url origin --push --add https://gitlab.com/username/MyDiss.git

The --push option indicates that this remote is only for pushing, not for fetching. Normally, fetching (pulling) will be done from GitLab since Dropbox serves as a rolling backup.

Verify the setup with the following command:

git remote -v

The expected output should be:

origin  https://gitlab.com/username/MyDiss (fetch)
origin  https://gitlab.com/username/MyDiss (push)
origin  /home/computerusername/Dropbox/Git (push)

If any issues arise, edit the repository’s Git configuration directly to remove any incorrect pushurl entries:

git -C <repo_dir> config --edit

Since Windows Command Prompt does not recognize ~, ensure that each Terminal used has softlinks created with the same link name. The absolute pathnames differ for WSL, but the softlinks can appear identical.

Windows Subsystem for Linux:

cd ~
ln -s /mnt/c/users/joe/Dropbox

NEXTEL is back?

Retrobrands USA makes a business from “disused” trademarks and licensing them to those who hope to find new audiences for their products from the brand’s afterglow. USPTO trademark filings were brought and a lawsuit over use of the NEXTEL name. The product brochures shows the NEXTEL logo “photoshopped” onto 3G radios. As the lawsuit notes, the “Direct Connect” and “Group Connect” of this product are in effect an app using data to relay voice, with what is claimed to be considerably more latency than the lower layer iDEN dispatch protocol.

Although I long to see a service of the quality of Nextel iDEN dispatch return, this creative use of a trademark that saw $750 million spent on NASCAR sponsorship alone is quite something to ride the laurels of. iDEN still exists overseas and Motorola Harmony in limited regions. Zello uses the Nextel chirp sound without public complaint so far.

Anysecu 3G-HD6500 from various angles.

Anysecu 3G-HD6500

NEXTEL 2018 walkie talkie in box with charger.

One model of NEXTEL 2018 walkie talkie.

Install ImageJ for Linux

In general for Linux it’s better to install ImageJ directly instead of apt install imagej. This method also works for Raspberry Pi and other ARM systems.

Install Java Runtime Environment (also works with openjdk-jre)

apt install default-jre

Download latest platform independent ImageJ Unzip to ~/ImageJ recursively

unzip ij*.zip -d ~

Add to ~/.bash_aliases

alias imagej="$HOME/ImageJ/ImageJ"

Close and reopen Terminal, then start ImageJ by:

imagej

Create Imagej icon by creating file ~/.local/share/applications/imagej.desktop with contents:

[Desktop Entry]
Type=Application
Exec=~/ImageJ/ImageJ
Name=ImageJ
Icon=~/ImageJ/images/icon.png
Categories=AudioVideo;Video;Science;

If can’t open ImageJ via the menu/icon,

~/ImageJ/ImageJ

should open ImageJ properly.

Stop Ubuntu printer added messages

If Ubuntu gives popup messages about auto-adding “new” printers upon connecting to a wired or WiFi network, try the configuration below.

Stop auto-add printer on network connect by editing /etc/cups/cups-browsed.conf:

BrowseRemoteProtocols none

Then restart CUPS from Terminal:

service cups restart

Test: reboot PC with network disconnected, check that the offending printers are not in Settings → Printers, and then connect to the network and verify that the printers don’t auto-add again.

Reference

IEEEtran.cls prerequisites

IEEE LaTeX submissions require IEEEtran.cls, which itself requires:

apt install texlive-publishers texlive-science texlive-fonts-recommended texlive-bibtex-extra texlive-latex-recommended texlive-latex-extra texlive-humanities

IEEE LaTeX article style is invoked by starting the .tex file with:

\documentclass[]{IEEEtran}

Thereby avoiding errors:

IEEEtran.cls, cite.sty, or subfigure.sty not found

Font OT1/ptm/m/n/10=ptmr7t at 10.0pt not loadable error

Brother HL-3170CDW Linux

Like other Brother printers we’ve used, the HL-3170CDW works great from Linux. With Ubuntu, the Gutenprint USB driver automatically came up and worked fine. The OEM driver below is optional.

Download linux-brprinter-installer script from “Driver Install Tool”. Plug in HL-3170 via USB. Don’t skip the mkdir step or the installer will hang!

mkdir -p /var/spool/lpd/hl3170cdw

chmod +x linux-brprinter-installer*
./linux-brprinter-installer*

“Input model name ->” HL-3170CDW “Will you specify the Device URI? [Y/n]”

  • USB: no
  • network: yes

Linux WiFi indicator low signal strength

You may wonder why Linux shows less than full “signal bars” for Wifi, even for a device relatively close to the Wifi AP (Access Point, the “router”). The answer is that the Linux desktop GUI is being honest about the quality of the connection, which is immediately relevant to the data throughput and connection latency. The end user shouldn’t care as much about raw RF signal strength (e.g. -70 dBm) as they should about the quality (SNR) of that connection. Of course, low signal strength < -80 dBm also causes low SNR and hence decreased link quality, even in relatively clear Wifi signal environments.

Unfortunately, many OEMs (and tech websites on click-commission) have duped people into buying expensive individual APs instead of quality APs such as from Ubiquiti that can be distributed evenly throughout the home or office. You actually typically want to lower transmit power from the default level to around +18..+21 dBm to help the user devices roam between APs for best performance, and to disconnect promptly as a user moves off-premises.

In a particular client site with suboptimally configured Wifi network, the GNOME desktop environment (and also in Unity desktop) 2 out of 3 signal bars for WiFi, despite being connected at MCS index 15 to an 802.11n AP on 5 GHz with a signal strength approaching -50 dBm. MCS 15 is the fastest possible connection for 802.11n, so why does GNOME/Unity show only moderate “signal bars”? This is because there are very many other high utilization APs on the same channel so that SNR (“link quality” for many Wifi cards in iwconfig) is low (less than say 0.7 normalized).

Summary

Home and business Wifi users will virtually always get better performance from:

  • multiple low-power APs instead of single high-power AP
  • 5 GHz instead of 2.4 GHz
  • APs set to the clearest possible Wifi channels (such as DFS)
  • APs placed as much as possible to interior of environment, high on wall or ceiling
  • iterative tuning of the system to minimize co-channel high utilization APs

The goal is for the AP to not “hear” other off-premises Wifi or other on-channel wireless activity, since generally the AP due to siting and high performance chipset “hears” significantly better than the end user devices.

Related: Wifi performance at low signal strength

Make Linux lock on lid close

Some Windows-oriented computers like Microsoft Surface with “Connected Standby” or “Modern Standby” may not be well supported in Suspend / Sleep with Linux yet. Consider having such a system lock on lid close until the Linux kernel is updated to support these newer power states. For better security in general, shut the laptop down while in transit in case of loss or theft. Locking screen with screen turned off gives sufficient power savings for short walks.

Force Linux lock on lid close with a systemd-based Linux distro such as Ubuntu by editing “/etc/systemd/logind.conf”, uncommenting line:

HandleLidSwitch=lock

Reboot the computer and verify lock behavior on lid close.

Reference:

  • Microsoft description of traditional S3 standby vs. connected standby vs. modern standby
  • Lock on lid close may not work when the laptop is physically docked, but does generally work when the laptop is out of dock. Do the manual lock if this doesn’t work when physically docked.

Install Intel Python

Intel Distribution for Python utilizes the conda package manager, set to the “intel” channel.

Pros: Intel Python uses highly accelerated math library versions of popular packages like Numpy, Scikit-learn, etc. reside.

Cons: Intel Python is slow to update to new library versions. Anaconda updates within a couple days, but Intel might take weeks or months to update the libraries.

Note that standard Anaconda Python already gives MKL performance in some libraries like Numpy and Scipy. We generally use the regular Anaconda instead of Intel Python to get updated libraries with most of them having MKL.

Find boundary indices of region edges in Python

The convex hull is frequently used to process a pixel region. To find the indices of the outer edge of the convex hull may be accomplished using the distance transform. I do not claim this to be the most efficient method. This algorithm gives similar results to Matlab boundarymask().

Algorithm

By definition, the distance transform of all region edge pixels to the background is identically one. The chamfer distance transform is suitable for smooth regional boundaries, and has significant speed advantages over more brute force approaches that may be more generally applicable for non-smooth boundaries. Use either masked image arrays or use NaN as a sentinel value in 2-D array mask. SciPy ≥ 0.17 is assumed.

import scipy.ndimage as ndi

boundary_mask = ndi.distance_transform_cdt(~np.isnan(az), 'taxicab') == 1
coin with red boundary outline

Red boundary represents boundary_mask pixels.

For the smooth boundary cases I tried, distance_transform_cdt() was six times faster and gave equivalent results to the more general distance_transform_edt().

Notes

Reference