// Copyright (C) Stichting Deltares 2017. All rights reserved.
//
// This file is part of Ringtoets.
//
// Ringtoets is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see .
//
// All names, logos, and references to "Deltares" are registered trademarks of
// Stichting Deltares and remain full property of Stichting Deltares at all times.
// All rights reserved.
using System;
using Ringtoets.Common.IO.Exceptions;
using Ringtoets.Common.IO.Properties;
namespace Ringtoets.Common.IO.SoilProfile
{
///
/// Class which provides helper methods for validating distributions of
/// .
///
public static class SoilLayerDistributionHelper
{
private const double tolerance = 1e-6;
///
/// Validates that the distribution is a non-shifted log normal distribution.
///
/// The distribution type.
/// The value of the shift.
/// The name of the parameter to be validated.
/// Thrown when
/// is null.
/// Thrown when the parameter is not a
/// log normal distribution with a zero shift.
public static void ValidateIsNonShiftedLogNormal(long? distributionType, double shift, string parameterName)
{
if (parameterName == null)
{
throw new ArgumentNullException(nameof(parameterName));
}
if (distributionType.HasValue && (distributionType.Value != SoilLayerConstants.LogNormalDistributionValue
|| Math.Abs(shift) > tolerance))
{
throw new ImportedDataTransformException(string.Format(
Resources.SoilLayer_Stochastic_parameter_0_has_no_lognormal_distribution,
parameterName));
}
}
///
/// Validates that the distribution is a log normal distribution.
///
/// The distribution type.
/// The name of the parameter to be validated.
/// Thrown when
/// is null.
/// Thrown when the parameter is not a
/// log-normal distribution.
public static void ValidateIsLogNormal(long? distributionType, string parameterName)
{
if (parameterName == null)
{
throw new ArgumentNullException(nameof(parameterName));
}
if (distributionType.HasValue && distributionType != SoilLayerConstants.LogNormalDistributionValue)
{
throw new ImportedDataTransformException(string.Format(
Resources.SoilLayer_Stochastic_parameter_0_has_no_shifted_lognormal_distribution,
parameterName));
}
}
}
}