Skip to content

Instantly share code, notes, and snippets.

@seumasmorrison
Last active May 31, 2019 03:33
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 4 You must be signed in to fork a gist
  • Save seumasmorrison/5935386 to your computer and use it in GitHub Desktop.
Save seumasmorrison/5935386 to your computer and use it in GitHub Desktop.
Datawell processing scripts

As part of the HebMarine project a number of scripts were developed for processing the data recieved from the Datawell Waverider buoys and latterly the Nortek AWAC ADCPs.

Spectral polar plot

A number of approaches were taken with the various data outputs from the buoys. Visual representations of 3 minutely spectral data took place every half hour after the sync had taken place with the recieving station. This produced a polar contour plot for each buoy based on the direction, power spectral density, spread and skew. See Spectral Polar Plot repository and accompanying plot_spectra.py. The colorbar represents power spectral density (m2/Hz), the peak value on the plot can deviate from the max psd in the spectral file due to a hard to fit surface. example plot

Spectral KML representation

See archived example on hebmarine.com. A buoy map was designed making use of KML( Keyhole Markup Language ), OpenLayers ( Javascript map library ) and using OpenStreetMap as a background map. A bash shell script on the server calls a python script which queries an SQLite databases containing spectral data, then creates a KML file using simpleKML and geopy, with example code shown in generate_arrows.py is the class used to create the arrows with an example call. The length of the arrows are intended to be proportional to the significant wave height. The full code can be made available for generating the KML from an SQLite database but this is really specific to the HebMarine setup and need further refactoring to be made useful for other projects. I would recommend parsing the spectral files on the fly as is done in plot_spectra.py. buoy_map.png

Waveroses

See waverose repository on Bitbucket based upon joshua_fr's windrose project on sourceforge. This allows the easy creation of stacked, binned, polar plots as shown below.

waverose.png

Time Series Analysis - Hebtools

Due to the limited processing capabilities of the standard tools provided from Datawell, it was decided to take an approach that would allow batch processing of long time series. Initially the text data files were processed via Python scripts and the values passed into an SQLite database. The performance of reading the records from an SQLite database and converting them into a Python object was slow and clunky.

The pandas (Python Data Analysis Library) provided good support for time series based indexing and querying. The use of pandas also allowed for statistical processing and the ability to save the data in its own binary format without any costly conversion upon loading and saving.

pandas is built upon Numpy ( a fundamental package for scientific computing in Python ) which allows access to many powerful functions available in the scientific python stack and the powerful plotting capabilities of Matplotlib.

IPython was used extensively to process, query and plot the displacement and spectral data. The IPython Notebook interface was made use of presenting the queries and plots inline, this allowed a certain amount of provenance and reproducibility of the plots. The notebook also allows easy dissemination of code and results via printing to PDF, especially to colleagues who do not directly use Python but made use of the pandas datasets ( DataFrames ) through export to Excel via openpyxl.

The proccess,use and design of the code is documented on the repository page for hebtools.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment