def main(): """Main function for visibility corruptor.""" # Check command line arguments. if len(sys.argv) < 2: raise RuntimeError('Usage: python corruptor.py ' '<oskar_sim_interferometer.ini>') # Load the OSKAR settings INI file for the application. settings = oskar.SettingsTree('oskar_sim_interferometer', sys.argv[-1]) # Set up the corruptor and run it (see method, above). corruptor = Corruptor(oskar_settings=settings) corruptor.run()
def make_image(name, algorithm, root_prefix, fov_deg, num_pixels): """Generates an image from visibility data.""" settings_dict = { 'image': { 'size': str(num_pixels), 'fov_deg': str(fov_deg), 'algorithm': algorithm, 'fft/use_gpu': 'true', 'fft/grid_on_gpu': 'true', 'input_vis_data': 'sim_' + name + '.vis', 'root_path': root_prefix + '_' + name } } settings = oskar.SettingsTree('oskar_imager') settings.from_dict(settings_dict) if name == 'large': settings['image/fft/use_gpu'] = 'false' LOG.info('Starting imager for "%s"', settings['image/root_path']) imager = oskar.Imager(settings=settings) imager.run() LOG.info('Imaging complete')
def main(): """Main function for OSKAR SPEAD sender module.""" # Check command line arguments. if len(sys.argv) < 3: raise RuntimeError('Usage: python spead_send.py ' '<spead_send.json> <oskar_sim_interferometer.ini>') # Get logger. log = logging.getLogger() log.addHandler(logging.StreamHandler(stream=sys.stdout)) log.setLevel(logging.DEBUG) # Load SPEAD configuration from JSON file. with open(sys.argv[-2]) as f: spead_config = json.load(f) # Load the OSKAR settings INI file for the application. settings = oskar.SettingsTree('oskar_sim_interferometer', sys.argv[-1]) # Set up the SPEAD sender and run it (see method, above). sender = SpeadSender(log, spead_config, oskar_settings=settings) sender.run()
def make_vis_data(name, sky0, ra_deg, dec_deg, max_radius_deg, length_sec, num_time_steps, num_channels): """Generates visibility data.""" settings_dict = { 'simulator': { 'max_sources_per_chunk': '2000' }, 'observation': { 'length': str(length_sec), 'num_time_steps': str(num_time_steps), 'start_frequency_hz': '140e6', 'frequency_inc_hz': '1e6', 'num_channels': str(num_channels), 'phase_centre_ra_deg': str(ra_deg), 'phase_centre_dec_deg': str(dec_deg) }, 'telescope': { 'input_directory': 'SKA1-LOW_SKO-0000422_Rev3_38m.tm', 'pol_mode': 'Scalar' }, 'interferometer': { 'channel_bandwidth_hz': '100e3', 'time_average_sec': '1.0', 'max_time_samples_per_block': '4', 'ms_filename': 'sim_' + name + '.ms', 'oskar_vis_filename': 'sim_' + name + '.vis' } } settings = oskar.SettingsTree('oskar_sim_interferometer') settings.from_dict(settings_dict) settings['observation/start_time_utc'] = get_start_time(ra_deg, length_sec) sky = make_sky_model(sky0, settings, max_radius_deg) sky.save('sky_' + name + '.txt') sim = oskar.Interferometer(settings=settings) sim.set_sky_model(sky) sim.run()
def main(): try: from mpi4py import MPI except: pass logging.basicConfig(stream=sys.stdout, level=logging.DEBUG) parser = argparse.ArgumentParser(description='Run Averager.') parser.add_argument('--conf', dest='conf', required=True, help='spead configuration json file.') args = parser.parse_args() # Load SPEAD configuration from JSON file. with open(args.conf) as f: spead_config = json.load(f) # Load the OSKAR settings INI file for the application. settings = oskar.SettingsTree('oskar_sim_interferometer', spead_config["simulation"]) # Set up the SPEAD sender and run it (see method, above). sender = SpeadSender(spead_config, oskar_settings=settings) sender.run()
def main(): """Main function for OSKAR SPEAD receiver module.""" # Check command line arguments. if len(sys.argv) < 3: raise RuntimeError('Usage: python spead_recv_imager.py ' '<port> <oskar_imager.ini>') # Get logger. log = logging.getLogger() log.addHandler(logging.StreamHandler(stream=sys.stdout)) log.setLevel(logging.DEBUG) # Get socket port number. port = int(sys.argv[-2]) # Load the OSKAR settings INI file for the application. settings = oskar.SettingsTree('oskar_imager', sys.argv[-1]) # Check that illegal options are not selected. if settings['image/weighting'] == 'Uniform': raise RuntimeError( 'Cannot use uniform weighting in streaming mode ' 'as this requires baseline coordinates to be known in advance.') if settings['image/algorithm'] == 'W-projection' and \ settings['image/wproj/num_w_planes'] == '0': raise RuntimeError( 'Cannot auto-determine required number of W-projection planes ' 'as this requires baseline coordinates to be known in advance.') # Append the port number to the output file root path. key = 'image/root_path' settings.set_value(key, settings[key] + "_" + str(port), False) # Set up the SPEAD receiver and run it (see method, above). receiver = SpeadReceiver(log, port, oskar_settings=settings) receiver.run()
def main(): """Main function.""" # Name of the application to run, and a settings file for it. app1 = 'oskar_sim_interferometer' settings_path = '_temp_settings.ini' data_dir = os.environ["DATA_DIR"] src_dir = os.path.dirname(__file__) # Define some basic observation parameters. ra0_deg = 20.0 dec0_deg = -30.0 length_sec = 3600.0*8 # Define base settings dictionary. common_settings = { 'observation': { 'phase_centre_ra_deg': ra0_deg, 'phase_centre_dec_deg': dec0_deg, #'pointing_file': 'station_pointing.txt', 'start_time_utc': get_start_time(ra0_deg, length_sec), 'length': length_sec, 'num_time_steps': 600 }, 'telescope': { 'normalise_beams_at_phase_centre': False, 'aperture_array/element_pattern/normalise': False }, } # Define frequencies of interest (in MHz). freqs = [50] #freqs = [70] # Define telescope models to use, and associated overrides for them. telescopes = { #'stationresponse': { 'basefunctions': { 'telescope/input_directory': os.path.join(data_dir, 'skalowmini-coef.tm'), 'telescope/aperture_array/element_pattern/enable_numerical': True, 'telescope/aperture_array/element_pattern/swap_xy': True, 'telescope/aperture_array/array_pattern/enable': True, 'telescope/aperture_array/array_pattern/normalise': True }, } # Loop over telescope models. for tel, tel_params in telescopes.items(): # Copy the base settings diction.ary. current_settings = copy.deepcopy(common_settings) # Update current settings with telescope model parameters. current_settings.update(tel_params) # Loop over frequencies. for freq in freqs: # Create the settings file. open(settings_path, 'w').close() settings = oskar.SettingsTree(app1, settings_path) settings.from_dict(current_settings) # Update output root path and frequency. tel_root = re.sub(r'[^\w]', '', tel) # Strip symbols from tel. root_path = tel_root + ('_%03d_MHz' % freq) settings['observation/start_frequency_hz'] = 1e6 * freq settings['interferometer/ms_filename'] = 'testdata.ms' settings['sky/oskar_sky_model/file'] = os.path.join(src_dir, 'sky.osm') # Run the app with the settings file. subprocess.call([app1, settings_path])
def create_settings(app, settings_path, current_settings): open(settings_path, 'w').close() settings = oskar.SettingsTree(app, settings_path) settings.from_dict(current_settings) return settings
'phase_centre_dec_deg': '-30', 'num_time_steps': '24', 'start_time_utc': '01-01-2000 12:00:00.000', 'length': '12:00:00.000' }, 'telescope': { 'input_directory': 'telescope.tm' }, 'interferometer': { 'oskar_vis_filename': 'example.vis', 'ms_filename': '', 'channel_bandwidth_hz': '1e6', 'time_average_sec': '10' } } settings = oskar.SettingsTree('oskar_sim_interferometer') settings.from_dict(params) # Set the numerical precision to use. precision = 'single' if precision == 'single': settings['simulator/double_precision'] = 'false' # Create a sky model containing three sources from a numpy array. sky_data = numpy.array( [[20.0, -30.0, 1, 0, 0, 0, 100.0e6, -0.7, 0.0, 0, 0, 0], [20.0, -30.5, 3, 2, 2, 0, 100.0e6, -0.7, 0.0, 600, 50, 45], [20.5, -30.5, 3, 0, 0, 2, 100.0e6, -0.7, 0.0, 700, 10, -10]]) sky = oskar.Sky.from_array(sky_data, precision) # Pass precision here. # Set the sky model and run the simulation.