Class: QgsMagneticModel¶
Represents a model of the Earth’s magnetic field.
Warning
This class is only usable if QGIS was built with GeographicLib support. If not,
then QgsNotSupportedException exceptions will be raised when calling the
methods for this class.
The Qgis.hasGeographicLib() method can be used to determine
if QGIS was built with GeographicLib support.
Added in version 4.0.
List of all members, including inherited members
Methods
Returns the date of the magnetic model, if available. |
|
Calculates the declination of the field at a point. |
|
Returns the default path used by GeographicLib to search for magnetic models. |
|
Returns the name of the default magnetic model used by GeographicLib. |
|
Returns the maximum degree of the components of the model. |
|
Returns the description of the magnetic model, if available. |
|
Returns the full directory name containing the magnetic model file. |
|
Returns a string for the last error encountered by the model. |
|
Returns the full file name for the magnetic model. |
|
Evaluates the components of the geomagnetic field at a point. |
|
Evaluates the components of the geomagnetic field at a point, and their time derivatives. |
|
Calculates the inclination of the field at a point. |
|
Returns |
|
Returns the maximum height above the ellipsoid (in meters) for which the model should be used. |
|
Returns the maximum time (in decimal years) for which the model should be used. |
|
Returns the minimum height above the ellipsoid (in meters) for which the model should be used. |
|
Returns the minimum time (in decimal years) for which the model should be used. |
|
Returns the name of the magnetic model. |
|
Returns the maximum order of the components of the model. |
Static Methods
Compute various quantities dependent on a magnetic field. |
|
Compute various quantities dependent on a magnetic field and their rates of change. |
- class qgis.core.QgsMagneticModel[source]¶
Bases:
object- __init__(name: str | None, path: str | None = '', maxDegree: int = -1, maxOrder: int = -1)
Constructor for QgsMagneticModel.
A filename is formed by appending “.wmm” (World Magnetic Model) to the
nameargument.If
pathis specified (and is non-empty), then the associated file is loaded from this path. Otherwise the file path is given by thedefaultFilePath().The associated file must exist and point to a valid magnetic model file. If not, then
isValid()will returnFalseand a descriptive error can be retrieved byerror().If
maxDegree≥ 0 andmaxOrder< 0, thenmaxOrderis set tomaxDegree. After the model is loaded, the maximum degree and order of the model can be found by thedegree()andorder()methods.- Parameters:
name (Optional[str]) – the name of the model.
path (Optional[str] = '') – optional directory for data file. If not specified then
defaultFilePath()is used.maxDegree (int = -1) – if nonnegative, truncate the degree of the model to this value
maxOrder (int = -1) – if nonnegative, truncate the order of the model to this value
- dateTime(self) QDateTime[source]¶
Returns the date of the magnetic model, if available.
- Raises:
QgsNotSupportedException – if GeographicLib is not available
- Return type:
QDateTime
- declination(self, years: float, latitude: float, longitude: float, height: float)[source]¶
Calculates the declination of the field at a point.
Note
The latitude and longitude should be specified as a WGS84 coordinate
Note
If calculating both the inclination and declination at the same point it is more efficient to use
getComponents()andfieldComponents()- Parameters:
years (float) – the time (in fractional years)
latitude (float) – latitude of the point (in decimal degrees)
longitude (float) – longitude of the point (in decimal degrees)
height (float) – height of the point above the ellipsoid (in meters)
- Return type:
(bool, float)
- Returns:
Trueif declination was successfully calculateddeclination: magnetic field declination, in degrees east of north
- Raises:
QgsNotSupportedException – if GeographicLib is not available
See also
- defaultFilePath() str[source]¶
Returns the default path used by GeographicLib to search for magnetic models.
See also
- Return type:
str
- defaultModelName() str[source]¶
Returns the name of the default magnetic model used by GeographicLib.
See also
- Return type:
str
- degree(self) int[source]¶
Returns the maximum degree of the components of the model.
- Raises:
QgsNotSupportedException – if GeographicLib is not available
See also
- Return type:
int
- description(self) str[source]¶
Returns the description of the magnetic model, if available.
- Raises:
QgsNotSupportedException – if GeographicLib is not available
- Return type:
str
- directory(self) str[source]¶
Returns the full directory name containing the magnetic model file.
- Raises:
QgsNotSupportedException – if GeographicLib is not available
- Return type:
str
- error(self) str[source]¶
Returns a string for the last error encountered by the model.
- Return type:
str
- static fieldComponents(Bx: float, By: float, Bz: float)[source]¶
Compute various quantities dependent on a magnetic field.
- Parameters:
Bx (float) – the easterly component of the magnetic field (in nanotesla)
By (float) – the northerly component of the magnetic field (in nanotesla)
Bz (float) – the vertical (up) component of the magnetic field (in nanotesla)
- Return type:
(bool, float, float, float, float)
- Returns:
Trueif the components were successfully calculatedH: the horizontal magnetic field (in nanotesla)
F: the total magnetic field (in nanotesla)
D: the declination of the field (degrees east of north)
I: the inclination of the field (degrees down from horizontal)
- Raises:
QgsNotSupportedException – if GeographicLib is not available
See also
- static fieldComponentsWithTimeDerivatives(Bx: float, By: float, Bz: float, Bxt: float, Byt: float, Bzt: float)[source]¶
Compute various quantities dependent on a magnetic field and their rates of change.
- Parameters:
Bx (float) – the easterly component of the magnetic field (in nanotesla)
By (float) – the northerly component of the magnetic field (in nanotesla)
Bz (float) – the vertical (up) component of the magnetic field (in nanotesla)
Bxt (float) – the rate of change of Bx (nT/yr)
Byt (float) – the rate of change of By (nT/yr)
Bzt (float) – the rate of change of Bz (nT/yr)
- Return type:
(bool, float, float, float, float, float, float, float, float)
- Returns:
Trueif the components were successfully calculatedH: the horizontal magnetic field (in nanotesla)
F: the total magnetic field (in nanotesla)
D: the declination of the field (degrees east of north)
I: the inclination of the field (degrees down from horizontal)
Ht: the rate of change of H (nT/yr)
Ft: the rate of change of F (nT/yr)
Dt: the rate of change of D (degrees/yr)
It: the rate of change of I (degrees/yr)
- Raises:
QgsNotSupportedException – if GeographicLib is not available
See also
- file(self) str[source]¶
Returns the full file name for the magnetic model.
- Raises:
QgsNotSupportedException – if GeographicLib is not available
- Return type:
str
- getComponents(self, years: float, latitude: float, longitude: float, height: float)[source]¶
Evaluates the components of the geomagnetic field at a point.
Note
The latitude and longitude should be specified as a WGS84 coordinate
- Parameters:
years (float) – the time (in fractional years)
latitude (float) – latitude of the point (in decimal degrees)
longitude (float) – longitude of the point (in decimal degrees)
height (float) – height of the point above the ellipsoid (in meters)
- Return type:
(bool, float, float, float)
- Returns:
Trueif the components were successfully calculatedBx: the easterly component of the magnetic field (in nanotesla).
By: the northerly component of the magnetic field (in nanotesla)
Bz: the vertical (up) component of the magnetic field (in nanotesla)
- Raises:
QgsNotSupportedException – if GeographicLib is not available
See also
- getComponentsWithTimeDerivatives(self, years: float, latitude: float, longitude: float, height: float)[source]¶
Evaluates the components of the geomagnetic field at a point, and their time derivatives.
Note
The latitude and longitude should be specified as a WGS84 coordinate
- Parameters:
years (float) – the time (in fractional years)
latitude (float) – latitude of the point (in decimal degrees)
longitude (float) – longitude of the point (in decimal degrees)
height (float) – height of the point above the ellipsoid (in meters)
- Return type:
(bool, float, float, float, float, float, float)
- Returns:
Trueif the components were successfully calculatedBx: the easterly component of the magnetic field (in nanotesla).
By: the northerly component of the magnetic field (in nanotesla)
Bz: the vertical (up) component of the magnetic field (in nanotesla)
Bxt: the rate of change of Bx (nT/yr)
Byt: the rate of change of By (nT/yr)
Bzt: the rate of change of Bz (nT/yr)
- Raises:
QgsNotSupportedException – if GeographicLib is not available
See also
- inclination(self, years: float, latitude: float, longitude: float, height: float)[source]¶
Calculates the inclination of the field at a point.
Note
The latitude and longitude should be specified as a WGS84 coordinate
Note
If calculating both the inclination and declination at the same point it is more efficient to use
getComponents()andfieldComponents()- Parameters:
years (float) – the time (in fractional years)
latitude (float) – latitude of the point (in decimal degrees)
longitude (float) – longitude of the point (in decimal degrees)
height (float) – height of the point above the ellipsoid (in meters)
- Return type:
(bool, float)
- Returns:
Trueif inclination was successfully calculatedinclination: magnetic field inclination, in degrees down from horizontal
- Raises:
QgsNotSupportedException – if GeographicLib is not available
See also
- isValid(self) bool[source]¶
Returns
Trueif the model is valid and can be used.- Raises:
QgsNotSupportedException – if GeographicLib is not available
See also
- Return type:
bool
- maximumHeight(self) float[source]¶
Returns the maximum height above the ellipsoid (in meters) for which the model should be used.
- Raises:
QgsNotSupportedException – if GeographicLib is not available
See also
- Return type:
float
- maximumYear(self) float[source]¶
Returns the maximum time (in decimal years) for which the model should be used.
- Raises:
QgsNotSupportedException – if GeographicLib is not available
See also
- Return type:
float
- minimumHeight(self) float[source]¶
Returns the minimum height above the ellipsoid (in meters) for which the model should be used.
- Raises:
QgsNotSupportedException – if GeographicLib is not available
See also
- Return type:
float
- minimumYear(self) float[source]¶
Returns the minimum time (in decimal years) for which the model should be used.
- Raises:
QgsNotSupportedException – if GeographicLib is not available
See also
- Return type:
float
- name(self) str[source]¶
Returns the name of the magnetic model.
- Raises:
QgsNotSupportedException – if GeographicLib is not available
- Return type:
str
- order(self) int[source]¶
Returns the maximum order of the components of the model.
- Raises:
QgsNotSupportedException – if GeographicLib is not available
See also
- Return type:
int