Add temperatureToSoundSpeed function.

This commit is contained in:
sunwen
2023-05-19 14:02:00 +08:00
parent 3dba797a0e
commit 6f50858129
2 changed files with 40 additions and 23 deletions

View File

@@ -125,6 +125,29 @@ TransFormInfo Recon::getTransformationMatrix(Parser* aParser, const Matrix& aMot
return result;
}
Matrix Recon::temperatureToSoundSpeed(const Matrix& aTemperature, const std::string& aMethod)
{
Matrix result;
if (aMethod == "marczak")
{
double* kData = new double[6] {2.78786e-9, -1.398845e-6, 3.287156e-4, -5.799136e-2, 5.038813, 1.402385e3};
Matrix k = Matrix::fromRawData(kData, 6);
result = polyval(k, aTemperature);
}
else if(aMethod == "mader")
{
double* kData = new double[6] {3.14643e-9, -1.478e-6, 0.000334199, -0.0580852, 5.03711, 1402.39};
Matrix k = Matrix::fromRawData(kData, 6);
result = polyval(k, aTemperature);
}
else if(aMethod == "jan")
{
double speedData = 1557 - 0.0245 * pow((74 - aTemperature.getData()[0]), 2);
result = Matrix::fromRawData(new double[1] {speedData}, 1);
}
return result;
}
//已验证,完全正确
TempInfo Recon::getTemperatureInfo(Parser* aParser, double aNumTas)
{
@@ -200,13 +223,13 @@ TempInfo Recon::getTemperatureInfo(Parser* aParser, double aNumTas)
// temp.TASTemperature(1, :, :) = correctTASTemperatures(temp2, temp.jumoTemp);
// catch ME
// % if tas temperatures not there
// % take temperatures from calibrated sensors
// % and use them for all TAS the same
// writeReconstructionLog(sprintf('%s: %s TAS temperatures approximated from calibrated reference sensors.', ME.identifier, ME.message), 3)
// if(~jumoAllNaN)
// temp.TASTemperature = zeros(2, numTAS, size(temp.jumoTemp, 2));
// temp.TASTemperature(1, :, :) = repmat(mean(temp.jumoTemp), size(temp.TASTemperature, 2), 1);
@@ -214,7 +237,7 @@ TempInfo Recon::getTemperatureInfo(Parser* aParser, double aNumTas)
// else % worst case: no temperature data at all! cannot continue!
// error([mfilename ':noTemperatureAvailable'],'No TAS and no Jumo temperature available! Cannot reconstruct!');
// end
// end
}
}
@@ -228,25 +251,7 @@ TempInfo Recon::getTemperatureInfo(Parser* aParser, double aNumTas)
{
result.expectedTemp = mean(result.jumoTemp,FunctionDirection::All,false);
}
std::string speedMethod = "marczak";
if (speedMethod == "marczak")
{
double* kData = new double[6] {2.78786e-9, -1.398845e-6, 3.287156e-4, -5.799136e-2, 5.038813, 1.402385e3};
Matrix k = Matrix::fromRawData(kData, 6);
result.expectedSOSWater = polyval(k, result.expectedTemp);
}
else if(speedMethod == "mader")
{
double* kData = new double[6] {3.14643e-9, -1.478e-6, 0.000334199, -0.0580852, 5.03711, 1402.39};
Matrix k = Matrix::fromRawData(kData, 6);
result.expectedSOSWater = polyval(k, result.expectedTemp);
}
else if(speedMethod == "jan")
{
double speedData = 1557 - 0.0245 * pow((74 - result.expectedTemp.getData()[0]), 2);
result.expectedSOSWater = Matrix::fromRawData(new double[1] {speedData}, 1);
}
result.expectedSOSWater = temperatureToSoundSpeed(result.expectedTemp , "marczak");
return result;
}