back to:

Report
Index

Thermocline Extraction
RV Celtic Explorer Cruise CE17-01
Chief Scientist: Kevin Sheehan, MI
July 22nd to August 6th 2017
John E. Hughes Clarke
Anand Hiroji
Jose Cordero Ros
Center for Coastal and Ocean Mapping
University of New Hampshire

Overview:

The Msc thesis topic of Jose is to assess the feasibility of automatically extracting the depth of the thermocline from the underway acoustic imagery (primarily the EK60 data). As we are running the MVP every ~ 30 minutes, we can directly compare the location of the top and bottom of the thermocline (as defined by the sound speed profiles) to the EK 60 imagery at all of 18, 38 and 120 kHz (200 kHz is disabled as it interferes with the EM2040). Examples of MVP profiles plotted over EK60 imagery can be seen on the EK60 page.

From all the MVP overlays, it is clear that the most common horizon that correlates with the scattering layer is the bottom of the thermocline. But occasionally I've noticed that sometimes you track two horizons - and (with a lot of imagination) maybe we can occasionally get the top of the thermocline as well as the bottom?

THe example below is last night's profile - note that the MVP's show that the thickness of the thermocline decreases towards the centre of the section. So does the two layer spacing?.

imagery with MVP
extraction
L033 - NIGHTTIME
3 bands of data with MVP dips superimposed
L037 - DAYTIME
L033 - NIGHTIME
extraction - but showing two horizons. 
L037 - DAYTIME
3 bands plus mvp
tracking



To that end a series of scripts have been set up to start Jose looking into the choice of appropriate filter settings.


Basic Software Tools:

All the scripts and data are set up to be used in the directory :          
>CE17_01/EK60/Filtering_Sections/
there are a number of scripts, all of which are built around a simple command line tool called r4filter (in ~/code/grid):
>r4filter
Usage : r4filter -box 5 (odd)  or -xbox 7 -ybox 1
    (-high or -low)
    (-ignore 8bitval)
    floatfile filterfile
Note box dimensions should always be odd (5x1 or 3x21 etc..).

a typical use would be :
> r4filter -xbox 3 -ybox 15 -low -ignore 0 test_image test_image.filt_low_03x15
this would run a 3x15 box car low pass filter through image "test_image" and write the output to image : "test_image.filt_low_03x15". Note the "-ignore" value is an 8bit value that is considered to not be part of the image.

A file called "test.image" exists in this directory so you can try it out.

The input and output image formats are the UNB_OMG format, which consists of a 1024 byte header followed by X x Y unsigned characters (8 bit 0-255). You can see this by using jview:
> jview test_image.filt_low_03x15
which will allow you to see that image - or if you want to compare two images:
> jview test_image test_image.filt_low_03x15
pull out a zoom window with the left mouse button. And then toggle between the two images using the "Y" key. If you want to see a larger areas (max 800x800 is the default) add -maxsub 2000 to the command line:
>jview test.image -maxsub 2000

If you want to see an image in a more conventional image viewing software, you can convert it to a pgm format:
> stretchacres -low 100 -high 200 -in test_image.filt_low_03x15 -pgm -out test_image.filt_low_03x15.pgm
This does a linear stretch on the greyscale (all pixels with a value below 100 are black and all pixels above 200 are  white and the greyscale changes linearly between 100 and 200). The image is output into a pgm (portable greymap) and then you can look at it using either:
> xv test_image.filt_low_03x15.pgm
or
> eog test_image.filt_low_03x15.pgm
if you want to convert the image to another format, just use :
> convert test_image.filt_low_03x15.pgm test_image.filt_low_03x15.jpg



The r4filter calls are embedded in a series of scripts:


Specific Scripts:

As each line of the EK60 data is logged, it is being stored in the raw directory.  From there it is being converted to the OMG format and then reprojected into a geographic framework corresponding to a standard W-E transect for each line. This is being done in the :
>EK60/Registered_Sections
directory.

All the scripts take the registered sections from that directory, rotate them by 90 degrees (so that you can look at a section conventionally) and then the filters are applied.

The first script as an introduction is :
>Do_Filter_Combinations L024 038kHz
This just runs with two arguments (line_# and freq) and jview will pop up and you can compare the same section viewed with a wide range of high and low pass filters. A sub-window will pop up of the detail of the section. You can use the left arrow and right arrow keys to pan back and forth along the section.  To jump between all the filtered versions of the same image, either click on the name in the map selection window or use the "Y" and "T" keys in the image window to go forward or back.



Note that, when you get to the high pass filters, you will need to change the greyscale stretch. You do this by using the left and right mouse buttons in the greyscale window.  To inherit the stretch you used in the previous image, press the "L" key in the image or map-selection windows.

Once you get what this is doing, you will notice that the thermocline shows up best from a high pass filter that is directed vertically ((ie. X=1 or 3, and Y=15+).  However, that high pass image also contains shorter wavelength noise that is not related to the thermocline. To best reduce the pseudo-random short wavelength noise, one needs to prefilter the data with an omnidirectional low pass filter.
So to get the best results, you need to combine high and low pass filters - basically you are doing a directional bandpass filter.

To try this out, there is a second script:
>Do_Custom_Filter_One_Freq L009 018kHz
as you can see it requires two arguments - the Line_# (L0XX) and the choice_of_frequency (one of "018kHz", "038kHz" or "120kHz"). It does the two most useful filters from the previous introduction (11x11 low pass and 01x17 high pass) and then does them sequentially. It pops up the 4 views in jview so that you can take a look.

Once you understand how this works, you can now try the last script which does this automatically for all three frequencies of a single line. Your variables now are what you want the dimensions of the high (01xYY) and low (ZZxZZ) pass filters to be. The syntax is like this:
>Do_Custom_Filter_All_Three_Freqs L009 YY ZZ     (try 11 17 initially)
The results are now automatically converted into three colour images and combined together with an RGB version of the original data. It pops up in front to you using eog. From that you can get an idea of whether you are tracking the thermocline adequately.

For line L009, this will work pretty well. But as you can see the thermocline is rather obvious. Now try and repeat this for a few other lines, especially those at night and those where the thermocline is rather diffuse. You will see that the initial settings (11 (x11) and 17(x1), do not work so well there.

So what you need to do is try other dimensions.
 
Note that the low pass filter setting HAS to be smaller than the high pass filter setting. Conceptually, you are saying that the thermocline is characterized by a rapid change in the intensity in the vertical direction, and that that change occurs over a wavelength of between ~ 11 and 17 pixels.

Remember that for these images we have fixed on a 0.2m vertical pixel size (and a 10m horizontal pixel size). So this is saying that the thermocline boundary occurs over a length scale of about ~ 15 vertical pixels or 3m.

Try another line like L007. Compare it at  11-17 and then at 15-31 and then at 27-51.  You will see the thermocline gradually becomes clearer as you move to longer wavelengths, but at the same time, the detail on it is being lost.


This is really the core of your thesis - you need to come up with a filter combination that can track the thermocline, as it evolves from day to night from sharp to diffuse.  And you want to be able to combine the estimate from the three frequencies. You will notice that it is clearer on one or another filter size and from one compared to another of the three frequencies, and that optimal setting changes from line to line.  How can you adapt to this? At what point can you not reliably track the thermocline and how can you tell when this condition occurs?

Also you will want to add more functionality to r4filter - median filters, filters that extract standard deviation, and gradients vertically and horizontally. - all things you started in matlab.


this should get you going --- lots to think about!!!!




page composed offshore --  JEHC