Scientific Computing

GitHub Oauth private repo access

To give secure access to private GitHub repositories on less-trusted systems like CI or HPC or shared workstation, consider GitHub Oauth tokens. The Oauth token can give read-only (or other fine-grained permissions) to all or a specific subset of repositories the GitHub account has access to.

Create a GitHub Oauth token with the desired permissions.

For read-only private GitHub repo access the “repo” permission group is selected.

Copy the text string token and SSH into the remote system where access is desired. Configure the global user Git config to use the Oauth token for the desired GitHub organization or user.

Private GitHub repo of a collaborator

Suppose a coworker with GitHub username “my1friend” has a private GitHub repo “myrepo”. Have “my1friend” add your GitHub username as a collaborator in the “myrepo” settings. Create a GitHub Oauth classic token with the “repo” permission group. Copy and paste that token string into the laptop or workstation you’ll use to access the private repo like:

git config --global url.https://oauth2:OauthToken@github.com/my1friend/.insteadOf https://github.com/my1friend/

A similar syntax is used for GitHub organizations or specific repositories.

The text OauthToken is replaced with the actual Oauth token string copied from GitHub.

Troubleshooting

Use git remote -v in the Git repo or Git submodule to ensure old information in ~/.gitconfig is not overriding the new API token. If a Git submodule won’t clone due to incorrect token credentials, try Git cloning the submodule repository itself in another directory to see if the old credential are slipping in somewhere.


Related: Git pull HTTPS push SSH

CMake per-language option flags

CMake can set per-language compiler flags scoped to directory or target. The directory scope propagates to targets in the directory and subdirectories. Per-language options that are intended for all targets in the project are often set near the beginning of the top-level CMakeLists.txt, before any targets are declared. The same concepts and scope apply to compile definitions and linker flags.

By default, add_compile_options() and target_compile_options() add flags for all target languages. Multi-language targets (for example, a target that has C and C++ source files) would have the flags applied to all languages. In general, this may cause problems if the flags are not appropriate for all languages.

The options are restricted by compiler, language, build configuration, etc. using CMake generator expressions. For example, $<COMPILE_LANGUAGE:Fortran> is used to restrict options to Fortran targets. A stanza like $<AND:$<COMPILE_LANGUAGE:Fortran>,$<CONFIG:Debug,RelWithDebInfo>> sets flags for Fortran targets in the debug and RelWithDebInfo build configurations.

Note: where using FetchContent, the main project may desire -Wall but this may cause megabytes of warnings from a legacy Fetched project. A solution is to put add_compile_options() in each of the parent project directories and/or use target_compile_options() in the parent project.

This example is for a C and Fortran project, where some flags apply to C and Fortran, and other flags are Fortran-specific. It’s often useful to use a convenience function to make the code more readable, say in a file “AddOptions.cmake”:

function(add_compile_lang_options lang)

  set(args "")

  foreach(arg ${ARGN})
    string(APPEND args ${arg}$<SEMICOLON>)
  endforeach()

  add_compile_options($<$<COMPILE_LANGUAGE:${lang}>:${args}>)
endfunction()
project(Demo LANGUAGES C Fortran)

include(AddOptions.cmake)

add_compile_lang_options(Fortran -Wall -fimplicit-none)

# more advanced example to add debug-only, compiler-specific and language-specific options:

add_compile_options(
  $<$<AND:$<COMPILE_LANG_AND_ID:Fortran,GNU>,$<CONFIG:Debug,RelWithDebInfo>>:-Werror=array-bounds>
)

FFmpeg merge files into single multichannel file

FFmpeg can merge several files each containing one audio channel into a single file with multiple channels. For example, a multichannel data collection might save each sensor channel into individual files. For data analysis and for practicality to avoid mixing channels from different experiments, it can be useful to combine the individual channel files into a single multichannel file. The amerge filter can merge multiple files into a single multichannel file. . The amerge filter requires all input files to have the same sample rate and format.

CB Radio President P channels

The mapping between CB radio channel to President P channel and coded squelch is:

President P channel CB channel Center Frequency (MHz) coded squelch
1 1 26.965 94.8 Hz
2 3 26.985 D073N
3 11 27.085 131.8 Hz
4 18 27.175 D624N
5 24 27.235 203.5 Hz

Some newer President CB radios have preprogrammed FM mode with CTCSS squelch on “President P channels”:

Name Model FCC ID
Bill III FCC TXUS201 2AEOCPC210
Blll II+
Johnson III TXPR767
Barry II+ TXPR122
Taylor IV CL TXPR423

Similar to some OEM FRS / GMRS radios that have preprogrammed channels with CTCSS or DCS codes, the P channels are a convenience that immediately allow users with CB radios having FM and CTCSS to interoperate with each other. We welcome preprogrammed P channel-like features with FM and CTCSS as they are likely to increase usage of FM mode and CTCSS on CB radios. This gives the benefits of maximum range with minimum interference. Before these preprogrammed channels, setting CB radio CTCSS coded squelch involved diving through menus.

Using FM mode with coded squelch experiences much less disturbance from adjacent channel splatter versus the AM mode with signal squelch.

Weather radio channel to frequency

While dedicated NOAA NWR weather (WX) radios are available, two-way communications radios such as CB radio and GMRS etc. can also have 162 MHz weather radio receivers. 162 MHz WX radio is a one-way radio service that broadcasts weather information and emergency alerts across much of the USA, Canada, and Mexico. When determining which WX channel to receive on, it can be confusing because there is no standard WX channel number to 162 MHz frequency mapping. Use the NOAA USA search or Canada search to find nearby WX radio transmitter frequencies.

Channel number to frequency mapping: a common practice is to start with the lowest frequency and go up across the 7 WX radio frequencies. This is perhaps the most common channel number to frequency mapping.

WX Channel Frequency (MHz)
1 162.400
2 162.425
3 162.450
4 162.475
5 162.500
6 162.525
7 162.550

Non-sequential channel order is used by some CB radios such as Radioddity / Anytone radios made by Qixiang.

WX Channel Frequency (MHz)
1 162.550
2 162.400
3 162.475
4 162.425
5 162.450
6 162.500
7 162.525

Comparing the reception performance on a known frequency vs. a handheld radio can give a quick indication that an antenna system is working OK–even if like 27 MHz CB radio the designed antenna frequency is far from the 162 MHz weather radio frequency. Comparing WX radio reception on a CB radio with base or mobile antenna versus a handheld radio on the same 162 MHz WX radio frequency indicates that the CB radio antenna coax is perhaps not severely damaged or lossy, and the radio is working OK.

TV unable to receive any ATSC channels

Modern sub-$250 television receivers make compromises in low cost hardware while supporting the best possible picture quality for internet streams. This can lead to compromises in fundamental performance for over-the-air (OTA) reception of digital ATSC TV signals. For example, the ability to monitor signal strength is often not present in such low-cost TVs. When a channel(s) that should be easily received is not available, the fundamental step of checking signal strength might be unavailable on a low-cost TV. A first step is generally to rerun the channel scan with the antenna (if indoor) positioned in a window facing the transmitter direction.

A diagnostic tool and possible solution is an ATSC tuner connected to the TV via HDMI. ATSC 1.0 HDMI tuners are available for under $30. The dedicated tuner may be of higher quality than the TV’s built-in tuner, and may provide a signal strength reading. Check product reviews to ensure the tuner is of good quality and has a signal strength meter. Some tuners can connect to an Android device or laptop via USB to receive broadcasts or monitor signal strength. This can allow a technically-minded user to diagnose reception issues including interference.

N7DDC ATU-100 Antenna Tuner

An antenna tuner is commonly used in the HF radio bands to match the impedance of the antenna and typically the feedline as well to the transceiver. If the antenna tuner is located at or very near the antenna feedpoint, losses and feedline radiation can be greatly reduced. For practicality most applications place the antenna tuner near the transceiver, which may require grounding the antenna tuner and/or putting a coaxial choke in the feedline to reduce common mode currents that can cause interference to one’s own transmission.

The N7DDC ATU-100 is a compact antenna tuner that can be purchased as a kit or assembled. It is designed to handle up to 100 watts of power and is typically built to cover the HF bands from 160m to 6m.

A popular implementation is the “7x7” configuration that uses 7 inductors and 7 capacitors to provide a wide range of matching options. The “7x7” setup is comparable to the “8x8” configuration used in more expensive commercial tuners. An example maximum capacitance of 1.822 nF and maximum inductance of 8.53 uH is typical for the “7x7” configuration.

Tuner model Maximum Capacitance (nF) Maximum Inductance (uH)
N7DDC ATU-100 1.82 8.53
MFJ-994 2.95 17.0
Icom AH-4 2.4 19.0
Elecraft T1 1.3 7.5

By putting the ATU-100 into Test Mode by holding the Auto and Bypass buttons on power up, the user can flip the high / low tuning by a short press of the Tune button. A long press of the Tune button switches between tuning “L” inductance and “C” capacitance. Thus by writing down the auto-tuned settings for a particular frequency, the user can manually tune the ATU-100 for that frequency in the future without needing to go through a full tuning cycle. This can be useful to get a more efficient match or handle a tricky matching scenario.

Be sure to ground the radio and antenna tuner to a common ground point, and if possible, use a coaxial choke in the feedline to prevent common mode currents. Note that the RF voltages on any antenna even at “low” power levels can reach thousands of volts, particularly where baluns and ununs are used to match high antenna impedances (e.g. 4:1, 9:1, 49:1, 64:1).

The efficiency of the antenna is a limiting factor of the effectiveness of all antenna matching schemes, whether manual or automatic. The tuning impedance range of the relatively inexpensive ATU-100 is remarkable, as observed in this video testing a 102" whip antenna from 160m to 10m bands:

An important feature lacking in the current N7DDC ATU-100 is tuning memories. The tuner simply remembers the last tuning setting, but any significant frequency change will require a complete tuning cycles. This can be surprising as compared to the near instant retune common in commercial antenna tuners that typically remember thousands of frequency tuning settings even after power is removed and restored. The ATU-100 price point is about 1/3 most commercial antenna tuners, so this lack of tuning memories is a compromise one might be willing to accept.

C23 function declaration needs arguments

The C23 standard requires function declarations to have the arguments specified, else (void) (zero arguments) is assumed. This is a breaking change for code that didn’t use the best practice of specifying the argument types in the function declaration. A real life example of upgrading a large project (Red Hat Linux) to C23 compliance is illustrative. This change emphasizes the importance of adhering to recent C standards for clarity while maintaining compatibility with older language standards if possible.

Freezing the compiler version range for project code is generally a costly long-term strategy as technical debt and developer frustration accumulate. Newer compilers keep adding debugging features and performance improvements.

C++ std::endl requires <ostream> header

C++ standard library (STL) improvements over time include paring down internal includes where possible as best practice and to improve compilation time. When user code accidentally relies on internal includes, it can lead to compilation errors when the internal includes are removed by the STL maintainers or external libraries. Tools like IWYU can help identify missing or unused include statements.

GCC 15 STL removed some superfluous <ostream> includes that may affect code using std::endl without including <ostream>. It’s a common mistake to assume that <iostream> includes std::endl. When checking code to ensure that std::endl code files include <ostream>, consider if the code could use \n newline instead to improve code performance by avoiding unnecessary stream flushing with std::endl. Part of checking if \n can be used instead of std::endl is to observe if downstream code requires the output buffer to be flushed – for example in interactive CTest runs.

8 meter 40 MHz ham band in the USA

Several countries have created an 8 meter ham band near 40 MHz. The USA FCC has a proposed rulemaking RM-11843 to create an 8 meter ham band in the USA. A key conflicting user SNOTEL, which used meteorburst communications to connect very remote sites, has ceased use of the 40 MHz band. As commenters indicate, a rich surplus equipment market exists of military surplus radios and commercial equipment that can be used on the 8 meter ham band. Proposed bandplans allocate FM, CW, and digital modes.