{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# Finding unit vector in QD northward direction\n", "\n", "How to find a unit vector in teh QD northward direction (along QD meridians) at any location, using apexpy:" ] }, { "cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [], "source": [ "import apexpy\n", "import numpy as np\n", "\n", "epoch = 2015 # year at which IGRF coefficients are evaluated\n", "a = apexpy.Apex(epoch)\n", "\n", "glat, glon = 60, 30 # set geodetic latitude and longitude\n", "f1, f2 = a.basevectors_qd(glat, glon, 0, coords = 'geo') # last param is height - set to ground here\n" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "$\\bf{f}_2$ is a vector that points along contours of constant longitude - i.e., along magnetic meridians. The apexpy function returns the east and north-components of this vector. However, it is not a unit vector, so the last step to find a QD northward unit vector is normalize $\\bf{f}_2$:\n" ] }, { "cell_type": "code", "execution_count": 2, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "QD north at (glat, glon) = (60.0, 30.0) is -0.177 east, 0.984 north\n" ] } ], "source": [ "qd_north = f2 / np.linalg.norm(f2)\n", "print('QD north at (glat, glon) = (%.1f, %.1f) is %.3f east, %.3f north' % (glat, glon, qd_north[0], qd_north[1]))" ] } ], "metadata": { "kernelspec": { "display_name": "Python 3", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.7.6" } }, "nbformat": 4, "nbformat_minor": 4 }