def test_get_obs_from_geo(self): """ChannelConverter_test.test_get_obs_from_geo() The geographic north and east components ``X`` and ``Y`` of the magnetic field vector H, combined with the declination baseline angle ``d0`` can be used to produce the observatory components ``h`` and ```e`` """ # 1) Call get_obs_from_geo using equal X,Y values with a d0 of 0 # the observatory values h,e will be the same. X = 1 Y = 1 (h, e) = channel.get_obs_from_geo(X, Y) assert_almost_equal(h, 1.0, 8, "Expect h to be 1.", True) assert_almost_equal(e, 1.0, 8, "Expect e to be 1.", True) # 2) Call get_obs_from_geo using equal X,Y values to create a 45 # degree angle (D), with a d0 of 45/2. The observatory declination # (d) will be 45/2, the difference between the total field angle, # and d0. X = 1 Y = 1 d0 = 22.5 * D2R (h, e) = channel.get_obs_from_geo(X, Y, d0) d = channel.get_obs_d_from_obs(h, e) assert_almost_equal(d, 22.5 * D2R, 8, "Expect d to be 22.5 degrees.", True) # 3) Call get_obs_from_geo using equal X,Y values to create a 45 # degree angle (D), with a d0 of 315 degrees. The observatory # declination (d) will be 90 degrees. X = 1 Y = 1 d0 = 315 * D2R (h, e) = channel.get_obs_from_geo(X, Y, d0) d = channel.get_obs_d_from_obs(h, e) assert_almost_equal(d, 90 * D2R, 8, "Expect d to be 90 degrees.", True) # 4) Call get_obs_from_geo using X,Y values of cos(60), sin(60), and # d0 of 30 degrees. The observatory values h,e will be cos(30) # and sin(30), and the observatory declination will be 30 degrees. # The observatory angle of 30 degrees + the d0 of 30 degrees produces # the total declination (D) of 60 degrees. X = cos(60 * D2R) Y = sin(60 * D2R) d0 = 30 * D2R (h, e) = channel.get_obs_from_geo(X, Y, d0) assert_almost_equal(h, cos(30 * D2R), 8, "Expect h to be cos(30).", True) assert_almost_equal(e, sin(30 * D2R), 8, "Expect e to be sin(30).", True) d = channel.get_obs_d_from_obs(h, e) assert_almost_equal(d, 30 * D2R, 8, "Expect d to be 30 degrees.", True)
def test_geo_to_obs_to_geo(self): """ChannelConverter_test.test_geo_to_obs_to_geo() Call get_geo_from_obs using values from Boulder, then call get_obs_from_geo using the X,Y values returned from get_geo_from_obs. Expect the end values to be the same as the start values. """ h_in = 20840.15 e_in = -74.16 d0 = dec_bas_rad (X, Y) = channel.get_geo_from_obs(h_in, e_in, d0) (h, e) = channel.get_obs_from_geo(X, Y, d0) assert_almost_equal(h, 20840.15, 8, "Expect h to = 20840.15.", True) assert_almost_equal(e, -74.16, 8, "Expect e to = -74.16", True)