For those transitioning between Matlab/Octave and Python, the “logical not” tilde ~ operator of Matlab/Octave is NOT matched in Python.
In Python (on non-Numpy variables), ~ means
unary complement.
~ operates on the bits of the byte underlying each non-Numpy Boolean (in Matlab/Octave, boolean is class logical)
tl;dr:
Numpy does not allow the word not for Numpy arrays.
safest way (if cumbersome) is to always use numpy.logical_not().
If never using Numpy arrays, not is usable.
If always using Numpy arrays, ~ is usable, but it’s safer to use numpy.logical_not().
not will at least throw a ValueError on a Numpy array, rather than silently giving the wrong value as ~ will on non-Numpy arrays.
Use not or logical_not() and avoid ~ to avoid silent failures.
Type
~ operation
non-Numpy
unary complement ~False ==- 1; ~True == -2
Numpy
logical not x=numpy.array(False); ~x==True; ~~x==False
Matlab
logical not ~false = true; ~true==false
This critically important distinction comes from the short int (byte) inherited by the Python bool.
Groups are planning to use several HF Amateur Radio monitoring efforts to characterize the impact of this solar eclipse vs. previous eclipses.
Occurring essentially at local noon, and lasting for over 2 minutes in totality near the center of the eclipse path, several notable effects will occur in the Earth’s ionosphere.
The D-region recombination will settle out quickly near totality.
E-region changes are also expected to be detectable as the gradual increase and decrease of the eclipse evolve over hours.
Previous eclipses have shown f0F2 to be impacted as well.
Modeling is needed to determine the best frequency coverage for PiRadar as well as amateur radio stations that want to participate in other modes of operation.
We run fairly large complicated Fortran codebases from Python with f2py.
The only modification required to Fortran code to work with f2py is at the subroutine called from Python, add Intent() for each variable.
To avoid modifying the source code, put a comment like
!f2pyIntent(in)::x
If using intent(out), be sure the variable is always initialized for all cases in the subroutine.
Otherwise 0 or an unpredictable result may return (this is true for plain standalone Fortran, too).
f2py currently assumes intent(in) for all variables, which clearly won’t work for many use cases.
Plain Fortran defaults to intent(inout).
However, with f2py the intent(inout) will return None unless the inout variable is a Numpy ndarray.
Scalar inout will be left unmodified.
It’s OK to have the Fortran code expecting a scalar with a 0d ndarray inout.
WSPR
is used by radio amateurs and radio scientists to measure radio propagation from VLF to VHF.
On the order of
one million WSPR spots
occur daily worldwide.
Most of these measurements are at HF (2-30 MHz) frequencies.
Here is a discussion of one possible science application of WSPR in an NVIS configuration.
The units used are MKS.
The fundamental wave modes explored by Tonks and Langmuir [1] in the 1920s are responsible for important behaviors observed in plasmas such as those present in Earth’s ionosphere.
Key inflection points in behavior of externally excited waves traveling through a region of plasma are marked by the electron plasma frequency ω_pe or equivalently f_pe.
Where f ≪ f_pe, waves will not pass through the plasma–they will be reflected.
Where f ≫ f_pe, waves will pass through the plasma, with a detectable phase shift.
This phase shift is exploited to compute total electron content (TEC) via GPS receivers in the 1-1.5 GHz range (and beacons at other frequencies), a key quantity used in tomography of ionospheric number density reconstruction.
If we consider measurements from networks of radio amateurs using programs such as WSPR,
which records SNR vs. time for numerous frequencies and disparate stations with a two-minute cadence, we may generate dynamic maps of electron density at the midpoint of each single-hop path.
For this study, we initially focus on NVIS stations to keep within a single ionospheric hop.
For world-wide communications, 10-20 or so hops may be involved, and in general the ionosphere and lithosphere will be heterogeneous, increasing the difficulty of the estimation problem.
Estimation of electron number density in ionosphere F2 layer:
An oft-cited approximation for the maximum number density in the F2 layer (NmF2) is given as:
f_c = 9 * (N_max)^(1/2) [Hz]
or
N_max = f_c2 / 81 [m(-3)]
This is an approximation for:
N_e = f_pe2 * (4𝜋2 m_e ε_0) / e^2
assuming you know the critical frequency from a frequency swept (chirp) measurement from a vertical ionosonde.
For a locally stratified and homogeneous ionosphere near the midpoint of an NVIS path, we might estimate electron density N_e at an NVIS path midpoint, with assumptions on the height of the refracting layer.
Oblique incidence chirp ionospheric sounders have been known since 1964 and vertical incidence chirp ionospheric sounder since 1971 to be a highly power-efficient means of ionospheric characterization [2].
In the 1996, the benefits of adding time synchronization to remotely located oblique ionosondes was realized, giving absolute time delay, allowing virtual height to be estimated more accurately than with relative-only timing available from unsynchronized chirp transmitter and obliquely-located receivers.
Chirp sounders in modern times have seen further benefit from addition of broadband phase modulation to the stepped-frequency chirp.
TEC and f_0F_2 related statistically:
TEC and f_0F_2 have been related in a coarse sense as confirmed via observation [3] to be during nighttime hours:
TEC = 1.24 x 10^(-6) τ (f_0F_2)^2
where τ is slab thickness in meters, taken to be 230 x 10^3 in [3].
References:
[1] Tonks, L. and Langmuir, I. (1929). Oscillations in ionized gases. DOI: 10.1103/PhysRev.33.195.
Physical Review 33:195-210.
[2] Barry, G. (1971). A Low-Power Vertical-Incidence Ionosonde. DOI: 10.1109/TGE.1971.271471. IEEE Transactions on Geoscience Electronics 9(2):86-89.
Adding the -f option to pgrep and pkill searches the whole command line, instead of the default first 15 characters.
This is useful for example with chromium-browser that actually lists in ps as /usr/lib/chromium-browser/chromium-browser–too long for pgrep and pkill default to find.
pgrep -f chromium
works, while
pgrep chromium
does not work with default settings.
Make this change persistent by adding these lines to ~/.bash_aliases
aliaspgrep="pgrep -f"aliaspkill="pkill -f"
Examples for Chromium:
find running process by name: pgrep chromium returns the PID (integer).
The
PiCamera Python module
acquires RAW Bayer masked data from the color Raspberry Pi camera module.
Getting raw Bayer images from the camera into 2592 x 1944 pixels for the V1 camera, 3280 x 2464 for the V2 camera requires a program as simple as:
importpicameraimportpicamera.arraywith picamera.PiCamera() as cam:
with picamera.array.PiBayerArray(cam) as stream:
cam.capture(stream, 'jpeg', bayer=True)
img = stream.array
If a remote PC with the graphical Dropbox client isn’t syncing, it may be due to a reboot where the Dropbox dæmon didn’t restart because there was no remote login to the graphical desktop. Dropbox can be remotely restarted over SSH with the command
Format a micro SD card to FAT32 (find the SD card device name from df – be sure you don’t overwrite your hard drive!).
Let’s suppose you found your SD card at /dev/mmcblk0, then:
Setup Red Pitaya NMR image: format a micro SD card to FAT32 (find the SD card device name from df – be sure you don’t overwrite your hard drive!). Let’s suppose you found your SD card at /dev/mmcblk0, then:
cd ~
git clone https://github.com/pavel-demin/red-pitaya-notes
Run the NMR control program
cd red-pitaya-notes/projects/pulsed_nmr/client
python3 pulsed_nmr.py
You should see some perturbation (even if essentially zero amplitude) in the NMR trace plot.
If “start” button doesn’t change to “stop” when clicked, that can indicate that the Red Pitaya NMR dæmon is not running. Be sure you copied over the correct image to the SD card when you did the unzip step.
pulsed-nmr consumes about 8% CPU when generating a waveform and 5% CPU when idle.
Recompile server code: this is precompiled and running as a service in Pavel’s image.
TODO: Does it take rewriting the image since the SD card filesystem is read-only?