Data Quality, Analysis and Reporting

Validation, gaps, calibration, uncertainty, control charts, summary statistics, honest plots and a troubleshooting table.

What data quality means

Data is of good quality when it is accurate (close to the truth), complete (nothing missing without a reason), consistent (same units and meaning over time), timely (the time stamps are right) and traceable (you can show where each number came from). Quality is a property of the whole chain in this guide, and it is easier to build in than to repair afterwards. The analysis code that reads the files is in Data, Files and Parsing.

QualityQuestionCheck
AccuracyIs the value right?Calibration, a reference, a second sensor (see Sensors, Signal Conditioning and ADCs)
CompletenessIs anything missing?Count the samples against the expected number
PlausibilityIs it physically possible?Range and rate-of-change limits
TimelinessIs the time right and in order?Monotonic times, clock sync flags (see Time Stamps and Clocks)
ConsistencySame units and meaning?Metadata, version of the firmware and scaling
ProvenanceWhere did it come from?Logger ID, file, checksum, change log

Worked example: completeness of a day

A 1 Hz logger should produce 86 400 samples a day. This day has 85 620: 99.10 % complete, 780 samples missing. If the plan required 99.5 % (see Planning a Logging System), this day passes with a margin of -0.40 percentage points; if the missing samples are all in one 13-minute gap during an event, the day may still be useless. Look at where the gaps are, not just how many.

Validating at the logger and at the server

CheckCatchesExample rule
RangeOpen or shorted sensor, wrong unitsA cold-room temperature must lie between −40 and 60 °C; a 4–20 mA reading below 3.6 mA is a fault (see Sensors, Signal Conditioning and ADCs)
Rate of changeSpikes, glitches, loose wireWater temperature cannot move 10 °C in a second
Stuck valueFrozen sensor, dead channel, a repeating last valueThe same exact value for 30 minutes on a noisy channel
Cross-checkA drifting or failed sensorTwo probes in the same place within 1 °C; flow in equals flow out
Sequence / counterLost or duplicated recordsThe counter increases by exactly one
TimeClock jumps, reorderingTime never goes backwards; the interval is within 10 % of nominal
Checksum / CRCCorrupted recordsComputed per record or block (see Storage, Formats and Data Rates)
  • Flag, do not delete. Keep the original value and add a quality flag (good, suspect, bad, estimated, missing). Whoever uses the data can then decide.
  • Validate twice: simple checks at the logger so that an alarm can fire, thorough ones at the server where you can compare channels.
  • Record the test results, and the version of the rules, so that a changed rule does not silently change old results.
import pandas as pd
df = pd.read_csv("log.csv", parse_dates=["t"]).set_index("t").sort_index()
bad_range = ~df["air_c"].between(-40, 60)
bad_rate  = df["air_c"].diff().abs() > 5          # more than 5 degC between samples
stuck     = df["air_c"].rolling(30).std() == 0    # no variation for 30 samples
df["flag"] = (bad_range | bad_rate | stuck).astype(int)

Gaps, duplicates and ordering

Worked example: a 13-minute gap

  • A 60 s logger stops for 780 s: 13 records are missing. Detect it as a time difference greater than 1.5 × the interval.
  • Do not interpolate silently. A straight line across the gap draws a trend that was never measured. Show the gap in plots (break the line), and leave it empty in statistics, or fill it with a flagged estimate if a method requires continuous data.
  • Resampling 1 440 one-minute samples to 15 minutes gives 96 rows. Use the mean, and count the samples in each bucket so that a bucket made of two readings is flagged: df.resample("15min").agg(["mean","min","max","count"]).
  • Duplicates come from retries and overlapping downloads: remove them on time + logger ID, keeping the first.
  • Out-of-order records come from buffering: sort on the device time, not the file order.
  • Overlaps and restarts: when a logger is restarted, the new file starts again; mark the boundary and treat the first samples after a restart with suspicion (sensors warming up).

Outliers and spikes

A single wild value may be a real event, a glitch in the wiring, or a transmission error. Decide by cause, not by looks. A robust test uses the median and the median absolute deviation (MAD), because the mean and standard deviation are themselves pulled by the outlier.

Worked example: a spike in ten readings

  • Ten readings contain one value of 9.80 among values near 4.3. The median is 4.32 and the MAD is 0.075.
  • The robust score is |9.80 − 4.32| ÷ (1.4826 × 0.075) = 49.3; values above about 3.5 are usually flagged. This one is obviously suspect.
  • Check the cause first: was something switched on? Is there a neighboring channel with the same jump (real) or only this one (wiring or electronics)?
  • Choose the treatment: keep and flag; replace with a flagged estimate (median of neighbors) for analysis that needs it; never delete without a note.

Calibration and correction

Compare the channel with a better reference at two or more points and fit a straight line reference = (reading − offset) ÷ gain. Apply the correction in the analysis and store the coefficients in the metadata, so that the raw data is never overwritten (see Planning a Logging System).

Worked example: a three-point check

  • Readings against a reference at 0, 50 and 100: 0.31 for 0, 50.18 for 50, 99.74 for 100.
  • A least-squares line gives a gain of 0.994 and an offset of 0.36. So a raw reading of 60.00 corrects to 59.98.
  • Check the residuals at each point after the fit: they show the remaining error and any non-linearity. Fit more points for a curved sensor.
  • Re-check at intervals and compare the offset with last time; a change that exceeds the uncertainty means drift and the data in between needs a time-varying correction.
  • Hold the reference to a higher standard than the channel (the 4:1 rule) and keep its certificate.

Summary statistics and uncertainty

Worked example: ten readings

  • Ten readings: 4.21, 4.35, 4.18, 4.42, 4.30, 4.27, 4.39, 4.24, 4.33, 4.29.
  • Mean = 4.298, median = 4.295, sample standard deviation s = 0.077.
  • Standard error of the mean = s ÷ √n = 0.024. The 95 % confidence interval, with t = 2.262 for 9 degrees of freedom, is 4.298 ± 0.055.
  • The instrument’s uncertainty adds: with ±0.30 from the budget (see Sensors, Signal Conditioning and ADCs), the combined value is √(0.30² + 0.024²) = 0.301, and the expanded uncertainty (k = 2) is ±0.60. Averaging reduces the random part but not the instrument part.
  • Report the result as 4.3 ± 0.6 with the coverage factor, not as 4.298 000 000.
StatisticUseWatch out
MeanThe central value of a steady signalPulled by outliers; meaningless for angles or cyclic values
MedianRobust central valueIgnores the extremes
Standard deviationSpread (noise or variation)Use n−1 for a sample; not for skewed data
Min / maxExtremes and complianceDepends on the sample rate and the filter
Percentiles (5, 50, 95)The typical range, without outliersNeed enough samples
Time above / below a limitCompliance and excursionsState the limit, the interval and how gaps are counted
Integral (energy, volume)Totals from ratesTime step and gaps matter: use the totaliser if you have one

Control charts

A control chart separates normal variation from a real change. Take the mean of each subgroup (for example five readings), compute the center line and the standard deviation of the means from a period when the process was known to be stable, and draw limits at ±3σ. A point outside, or a run of points on one side, signals that something changed.

A control chart: seeing a shift in logged data0510152025309.29.61010.410.8subgroupaverageUCL 10.25CL 9.98LCL 9.71
A control chart: center line and ±3σ limits from the first 20 subgroups; the last points shift above the upper limit.

Worked example: limits from 20 subgroups

  • From the first 20 subgroup means: center line = 9.981, σ of the means = 0.089, so UCL = 10.249 and LCL = 9.714.
  • Points beyond a limit: subgroups 24, 25, 26, 27, 28, 30. The longest run above the center line is 10 points, starting at subgroup 21.
  • Two rules help: a point beyond 3σ, or about eight in a row on one side of the center line, deserve a look. A shift of 0.35 in a process with σ(mean) = 0.089 is a 3.9σ change: real, but small enough that a single reading might not show it.
  • Compute the limits from stable data, not from the data that contains the problem, and re-compute only when the process is deliberately changed.

Honest plots

DoAvoid
Show gaps as breaks in the lineJoining across a missing hour
Start the axis where it is honest, or say that it is cutA truncated axis that turns 0.2 degrees into a cliff
Plot the right time (UTC or stated local time) and label the axis with unitsUnlabeled axes and mixed zones
Use min and max bands with the mean for aggregated dataThe mean alone for a fast signal
Keep the same scale across panels you compareAuto-scaling each panel so a noise floor looks like a trend
Mark events, set-points and limitsA line that nobody can interpret
Show the uncertainty: error bars or a bandFalse precision on the plot or the table

Reporting and traceability

  • State the question and the answer first; the plots and tables support it.
  • Say what was measured, how and by whom: sensor, logger, firmware, sample rate, filtering, calibration date, time source (the metadata, see Planning a Logging System).
  • Give the completeness and the treatment of gaps and outliers (“3 samples flagged and excluded, 780 s missing in one gap”).
  • Quote numbers with their uncertainty and units, to a sensible number of digits.
  • Keep the raw data, the code and the report together, with a checksum of the raw files, so the result can be reproduced.
  • Regulated records (food safety, pharmaceutical) may require audit trails, electronic signatures, defined retention and validated software; check the rules that apply before you design the system.

Troubleshooting table

SymptomLikely causeCheck
Readings flat at an odd valueOpen input floating, sensor disconnected, ADC clippingLook at the raw counts; short the input; check the NAMUR level
Noise much larger than expectedPick-up, ground loop, supply noiseShort the input; shield and ground (see Sensors, Signal Conditioning and ADCs)
A slow oscillation nobody expectedAliasing of a faster signalChange the sample rate and see if it moves (see Sampling, Aliasing and Filtering)
Slow driftSensor aging, reference drift, temperatureCompare with a reference over time; log the board temperature
SpikesSwitching noise, loose connection, radio interferenceDo they coincide with a motor or relay? Do other channels see them?
Steps in the dataRange switching, a restart, a calibration changeCompare with the event log and the metadata
Missing recordsBuffer overflow, power loss, full cardCount records, check the sequence number and the free space
Time jumpsClock step, DST, lost power with no RTCLook at the sync log (see Time Stamps and Clocks)
Values too high or low by a constant factorWrong scaling or unitsCompare with the metadata; check against a known point
Files will not openCorrupt file, power cut during writeCheck the CRC; recover to the last good record (see Storage, Formats and Data Rates)

Related

FAQ

Should I delete bad data?

No: flag it and keep the original. Delete only copies for a particular analysis, and record what was excluded and why.

Can I fill gaps by interpolation?

For a plot or a calculation that needs continuous data, yes, as a flagged estimate and for short gaps. Never present interpolated values as measurements.

How do I know my sensor has drifted?

Compare it with a reference or a second sensor at intervals, and log the difference. A trend in the difference is drift; a step is a fault or a change.

How many significant figures should I report?

Few enough that the last one is meaningful given the uncertainty: if the expanded uncertainty is ±0.6, report 4.3 ± 0.6, not 4.2983.

References

  • JCGM 100:2008 (GUM) and JCGM 200 (VIM); ISO 5725 (accuracy of measurement methods).
  • Montgomery, D. C., Introduction to Statistical Quality Control; Wheeler, D. J., Understanding Variation.
  • Tufte, E., The Visual Display of Quantitative Information; ALCOA+ principles for data integrity (FDA and MHRA guidance).

Last reviewed: October 2026. The numbers on this page are computed from the example data shown; replace them with your own.