Magnetic field models, such as IGRF2000, often provide the output as a vector in a World Reference Frame, ENU (East, North, Up) or NED (North, East, Down). The components X, Y and Z from the question correspond to NED (X -> N, Y -> E, Z -> D).
If you have a position vector p$\vec{p}$ of the location where the magnetic field vector is taken in some reference frame F$F$, you can find a rotation matrix that will convert your magnetic field vector to that frame F$F$. If you have the position vector in ECEF, just follow the procedure explained below. In case the vector is in ECI, either convert it to ECEF first or you can convert the resulting magnetic field vector in ECI to ECEF (I might add this part to answer a bit later). Some hints on how to do this conversion can be found here: Transform ECI to ECEF
NED to F$F$ conversion
The goal is to find all three I apologize for quite bad axes inalignment job on the F framepicture, it was my first time using Blender. I'll use upper caseOn the picture there is a big coordinate system, Nrepresenting the $F$ reference frame, Elocated at the center of a sphere representing Earth. Red axis is $\hat{x}$, blue is $\hat{y}$ and D forgreen is $\hat{z}$. Small coordinate system is the NED reference frame, and lower case, nwith the red axis being North $\hat{n}$, eblue is East $\hat{e}$ and d for F framegreen is Down $\hat{d}$. The yellow line is a vector $\vec{p}$ going from the Earth center to the location of the magnetic field vector measurement.
FromTwo things should be noticed from the picture. First is that the vector $\vec{p}$ and $\hat{d}$ are coincident. Second is that $\vec{z}$, $\hat{d}$ and $\hat{n}$ are always in the same plane. For the NED reference frame, these vectors have$\hat{n}$ is always pointing straight to the following values:Earth's north, where the $\hat{z}$ is located, $\hat{d}$ straight to the Earth's center, while the $\hat{e}$ is only generally in the East direction, completing the orthogonal right handed axes triad.
- N = [1 0 0]
- E = [0 1 0]
- D = [0 0 1]
The vector p itself coincides with the vector D, with D being unitary andgoal is to find all three axes of opposite directionthe NED frame in the $F$ frame. Then d
Vector $\hat{d}$ can be calculatedobtained by taking negative of unitized p:unitizing $\vec{p}$ and negating it.
- d = - |p|$\hat{d} = - |\vec{p}|$
Crucial detail is to realize that the e vectorVector $\hat{e}$ is normal both to the just calculated d vector and the Z vector in the Earth reference frame, the vector coincident with the Earth's rotation vector,plane within which is same in both ECIlie $\hat{n}$, $\hat{d}$ and ECEF$\hat{z}$. Which means the e vector is calculated as unitized crossCross product of theseany of the two vectors: from this plane will produce $\hat{e}$. We calculated $\hat{d}$ already and we know $\hat{z} = [0 \; 0 \; 1]^T$.
- e = |p x [0 0 1]|$\hat{e} = \hat{d} \times \hat{z}$
Finally, n$\hat{n}$ vector is normal to both d$\hat{d}$ and e$\hat{e}$, sothus:
- n = e x d$\hat{n} = \hat{e} \times \hat{d}$
The final rotation matrix can be obtained by taking transpose of the matrix constructed with these three vectors: R = inv([n e d])
- $R = [\hat{n} \; \hat{e} \; \hat{d}]^T$