Class GeoMagneticField


  • public class GeoMagneticField
    extends Object
    Used to calculate the geomagnetic field at a given geodetic point on earth. The calculation is estimated using spherical harmonic expansion of the geomagnetic potential with coefficients provided by an actual geomagnetic field model (e.g. IGRF, WMM).

    Based on original software written by Manoj Nair from the National Geophysical Data Center, NOAA, as part of the WMM 2010 software release (WMM_SubLibrary.c)

    Author:
    Thomas Neidhart
    See Also:
    World Magnetic Model Overview, WMM Software Downloads
    • Constructor Detail

      • GeoMagneticField

        protected GeoMagneticField​(String modelName,
                                   double epoch,
                                   int maxN,
                                   int maxNSec,
                                   double validityStart,
                                   double validityEnd)
        Create a new geomagnetic field model with the given parameters. Internal structures are initialized according to the specified degrees of the main and secular variations.
        Parameters:
        modelName - the model name
        epoch - the epoch of the model
        maxN - the maximum degree of the main model
        maxNSec - the maximum degree of the secular variations
        validityStart - validity start of this model
        validityEnd - validity end of this model
    • Method Detail

      • getEpoch

        public double getEpoch()
        Returns the epoch for this magnetic field model.
        Returns:
        the epoch
      • getModelName

        public String getModelName()
        Returns the model name.
        Returns:
        the model name
      • validFrom

        public double validFrom()
        Returns the start of the validity period for this model.
        Returns:
        the validity start as decimal year
      • validTo

        public double validTo()
        Returns the end of the validity period for this model.
        Returns:
        the validity end as decimal year
      • supportsTimeTransform

        public boolean supportsTimeTransform()
        Indicates whether this model supports time transformation or not.
        Returns:
        true if this model can be transformed within its validity period, false otherwise
      • setMainFieldCoefficients

        protected void setMainFieldCoefficients​(int n,
                                                int m,
                                                double gnm,
                                                double hnm)
        Set the given main field coefficients.
        Parameters:
        n - the n index
        m - the m index
        gnm - the g coefficient at position n,m
        hnm - the h coefficient at position n,m
      • setSecularVariationCoefficients

        protected void setSecularVariationCoefficients​(int n,
                                                       int m,
                                                       double dgnm,
                                                       double dhnm)
        Set the given secular variation coefficients.
        Parameters:
        n - the n index
        m - the m index
        dgnm - the dg coefficient at position n,m
        dhnm - the dh coefficient at position n,m
      • calculateField

        public GeoMagneticElements calculateField​(double latitude,
                                                  double longitude,
                                                  double height)
        Calculate the magnetic field at the specified geodetic point identified by latitude, longitude and altitude.
        Parameters:
        latitude - the WGS84 latitude in radians
        longitude - the WGS84 longitude in radians
        height - the height above the WGS84 ellipsoid in meters
        Returns:
        the GeoMagneticElements at the given geodetic point
      • transformModel

        public GeoMagneticField transformModel​(double year)
        Time transform the model coefficients from the base year of the model using secular variation coefficients.
        Parameters:
        year - the year to which the model shall be transformed
        Returns:
        a time-transformed magnetic field model
      • transformModel

        public GeoMagneticField transformModel​(GeoMagneticField otherModel,
                                               double year)
        Time transform the model coefficients from the base year of the model using a linear interpolation with a second model. The second model is required to have an adjacent validity period.
        Parameters:
        otherModel - the other magnetic field model
        year - the year to which the model shall be transformed
        Returns:
        a time-transformed magnetic field model
      • getDecimalYear

        public static double getDecimalYear​(int day,
                                            int month,
                                            int year)
        Utility function to get a decimal year for a given day.
        Parameters:
        day - the day (1-31)
        month - the month (1-12)
        year - the year
        Returns:
        the decimal year represented by the given day