We assume that a file dc.page exits and contains plots of dispersion curves , slowness versus frequency. We want to transform them into wavelength versus slowness. Additionally, we would like to smooth these curves in a "clever" way which keep the up-down traveltimes constant.
We first extract the content.xml file contained in the .page file:
The content.xml file is an xml file encoded in UTF16 (unicode). With 'cat', 'awk',... unicode may not be considered properly. First we convert it to basic ascii encoding:
Code: Select all
iconv -f UTF16 -t ASCII contents.xml > contents-ascii.xml
All dispersion curves can be extracted from the xml content:
Code: Select all
cat contents-ascii.xml | awk '/[0-9\.]+ +[0-9\.]+ +[0-9\.]+/{print $0}'
The next step is to modify these parts of the xml content without touching the rest. We replace the [frequency,slowness] by [slowness, 1/(frequency*slowness)=wavelength].
Code: Select all
cat contents-ascii.xml | awk '/[0-9\.]+ +[0-9\.]+ +[0-9\.]+/{print $2 " " 1/($1*$2)}!/[0-9\.]+ +[0-9\.]+ +[0-9\.]+/{print $0}' > contents.xml
We re-direct everything to content.xml to build a new .page file. If the original dc.page contains other files (usually starting by bin_...) you must pack them as well in the new file. Skip 'bin_data_100*' if your original dc.page file contains no binary file.
Code: Select all
tar cvfpz dc-wavelength.page bin_data_100* contents.xml
The created file can opened in figue:
You may be a bit disappointed because all plots are probably blank. This is just a problem of axis limits. Change the axis properties as you want, make use of mkup files to propagate them if you have various plots. Save your changes to dc-wavelength.page.
Secondly, we can calculate the smoothed slowness curves keeping the traveltimes constant. We start from the last dc-wavelength.page.
We first extract the content.xml file contained in the .page file and convert it:
Code: Select all
tar xvfpz dc-wavelength.page
iconv -f UTF16 -t ASCII contents.xml > contents-ascii.xml
We revert the sort of curves obtained so far to get increasing wavelengths:
Code: Select all
cat contents-ascii.xml | awk 'BEGIN{n=0}/[0-9\.]+ +[0-9\.]+ +[0-9\.]+/{x[n]=$0;n++}!/[0-9\.]+ +[0-9\.]+ +[0-9\.]+/{if (n>0){for(i=n-1;i>=0;i--)print x[i];n=0};print $0}' > tmp
We compute the smoothing itself:
Code: Select all
cat tmp | awk 'BEGIN{l=0;s=0}/[0-9\.]+ +[0-9\.]+ +[0-9\.]+/{nl=$2;s+=$1*(nl-l);l=nl;print s/l " " $2}!/[0-9\.]+ +[0-9\.]+ +[0-9\.]+/{s=0;l=0;print $0}' > contents.xml
The contents.xml can be converted to .page file the same way as shown above.