def _calculateBVector(self, date, coordinate): """ Given a date, and a coordinate, calculate the value of the B-field. @param date (\a float) the decimal year at which to calulate the B-field @param coordinate (\a isceobj.Location.Coordinate) the location at which to calculate the B-field @return (\a list) the north, east and down values of the B-field in gauss """ from ctypes import cdll, c_float, c_char_p lib = cdll.LoadLibrary(os.path.dirname(__file__) + '/issi.so') year = DTU.dateTimeToDecimalYear(date) year_c = c_float(year) lat_c = c_float(coordinate.getLatitude()) lon_c = c_float(coordinate.getLongitude()) alt_c = c_float(coordinate.getHeight()) beast_c = (c_float * 1)(*[0.0]) bnorth_c = (c_float * 1)(*[0.0]) bdown_c = (c_float * 1)(*[0.0]) babs_c = (c_float * 1)(*[0.0]) dataPath_c = c_char_p(dataPath) # Point to the library directory lib.calculateBVector(year_c, lat_c, lon_c, alt_c, beast_c, bnorth_c, bdown_c, babs_c, dataPath_c) beast = beast_c[0] bnorth = bnorth_c[0] bdown = bdown_c[0] return [beast, bnorth, bdown]
def testDateTimeToDecimalYear(self): ans = 2004.2053388 decimalYear = DateTimeUtil.dateTimeToDecimalYear(self.dt1) self.assertAlmostEquals(decimalYear, ans, 5)