def test_geo2qd_invalid_lat(): A = Apex(date=2000, refh=300) with pytest.raises(ValueError): A.geo2qd(91, 0, 0) with pytest.raises(ValueError): A.geo2qd(-91, 0, 0) A.geo2qd(90, 0, 0) A.geo2qd(-90, 0, 0) assert_allclose(A.geo2qd(90+1e-5, 0, 0), A.geo2qd(90, 0, 0), rtol=0, atol=1e-8)
def test_geo2qd_invalid_lat(): apex_out = Apex(date=2000, refh=300) with pytest.raises(ValueError): apex_out.geo2qd(91, 0, 0) with pytest.raises(ValueError): apex_out.geo2qd(-91, 0, 0) apex_out.geo2qd(90, 0, 0) apex_out.geo2qd(-90, 0, 0) assert_allclose(apex_out.geo2qd(90 + 1e-5, 0, 0), apex_out.geo2qd(90, 0, 0), rtol=0, atol=1e-8)
def add_apex_coords(dataframe, date='none', h=470): """ Add quasidipol geomagtic coordinates to the dataframe using apexPy """ if ('mLatitude' in dataframe.columns): print('mLatitude is all ready in the dataframe') return None if date == 'none': date = dataframe.index[int(len(dataframe) / 2)].date() model = Apex(date) ## Get the apex coordinates mlat, mlon = model.geo2qd(dataframe.Latitude, dataframe.Longitude, h) # adds to the dataframe dataframe.loc[:, 'mLatitude'] = mlat dataframe.loc[:, 'mLongitude'] = mlon return None
def test_geo2qd_vectorization(): A = Apex(date=2000, refh=300) assert A.geo2qd([60, 60], 15, 100)[0].shape == (2,) assert A.geo2qd(60, [15, 15], 100)[0].shape == (2,) assert A.geo2qd(60, 15, [100, 100])[0].shape == (2,)
def test_geo2qd(): A = Apex(date=2000, refh=300) lat, lon = A.geo2qd(60, 15, 100) assert_allclose((lat, lon), A._geo2qd(60, 15, 100)) assert type(lat) != np.ndarray assert type(lon) != np.ndarray
def test_convert_geo2qd(): A = Apex(date=2000, refh=300) assert_allclose(A.convert(60, 15, 'geo', 'qd', height=100), A.geo2qd(60, 15, 100))
def test_geo2qd_vectorization(): apex_out = Apex(date=2000, refh=300) assert apex_out.geo2qd([60, 60], 15, 100)[0].shape == (2, ) assert apex_out.geo2qd(60, [15, 15], 100)[0].shape == (2, ) assert apex_out.geo2qd(60, 15, [100, 100])[0].shape == (2, )
def test_geo2qd(): apex_out = Apex(date=2000, refh=300) lat, lon = apex_out.geo2qd(60, 15, 100) assert_allclose((lat, lon), apex_out._geo2qd(60, 15, 100)) assert type(lat) != np.ndarray assert type(lon) != np.ndarray
def test_convert_geo2qd(): apex_out = Apex(date=2000, refh=300) assert_allclose(apex_out.convert(60, 15, 'geo', 'qd', height=100), apex_out.geo2qd(60, 15, 100))
def test_convert_geo2qd(): A = Apex(date=2000, refh=300) assert_allclose(A.convert(60, 15, 'geo', 'qd', height=100), A.geo2qd(60, 15, 100))