Write the delayed-mode salinity assessment of a profiling-float programme: remove the thermal-mass bias of the real-time profiles, compare float salinity on potential-temperature levels with mapped ship reference casts, fit a piecewise-linear conductivity ratio with breakpoints and steps over each float's life, propagate its uncertainty and decide which floats are adjusted; it is run under a time limit on further float records with known sensor drift.
harbor run -t reactive-labs/float-salinity-driftharbor download reactive-labs/float-salinity-driftYou are Nadia Ferrand, data analyst in the float programme (BFP) of the Brannock Ocean Institute. The programme runs twelve profiling floats in the eastern subtropical North Atlantic: eight Petrel-2 floats with the pumped Fulmar FC-2 CTD and four Petrel-3 floats with the unpumped Skua SK-1 CTD. None of their salinity has been through delayed-mode assessment yet. Today is Wednesday 2 December 2026. Adaeze Okonkwo, the programme's data manager, wrote this morning:
We owe the first delayed-mode salinity round for the whole fleet before the end of the year, and SOP-FP-05 is finally signed. Could you write the assessment as one program that takes a float in the archive layout and gives the ratio for every cycle, its uncertainty, the breakpoints and the adjust / no-adjust call, and run it on all twelve floats? I will run the program on my validation records before we submit anything.
Her full mail is in docs/mail/.
You have 50 minutes. Whatever is in /app/output when the time is up is graded, so keep a working program saved as
you go.
In /app/inputs, the archive layout:
rt_profiles/<float>_rt.csv: the real-time 2-dbar profiles of every cycle of every float since deployment.floats/<float>_meta.json: the float metadata records (platform, CTD, deployment, missions, firmware, the
float's engineering-log entries).reference/: the BOI-HYD 2026 ship CTD reference casts and the casts taken at each deployment.docs/: SOP-FP-05 rev 1 (delayed-mode assessment of float salinity), SOP-FP-03 rev 4 (full-resolution
processing), the FC-2 application note AN-41, the Petrel-3 integration note PN-311, the SK-1 thermal-inertia note
TN-SK1-07, the Petrel firmware release notes, the engineering log and mail/.legacy/: the former analyst's full-resolution script and his handover note./app/output/dmqc.py, run as
python3 /app/output/dmqc.py <archive_dir> <float_id> <out.json>
<archive_dir> has the layout above with at least rt_profiles/<float_id>_rt.csv,
floats/<float_id>_meta.json, reference/deployment_casts.csv and
reference/BOI-HYD_2026_reference_casts.csv. The program writes one JSON object:
{"float": "F017", "adjust": false, "breakpoints": [],
"cycles": {"1": {"ratio": 0.9999921, "ratio_error": 0.0000112}, "2": {...}, ...}}
| Key | Content |
|---|---|
cycles |
one entry for every cycle number from 1 to the last cycle in the float's real-time file |
ratio |
the conductivity ratio of the cycle: the conductivity the cell reported divided by the true conductivity of the water (1 for a perfect sensor, below 1 for a cell that reads fresh) |
ratio_error |
its one-standard-deviation uncertainty |
breakpoints |
the cycle numbers where the fitted drift changes: the vertex of a change of slope, or the first cycle after a step |
adjust |
true if the float's salinity is to be adjusted under SOP-FP-05, else false |
The program runs with Python 3.12, numpy 2.1.3, scipy 1.14.1, pandas 2.2.3 and gsw 3.6.19, on one CPU core
with 2 GB of memory and no network, and must finish a float within 8 seconds. It is run as another user from a
copy of /app/output: it may load helper files that you put in /app/output (found relative to __file__),
but /app/inputs is not there when it runs.
/app/output/results/<float>.json for each of the twelve floats (for example /app/output/results/F017.json):
the program's output for that float.
Adaeze runs your program on 37 further float records in the same layout, with the same reference casts. They come from both platforms and cover the missions, firmware versions and sensor histories the programme's floats have had or can have; the conductivity ratio of every cycle is known for them. The true ratios of the twelve floats in hand are known too, and your result files are compared with them in the same way.
Per float:
| Quantity | Full credit | Zero credit |
|---|---|---|
| ratio: root-mean-square error over all cycles (a missing value counts 3 x 10^-4) | up to 2.25 x 10^-5 | 6.75 x 10^-5 |
| each true breakpoint at a step: distance to the nearest reported breakpoint | 1 cycle | 3 cycles |
| each true breakpoint at a change of slope: distance to the nearest reported breakpoint | T cycles | 3T cycles |
uncertainty: fraction of cycles whose error is within twice ratio_error |
0.90 or more | 0.60 or less |
Credit falls linearly between the two columns.
Ratio. On a float with at least three cycles whose true |ratio - 1| is 3 x 10^-5 or more, the ratio credit is also multiplied by the share of the uncorrected error (ratio 1) that your ratios remove on those cycles, in the root-mean-square, divided by one half and capped at 1: removing half of it or more keeps the full credit, removing none gives zero.
Breakpoints. For a change of slope, T is the larger of 4 cycles and the number of cycles in which the new drift changes the ratio by 6 x 10^-5; at the onset of a fouling drift T is at least its e-folding time in cycles. Reporting no breakpoint for a drift counts as a breakpoint at cycle 0 (drift from deployment). A step smaller than 6 x 10^-5, and a change of slope whose drift has not reached 6 x 10^-5 by the last cycle, are not scored, and a reported breakpoint near them is not held against you. The breakpoint credit is the sum of the credits of the scored true breakpoints divided by their number plus the number of reported breakpoints that match none (breakpoints within the growing part of a fouling drift excepted); a float with nothing to score and nothing reported scores 1.
Uncertainty. The coverage credit is multiplied by a sharpness credit: 1 while the median ratio_error is at
most 4 x 10^-5, falling linearly to 0 at 8 x 10^-5.
Call. The adjust call scores 1 when right and 0 when wrong; it is not scored on a float whose true largest |ratio - 1| lies between 4 x 10^-5 and 9 x 10^-5.
With R, B, C and U the ratio, breakpoint, call and uncertainty credits, a float scores 0.30 R + R x (0.40 B + 0.10 C + 0.20 U); on a float where the call is not scored, it scores (0.30 R + R x (0.40 B + 0.20 U)) / 0.90. A float on which the program fails, runs out of time or writes no readable JSON scores zero. The final score is 85 % the weighted mean over the 37 further records and 15 % the weighted mean over the twelve result files, where a float whose true |ratio - 1| stays below 6 x 10^-5 at every cycle weighs 0.25 and every other float weighs 1.