astrohack.utils.text

Attributes

lnbr

spc

Functions

tuple_inspect(param_tuple)

approve_prefix(key)

add_prefix(input_string, prefix)

Adds a prefix to a string filename, if the filename is a path with /, adds the prefix to the actual filename at the

param_to_list(param, data_dict, prefix)

Transforms a string parameter to a list if parameter is all or a single string

get_default_file_name(→ str)

get_data_content_string(data_object[, alignment, ...])

Factorized printing of the prettytable with the data contents

print_dict_types(le_dict[, ident, show_values])

get_property_string(root_attrs[, split_key, ...])

rad_to_hour_str(rad)

Converts an angle in radians to hours minutes and seconds

rad_to_deg_str(rad)

Converts an angle in radians to degrees minutes and seconds

get_summary_header(filename[, print_len, frame_char, ...])

Print a summary header dynamically adjusted to the filename

get_method_list_string(astrohack_obj[, alignment, ...])

Print the method list of a mds object

format_frequency(freq_value[, unit, decimal_places])

format_wavelength(user_value[, unit, decimal_places])

format_duration(duration[, unit, decimal_places])

format_angular_distance(user_value[, unit, decimal_places])

format_label(label[, separators, new_separator])

format_value_unit(value, unit[, decimal_places])

format_value_error(value, error, scaling, tolerance)

Format values based and errors based on the significant digits

fixed_format_error(value, error, scaling, ...)

Format value and error based on a significance scale

bool_to_str(boolean)

string_to_ascii_file(string, filename)

create_pretty_table(field_names[, alignment])

create_dataset_label(ant_id, ddi_id[, separator])

get_data_name(data_id)

significant_figures_round(x, digits)

statistics_to_text(data_statistics[, keys, num_format])

dynamic_format(value)

format_az_el_information(az_el_dict[, key, unit, ...])

format_general_information(obs_dict, tab, ident, key_size)

format_spectral_information(freq_dict, tab, ident, ...)

format_beam_information(beam_dict, tab, ident, key_size)

format_aperture_information(aperture_dict, tab, ident, ...)

format_observation_summary(obs_sum[, tab_size, ...])

make_header(heading, separator, header_width, buffer_width)

Module Contents

lnbr = Multiline-String[source]
Show Value
"""
"""
spc = ' '[source]
tuple_inspect(param_tuple)[source]
approve_prefix(key)[source]
add_prefix(input_string, prefix)[source]

Adds a prefix to a string filename, if the filename is a path with /, adds the prefix to the actual filename at the end of the path :param input_string: filename or file path :param prefix: prefix to be added to the filename

Returns: filename or path plus prefix added to the filename

param_to_list(param, data_dict, prefix)[source]

Transforms a string parameter to a list if parameter is all or a single string :param param: string or list parameter :param data_dict: Dictionary in which to search for data to be listed :param prefix: prefix to be added to parameter

Returns: parameter converted to a list

get_default_file_name(input_filename: str, output_ext: str, user_filename: str | None) str[source]
get_data_content_string(data_object, alignment='l', field_names=None)[source]

Factorized printing of the prettytable with the data contents :param data_object: Dictionary with data to be displayed :param field_names: Field names in the table :param alignment: Contents of the table to be aligned Left or Right

print_dict_types(le_dict, ident=4, show_values=False)[source]
get_property_string(root_attrs, split_key=None, alignment='l', heading='Input Parameters')[source]
rad_to_hour_str(rad)[source]

Converts an angle in radians to hours minutes and seconds :param rad: angle in radians

Returns: xxhyymzz.zzzs

rad_to_deg_str(rad)[source]

Converts an angle in radians to degrees minutes and seconds :param rad: angle in radians

Returns: xx°yymzz.zzzs

get_summary_header(filename, print_len=80, frame_char='#', frame_width=3)[source]

Print a summary header dynamically adjusted to the filename :param filename: filename :param print_len: Length of the print on screen :param frame_char: Character to frame header :param frame_width: Width of the frame

Returns:

header string

get_method_list_string(astrohack_obj, alignment='l', print_len=80)[source]

Print the method list of a mds object

format_frequency(freq_value, unit='Hz', decimal_places=4)[source]
format_wavelength(user_value, unit='m', decimal_places=2)[source]
format_duration(duration, unit='sec', decimal_places=2)[source]
format_angular_distance(user_value, unit='rad', decimal_places=2)[source]
format_label(label, separators=('_', '\n'), new_separator=' ')[source]
format_value_unit(value, unit, decimal_places=2)[source]
format_value_error(value, error, scaling, tolerance)[source]

Format values based and errors based on the significant digits

fixed_format_error(value, error, scaling, significance_scale)[source]

Format value and error based on a significance scale :param value: value to be formatted :param error: error to be formatted :param scaling: scaling to be applied to value and error :param significance_scale: scale for which signifcant values are expected

Returns:

formatted string with value +- error

bool_to_str(boolean)[source]
string_to_ascii_file(string, filename)[source]
create_pretty_table(field_names, alignment='c')[source]
create_dataset_label(ant_id, ddi_id, separator=':')[source]
get_data_name(data_id)[source]
significant_figures_round(x, digits)[source]
statistics_to_text(data_statistics: dict, keys: list = None, num_format: str = None)[source]
dynamic_format(value)[source]
format_az_el_information(az_el_dict, key='center', unit='deg', precision='.1f')[source]
format_general_information(obs_dict, tab, ident, key_size, az_el_key='mean', phase_center_unit='radec', az_el_unit='deg', time_format='%d %h %Y, %H:%M:%S', precision='.1f')[source]
format_spectral_information(freq_dict, tab, ident, key_size)[source]
format_beam_information(beam_dict, tab, ident, key_size)[source]
format_aperture_information(aperture_dict, tab, ident, key_size)[source]
format_observation_summary(obs_sum, tab_size=3, tab_count=0, az_el_key='mean', phase_center_unit='radec', az_el_unit='deg', time_format='%d %h %Y, %H:%M:%S', precision='.1f', key_size=18)[source]
make_header(heading, separator, header_width, buffer_width)[source]