Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
The beam list is spoofed, since that information cannot be found in a UVData object.
layout_csv: tab separated value file giving ENU antenna positions/
Beam ID is spoofed as well.
"""
if telescope_config_name is None:
telescope_config_path = \
check_file_exists_and_increment(
os.path.join(
path_out, 'telescope_config_{}.yaml'.format(uvdata_in.telescope_name)
)
)
telescope_config_name = os.path.basename(telescope_config_path)
if layout_csv_name is None:
layout_csv_path = check_file_exists_and_increment(
os.path.join(path_out, uvdata_in.telescope_name + "_layout.csv"))
layout_csv_name = os.path.basename(layout_csv_path)
antpos_enu, antenna_numbers = uvdata_in.get_ENU_antpos()
_write_layout_csv(
os.path.join(path_out, layout_csv_name),
antpos_enu, uvdata_in.antenna_names, uvdata_in.antenna_numbers
)
# Write the rest to a yaml file.
yaml_dict = {
"telescope_name": uvdata_in.telescope_name,
"telescope_location": repr(uvdata_in.telescope_location_lat_lon_alt_degrees),
"Nants": uvdata_in.Nants_telescope,
"beam_paths": {0: beam_filepath}
outfile = output_layout_filename is not None
if write_files:
if path_out is None:
path_out = '.'
if not outfile:
if not arrfile:
output_layout_filename = 'antenna_layout.csv'
else:
output_layout_filename = os.path.basename(antenna_layout_filepath)
outfile = True
# Increment name appropriately:
output_layout_filepath = os.path.join(path_out, output_layout_filename)
output_layout_filename = os.path.basename(
check_file_exists_and_increment(output_layout_filepath, 'csv')
)
if output_yaml_filename is None:
output_yaml_filename = 'obsparam.yaml'
output_yaml_filename = check_file_exists_and_increment(
os.path.join(path_out, output_yaml_filename), 'yaml'
)
if antenna_layout_filepath is not None:
# Copying original file to new place, if it exists
if os.path.exists(antenna_layout_filepath):
shutil.copyfile(
antenna_layout_filepath,
os.path.join(path_out, output_layout_filename)
)
"""
Extract simulation configuration settings from uvfits.
Args:
uvdata_in (UVData): uvdata object.
Keywords:
param_filename (str, optional): output param file name, defaults to obsparam_#.yaml.
telescope_config_name (str, optional): Name of yaml file file. Defaults to blank string.
layout_csv_name (str, optional): Name of layout csv file. Defaults to blank string.
catalog (str, optional): Path to catalog file, defaults to 'mock'.
path_out (str, optional): Where to put config files.
"""
if param_filename is None:
param_filename = check_file_exists_and_increment(os.path.join(path_out, 'obsparam.yaml'))
param_filename = os.path.basename(param_filename)
freq_array = uvdata_in.freq_array[0, :]
time_array = uvdata_in.time_array
integration_time_array = np.array(uvdata_in.integration_time)
if np.max(integration_time_array) != np.min(integration_time_array):
warnings.warn('The integration time is not constant. Using the shortest integration time')
tdict = time_array_to_params(time_array)
fdict = freq_array_to_params(freq_array)
if 'time_array' in tdict:
tdict.pop('time_array')
param_dict = {
"time": tdict,
if not outfile:
if not arrfile:
output_layout_filename = 'antenna_layout.csv'
else:
output_layout_filename = os.path.basename(antenna_layout_filepath)
outfile = True
# Increment name appropriately:
output_layout_filepath = os.path.join(path_out, output_layout_filename)
output_layout_filename = os.path.basename(
check_file_exists_and_increment(output_layout_filepath, 'csv')
)
if output_yaml_filename is None:
output_yaml_filename = 'obsparam.yaml'
output_yaml_filename = check_file_exists_and_increment(
os.path.join(path_out, output_yaml_filename), 'yaml'
)
if antenna_layout_filepath is not None:
# Copying original file to new place, if it exists
if os.path.exists(antenna_layout_filepath):
shutil.copyfile(
antenna_layout_filepath,
os.path.join(path_out, output_layout_filename)
)
antenna_numbers = None
if isinstance(array_layout, dict):
antenna_numbers = np.fromiter(array_layout.keys(), dtype=int)
antpos_enu = array_layout.values()
if antenna_names is None:
Returns:
if return_names, returns tuple (path, telescope_config_name, layout_csv_name)
Notes:
The generate files are, briefly:
telescope_config: YAML file with telescope_location and telescope_name
The beam list is spoofed, since that information cannot be found in a UVData object.
layout_csv: tab separated value file giving ENU antenna positions/
Beam ID is spoofed as well.
"""
if telescope_config_name is None:
telescope_config_path = \
check_file_exists_and_increment(
os.path.join(
path_out, 'telescope_config_{}.yaml'.format(uvdata_in.telescope_name)
)
)
telescope_config_name = os.path.basename(telescope_config_path)
if layout_csv_name is None:
layout_csv_path = check_file_exists_and_increment(
os.path.join(path_out, uvdata_in.telescope_name + "_layout.csv"))
layout_csv_name = os.path.basename(layout_csv_path)
antpos_enu, antenna_numbers = uvdata_in.get_ENU_antpos()
_write_layout_csv(
os.path.join(path_out, layout_csv_name),
antpos_enu, uvdata_in.antenna_names, uvdata_in.antenna_numbers