A C# WinForms application for calculating geomagnetic field values using spherical harmonic models. This is a port of the NOAA Geomag 7.0 software with a modern graphical interface.
GeoMagSharpGUI calculates Earth's magnetic field components (declination, inclination, intensity) at any location and date using coefficient files from models like:
- IGRF (International Geomagnetic Reference Field)
- WMM (World Magnetic Model)
- DGRF (Definitive Geomagnetic Reference Field)
- EMM (Enhanced Magnetic Model)
- Calculate magnetic declination, inclination, and field intensity
- Support for multiple coordinate input formats (Decimal Degrees, DMS)
- GPS location integration via Windows Location Services
- Historical calculations with date range support
- Multiple output units (nanoTesla, Gauss)
- Secular variation (change per year) calculations
- Save results to file
- User-configurable preferences
GeoMagGUI.sln
├── GeoMagGUI/ # WinForms Application (.NET Framework 4.0)
│ ├── coefficient/ # Magnetic model coefficient files
│ │ ├── IGRF12.COF
│ │ ├── WMM2015.COF
│ │ └── MagneticModels.json
│ ├── assets/ # Icons and images
│ ├── documentation/ # License and docs
│ ├── frmMain.cs # Main application window
│ ├── frmAddModel.cs # Add model dialog
│ ├── frmPreferences.cs # User preferences dialog
│ └── Program.cs # Application entry point
│
├── GeoMagSharp/ # Core Calculation Library (.NET Framework 4.0)
│ ├── GeoMag.cs # Main calculation orchestrator
│ ├── Calculator.cs # Spherical harmonic calculations
│ ├── DataModel.cs # Data structures and models
│ ├── ModelReader.cs # Coefficient file parser
│ ├── Units.cs # Unit conversion utilities
│ └── GeoMagException.cs # Custom exception types
│
├── GeoMagSharp-UnitTests/ # Unit Tests (MSTest, .NET Framework 4.5.2)
│ └── ExtensionMethodsUnitTest.cs
│
└── docs/ # Documentation
├── prompts/ # Claude personas and prompt templates
└── features/ # Feature specifications and plans
- Visual Studio 2019 or later
- .NET Framework 4.0 (GUI and Library)
- .NET Framework 4.5.2 (Unit Tests)
Use Developer Command Prompt for Visual Studio:
# Debug build (x86)
msbuild GeoMagGUI.sln /p:Configuration=Debug /p:Platform="x86"
# Release build (x86)
msbuild GeoMagGUI.sln /p:Configuration=Release /p:Platform="x86"
# Run unit tests
vstest.console.exe GeoMagSharp-UnitTests\bin\Debug\GeoMagSharp-UnitTests.dll- Select a Magnetic Model - Choose from available models (IGRF, WMM, etc.)
- Enter Location - Input coordinates as decimal degrees or DMS
- Set Elevation - Enter altitude above MSL or depth below MSL
- Choose Date(s) - Select single date or date range
- Calculate - View magnetic field results in the grid
- Save Results - Export to text file if needed
| Component | Description |
|---|---|
| Declination | Angle between true north and magnetic north |
| Inclination | Angle between horizontal and magnetic field vector |
| Horizontal Intensity | Horizontal component of magnetic field |
| North Component | Northward component of horizontal intensity |
| East Component | Eastward component of horizontal intensity |
| Vertical Component | Vertical component of magnetic field |
| Total Field | Total magnetic field intensity |
- Obtain coefficient file (.COF or .DAT format)
- Place in
GeoMagGUI/coefficient/directory - Use Tools > Add Model to register the model
- Model will be available in the dropdown
- Newtonsoft.Json v10.0.1 - JSON serialization
- System.Device - GPS location services (Windows)
┌─────────────────────────────────────┐
│ Presentation (WinForms) │
│ frmMain, dialogs, UI controls │
├─────────────────────────────────────┤
│ Business Logic (GeoMagSharp) │
│ GeoMag, Calculator, Models │
├─────────────────────────────────────┤
│ Data Access │
│ ModelReader, JSON serialization │
├─────────────────────────────────────┤
│ External Data │
│ COF/DAT coefficient files │
└─────────────────────────────────────┘
See AGENTS.md for coding standards and development guidelines.
For Claude Code assistance, see docs/prompts/ for personas and templates.
See GeoMagGUI/documentation/LICENSE
- Original NOAA Geomag 7.0 software
- British Geological Survey (BGS) calculation algorithms
- Port to C# with GUI by StreckerCM