import arcpy
# Check Out Aeronautical Extension
arcpy.CheckOutExtension("Aeronautical")
#Input ATS Route Feature Layer
in_features = r"C:\data\AIS.gdb\ATSRoutes"
#Add fields in the in_features if not exist already
arcpy.AddField_management(in_features, 'Length', 'DOUBLE')
arcpy.AddField_management(in_features, 'TRUETRACK_VAL', 'DOUBLE')
arcpy.AddField_management(in_features, 'REVERSETRUETRACK_VAL', 'DOUBLE')
arcpy.AddField_management(in_features, 'MAGTRACK_VAL', 'DOUBLE')
arcpy.AddField_management(in_features, 'REVERSE_MAG_TRACK', 'DOUBLE')
#Input ATS Route Attributes to be calculated
atsroute_attributes= "LENGTH Length;TRUE_TRACK TRUETRACK_VAL;REVERSE_TRUE_TRACK REVERSETRUETRACK_VAL;MAG_TRACK MAGTRACK_VAL;REVERSE_MAG_TRACK REVERSEMAGTRACK_VAL"
#Input Magnetic Variation Date
magnetic_variation="12/31/2021 10:52:18 AM"
# Exceute Calculate ATSRoute Attributes
arcpy.aviation.CalculateATSRouteAttributes(in_features, atsroute_attributes, magnetic_variation)
# Check In Aeronautical Extension
arcpy.CheckInExtension("Aeronautical")