The FITS data file format is used in astronomical imagery.
Two of the easiest ways to view FITS file image stacks with standalone programs are
HDFView and
NASA
FV.
While FV has utilities and a UI more oriented to astronomical uses, HDFView is a generally useful tool to view HDF5, HDF4 and FITS files.
The Perl script “latexdiff” generates highlighted differences between two versions of a LaTeX document.
This is required in submitting academic paper revisions.
macOS: brew install latexdiff
Linux / WSL: apt install latexdiff
Recursive
latexdiff.py
processes all .tex files in the directory.
This is useful for very large projects like Ph.D. thesis or journal article.
A wide variety of programming languages are used by engineers and scientists.
Tie them all together (C, C++, C#, Cuda, Fortran, etc.) in a platform-independent and simple way using CMake or Meson.
These high-level build systems generate low-level build system backend files for
Ninja
(strongly recommended) or Make.
Assume a single-file C++ program that uses the Math library and Boost for flexible command-line input of numerous parameters.
Turn on additional compiler warnings to help avoid common coding pitfalls.
Consider an example
CMakeLists.txt
for a C++ and Fortran project, line by line.
Language(s) selection:
project(zakharovCXX)
Naming a project facilitates packaging and installation.
CXX is required to enable the hooks for the language(s) you used.
The most frequently used languages include
tag
language
C
C
C#
C#
CXX
C++
Fortran
Fortran
Languages that aren’t built into Cmake such as
Pascal
can be added via custom Cmake modules.
This project requires C++11 features, so an old compiler not supporting C++11 will emit a configuration error.
zakh
the exe file that will be created on compile, run with ./zakh.
zakh.cpp
the files making up “zakh”
Compiling a simple project with CMake: It’s convenient to create a separate directory, typically build/ under your main code directory.
Let’s say your main code directory is ~/code/zakharov, then do
The ** operator in Python also has the advantage of returning int if inputs are int and arithmetic result is integer.
10**(-3)
8.22 ns ± 0.0182 ns per loop (mean ± std. dev. of 7 runs, 100000000 loops each)
pow(10, -3)
227 ns ± 0.313 ns per loop (mean ± std. dev. of 7 runs, 1000000 loops each)
math.pow(10, -3)
252 ns ± 1.56 ns per loop (mean ± std. dev. of 7 runs, 1000000 loops each)
numpy.power(10., -3)
1.5 µs ± 2.91 ns per loop (mean ± std. dev. of 7 runs, 1000000 loops each)
Numpy is known in general to be slower at scalar operations than Python-native operators and Python built-in
math.
But of course Numpy is generally a lot faster and easier for N-dimensional array operations.
For scenarios where a function outputs a list, and that function is in a for loop or asyncio event loop,
the final output will be a list of lists, like:
x = [[1,2,3], [4, 5, 6]]
This may be inconvenient for applications where a flattened list is required.
The simplest and fastest way to flatten a list of lists in like:
Using networks of GNSS receivers along with appropriate post-processing techniques, estimated maps of vertical TEC (integrated electron density) can be
derived.
Conversion between any/all of BGR, RGB, and GBR may be necessary when working with
Matplotlib pyplot.imshow(): M x N x 3 image, where last dimension is RGB.
OpenCV imshow(): M x N x 3 image, where last dimension is BGR
Scientific Cameras: some output M X N x 3 image, where last dimension is GBR
Note: as in any programming language, operations on memory-contiguous arrays are most efficient.
In particular, OpenCV in-place operations require a contiguous array from Python to avoid unexpected results.
The safest approach is to always make a copy of the array as in the examples below.
Use .copy() to avoid unexpected results if using OpenCV.
If just using Matplotlib, .copy() is not necessary–but performance (speed) may benefit from .copy().
BGR to RGB: OpenCV image to Matplotlib
rgb = bgr[...,::-1].copy()
RGB to BGR: Matplotlib image to OpenCV
bgr = rgb[...,::-1].copy()
RGB to GBR:
gbr = rgb[...,[2,0,1]].copy()
The axis order convention for Python images:
3-D: W x H x 3, where the last axis is color (e.g. RGB)
4-D: W x H x 3 x 1, where the last axis is typically an alpha channel
Non-standard language options and incomplete feature support are normal for compilers across virtually all programming languages from BASIC to Fortran and here C++.
Modern C++ features typically require using specific compiler flags to enable support.
Knowing what compiler flags to set can be confusing for those new to modern C++ features.
Setup of C++ compiler flags for modern C++ features is easily and automatically handled by
CMake.
C++ fstream allows writing files to disk.
Some operations need to manage directory slashes (Windows vs. POSIX).
C++
std::filesystem::path::preferred_separator
manages platform-agnostic path separators.
Akin to Python pathlib, use std::filesystem::path.
C++ filesystem works on almost all current C++ compilers.
Note: Winget
might be preferred for Windows packages.
Scoop
brings easy install like scoop install gcc of developer programs in the
package list
to Microsoft Windows.
Scoop works from a fresh Windows install, for example a
free Windows virtual machine image.
Install
Scoop,
then install Git via Scoop, so that Scoop can update its recipes:
scoop install git
Commmon development tools:
gcc / gfortran: scoop install gcc
make / cmake: scoop install make cmake
clang / LLVM: scoop install clang
GNU Octave: scoop install octave
From time to time scoop update gcc or similar to update individual packages.