953def get_world_parameters(x, y, radius, angle, ratio):
955 Convenience function for generating five dependent parameters, in world coordinates, for the position
956 and shape of a model.
962 radius : ParameterBase
963 angle : ParameterBase
964 ratio : ParameterBase
968 ra : DependentParameter
970 dec : DependentParameter
972 rad : DependentParameter
974 angle : DependentParameter
976 ratio : DependentParameter
977 Aspect ratio. It has to be recomputed as the axis of the ellipse may have different ratios
978 in image coordinates than in world coordinates
982 >>> flux = get_flux_parameter()
983 >>> x, y = get_pos_parameters()
984 >>> radius = FreeParameter(lambda o: o.radius, Range(lambda v, o: (.01 * v, 100 * v), RangeType.EXPONENTIAL))
985 >>> angle = FreeParameter(lambda o: o.angle, Range((-np.pi, np.pi), RangeType.LINEAR))
986 >>> ratio = FreeParameter(1, Range((0, 10), RangeType.LINEAR))
987 >>> add_model(group, ExponentialModel(x, y, flux, radius, ratio, angle))
988 >>> ra, dec, wc_rad, wc_angle, wc_ratio = get_world_parameters(x, y, radius, angle, ratio)
989 >>> add_output_column('mf_world_angle', wc_angle)
994 def get_major_axis(x, y, radius, angle, ratio):
996 x2 = x + math.cos(angle) * radius
997 y2 = y + math.sin(angle) * radius
999 x2 = x + math.sin(angle) * radius * ratio
1000 y2 = y + math.cos(angle) * radius * ratio
1004 def get_minor_axis(x, y, radius, angle, ratio):
1006 x2 = x + math.sin(angle) * radius * ratio
1007 y2 = y + math.cos(angle) * radius * ratio
1009 x2 = x + math.cos(angle) * radius
1010 y2 = y + math.sin(angle) * radius
1014 def wc_rad_func(x, y, radius, angle, ratio):
1015 x2, y2 = get_major_axis(x, y, radius, angle, ratio)
1016 return get_separation_angle(x, y, x2, y2)
1018 def wc_angle_func(x, y, radius, angle, ratio):
1019 x2, y2 = get_major_axis(x, y, radius, angle, ratio)
1020 return get_position_angle(x, y, x2, y2)
1022 def wc_ratio_func(x, y, radius, angle, ratio):
1023 minor_x, minor_y = get_minor_axis(x, y, radius, angle, ratio)
1024 minor_angle = get_separation_angle(x, y, minor_x, minor_y)
1026 major_x, major_y = get_major_axis(x, y, radius, angle, ratio)
1027 major_angle = get_separation_angle(x, y, major_x, major_y)
1029 return minor_angle / major_angle
1035 return ra, dec, wc_rad, wc_angle, wc_ratio
1222def print_model_fitting_info(group, show_params=False, prefix='', file=sys.stderr):
1224 Print a human-readable representation of the configured models.
1228 group : MeasurementGroup
1229 Print the models for this group.
1231 If True, print also the parameters that belong to the model
1233 Prefix each line with this string. Used internally for indentation.
1235 Where to print the representation. Defaults to sys.stderr
1237 if hasattr(group,
'models')
and group.models:
1238 print(
'{}Models:'.format(prefix), file=file)
1239 for m
in group.models:
1240 print(
'{} {}'.format(prefix, m.to_string(show_params)), file=file)
1242 if isinstance(x, tuple):
1243 print(
'{}{}:'.format(prefix, x[0]), file=file)
1244 print_model_fitting_info(x[1], show_params, prefix +
' ', file=file)