.. _python_pingdata_watertrack: Water Tracking ----------------- Part I: CODAS binaries ~~~~~~~~~~~~~~~~~~~~~~~~~~~ Use CODAS binaries to stage the data for watertrack calibration calculation. This has not changed since the original Pindata demo. (1) **timslip** Detect ship accelerations and turns from ship velocity, as recorded by the ADCP, and from position fixes. It can be used to derive an estimate of the time difference between the ADCP ensembles and the satellite time. It also provides estimates of the amplitude and phase of the transducer misalignment. Make changes in ``timeslip.tmp`` to extract more points for the watertrack calibration calculation, for example: allowing a slower ship-speed transition, or less smoothing before extracting the points. An example of this is :ref:`here `. - edit ``timslip.tmp`` (documented in ``timslip.cnt``) - run ``timslip timslip.tmp`` - creates specified output file, eg. ``aship_7.cal`` The default ``timslip.tmp`` is shown below (for database name ``aship``): :: fix_file_type: simple fix_file: ../../nav/aship.ags reference_file: ../../nav/aship.nav output_file: aship_7.cal year_base= 1993 min_n_fixes= 7 /* 5 7 9 */ n_refs= 7 /* 5 7 9 */ i_ref_l0= 1 i_ref_l1= 2 /* 1 2 3 */ i_ref_r0= 5 /* 4 5 6 */ i_ref_r1= 6 /* 4 6 8 */ up_thresh= 3.0 /* m/s */ down_thresh= 3.0 /* m/s */ turn_speed= 2.0 /* m/s */ turn_thresh= 60 /* degrees */ dtmax= 360 /* seconds, for 300-second ensembles */ tolerance= 5.e-5 /* days, about 5 seconds */ grid: ensemble use_shifted_times? no .. Part II: Python (used to be Matlab) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Use Python to calculate water track calibration values and make plots. This replaces the Matlab program ``calladcpcal_tmp.m``. Edit the file ``Wtplot_script.py`` Run the Python py typing: :: python Wtplot_script.py Example: Default ``Wtplot_script.py`` for pingdata demo: :: #!/usr/bin/env python ## written by quick_mplplots.py -- edit as needed: ## cruiseid is 'ADCP' ## dbname is 'aship' ## proc_yearbase is 1993 ## printformats is 'png' import matplotlib.pyplot as plt from pycurrents.adcp.quick_mplplots import Wtplot ## other options that can be chosen ## ## name value ## ------------- ----------- ## cruiseid 'ADCP ## printformats 'pdf' ## dpi 100 ## outfilebase 'wtcal' ## statsfile 'adcpcal.out' ## comment '#' ## ddrange 'all' ## clip_ph 3, ## clip_amp 0.04 ## clip_var 0.05 ## clip_dt 60 ## clip_u [-100,100] ## clip_v [-100,100] WT = Wtplot() WT(cal_filename = 'aship_7.cal', printformats = 'png', cruiseid = 'ADCP', proc_yearbase = '1993') plt.show() .. This appends a block of Water Track Calibration information to the file ``adcpcal.out``: :: ADCP watertrack calibration ## Time range 98.05 to 99.32 Calculation done at Tue Apr 23 02:52:40 2013 delta-u min = -100.00, max = 100.00 delta-v min = -100.00, max = 100.00 clip_amp = 0.04, clip_ph = 3.0 clip_dt = 60, clip_var = 0.050 Number of edited points: 15 out of 17 amp = 0.9940 + 0.0172 (t - 98.8) phase = 0.24 + -0.9924 (t - 98.8) median mean std amplitude 0.9930 0.9940 0.0161 phase 0.1350 0.2367 0.9394 nav - pc 4.0000 3.1333 5.5274 var 0.0080 0.0104 0.0066 min var 0.0080 0.0097 0.0067 delta-u 0.3700 0.7433 2.1442 delta-v 1.7500 0.4953 4.1361 .. To change some of the calculation parameters, copy the file ``Wtplot_script.py`` to another name, eg. ``Wtplot_slower.py`` and edit. For example, to change the following parameters: - new input filename (if ``timslip`` was changed and used a different output file): cal_filename = 'aship_5.cal' - new output filename : outfilebase = 'wtcal5_slower' - more phase clipping: clip_ph = 2 \... replace the call to WT (above) in ``Wtplot_slower.py`` with these additions: :: WT(cal_filename = 'aship_5.cal', printformats = 'png', cruiseid = 'ADCP', proc_yearbase = '1993', outfilebase = 'wtcal5_slower', clip_ph = 2) .. .. Do not forget to add commas after each new line. Run again: :: python Wtplot_slower.py Now the Water Track Calibration values have changed: :: ADCP watertrack calibration ## Time range 98.05 to 99.73 Calculation done at Fri May 10 08:43:11 2013 delta-u min = -100.00, max = 100.00 delta-v min = -100.00, max = 100.00 clip_amp = 0.04, clip_ph = 2.0 clip_dt = 60, clip_var = 0.050 Number of edited points: 20 out of 24 amp = 0.9861 + 0.0240 (t - 98.9) phase = 0.18 + 0.3759 (t - 98.9) median mean std amplitude 0.9820 0.9861 0.0208 phase 0.2305 0.1794 0.9147 nav - pc 2.0000 2.9000 10.1872 var 0.0075 0.0086 0.0043 min var 0.0060 0.0072 0.0041 delta-u 0.4350 0.0585 2.0352 delta-v -1.3150 -0.3795 3.7571 .. This is just a demonstration of how th make the changes. You have to decide what to apply. Summary: :: before: ------- Number of edited points: 15 out of 17 amp = 0.9940 + 0.0172 (t - 98.8) phase = 0.24 + -0.9924 (t - 98.8) median mean std amplitude 0.9930 0.9940 0.0161 phase 0.1350 0.2367 0.9394 after: ----- Number of edited points: 20 out of 24 amp = 0.9861 + 0.0240 (t - 98.9) phase = 0.18 + 0.3759 (t - 98.9) median mean std amplitude 0.9820 0.9861 0.0208 phase 0.2305 0.1794 0.9147 ..