Skip to main content

Python tool to read and plot Geophysical Survey Systems Incorporated (GSSI) radar data in DZT format

Project description

readgssi

Copyleft 🄯 2017-2019

Example Radargram

PyPI version DOI License

readgssi is a tool intended for use as an open-source reader and preprocessing module for subsurface data collected with Geophysical Survey Systems Incorporated (GSSI) ground-penetrating georadar (GPR) devices. It has the capability to read DZT and DZG files with the same pre-extension name and plot the data contained in those files. readgssi is also currently able to translate most DZT files to CSV and will be able to translate to multiple other output formats including HDF5 and SEG-Y, though not all formats are available yet (see future). Matlab code donated by Gabe Lewis, Dartmouth College Department of Earth Sciences. Python adaptation of Matlab code written with permission by Ian Nesbitt, University of Maine School of Earth and Climate Sciences.

The file read parameters are based on GSSI's DZT file description, similar to the ones available on pages 55-57 of the SIR-3000 manual. File structure is, unfortunately, prone to change at any time, and although I've been able to test with files from several systems, I have not encountered every iteration of file header yet. If you run into trouble, please create a github issue, or contact me at the address below.

Questions, feature requests, and bugs: ian * nesbitt at gmail * com (kindly provide the error, what you are attempting to do, and the file causing you trouble when you contact me)

requirements

Strongly recommended to install via anaconda:

Install via pip:

installation

Once you have anaconda running, installing requirements is pretty easy.

conda config --add channels conda-forge
conda create -n readgssi python==3.7 pandas h5py pytz obspy
conda activate readgssi
pip install readgssi

That should allow you to run the commands below.

Note:

If you choose to install a specific commit rather than the latest working release of this software, you may download this package, unzip to your home folder, open a command line, then install in the following way:

pip install ~/readgssi

usage

To display the help text:

$ readgssi -h

usage:
readgssi -i input.DZT [OPTIONS]

optional flags:
     OPTION     |      ARGUMENT       |       FUNCTIONALITY
-o, --output    | file:  /dir/f.ext   |  specify an output file
-f, --format    | string, eg. "csv"   |  specify output format (csv is the only working format currently)
-p, --plot      | +integer or "auto"  |  plot will be x inches high (dpi=150), or "auto". default: 10
-n, --noshow    |                     |  suppress matplotlib popup window and simply save a figure (useful for multiple file processing)
-c, --colormap  | string, eg. "Greys" |  specify the colormap (https://matplotlib.org/users/colormaps.html#grayscale-conversion)
-g, --gain      | positive (+)integer |  gain value (higher=greater contrast, default: 1)
-r, --bgr       |                     |  horizontal background removal algorithm (useful to remove ringing)
-R, --reverse   |                     |  reverse (flip radargram horizontally)
-w, --dewow     |                     |  trinomial dewow algorithm
-t, --bandpass  | +int-+int (MHz)     |  butterworth bandpass filter (positive integer range in megahertz; ex. 100-145)
-b, --colorbar  |                     |  add a colorbar to the radar figure
-a, --antfreq   | positive integer    |  specify antenna frequency (read automatically if not given)
-s, --stack     | +integer or "auto"  |  specify trace stacking value or "auto" to autostack to ~2.5:1 x:y axis ratio
-N, --normalize |                     |  reads a .DZG NMEA data if it exists; otherwise tries to read a csv file with lat, lon, and time fields to distance normalize with
-m, --histogram |                     |  produce a histogram of data values
-z, --zero      | positive integer    |  skip this many samples from the top of the trace downward (useful for removing transceiver delay)

naming scheme for exports:
   CHARACTERS   |      MEANING
    c0          |  Profile from channel 0 (can range from 0 - 3)
    Dn          |  Distance normalization
    Tz233       |  Time zero at 233 samples
    S8          |  Stacked 8 times
    Rv          |  Profile read in reverse (flipped horizontally)
    Bgr         |  Background removal filter
    Dw          |  Dewow filter
    Bp100-145   |  2-corner bandpass filter applied from 100 to 145 MHz
    G30         |  30x contrast gain

From a unix command line:

readgssi -i DZT__001.DZT

Simply specifying an input DZT file like in the above command (-i file) will display a host of data about the file including:

  • name of GSSI control unit
  • antenna model
  • antenna frequency
  • samples per trace
  • bits per sample
  • traces per second
  • L1 dilectric
  • sampling depth
  • speed of light at given dilectric
  • number of traces
  • number of seconds

basic functionality

CSV output

readgssi -i DZT__001.DZT -o test.csv -f CSV

Translates radar data array to CSV format, if that's your cup of tea. One might use this to export to Matlab. One CSV will be written per channel. The script will rename the output to 'test_100MHz.csv' automatically. No header information is included in the CSV.

readgssi -i DZT__001.DZT -s 8 -w -r -o test.csv -f CSV

Applies 8x stacking, dewow, and background removal filters before exporting to CSV.

plotting

example 1A

readgssi -i DZT__001.DZT -p 5 -s auto -c viridis -m

The above command will cause readgssi to save and show a plot named "DZT__001_100MHz.png" with a y-size of 6 inches at 150 dpi (-p 6) and the autostacking algorithm will stack the x-axis to some multiple of times shorter than the original data array for optimal viewing, approximately 2.5*y (-s auto). The plot will be rendered in the viridis color scheme, which is the default for matplotlib. The -m flag will draw a histogram for each data channel. Example 1a Example 1a histogram

example 1B

readgssi -i DZT__001.DZT -o 1b.png -p 5 -s auto -c viridis -g 50 -m -r -w

This will cause readgssi to create a plot from the same file, but matplotlib will save the plot as "1b.png" (-o 1b.png). The script will plot the y-axis size (-p 5) and automatically stack the x-axis to (-s auto). The script will plot the data with a gain value of 50 (-g 50), which will increase the plot contrast by a factor of 50. Next readgssi will run the background removal (-r) and dewow (-w) filters. Finally, the -m flag will draw a histogram for each data channel. Note how the histogram changes when filters are applied. Example 1b Example 1b histogram

example 1C: gain can be tricky depending on your colormap

readgssi -i DZT__001.DZT -o 1c.png -p 5 -s auto -r -w -c seismic

Here, background removal and dewow filters are applied, but no gain adjustments are made (equivalent to -g 1). The script uses matplotlib's "seismic" colormap (-c seismic) which is specifically designed for this type of waterfall array plotting. Even without gain, you will often be able to easily see very slight signal perturbations. It is not colorblind-friendly for either of the two most common types of human colorblindness, however, which is why it is not the default colormap. Example 1c

example 2A: no background removal

readgssi -i DZT__002.DZT -o 2a.png -p 10 -s 3 -n

Here readgssi will create a plot of size 10 and stack 3x (-p 10 -s 3). Matplotlib will use the default "Greys" colormap and save a PNG of the figure, but the script will suppress the matplotlib window (-n, useful for processing an entire directory full of DZTs at once). Example 2a

example 2B: horizontal mean BGR algorithm applied

readgssi -i DZT__002.DZT -o 2b.png -p 10 -s 3 -n -r

The script does the same thing, except it applies horizontal mean background removal -r. Note the difference in ringing artifacts between examples 2a and 2b. Example 2b

contributors

citation suggestion:

Ian M. Nesbitt, François-Xavier Simon, Thomas Paulin, 2018. readgssi - an open-source tool to read and plot GSSI ground-penetrating radar data. doi:10.5281/zenodo.1439119

changes since 0.0.9

  • a patch was added that includes several important bug fixes
    • added support for the 400MHz antenna type
    • fixed a bug that affected the stacking routine
    • fixed a bug with the time zero variable not being available when implementing the naming scheme
  • fixed a bug with plotting that resulted from a key error in the header variable
  • moved dzt reading-related functions to dzt.py
  • changed tab spacing aesthetics in two plotting routines
  • fixed a bug that caused errors reading multi-channel files
  • script has more degrees of freedom while handling unknown antenna types
    • script should handle unknown antennas gracefully
    • script will try to extract frequency information from antenna name (harder than it sounds given GSSI naming inconsistency)
  • added ability to reverse radargram (i.e. flip horizontal left to right)
  • fixed bug with command line autostack
  • changed command line verbose messages
  • added ability to distance-normalize profile using GPS records
    • currently can read .DZG GPS records only, but plan to add ability to read .csv (lat, long, time) and NMEA GGA/RMC textfiles
  • changed naming scheme to be "more readable"
    • changed filename differentiator from frequency to channel number (makes sense because theoretically, a user can have the same frequency antenna on two different channels, which would result in a naming conflict)
  • fixed a bug in normalization caused by an errant format string
  • stacking algorithm now uses reduce function to create copy array
  • normalization will now automatically set traces per meter value of header['rhf_spm']
  • added export numpy binary file (.npy)
  • added header export to json
  • added export to gprpy (.npy & .json) per this discussion

changes since 0.0.8

  • moved plotting routines to new module plot.py
  • moved translations to new module translate.py
  • moved gps reading to new module gps.py
  • moved geophysical and GSSI constants to new module constants.py
  • moved stacking algorithm to filtering.py
  • significantly improved layout of main processing function readgssi.readgssi()
    • script flow is so much more natural now
    • made way for future additions like interactive picking
  • csv output improvements
    • added the ability to filter prior to csv export (duh?)
    • added the ability to export multiple csv files when more than one radar channel is present
  • improved histogram plotting
  • improved array handling when passing to functions
  • changed the way files are named if no output file is passed (the Seth Campbell Honorary Naming Scheme)

changes since 0.0.7

  • moved filtering routines to new module filtering.py
  • added a way to call readgssi.__version__
  • moved some config stuff to config.py
  • bitwise datetime read works properly now!! this was a longstanding bug that took me forever to figure out. the bit structure was not at all intuitive and the script kind of ends up using brute force to decode them to datetime objects, but it works. dates and times of file creation and modification should now match those in RADAN.
  • changed to verbose by default and quiet if -q / --quiet flag is set
  • changed print statement to output date and timestamp (helpful for tracking date and time of things when, for example, processing a whole survey data folder full of radar files)

changes since 0.0.6

  • added ability to install via PyPI
    • setuptools integrated command line script creation (i.e. readgssi instead of python readgssi.py)
  • broke out several routines into individual functions

changes since 0.0.5

  • now define time zero point manually (time zero is when the direct wave passes the receiver. previously, i used an unreliable calculation using header values to determine the time zero point)
    • in the future, i will add a signal processing algorithm to detect the time zero point automatically
  • added bandpass filter (requires obspy)
  • significantly optimized background removal and dewow algorithms
  • added example code and plots
  • fixed a bug that caused both plots of dual-channel radar files to be written out to one file
  • fixed a bug that caused manually-created output file names to be ignored when plotting
  • added basic background removal and dewow capability (#5 from @fxsimon)
  • added support for the D50800/D50300 antenna
    • added plotting support for dual-channel radar devices
    • merged #3 from @fxsimon which fixed a bug that caused multi-channel file traces to be read in a 121212 sequence instead of 111222
  • updated the workings of the plotting algorithm's colormap
  • changed the way files are saved (bug in 0.0.5 mangled some filenames)
  • added the ability to specify colormap and whether to draw a colorbar and a histogram
  • added an automatic figsize option (leaves figsize up to Matplotlib)
  • added ability to apply gain
  • fixed bug that caused gain to be applied incorrectly
  • script now tries to automatically calculate timezero using (nsamp*range)/position

known bugs:

  • translation to anything but csv is not successfully implemented yet (hope to have time to at least fix HDF5 output soon)
  • color bar shows up too large on some plots (matplotlib bug)

future

  • automatic script testing for smoother dev
  • GPS transcription from CSV with fields like mark name, lon, lat, elev, time
  • GUI-based geologic/dilectric layer picking
    • layer velocity calculation (using minimum of clustered hyperbola tail angle measurements, or manual input)
    • velocity-based depth adjustments
    • ability to incorporate ground truth measurements
  • velocity gradient/angle of incidence-based array migration
  • translation to common geophysical formats (HDF5, SEGY, etc.)

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

readgssi-0.0.10.tar.gz (27.2 kB view details)

Uploaded Source

Built Distribution

readgssi-0.0.10-py3-none-any.whl (41.3 kB view details)

Uploaded Python 3

File details

Details for the file readgssi-0.0.10.tar.gz.

File metadata

  • Download URL: readgssi-0.0.10.tar.gz
  • Upload date:
  • Size: 27.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.12.1 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.6.3 requests-toolbelt/0.8.0 tqdm/4.29.1 CPython/3.6.7

File hashes

Hashes for readgssi-0.0.10.tar.gz
Algorithm Hash digest
SHA256 be17fcd5c72f832320f9343c648cdc36f573d5ff67cd67e8c5544c2948edf207
MD5 6bfba3b0b71befbde4362856c7c90f87
BLAKE2b-256 165bb6c94b7f2385130f450da90fb37233aab7df99e53582ab33ad0fb47d72fb

See more details on using hashes here.

File details

Details for the file readgssi-0.0.10-py3-none-any.whl.

File metadata

  • Download URL: readgssi-0.0.10-py3-none-any.whl
  • Upload date:
  • Size: 41.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.12.1 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.6.3 requests-toolbelt/0.8.0 tqdm/4.29.1 CPython/3.6.7

File hashes

Hashes for readgssi-0.0.10-py3-none-any.whl
Algorithm Hash digest
SHA256 3c1c308367731fdadb334b95259bb7568cd640872d55664e3831bf459b08f799
MD5 1b58731777476b59b13a07816ef7f87e
BLAKE2b-256 fe874de8ef4bbc5fa8692127373a6cea75bd332cfcdf752e7abd970df41690b7

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page