Skip to content

Commit

Permalink
Merge pull request #118 from ImperialCollegeLondon/task/mtt
Browse files Browse the repository at this point in the history
task: Add calibration for MTT sensor
  • Loading branch information
mfacchinelli authored Feb 28, 2025
2 parents 77bb945 + b77c442 commit 018f927
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 58 deletions.
2 changes: 1 addition & 1 deletion .env
Original file line number Diff line number Diff line change
@@ -1 +1 @@
MAG_DATA_VISUALIZATION_VERSION=7.3.0
MAG_DATA_VISUALIZATION_VERSION=7.3.1
10 changes: 1 addition & 9 deletions resources/release-notes.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,6 @@
> Starting v7.2.0, [MATLAB SPICE (MICE)](https://naif.jpl.nasa.gov/naif/toolkit_MATLAB.html) is required.
> Starting v7.2.0, MATLAB R2023b is no longer supported.
## All

- Use "metadata" instead of "meta data"

## Software

- Improve logic for loading of metadata for IMAP
- Add support for IMAP sensor and instrument metadata defined in JSON file
- Add support for any sensor model name
- Add calibration for Solar Orbiter sensors
- Fix typo in `mag.meta.Instrument/Attemps` property (now spelled `Attempts`)
- Add calibration for MTT sensor
5 changes: 5 additions & 0 deletions src/analyze/calibration/mtt_tany.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
1,1,1
-1,0,0
0,-1,0
0,0,-1
0,0,0
59 changes: 11 additions & 48 deletions tests/unit/analyze/tCalibration.m
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
classdef tCalibration < MAGAnalysisTestCase
% TCALIBRATION Unit tests for "mag.process.Calibration" class.

properties (TestParameter)
SensorDetails = {struct(Name = "LM2", Expected = [3, -1, -2]), ...
struct(Name = "JM1", Expected = [-2, 1, 3]), ...
struct(Name = "SOLO-OBS-QM", Expected = [-2, 1, -3]), ...
struct(Name = "MTT", Expected = [-1, -2, -3])}
end

methods (Test)

% Load all calibration test files, and make sure none of the values
Expand Down Expand Up @@ -149,59 +156,15 @@ function calibration_all(testCase)
"Calibrated value should match expectation.");
end

% Verify that correct calibration is selected for lab models.
function calibration_labModel(testCase)

% Set up.
uncalibratedData = testCase.createTestData(Time = datetime("now"), XYZ = [1, 2, 3], Range = 0, Sequence = 1);
metadata = mag.meta.Science(Setup = mag.meta.Setup(Model = "LM2"));

expectedData = uncalibratedData;
expectedData{:, "x"} = 3;
expectedData{:, "y"} = -1;
expectedData{:, "z"} = -2;

% Exercise.
calibrationStep = mag.process.Calibration(RangeVariable = "range", Variables = ["x", "y", "z"], Temperature = "Cold");
calibratedData = calibrationStep.apply(uncalibratedData, metadata);

% Verify.
testCase.verifyThat(calibratedData, matlab.unittest.constraints.IsEqualTo(expectedData, Within = matlab.unittest.constraints.AbsoluteTolerance(1e-10)), ...
"Calibrated value should match expectation.");
end

% Verify that correct calibration is selected for JMAG.
function calibration_jmag(testCase)

% Set up.
uncalibratedData = testCase.createTestData(Time = datetime("now"), XYZ = [1, 2, 3], Range = 0, Sequence = 1);
metadata = mag.meta.Science(Setup = mag.meta.Setup(Model = "JM1"));

expectedData = uncalibratedData;
expectedData{:, "x"} = -2;
expectedData{:, "y"} = 1;
expectedData{:, "z"} = 3;

% Exercise.
calibrationStep = mag.process.Calibration(RangeVariable = "range", Variables = ["x", "y", "z"], Temperature = "Cold");
calibratedData = calibrationStep.apply(uncalibratedData, metadata);

% Verify.
testCase.verifyThat(calibratedData, matlab.unittest.constraints.IsEqualTo(expectedData, Within = matlab.unittest.constraints.AbsoluteTolerance(1e-10)), ...
"Calibrated value should match expectation.");
end

% Verify that correct calibration is selected for Solar Orbiter.
function calibration_solo(testCase)
% Verify that correct calibration is selected for specific models.
function calibration_specificSensor(testCase, SensorDetails)

% Set up.
uncalibratedData = testCase.createTestData(Time = datetime("now"), XYZ = [1, 2, 3], Range = 0, Sequence = 1);
metadata = mag.meta.Science(Setup = mag.meta.Setup(Model = "SOLO-OBS-QM"));
metadata = mag.meta.Science(Setup = mag.meta.Setup(Model = SensorDetails.Name));

expectedData = uncalibratedData;
expectedData{:, "x"} = -2;
expectedData{:, "y"} = 1;
expectedData{:, "z"} = -3;
expectedData{:, ["x", "y", "z"]} = SensorDetails.Expected;

% Exercise.
calibrationStep = mag.process.Calibration(RangeVariable = "range", Variables = ["x", "y", "z"], Temperature = "Cold");
Expand Down

0 comments on commit 018f927

Please sign in to comment.