Create a deep ocean carbonate system monitoring array: sensors, drift, and calibration.
- User
Create a deep ocean carbonate system monitoring array: sensors, drift, and calibration.
Assistant
Create a deep ocean carbonate system monitoring array: sensors, drift, and calibration.
The user wants me to create a deep ocean carbonate system monitoring array visualization. This is a scientific visualization related to ocean chemistry and carbon cycle monitoring.
Key components I need to include:
Sensors - Various types of sensors that measure carbonate system parameters:
Drift - Sensor drift over time:
Calibration - Methods to correct drift:
For the visualization, I'll create an animated scene showing:
I'll use Three.js for 3D visualization with:
Let me design this with:
Color palette:
I'll create a sophisticated scientific visualization that's both informative and visually impressive.
This visualization shows a deep ocean monitoring mooring with various carbonate system sensors, their drift patterns, and calibration status. I'll create an interactive 3D scene with:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Deep Ocean Carbonate Monitoring Array</title>
<style>
* { margin: 0; padding: 0; box-sizing: border-box; }
body {
overflow: hidden;
background: #000810;
font-family: 'Courier New', monospace;
}
#canvas-container { width: 100vw; height: 100vh; }
#ui-panel {
position: fixed;
top: 20px;
left: 20px;
background: rgba(0, 20, 40, 0.9);
border: 1px solid #0af5;
border-radius: 8px;
padding: 15px;
color: #8cf;
max-width: 320px;
z-index: 100;
}
#ui-panel h1 {
font-size: 14px;
color: #0fa;
margin-bottom: 10px;
text-transform: uppercase;
letter-spacing: 2px;
}
#ui-panel h2 {
font-size: 11px;
color: #0cf;
margin: 10px 0 5px;
border-bottom: 1px solid #0af3;
padding-bottom: 3px;
}
.sensor-list {
font-size: 10px;
line-height: 1.6;
}
.sensor-item {
display: flex;
justify-content: space-between;
padding: 3px 5px;
margin: 2px 0;
background: rgba(0, 50, 80, 0.5);
border-radius: 3px;
cursor: pointer;
transition: background 0.3s;
}
.sensor-item:hover {
background: rgba(0, 100, 150, 0.6);
}
.sensor-item.selected {
background: rgba(0, 150, 200, 0.4);
border-left: 2px solid #0fa;
}
.status-ok { color: #0fa; }
.status-warning { color: #fa0; }
.status-critical { color: #f55; }
.status-calibrating { color: #0ff; }
#detail-panel {
position: fixed;
top: 20px;
right: 20px;
background: rgba(0, 20, 40, 0.9);
border: 1px solid #0af5;
border-radius: 8px;
padding: 15px;
color: #8cf;
width: 280px;
z-index: 100;
}
#detail-panel h3 {
font-size: 12px;
color: #0fa;
margin-bottom: 10px;
}
.data-row {
display: flex;
justify-content: space-between;
font-size: 10px;
padding: 4px 0;
border-bottom: 1px solid #0af2;
}
.data-label { color: #68a; }
.data-value { color: #0cf; font-weight: bold; }
.drift-bar {
height: 8px;
background: #012;
border-radius: 4px;
margin: 5px 0;
overflow: hidden;
}
.drift-fill {
height: 100%;
border-radius: 4px;
transition: width 0.5s, background 0.5s;
}
#calibration-btn {
width: 100%;
padding: 10px;
margin-top: 15px;
background: linear-gradient(135deg, #048, #06a);
border: 1px solid #0af;
border-radius: 5px;
color: #0fa;
font-family: inherit;
font-size: 11px;
cursor: pointer;
text-transform: uppercase;
letter-spacing: 1px;
transition: all 0.3s;
}
#calibration-btn:hover {
background: linear-gradient(135deg, #06a, #08c);
box-shadow: 0 0 15px #0af5;
}
#calibration-btn:disabled {
opacity: 0.5;
cursor: not-allowed;
}
#depth-scale {
position: fixed;
left: 360px;
top: 50%;
transform: translateY(-50%);
height: 400px;
width: 40px;
background: rgba(0, 20, 40, 0.8);
border: 1px solid #0af3;
border-radius: 5px;
z-index: 50;
}
.depth-mark {
position: absolute;
right: 5px;
font-size: 8px;
color: #68a;
transform: translateY(-50%);
}
#info-bar {
position: fixed;
bottom: 20px;
left: 50%;
transform: translateX(-50%);
background: rgba(0, 20, 40, 0.9);
border: 1px solid #0af5;
border-radius: 8px;
padding: 10px 25px;
color: #8cf;
font-size: 11px;
display: flex;
gap: 30px;
z-index: 100;
}
.info-item {
text-align: center;
}
.info-label {
font-size: 8px;
color: #68a;
text-transform: uppercase;
}
.info-value {
font-size: 14px;
color: #0fa;
font-weight: bold;
}
#notification {
position: fixed;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
background: rgba(0, 40, 60, 0.95);
border: 2px solid #0ff;
border-radius: 10px;
padding: 20px 40px;
color: #0ff;
font-size: 14px;
z-index: 200;
display: none;
text-align: center;
}
#notification.show {
display: block;
animation: pulse 0.5s ease-in-out infinite alternate;
}
@keyframes pulse {
from { box-shadow: 0 0 20px #0ff5; }
to { box-shadow: 0 0 40px #0ffa; }
}
</style>
</head>
<body>
<div id="canvas-container"></div>
<div id="ui-panel">
<h1>Carbonate Monitoring Array</h1>
<h2>Sensor Status</h2>
<div class="sensor-list" id="sensor-list"></div>
<h2>Array Statistics</h2>
<div class="data-row">
<span class="data-label">Deployment Days:</span>
<span class="data-value" id="deploy-days">0</span>
</div>
<div class="data-row">
<span class="data-label">Calibrations:</span>
<span class="data-value" id="cal-count">0</span>
</div>
<div class="data-row">
<span class="data-label">Data Points:</span>
<span class="data-value" id="data-points">0</span>
</div>
</div>
<div id="detail-panel">
<h3 id="sensor-name">Select a Sensor</h3>
<div id="sensor-details">
<div class="data-row">
<span class="data-label">Depth</span>
<span class="data-value" id="detail-depth">--</span>
</div>
<div class="data-row">
<span class="data-label">Type</span>
<span class="data-value" id="detail-type">--</span>
</div>
<div class="data-row">
<span class="data-label">Current Reading</span>
<span class="data-value" id="detail-reading">--</span>
</div>
<div class="data-row">
<span class="data-label">Drift Level</span>
<span class="data-value" id="detail-drift">--</span>
</div>
<div class="drift-bar">
<div class="drift-fill" id="drift-fill"></div>
</div>
<div class="data-row">
<span class="data-label">Last Calibration</span>
<span class="data-value" id="detail-lastcal">--</span>
</div>
<div class="data-row">
<span class="data-label">Status</span>
<span class="data-value" id="detail-status">--</span>
</div>
</div>
<button id="calibration-btn">Calibrate Selected Sensor</button>
</div>
<div id="depth-scale"></div>
<div id="info-bar">
<div class="info-item">
<div class="info-label">Array Depth</div>
<div class="info-value">4000m</div>
</div>
<div class="info-item">
<div class="info-label">Water Temp</div>
<div class="info-value" id="water-temp">2.3C</div>
</div>
<div class="info-item">
<div class="info-label">Pressure</div>
<div class="info-value" id="pressure">401.2 atm</div>
</div>
<div class="info-item">
<div class="info-label">pCO2</div>
<div class="info-value" id="pco2-avg">420 uatm</div>
</div>
<div class="info-item">
<div class="info-label">pH</div>
<div class="info-value" id="ph-avg">8.12</div>
</div>
</div>
<div id="notification"></div>
<script type="importmap">
{
"imports": {
"three": "https://unpkg.com/three@0.160.0/build/three.module.js",
"three/addons/": "https://unpkg.com/three@0.160.0/examples/jsm/"
}
}
</script>
<script type="module">
import * as THREE from 'three';
import { OrbitControls } from 'three/addons/controls/OrbitControls.js';
// Scene setup
const container = document.getElementById('canvas-container');
const scene = new THREE.Scene();
scene.background = new THREE.Color(0x000810);
scene.fog = new THREE.FogExp2(0x001020, 0.008);
const camera = new THREE.PerspectiveCamera(60, window.innerWidth / window.innerHeight, 0.1, 1000);
camera.position.set(30, 10, 40);
const renderer = new THREE.WebGLRenderer({ antialias: true });
renderer.setSize(window.innerWidth, window.innerHeight);
renderer.setPixelRatio(Math.min(window.devicePixelRatio, 2));
container.appendChild(renderer.domElement);
const controls = new OrbitControls(camera, renderer.domElement);
controls.enableDamping = true;
controls.dampingFactor = 0.05;
controls.maxDistance = 100;
controls.minDistance = 10;
// Sensor types and configuration
const sensorTypes = {
pH: { color: 0x00ff88, unit: 'pH', baseValue: 8.1, variance: 0.15 },
pCO2: { color: 0x00aaff, unit: 'uatm', baseValue: 420, variance: 30 },
Temperature: { color: 0xff6644, unit: 'C', baseValue: 2.5, variance: 0.5 },
Alkalinity: { color: 0xffaa00, unit: 'umol/kg', baseValue: 2320, variance: 20 },
DIC: { color: 0xaa44ff, unit: 'umol/kg', baseValue: 2150, variance: 25 },
Oxygen: { color: 0x44ffff, unit: 'umol/kg', baseValue: 180, variance: 15 }
};
// Sensor data structure
const sensors = [];
const sensorMeshes = [];
let selectedSensor = null;
let deploymentTime = 0;
let calibrationCount = 0;
let totalDataPoints = 0;
// Create depth scale
const depthScale = document.getElementById('depth-scale');
for (let d = 0; d <= 4000; d += 500) {
const mark = document.createElement('div');
mark.className = 'depth-mark';
mark.style.top = `${(d / 4000) * 100}%`;
mark.textContent = `${d}m`;
depthScale.appendChild(mark);
}
// Create main mooring line
const lineGeometry = new THREE.CylinderGeometry(0.1, 0.1, 80, 8);
const lineMaterial = new THREE.MeshPhongMaterial({
color: 0x334455,
emissive: 0x112233,
shininess: 30
});
const mooringLine = new THREE.Mesh(lineGeometry, lineMaterial);
mooringLine.position.y = 0;
scene.add(mooringLine);
// Create anchor
const anchorGeometry = new THREE.CylinderGeometry(2, 3, 4, 6);
const anchorMaterial = new THREE.MeshPhongMaterial({
color: 0x445566,
shininess: 50
});
const anchor = new THREE.Mesh(anchorGeometry, anchorMaterial);
anchor.position.y = -42;
scene.add(anchor);
// Create buoy at top
const buoyGeometry = new THREE.SphereGeometry(2, 16, 16);
const buoyMaterial = new THREE.MeshPhongMaterial({
color: 0xff4422,
emissive: 0x331100
});
const buoy = new THREE.Mesh(buoyGeometry, buoyMaterial);
buoy.position.y = 42;
scene.add(buoy);
// Create sensors along the mooring line
const sensorPositions = [
{ depth: 200, type: 'pH' },
{ depth: 500, type: 'pCO2' },
{ depth: 800, type: 'Temperature' },
{ depth: 1200, type: 'Alkalinity' },
{ depth: 1800, type: 'pH' },
{ depth: 2200, type: 'DIC' },
{ depth: 2800, type: 'Oxygen' },
{ depth: 3200, type: 'pCO2' },
{ depth: 3600, type: 'Temperature' },
{ depth: 3900, type: 'pH' }
];
function createSensorMesh(type, depth) {
const group = new THREE.Group();
const config = sensorTypes[type];
// Main sensor body
const bodyGeometry = new THREE.CylinderGeometry(0.8, 0.8, 2.5, 12);
const bodyMaterial = new THREE.MeshPhongMaterial({
color: 0x223344,
emissive: 0x001122,
shininess: 80
});
const body = new THREE.Mesh(bodyGeometry, bodyMaterial);
group.add(body);
// Sensor dome
const domeGeometry = new THREE.SphereGeometry(0.6, 16, 16, 0, Math.PI * 2, 0, Math.PI / 2);
const domeMaterial = new THREE.MeshPhongMaterial({
color: config.color,
emissive: new THREE.Color(config.color).multiplyScalar(0.3),
transparent: true,
opacity: 0.8,
shininess: 100
});
const dome = new THREE.Mesh(domeGeometry, domeMaterial);
dome.position.y = 1.25;
group.add(dome);
// Status light
const lightGeometry = new THREE.SphereGeometry(0.3, 12, 12);
const lightMaterial = new THREE.MeshBasicMaterial({
color: 0x00ff88
});
const statusLight = new THREE.Mesh(lightGeometry, lightMaterial);
statusLight.position.set(0.6, 0, 0);
group.add(statusLight);
// Point light for glow effect
const pointLight = new THREE.PointLight(config.color, 0.5, 8);
pointLight.position.y = 1.5;
group.add(pointLight);
// Clamping arms
const armGeometry = new THREE.BoxGeometry(0.2, 0.2, 1.5);
const armMaterial = new THREE.MeshPhongMaterial({ color: 0x445566 });
const arm1 = new THREE.Mesh(armGeometry, armMaterial);
arm1.position.set(0, 0, 0.9);
group.add(arm1);
const arm2 = new THREE.Mesh(armGeometry, armMaterial);
arm2.position.set(0, 0, -0.9);
group.add(arm2);
// Position based on depth
const yPos = 40 - (depth / 4000) * 80;
group.position.y = yPos;
return {
group,
dome,
statusLight,
pointLight,
body,
type,
depth
};
}
// Initialize sensors
sensorPositions.forEach((pos, index) => {
const mesh = createSensorMesh(pos.type, pos.depth);
scene.add(mesh.group);
sensorMeshes.push(mesh);
sensors.push({
id: index,
name: `${pos.type}-${pos.depth}m`,
type: pos.type,
depth: pos.depth,
drift: 0,
maxValue: 100,
currentValue: sensorTypes[pos.type].baseValue,
lastCalibration: 0,
status: 'ok',
mesh: mesh
});
});
// Update sensor list UI
function updateSensorList() {
const list = document.getElementById('sensor-list');
list.innerHTML = '';
sensors.forEach(sensor => {
const item = document.createElement('div');
item.className = `sensor-item ${sensor.id === selectedSensor ? 'selected' : ''}`;
item.innerHTML = `
<span>${sensor.name}</span>
<span class="status-${sensor.status}">${sensor.status.toUpperCase()}</span>
`;
item.onclick = () => selectSensor(sensor.id);
list.appendChild(item);
});
}
// Select sensor
function selectSensor(id) {
selectedSensor = id;
updateSensorList();
updateDetailPanel();
// Highlight selected sensor
sensorMeshes.forEach((mesh, idx) => {
if (idx === id) {
mesh.pointLight.intensity = 2;
} else {
mesh.pointLight.intensity = 0.5;
}
});
}
// Update detail panel
function updateDetailPanel() {
if (selectedSensor === null) return;
const sensor = sensors[selectedSensor];
const config = sensorTypes[sensor.type];
document.getElementById('sensor-name').textContent = sensor.name;
document.getElementById('detail-depth').textContent = `${sensor.depth}m`;
document.getElementById('detail-type').textContent = sensor.type;
document.getElementById('detail-reading').textContent =
`${sensor.currentValue.toFixed(2)} ${config.unit}`;
document.getElementById('detail-drift').textContent =
`${sensor.drift.toFixed(1)}%`;
const driftFill = document.getElementById('drift-fill');
driftFill.style.width = `${sensor.drift}%`;
driftFill.style.background = sensor.drift < 30 ? '#0fa' :
sensor.drift < 60 ? '#fa0' : '#f55';
document.getElementById('detail-lastcal').textContent =
`${Math.floor(sensor.lastCalibration / 60)} min ago`;
const statusEl = document.getElementById('detail-status');
statusEl.textContent = sensor.status.toUpperCase();
statusEl.className = `data-value status-${sensor.status}`;
}
// Calibrate sensor
function calibrateSensor(id) {
const sensor = sensors[id];
if (sensor.status === 'calibrating') return;
sensor.status = 'calibrating';
showNotification(`Calibrating ${sensor.name}...`);
// Visual feedback
const mesh = sensorMeshes[id];
const originalColor = sensorTypes[sensor.type].color;
let progress = 0;
const calInterval = setInterval(() => {
progress += 5;
mesh.dome.material.emissive.setHex(
progress % 20 < 10 ? 0x00ffff : originalColor
);
if (progress >= 100) {
clearInterval(calInterval);
sensor.drift = Math.random() * 10; // Reset drift
sensor.status = 'ok';
sensor.lastCalibration = 0;
calibrationCount++;
mesh.dome.material.emissive.setHex(originalColor);
mesh.dome.material.emissive.multiplyScalar(0.3);
hideNotification();
updateSensorList();
updateDetailPanel();
}
}, 100);
}
// Notification
function showNotification(text) {
const notif = document.getElementById('notification');
notif.textContent = text;
notif.classList.add('show');
}
function hideNotification() {
document.getElementById('notification').classList.remove('show');
}
document.getElementById('calibration-btn').onclick = () => {
if (selectedSensor !== null) {
calibrateSensor(selectedSensor);
}
};
// Ocean particles
const particleCount = 3000;
const particlesGeometry = new THREE.BufferGeometry();
const particlePositions = new Float32Array(particleCount * 3);
const particleSizes = new Float32Array(particleCount);
const particleVelocities = [];
for (let i = 0; i < particleCount; i++) {
particlePositions[i * 3] = (Math.random() - 0.5) * 100;
particlePositions[i * 3 + 1] = (Math.random() - 0.5) * 100;
particlePositions[i * 3 + 2] = (Math.random() - 0.5) * 100;
particleSizes[i] = Math.random() * 2 + 0.5;
particleVelocities.push({
x: (Math.random() - 0.5) * 0.02,
y: (Math.random() - 0.5) * 0.01 - 0.005,
z: (Math.random() - 0.5) * 0.02
});
}
particlesGeometry.setAttribute('position', new THREE.BufferAttribute(particlePositions, 3));
particlesGeometry.setAttribute('size', new THREE.BufferAttribute(particleSizes, 1));
const particleMaterial = new THREE.ShaderMaterial({
uniforms: {
uTime: { value: 0 },
uColor: { value: new THREE.Color(0x4488aa) }
},
vertexShader: `
attribute float size;
varying float vAlpha;
uniform float uTime;
void main() {
vec4 mvPosition = modelViewMatrix * vec4(position, 1.0);
gl_PointSize = size * (150.0 / -mvPosition.z);
gl_Position = projectionMatrix * mvPosition;
vAlpha = 0.3 + 0.3 * sin(uTime + position.y * 0.1);
}
`,
fragmentShader: `
uniform vec3 uColor;
varying float vAlpha;
void main() {
float dist = length(gl_PointCoord - vec2(0.5));
if (dist > 0.5) discard;
float alpha = vAlpha * (1.0 - dist * 2.0);
gl_FragColor = vec4(uColor, alpha);
}
`,
transparent: true,
blending: THREE.AdditiveBlending,
depthWrite: false
});
const particles = new THREE.Points(particlesGeometry, particleMaterial);
scene.add(particles);
// Caustic light patterns on seafloor
const floorGeometry = new THREE.PlaneGeometry(150, 150, 50, 50);
const floorMaterial = new THREE.ShaderMaterial({
uniforms: {
uTime: { value: 0 }
},
vertexShader: `
varying vec2 vUv;
varying vec3 vPosition;
void main() {
vUv = uv;
vPosition = position;
gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0);
}
`,
fragmentShader: `
uniform float uTime;
varying vec2 vUv;
varying vec3 vPosition;
float caustic(vec2 uv, float time) {
vec2 p = uv * 8.0;
float a = 0.0;
for(int i = 0; i < 3; i++) {
a += sin(p.x * sin(time * 0.3 + float(i)) + p.y * cos(time * 0.2 + float(i)));
p = p.yx + vec2(1.0, 1.0);
}
return a * 0.2 + 0.5;
}
void main() {
float c = caustic(vUv, uTime);
vec3 color = mix(vec3(0.0, 0.05, 0.1), vec3(0.0, 0.15, 0.2), c);
float dist = length(vUv - 0.5);
float vignette = 1.0 - dist * 0.8;
gl_FragColor = vec4(color * vignette, 1.0);
}
`
});
const floor = new THREE.Mesh(floorGeometry, floorMaterial);
floor.rotation.x = -Math.PI / 2;
floor.position.y = -45;
scene.add(floor);
// Lighting
const ambientLight = new THREE.AmbientLight(0x0a1520, 0.5);
scene.add(ambientLight);
const directionalLight = new THREE.DirectionalLight(0x0a3050, 0.3);
directionalLight.position.set(0, 50, 0);
scene.add(directionalLight);
// Add some volumetric light beams
for (let i = 0; i < 3; i++) {
const beamGeometry = new THREE.ConeGeometry(8, 60, 16, 1, true);
const beamMaterial = new THREE.ShaderMaterial({
uniforms: {
uTime: { value: 0 },
uOffset: { value: i * 2.1 }
},
vertexShader: `
varying vec2 vUv;
varying float vY;
void main() {
vUv = uv;
vY = position.y;
gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0);
}
`,
fragmentShader: `
uniform float uTime;
uniform float uOffset;
varying vec2 vUv;
varying float vY;
void main() {
float beam = sin(vUv.x * 3.14159) * (1.0 - (vY + 30.0) / 60.0);
float flicker = 0.8 + 0.2 * sin(uTime * 2.0 + uOffset);
float alpha = beam * 0.08 * flicker;
gl_FragColor = vec4(0.2, 0.5, 0.8, alpha);
}
`,
transparent: true,
side: THREE.DoubleSide,
blending: THREE.AdditiveBlending,
depthWrite: false
});
const beam = new THREE.Mesh(beamGeometry, beamMaterial);
beam.position.set((i - 1) * 20, 10, -10);
beam.rotation.x = Math.PI;
scene.add(beam);
}
// Animation loop
let lastTime = 0;
function animate(time) {
requestAnimationFrame(animate);
const delta = (time - lastTime) / 1000;
lastTime = time;
deploymentTime += delta;
totalDataPoints += sensors.length;
// Update particle positions
const positions = particles.geometry.attributes.position.array;
for (let i = 0; i < particleCount; i++) {
positions[i * 3] += particleVelocities[i].x;
positions[i * 3 + 1] += particleVelocities[i].y;
positions[i * 3 + 2] += particleVelocities[i].z;
// Wrap around
if (positions[i * 3 + 1] < -50) positions[i * 3 + 1] = 50;
if (Math.abs(positions[i * 3]) > 50) positions[i * 3] *= -0.9;
if (Math.abs(positions[i * 3 + 2]) > 50) positions[i * 3 + 2] *= -0.9;
}
particles.geometry.attributes.position.needsUpdate = true;
particleMaterial.uniforms.uTime.value = time * 0.001;
// Update floor caustics
floorMaterial.uniforms.uTime.value = time * 0.001;
// Update sensor readings and drift
sensors.forEach((sensor, idx) => {
if (sensor.status !== 'calibrating') {
// Accumulate drift
sensor.drift += delta * 0.05 * (1 + Math.random() * 0.5);
sensor.lastCalibration += delta;
// Update status based on drift
if (sensor.drift > 70) {
sensor.status = 'critical';
} else if (sensor.drift > 40) {
sensor.status = 'warning';
} else {
sensor.status = 'ok';
}
// Simulate reading with drift and noise
const config = sensorTypes[sensor.type];
const driftError = (sensor.drift / 100) * config.variance;
const noise = (Math.random() - 0.5) * config.variance * 0.2;
const depthEffect = Math.sin(time * 0.001 + sensor.depth * 0.01) * config.variance * 0.1;
sensor.currentValue = config.baseValue + driftError + noise + depthEffect;
// Update mesh visuals
const mesh = sensorMeshes[idx];
// Status light color
const statusColor = sensor.status === 'ok' ? 0x00ff88 :
sensor.status === 'warning' ? 0xffaa00 : 0xff5544;
mesh.statusLight.material.color.setHex(statusColor);
// Gentle floating motion
mesh.group.position.y += Math.sin(time * 0.002 + idx) * 0.002;
mesh.group.rotation.y = Math.sin(time * 0.001 + idx * 0.5) * 0.05;
}
});
// Update UI
document.getElementById('deploy-days').textContent =
(deploymentTime / 86400).toFixed(1);
document.getElementById('cal-count').textContent = calibrationCount;
document.getElementById('data-points').textContent =
Math.floor(totalDataPoints / 100);
// Update info bar with averages
const phSensors = sensors.filter(s => s.type === 'pH');
const pco2Sensors = sensors.filter(s => s.type === 'pCO2');
if (phSensors.length > 0) {
const avgPh = phSensors.reduce((a, s) => a + s.currentValue, 0) / phSensors.length;
document.getElementById('ph-avg').textContent = avgPh.toFixed(2);
}
if (pco2Sensors.length > 0) {
const avgPco2 = pco2Sensors.reduce((a, s) => a + s.currentValue, 0) / pco2Sensors.length;
document.getElementById('pco2-avg').textContent = `${Math.round(avgPco2)} uatm`;
}
// Water temp and pressure variations
document.getElementById('water-temp').textContent =
`${(2.3 + Math.sin(time * 0.0005) * 0.3).toFixed(1)}C`;
document.getElementById('pressure').textContent =
`${(401.2 + Math.sin(time * 0.0003) * 0.5).toFixed(1)} atm`;
if (selectedSensor !== null) {
updateDetailPanel();
}
updateSensorList();
// Buoyancy motion for buoy
buoy.position.y = 42 + Math.sin(time * 0.001) * 0.5;
buoy.rotation.z = Math.sin(time * 0.0008) * 0.1;
controls.update();
renderer.render(scene, camera);
}
// Handle resize
window.addEventListener('resize', () => {
camera.aspect = window.innerWidth / window.innerHeight;
camera.updateProjectionMatrix();
renderer.setSize(window.innerWidth, window.innerHeight);
});
// Initialize
updateSensorList();
selectSensor(0);
animate(0);
// Auto-calibration event simulation
setInterval(() => {
const criticalSensors = sensors.filter(s => s.status === 'critical');
if (criticalSensors.length > 0 && Math.random() < 0.3) {
const sensor = criticalSensors[Math.floor(Math.random() * criticalSensors.length)];
showNotification(`WARNING: ${sensor.name} requires calibration!`);
setTimeout(hideNotification, 3000);
}
}, 10000);
</script>
</body>
</html>