I am working with the IGRF (International Geomagnetic Reference Field) model and from a journal article found here, I am able to compute the earth's magnetic field at any point in spherical coordinates $(r, \theta, \phi)$, which can be trivially converted to Cartesian coordinates. The result from this conversion has the $z$-axis going from the center of the earth through magnetic north.
I am interested in a satellite for which I have a TLE (two-line element), which tells me where the satellite is in space (I have satellite propagation software to tell me where the satellite is at a given moment in time). I want to know the magnetic field at the satellite location. The problem is that the satellite is given in a Cartesian space where the $z$-axis goes from the center of the earth through true north, which is different from magnetic north.
How do I convert the satellite Cartesian coordinate system to the magnetic field Cartesian coordinate system? My thinking is I can take the satellite position, rotate to "magnetic coordinates", convert to spherical, and compute the magnetic field using the IGRF model, but I don't know how to do the coordinate rotation.