Scientific Computing

Convert PDF to SVG using Inkscape

Vector graphics in a PDF may be displayed directly in a webpage by using SVG. SVG is widely supported by virutally any web browser without plugins. This avoids having to download a PDF, while preserving full vector graphics resolution.

Convert PDF to SVG using Inkscape from Terminal:

inkscape in.pdf --export-plain-svg=out.svg

Basic PiRadar functionality test

Before conducting a field test, it’s beneficial to test the constituent parts of the radar. Since this is an HF radar, using a higher frequency where it’s easier to build antennas to test with targets smaller and closer than the ionosphere can be expedient. In general the three essential functions of a radar are:

  1. time synchronization: ability to send/receive with accurate absolute time–here provided by GPS into the GPIO and FPGA.
  2. transmit: ability to send a signal at a desired RF frequency and bandwidth, with accurate timing
  3. receive: ability to receive a signal at a desired RF frequency and bandwidth, with accurate timing

Timing test:

This test requires Pavel Demin’s Red Pitaya radar code and to setup an SD card for Red Pitaya. Since this code is untested, it is quite likely to need some changes.

PiRadar transmit timing test

PiRadar transmit timing test.

Transmit/receive test: requires the GPS-GPIO timing working first

The antennas can be build from wooden dowels with solid wire attached. The dowels are about $1 each from Home Depot. The test is run in the 38-50 MHz license free range since this fits within the Red Pitaya maximum frequency while using shorter/smaller antennas.

PiRadar receive timing test

PiRadar receive timing test.

Monostatic radar test:

As for test #2, the radar waveforms should be suitable to detect range and Doppler. If there are problems with the monostatic test, or if it’s desired to simulate the ionosphere “on-air”, a transponder can be used.

3a. Indoor test: Can the radar detect Doppler indoors or through the window? Is the window metallized, blocking radio/radar signals? Range measurements indoors will have extreme clutter and suffer from small lab size relative to radar wavelength. It may be possible to use an MTI algorithm to distinguish moving objects from the background.

3b. outdoor test: can radar outside detect range/Doppler of people and cars/trucks? Can it measure the range of individual buildings?

Radar algorithms: for ground-based testing, we intend to use more advanced algorithms for ionospheric sensing.

  • FMCW homodyne radar except using the 40 MHz band instead of 2.4 GHz
  • Doppler radar, where you deliberately don’t get much range information, just Doppler (velocity) like the earliest radars.
  • forward scatter–just for testing, not for ionosphere

Radar operation at low-band VHF license-free

Low-band VHF is within the 50 MHz maximum frequency of the Red Pitaya. This makes low-band VHF convenient for testing and calibration of a radar, even for use as a prime frequency for vehicle detection.

License-free use from 38.25 MHz to 54.0 MHz is governed by 47 CFR 15.209 to 100 μV/m at 3m ~ -55.2 dBm.

Cordless phones under Part 15.233 have a subset of 20 kHz channels authorized for 10,000 μV/m at 3m ~ -15 dBm. These channels are in the frequency ranges

  • 43.71-44.49 MHz
  • 46.60-46.98 MHz
  • 48.75-49.51 MHz
  • 49.66-50.0 MHz

Because essentially no one uses low-band VHF cordless phones anymore (at least in North America), one might consider these cordless phone frequencies as a less congested place to run tests.


Related: Global license-free 25-60 MHz

Radar transponder for radar calibration

This is the xpond_red-pitaya.grc Github PiRadar example. As a first test of the transponder alone, one could simply receive the AM broadcast band (530 kHz - 1710 kHz) and transpond it up to a frequency where you have a receiver, whether in the 40 MHz or 27 MHz or wherever you have a receiver for. That would show that the idea of transponding works with this hardware.

radar bent pipe transponder

The essential functions are:

  1. amplify incoming radar signal
  2. frequency translate incoming radar signal to frequency range radar receiver is listening at

When using a transponder, the radar needs to transmit and receive at different frequencies to avoid a feedback loop of having transmit and receive of the transponder on the same frequency.

To operate the radar in an ionospheric sensing mode, and with the ability for the “target” to add impairments including:

  1. fading
  2. frequency selective fading
  3. random phase shift

and other errors requires an active transponder. There are blocks in GNU Radio that simulate these channel impairments.

Poker Flat auroral data links

Geoscience Data Links: these links are to raw data that often require further processing with open-source tools to analyze.

Digital All-Sky Camera DASC:

Low resolution MPEG video http://optics.gi.alaska.edu/realtime/data/MPEG/PKR_DASC_256/ of DASC digital all-sky camera

Full fidelity 16-bit DASC data

One can process DASC data with DASCutils

Meridian Scanning Photometer DMSP:

2011-present DMSP NetCDF data read/plotted with meridian-spectrometer-reader

1983-2010 MSP data (NetCDF 3 in .PF files) was at http://optics.gi.alaska.edu/realtime/data/msp/pkr

Operate WSPR, WSJT, PSK31 remotely over Linux

When operating digital amateur radio modes remotely (i.e. controlling distant transceiver over the internet) it’s best to have the computer generating the tones local to the radio. That is, you should run VNC or Remote Desktop software connected to the remote PC, running the programs on the remote PC. You can do this even over very limited ≪ 1 Mbps connections.

Running ham radio digital modes over VNC: even if the internet connection drops, the program stays running (particularly for WSPR). The VNC server is configured to run any program remotely. If you use RDP (Windows Remote Desktop) to remote digital mode ham radio PC, be sure to NOT redirect audio, to avoid disrupting the audio to the remote program.

Problems with remote audio: for remote stations where line-of-sight links exists, it is possible to pass medium-fidelity audio over radio links with proper care. Although broadband audio codecs used over the Internet give better fidelity, consider if:

  1. phase continuity is assured (particularly for PSK modes)
  2. frequency resolution is high enough (particularly for narrowband FSK modes like WSPR and FT8)

Even gigabit Internet links are subject to VoIP packet drops. Typical VoIP uses UDP, which simply drops missed packets. UDP overlays that buffer and rerequest can lead to time sync issues, particularly for tightly time-synchronized modes like WSPR and FT8.

In short, remote tone generation might work somewhat, but performance will suffer.

Additionally, audio dropouts on digital modes cause interference to adjacent spectrum.

Tilde differences Python vs. Matlab

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.

August 2017 Solar Eclipse Amateur Radio Science

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.

f2py example import Fortran library from Python

f2py uses Fortran code from Python.

f2py_demo.py calls the Fortran code fortprod.f.

f2py requires Fortran Intent()

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

!f2py Intent(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.

Estimating Electron Number Density via WSPR

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.

The electron plasma frequency is:

ω_pe = (N_e e2 / (m_e ε_0))(1/2) [rad/s]

f_pe = ω_pe/(2𝜋) = 1/(2𝜋) (N_e e2 / (m_e ε_0))(1/2) [Hz]

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.

[3] Spalla P. and Ciraolo, L. (1994). TEC and f_0F_2 comparison. Annali Di Geofisica, 37(5):929-938.

NRL Plasma Forumulary