Loading...
Searching...
No Matches
EarthField.h
Go to the documentation of this file.
//# EarthField.h: EarthField class model claculations
//# Copyright (C) 1998
//# Associated Universities, Inc. Washington DC, USA.
//#
//# This library is free software; you can redistribute it and/or modify it
//# under the terms of the GNU Library General Public License as published by
//# the Free Software Foundation; either version 2 of the License, or (at your
//# option) any later version.
//#
//# This library 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 Library General Public
//# License for more details.
//#
//# You should have received a copy of the GNU Library General Public License
//# along with this library; if not, write to the Free Software Foundation,
//# Inc., 675 Massachusetts Ave, Cambridge, MA 02139, USA.
//#
//# Correspondence concerning AIPS++ should be addressed as follows:
//# Internet email: casa-feedback@nrao.edu.
//# Postal address: AIPS++ Project Office
//# National Radio Astronomy Observatory
//# 520 Edgemont Road
//# Charlottesville, VA 22903-2475 USA
#ifndef MEASURES_EARTHFIELD_H
#define MEASURES_EARTHFIELD_H
//# Includes
#include <mutex>
#include <casacore/casa/aips.h>
#include <casacore/casa/Arrays/Vector.h>
#include <casacore/casa/Quanta/MVPosition.h>
namespace casacore { //# NAMESPACE CASACORE - BEGIN
//# Forward Declarations
//# Constants
// Length of P and Q arrays, half length of CL/SL arrays in IGRF model
const Int PQ_LEN = 104;
// Interval (m) for derivatives in IGRF model
const Double DER_INTV = 10000;
// <summary> EarthField class model calculations </summary>
// <use visibility=local>
// <reviewed reviewer="UNKNOWN" date="before2004/08/25" tests="tEarthField" demos="">
// </reviewed>
// <prerequisite>
// <li> <linkto class=Measure>Measure</linkto> class for use
// <li> <linkto class=MeasTable>MeasTable</linkto> class for data
// </prerequisite>
//
// <etymology>
// Earth magnetic Field model
// </etymology>
//
// <synopsis>
// EarthField forms the class for Earth magnetic field calculations. It is a
// simple container with the selected model, and the mean epoch.<br>
// The method is selected from one of the following:
// <ul>
// <li> EarthField::STANDARD (at 1998/05/18 the IGRF definition)
// <li> EarthField::IGRF (IGRF reference field model)
// </ul>
// Epochs can be specified as the MJD (with defined constants
// MeasData::MJD2000 and MeasData::MJD1950 or the actual MJD),
// leading to the following constructors:
// <ul>
// <li> EarthField() default; assuming IGRF and MJD2000
// <li> EarthField(method); assuming J2000 as epoch
// <li> EarthField(method, epoch) with epoch Double(MJD)
// </ul>
// Actual EarthField for a certain position on Earth is calculated by the ()
// operator. Arguments can be:
// <ul>
// <li> MVPosition: a position on Earth (in the ITRF frame)
// </ul>
// The returned value is a 3D vector of the field (in nT) in ITRF coordinates.
// The derivative (d<sup>-1</sup>) can be obtained as well by
// derivative(MVPosition). <br>
// An EarthField can be re-initialised with a different method and/or other
// epoch with the <src>init()</src> functions (same format as constructors).
//
// To bypass the full, lengthy calculation actual returned values are calculated
// using the derivative if within about 50 km (error less than about
// 10<sup>-2</sup> G). A call to refresh() will re-initiate calculations
// from scratch.<br>
// The following details can be set with the
// <linkto class=Aipsrc>Aipsrc</linkto> mechanism:
// <ul>
// <li> measures.earthfield.d_interval: approximation radius
// (km is default unit) over which a linear approximation
// is used
// </ul>
// The field model is assumed to be constant over the time-span the class
// is used.
//
// The calculations are based on a routine provided by the IGRF community. See
// ftp.ngdc.noaa.gov/Solid_Earth/Mainfld_Mag/Models/IAGA, routine IGRFLIB.FOR.
// The values are in nT (10uG).
// </synopsis>
//
// <example>
// <srcblock>
// EarthField mine(EarthField::STANDARD,
// 45837.0); // define EarthField type
// // for 84/05/17
// MPosition pos;
// MeasTable::Observatory(pos, "WSRT"); // Obervatory position
// // Make sure correct position frame used
// MVPosition x(MPosition::Convert(pos, MPosition::ITRF)().getValue());
// MVEarthMagnetic now = mine(x); // get EarthField
// </srcblock>
// </example>
//
// <motivation>
// To have a container (with history) for field calculations
// </motivation>
//
// <todo asof="1998/05/18">
// <li> nothing I know off
// </todo>
class EarthField {
public:
//# Constants
// Default interval to be used for linear approximation (in m)
static constexpr Double INTV = 50000;
//# Enumerations
// Known EarthField calculation models
enum EarthFieldTypes {
// Standard IGRF model
IGRF,
// Make the field equal to zero
NONE,
// Standard default model if none specified
STANDARD = IGRF
};
//# Constructors
// Default constructor, generates default J2000 EarthField identification
EarthField();
// Copy constructor
EarthField(const EarthField &other);
// Constructor with epoch in MJulian days (default is J2000)
explicit EarthField(EarthFieldTypes model, Double catepoch=51544.5);
// Copy assignment
EarthField &operator=(const EarthField &other);
//# Destructor
~EarthField();
//# Operators
// Return the EarthField components. Note that the value returned has only
// a lifetime as long as the EarthField container exists, and no new
// derivative is asked for.
const Vector<Double> &operator()(const MVPosition &pos);
//# General Member Functions
// Return derivatives of field (to X, Y, Z). Note that the value returned
// has only a lifetime as long as the EarthField container exists, and
// no new components or derivative is calculated. The returned value should
// not be deleted.
const Vector<Double> *derivative(const MVPosition &pos);
// Re-initialise EarthField object with specified model and epoch, or
// defaults STANDARD and J2000.
// <group>
void init();
void init(EarthFieldTypes model, Double catepoch=51544.5);
// </group>
// Refresh calculations
void refresh();
private:
//# Data members
// Method to be used
EarthFieldTypes method_p;
// Fixed epoch to be used (MJD)
Double fixedEpoch_p;
// List of spherical components
Vector<Double> agh_p;
// Work arrays for calculations
// <group>
Vector<Double> p_p;
Vector<Double> q_p;
Vector<Double> cl_p;
Vector<Double> sl_p;
// </group>
// Check position
MVPosition checkPos_p;
// Cached calculated field components
Double pval_p[3];
// Cached derivatives
Double dval_p[3][3];
// To reference results, and use a few in interim calculations, results are
// calculated in a circular buffer.
// Current result pointer
Int lres_p;
// Last calculation
Vector<Double> result_p[4];
// Interpolation interval
inline static uInt interval_reg_p = 0;
inline static std::once_flag initialization_once_flag;
//# Member functions
// Make a copy
void copy(const EarthField &other);
// Create correct default fixedEpoch and catalogue field data
void fillField();
static void initializeRcValue();
// Calculate EarthField for longitude and latitude and altitude (m)
void calcField(const MVPosition &pos);
};
} //# NAMESPACE CASACORE - END
#endif
casacore::EarthField::derivative
const Vector< Double > * derivative(const MVPosition &pos)
Return derivatives of field (to X, Y, Z).
casacore::EarthField::EarthField
EarthField()
Default constructor, generates default J2000 EarthField identification.
casacore::EarthField::EarthField
EarthField(const EarthField &other)
Copy constructor.
casacore::EarthField::INTV
static constexpr Double INTV
Default interval to be used for linear approximation (in m).
Definition EarthField.h:134
casacore::EarthField::initialization_once_flag
static std::once_flag initialization_once_flag
Definition EarthField.h:210
casacore::EarthField::interval_reg_p
static uInt interval_reg_p
Interpolation interval.
Definition EarthField.h:209
casacore::EarthField::dval_p
Double dval_p[3][3]
Cached derivatives.
Definition EarthField.h:201
casacore::EarthField::initializeRcValue
static void initializeRcValue()
casacore::EarthField::p_p
Vector< Double > p_p
Work arrays for calculations.
Definition EarthField.h:191
casacore::EarthField::~EarthField
~EarthField()
casacore::EarthField::init
void init()
Re-initialise EarthField object with specified model and epoch, or defaults STANDARD and J2000.
casacore::EarthField::method_p
EarthFieldTypes method_p
Method to be used.
Definition EarthField.h:184
casacore::EarthField::EarthField
EarthField(EarthFieldTypes model, Double catepoch=51544.5)
Constructor with epoch in MJulian days (default is J2000).
casacore::EarthField::refresh
void refresh()
Refresh calculations.
casacore::EarthField::fillField
void fillField()
Create correct default fixedEpoch and catalogue field data.
casacore::EarthField::sl_p
Vector< Double > sl_p
Definition EarthField.h:194
casacore::EarthField::agh_p
Vector< Double > agh_p
List of spherical components.
Definition EarthField.h:188
casacore::EarthField::operator()
const Vector< Double > & operator()(const MVPosition &pos)
Return the EarthField components.
casacore::EarthField::lres_p
Int lres_p
To reference results, and use a few in interim calculations, results are calculated in a circular buf...
Definition EarthField.h:205
casacore::EarthField::q_p
Vector< Double > q_p
Definition EarthField.h:192
casacore::EarthField::checkPos_p
MVPosition checkPos_p
Check position.
Definition EarthField.h:197
casacore::EarthField::copy
void copy(const EarthField &other)
Make a copy.
casacore::EarthField::calcField
void calcField(const MVPosition &pos)
Calculate EarthField for longitude and latitude and altitude (m).
casacore::EarthField::operator=
EarthField & operator=(const EarthField &other)
Copy assignment.
casacore::EarthField::result_p
Vector< Double > result_p[4]
Last calculation.
Definition EarthField.h:207
casacore::EarthField::init
void init(EarthFieldTypes model, Double catepoch=51544.5)
casacore::EarthField::fixedEpoch_p
Double fixedEpoch_p
Fixed epoch to be used (MJD).
Definition EarthField.h:186
casacore::EarthField::cl_p
Vector< Double > cl_p
Definition EarthField.h:193
casacore::EarthField::EarthFieldTypes
EarthFieldTypes
Known EarthField calculation models.
Definition EarthField.h:138
casacore::EarthField::IGRF
@ IGRF
Standard IGRF model.
Definition EarthField.h:140
casacore::EarthField::STANDARD
@ STANDARD
Standard default model if none specified.
Definition EarthField.h:144
casacore::EarthField::NONE
@ NONE
Make the field equal to zero.
Definition EarthField.h:142
casacore::EarthField::pval_p
Double pval_p[3]
Cached calculated field components.
Definition EarthField.h:199
casacore::MVPosition
Definition MVPosition.h:111
casacore::Vector
Definition Vector.h:82
casacore
this file contains all the compiler specific defines
Definition mainpage.dox:28
casacore::DER_INTV
const Double DER_INTV
Interval (m) for derivatives in IGRF model.
Definition EarthField.h:43
casacore::uInt
unsigned int uInt
Definition aipstype.h:49
casacore::PQ_LEN
const Int PQ_LEN
Length of P and Q arrays, half length of CL/SL arrays in IGRF model.
Definition EarthField.h:41
casacore::Int
int Int
Definition aipstype.h:48
casacore::Double
double Double
Definition aipstype.h:53