|
|
@ -14,6 +14,7 @@ if not os.path.isfile("AP_Declination.h"): |
|
|
|
print("Please run this tool from the AP_Declination directory") |
|
|
|
print("Please run this tool from the AP_Declination directory") |
|
|
|
sys.exit(1) |
|
|
|
sys.exit(1) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def field_to_angles(x, y, z): |
|
|
|
def field_to_angles(x, y, z): |
|
|
|
intensity = sqrt(x**2+y**2+z**2) |
|
|
|
intensity = sqrt(x**2+y**2+z**2) |
|
|
|
r2d = 180.0 / pi |
|
|
|
r2d = 180.0 / pi |
|
|
@ -21,6 +22,7 @@ def field_to_angles(x,y,z): |
|
|
|
inclination = r2d * asin(z / intensity) |
|
|
|
inclination = r2d * asin(z / intensity) |
|
|
|
return [intensity, inclination, declination] |
|
|
|
return [intensity, inclination, declination] |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
isv = 0 |
|
|
|
isv = 0 |
|
|
|
date = datetime.datetime.now() |
|
|
|
date = datetime.datetime.now() |
|
|
|
itype = 1 |
|
|
|
itype = 1 |
|
|
@ -70,9 +72,11 @@ const float AP_Declination::SAMPLING_MAX_LON = %u; |
|
|
|
SAMPLING_MIN_LON, |
|
|
|
SAMPLING_MIN_LON, |
|
|
|
SAMPLING_MAX_LON)) |
|
|
|
SAMPLING_MAX_LON)) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def write_table(name, table): |
|
|
|
def write_table(name, table): |
|
|
|
'''write one table''' |
|
|
|
'''write one table''' |
|
|
|
tfile.write("const float AP_Declination::%s[%u][%u] = {\n" % (name, NUM_LAT, NUM_LON)); |
|
|
|
tfile.write("const float AP_Declination::%s[%u][%u] = {\n" % |
|
|
|
|
|
|
|
(name, NUM_LAT, NUM_LON)) |
|
|
|
for i in range(NUM_LAT): |
|
|
|
for i in range(NUM_LAT): |
|
|
|
tfile.write(" {") |
|
|
|
tfile.write(" {") |
|
|
|
for j in range(NUM_LON): |
|
|
|
for j in range(NUM_LON): |
|
|
@ -85,11 +89,10 @@ def write_table(name, table): |
|
|
|
tfile.write("\n") |
|
|
|
tfile.write("\n") |
|
|
|
tfile.write("};\n\n") |
|
|
|
tfile.write("};\n\n") |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
write_table('declination_table', declination_table) |
|
|
|
write_table('declination_table', declination_table) |
|
|
|
write_table('inclination_table', inclination_table) |
|
|
|
write_table('inclination_table', inclination_table) |
|
|
|
write_table('intensity_table', intensity_table) |
|
|
|
write_table('intensity_table', intensity_table) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
tfile.close() |
|
|
|
tfile.close() |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|