Beispiel #1
0
def test_mlon2mlt_offset():
    apex_out = Apex(date=2000, refh=300)
    date = dt.datetime(2000, 2, 3, 4, 5, 6)
    assert_allclose(apex_out.mlon2mlt(0, date),
                    apex_out.mlon2mlt(-15, date) + 1)
    assert_allclose(apex_out.mlon2mlt(0, date),
                    apex_out.mlon2mlt(-10 * 15, date) + 10)
Beispiel #2
0
def test_mlon2mlt2mlon():
    apex_out = Apex(date=2000, refh=300)
    date = dt.datetime(2000, 2, 3, 4, 5, 6)
    assert_allclose(apex_out.mlon2mlt(apex_out.mlt2mlon(0, date), date), 0)
    assert_allclose(apex_out.mlon2mlt(apex_out.mlt2mlon(6, date), date), 6)
    assert_allclose(apex_out.mlon2mlt(apex_out.mlt2mlon(12, date), date), 12)
    assert_allclose(apex_out.mlon2mlt(apex_out.mlt2mlon(18, date), date), 18)
    assert_allclose(apex_out.mlon2mlt(apex_out.mlt2mlon(24, date), date), 0)
Beispiel #3
0
def test_mlon2mlt2mlon():
    A = Apex(date=2000, refh=300)
    date = dt.datetime(2000, 2, 3, 4, 5, 6)
    assert_allclose(A.mlon2mlt(A.mlt2mlon(0, date), date), 0)
    assert_allclose(A.mlon2mlt(A.mlt2mlon(6, date), date), 6)
    assert_allclose(A.mlon2mlt(A.mlt2mlon(12, date), date), 12)
    assert_allclose(A.mlon2mlt(A.mlt2mlon(18, date), date), 18)
    assert_allclose(A.mlon2mlt(A.mlt2mlon(24, date), date), 0)
Beispiel #4
0
def test_mlt2mlon2mlt():
    A = Apex(date=2000, refh=300)
    date = dt.datetime(2000, 2, 3, 4, 5, 6)
    assert_allclose(A.mlt2mlon(A.mlon2mlt(0, date), date), 0)
    assert_allclose(A.mlt2mlon(A.mlon2mlt(90, date), date), 90)
    assert_allclose(A.mlt2mlon(A.mlon2mlt(180, date), date), 180)
    assert_allclose(A.mlt2mlon(A.mlon2mlt(270, date), date), 270)
    assert_allclose(A.mlt2mlon(A.mlon2mlt(360, date), date), 0)
Beispiel #5
0
def test_mlt2mlon2mlt():
    apex_out = Apex(date=2000, refh=300)
    date = dt.datetime(2000, 2, 3, 4, 5, 6)
    assert_allclose(apex_out.mlt2mlon(apex_out.mlon2mlt(0, date), date), 0)
    assert_allclose(apex_out.mlt2mlon(apex_out.mlon2mlt(90, date), date), 90)
    assert_allclose(apex_out.mlt2mlon(apex_out.mlon2mlt(180, date), date), 180)
    assert_allclose(apex_out.mlt2mlon(apex_out.mlon2mlt(270, date), date), 270)
    assert_allclose(apex_out.mlt2mlon(apex_out.mlon2mlt(360, date), date), 0)
Beispiel #6
0
def test_mlon2mlt_range():
    A = Apex(date=2000, refh=300)
    assert_allclose(A.mlon2mlt(range(0, 361, 30), dt.datetime(2000, 2, 3, 4, 5, 6)),
                    [23.01963, 1.01963, 3.01963, 5.01963, 7.01963,
                     9.01963, 11.01963, 13.01963, 15.01963, 17.01963,
                     19.01963, 21.01963, 23.01963],
                    rtol=1e-4)
Beispiel #7
0
def test_mlon2mlt_range():
    apex_out = Apex(date=2000, refh=300)
    assert_allclose(apex_out.mlon2mlt(range(
        0, 361, 30), dt.datetime(2000, 2, 3, 4, 5, 6)), [
            23.01963, 1.01963, 3.01963, 5.01963, 7.01963, 9.01963, 11.01963,
            13.01963, 15.01963, 17.01963, 19.01963, 21.01963, 23.01963
        ],
                    rtol=1e-4)
Beispiel #8
0
def test_convert_qd2mlt():
    datetime = dt.datetime(2000, 3, 9, 14, 25, 58)
    A = Apex(date=2000, refh=300)
    assert_allclose(
        A.convert(60,
                  15,
                  'qd',
                  'mlt',
                  height=100,
                  datetime=datetime,
                  ssheight=2e5)[1], A.mlon2mlt(15, datetime, ssheight=2e5))
Beispiel #9
0
def test_convert_apex2mlt():
    datetime = dt.datetime(2000, 3, 9, 14, 25, 58)
    apex_out = Apex(date=2000, refh=300)
    assert_allclose(
        apex_out.convert(60,
                         15,
                         'apex',
                         'mlt',
                         height=100,
                         datetime=datetime,
                         ssheight=2e5)[1],
        apex_out.mlon2mlt(15, datetime, ssheight=2e5))
Beispiel #10
0
def test_convert_geo2mlt():
    datetime = dt.datetime(2000, 3, 9, 14, 25, 58)
    A = Apex(date=2000, refh=300)
    assert_allclose(
        A.convert(60,
                  15,
                  'geo',
                  'mlt',
                  height=100,
                  ssheight=2e5,
                  datetime=datetime)[1],
        A.mlon2mlt(A.geo2apex(60, 15, 100)[1], datetime, ssheight=2e5))
Beispiel #11
0
def test_mlon2mlt_1Darray():
    A = Apex(date=2000, refh=300)
    assert_allclose(A.mlon2mlt([0, 180], dt.datetime(2000, 2, 3, 4, 5, 6)),
                    [23.019261, 11.019261],
                    rtol=1e-4)
Beispiel #12
0
        year.append(Timestamp[i][0])
        month.append(Timestamp[i][1])
        day.append(Timestamp[i][2])
        hour.append(Timestamp[i][3])
        minute.append(Timestamp[i][4])
        second.append(Timestamp[i][5])
        millisecond.append(Timestamp[i][6])
        doy.append(int(datetime(year[i], month[i], day[i]).strftime('%j')))
        hourUT.append((3600. * hour[i] + 60 * minute[i] + second[i] +
                       0.001 * millisecond[i]) / 3600.)

        #Magnetic coordinates
        mag_lat, mag_lon = A.convert(Latitude[i], Longitude[i], 'geo', 'qd',
                                     height[i])
        mlt = A.mlon2mlt(
            mag_lon,
            datetime(year[i], month[i], day[i], hour[i], minute[i], second[i]))
        mlat.append(mag_lat)
        mlon.append(mag_lon)
        MLT.append(mlt)

    year = np.array(year)
    month = np.array(month)
    day = np.array(day)
    hour = np.array(hour)
    minute = np.array(minute)
    second = np.array(second)
    millisecond = np.array(millisecond)
    doy = np.array(doy)
    hourUT = np.array(hourUT)
    hourLT = (hourUT + Longitude / 15.) % 24
Beispiel #13
0
def test_mlon2mlt_ssheight():
    apex_out = Apex(date=2000, refh=300)
    mlt = apex_out.mlon2mlt(0,
                            dt.datetime(2000, 2, 3, 4, 5, 6),
                            ssheight=50 * 2000)
    assert_allclose(mlt, 23.026712036132814)
Beispiel #14
0
def test_mlon2mlt_scalar():
    apex_out = Apex(date=2000, refh=300)
    mlon = apex_out.mlon2mlt(0, dt.datetime(2000, 2, 3, 4, 5, 6))
    assert_allclose(mlon, 23.019629923502603)
    assert type(mlon) != np.ndarray
Beispiel #15
0
def test_mlon2mlt_diffdates():
    A = Apex(date=2000, refh=300)
    assert A.mlon2mlt(0, dt.datetime(2000, 2, 3, 4, 5, 6)) != A.mlon2mlt(0, dt.datetime(2000, 2, 3, 5, 5, 6))
Beispiel #16
0
def test_mlon2mlt_offset():
    A = Apex(date=2000, refh=300)
    date = dt.datetime(2000, 2, 3, 4, 5, 6)
    assert_allclose(A.mlon2mlt(0, date), A.mlon2mlt(-15, date) + 1)
    assert_allclose(A.mlon2mlt(0, date), A.mlon2mlt(-10*15, date) + 10)
Beispiel #17
0
def test_mlon2mlt_ssheight():
    A = Apex(date=2000, refh=300)
    mlt = A.mlon2mlt(0, dt.datetime(2000, 2, 3, 4, 5, 6), ssheight=50*2000)
    assert_allclose(mlt, 23.026712036132814)
Beispiel #18
0
def test_mlon2mlt_2Darray():
    A = Apex(date=2000, refh=300)
    assert_allclose(A.mlon2mlt([[0, 180], [0, 180]], dt.datetime(2000, 2, 3, 4, 5, 6)), [[23.019261, 11.019261], [23.019261, 11.019261]], rtol=1e-4)
Beispiel #19
0
def test_mlon2mlt_scalar():
    A = Apex(date=2000, refh=300)
    mlon = A.mlon2mlt(0, dt.datetime(2000, 2, 3, 4, 5, 6))
    assert_allclose(mlon, 23.019629923502603)
    assert type(mlon) != np.ndarray
Beispiel #20
0
def test_convert_qd2mlt():
    datetime = dt.datetime(2000, 3, 9, 14, 25, 58)
    A = Apex(date=2000, refh=300)
    assert_allclose(A.convert(60, 15, 'qd', 'mlt', height=100, datetime=datetime, ssheight=2e5)[1], A.mlon2mlt(15, datetime, ssheight=2e5))
Beispiel #21
0
def test_convert_geo2mlt():
    datetime = dt.datetime(2000, 3, 9, 14, 25, 58)
    A = Apex(date=2000, refh=300)
    assert_allclose(A.convert(60, 15, 'geo', 'mlt', height=100, ssheight=2e5, datetime=datetime)[1], A.mlon2mlt(A.geo2apex(60, 15, 100)[1], datetime, ssheight=2e5))
Beispiel #22
0
def test_mlon2mlt_2Darray():
    apex_out = Apex(date=2000, refh=300)
    assert_allclose(apex_out.mlon2mlt([[0, 180], [0, 180]],
                                      dt.datetime(2000, 2, 3, 4, 5, 6)),
                    [[23.019261, 11.019261], [23.019261, 11.019261]],
                    rtol=1e-4)
Beispiel #23
0
def test_mlon2mlt_diffdates():
    apex_out = Apex(date=2000, refh=300)
    dtime1 = dt.datetime(2000, 2, 3, 4, 5, 6)
    dtime2 = dt.datetime(2000, 2, 3, 5, 5, 6)
    assert apex_out.mlon2mlt(0, dtime1) != apex_out.mlon2mlt(0, dtime2)