示例#1
0
def test_curl_free_current_magnitudes():
    "Make sure the curl free current amplitudes are correct."
    # Place the SEC at the North Pole
    sec_r = R_EARTH + 100
    sec_latlonr = np.array([[0., 0., sec_r]])
    # Going out in an angle from the SEC (in longitude)
    angles = np.linspace(0.1, 180)
    obs_latlonr = np.zeros(angles.shape + (3, ))
    obs_latlonr[:, 1] = angles
    obs_latlonr[:, 2] = sec_r

    J = np.squeeze(pysecs.J_cf(obs_latlonr, sec_latlonr))

    # Make sure all radial components are oppositely directed
    radial_component = 1. / (4 * np.pi * sec_r**2)
    assert np.all(J[:, 2] == radial_component)

    # All x components should be zero (angles goes around the equator and all
    # quantities should be parallel to that)
    # (ambiguous 0 degree angle so ignore the first input)
    assert_allclose(np.zeros(angles.shape), J[:, 0], atol=1e-16)

    # Actual magnitude
    tan_theta2 = np.tan(np.deg2rad(angles / 2))
    J_test = 1. / (4 * np.pi * sec_r)
    J_test = np.divide(J_test,
                       tan_theta2,
                       out=np.ones_like(tan_theta2) * np.inf,
                       where=tan_theta2 != 0.)

    assert_allclose(J_test, J[:, 1], atol=1e-16)
示例#2
0
def test_outside_current_plane():
    "Make sure all currents outside the SEC plane are 0."
    sec_r = R_EARTH + 100
    sec_latlonr = np.array([[0., 0., sec_r]])
    # Above and below the plane, also on and off the SEC point
    obs_latlonr = np.array([[0., 0., sec_r - 100.], [0., 0., sec_r + 100.],
                            [5, 0., sec_r - 100.], [5., 0., sec_r + 100.]])

    # df currents
    J = np.squeeze(pysecs.J_df(obs_latlonr, sec_latlonr))
    assert np.all(J == 0.)
    # cf currents
    J = np.squeeze(pysecs.J_cf(obs_latlonr, sec_latlonr))
    assert np.all(J == 0.)
示例#3
0
def test_curl_free_current_directions():
    "Make sure the curl free current angles are correct."
    # Place the SEC at the equator
    sec_r = R_EARTH + 100
    sec_latlonr = np.array([[0., 0., sec_r]])
    # Going around in a circle from the point
    obs_latlonr = np.array([[5., 0., sec_r], [0., 5., sec_r], [-5, 0., sec_r],
                            [0., -5., sec_r]])

    J = np.squeeze(pysecs.J_cf(obs_latlonr, sec_latlonr))

    angles = np.arctan2(J[:, 0], J[:, 1])
    # pointing out from the SEC direction to OBS direction.
    # northward, eastward, southward, westward
    expected_angles = np.deg2rad([90., 0., -90., -180])
    assert_allclose(angles, expected_angles, atol=1e-15)