Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 14 additions & 10 deletions GeoMagSharp/Calculator.cs
Original file line number Diff line number Diff line change
@@ -1,20 +1,24 @@
/****************************************************************************
* File: GeoMagBGGM.cs
* Description: routines to handle bggm coefficients file and calculate
* field values
* Akowlegements: Ported from the C++ model code created by the British Geological Survey
* Website: http://www.geomag.bgs.ac.uk/data_service/directionaldrilling/bggm.html
* Warnings: This code can be used with the IGRF, WMM, or BGGM coeficent file. The BGGM
* coeficient file is Commerically avalable from the British Geological Survey
* and is not distributed with this project. Please contcact the BGS for more information.
*
* File: Calculator.cs
* Description: Routines to calculate magnetic field values from
* spherical harmonic coefficient files
* Reference: Based on the NOAA World Magnetic Model (WMM) algorithm
* https://www.ncei.noaa.gov/products/world-magnetic-model
* Compatibility: This code can be used with IGRF, WMM, or other standard
* coefficient files in COF or DAT format.
* Current version: 2.21
* ****************************************************************************/
* Author: Christopher Strecker
* Website: https://github.com/StreckerCM/GeoMagSharpGUI
****************************************************************************/

using System;

namespace GeoMagSharp
{
/// <summary>
/// Static calculator for magnetic field values using spherical harmonic coefficients.
/// Based on the NOAA World Magnetic Model (WMM) algorithm.
/// </summary>
public static class Calculator
{

Expand Down
2 changes: 1 addition & 1 deletion GeoMagSharp/Enums/GeoMagEnums.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public enum CoordinateSystem
public enum Algorithm
{
/// <summary>
/// British Geological Survey algorithm
/// Default spherical harmonic algorithm
/// </summary>
BGS = 1,

Expand Down
13 changes: 13 additions & 0 deletions GeoMagSharp/ExtensionMethods.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@

namespace GeoMagSharp
{
/// <summary>
/// Extension methods for date/time conversion, angle conversion, and model identification.
/// </summary>
public static class ExtensionMethods
{
/// <summary>
Expand Down Expand Up @@ -167,11 +170,21 @@ public static DateTime ToDateTime(this double decDate)
return new DateTime(yearInt, monthInt, dayInt);
}

/// <summary>
/// Determines whether the year of the specified date falls within the valid range (1900 to DateTime.MaxValue.Year).
/// </summary>
/// <param name="date">The date to validate.</param>
/// <returns><c>true</c> if the year is within the valid range; otherwise, <c>false</c>.</returns>
public static bool IsValidYear(this DateTime date)
{
return (1900 <= date.Year && date.Year <= DateTime.MaxValue.Year);
}

/// <summary>
/// Determines whether the specified decimal year falls within the valid range (1900 to max DateTime as decimal).
/// </summary>
/// <param name="decDate">The decimal year to validate.</param>
/// <returns><c>true</c> if the decimal year is within the valid range; otherwise, <c>false</c>.</returns>
public static bool IsValidYear(this double decDate)
{
return (1900D <= decDate && decDate <= DateTime.MaxValue.ToDecimal());
Expand Down
Loading