static PyObject* create_copy(PyObject* self, PyObject* args) { oskar_Sky *h = 0, *t = 0; PyObject* capsule = 0; int status = 0; if (!PyArg_ParseTuple(args, "O", &capsule)) return 0; if (!(h = get_handle(capsule))) return 0; t = oskar_sky_create_copy(h, OSKAR_CPU, &status); /* Check for errors. */ if (status || !t) { PyErr_Format(PyExc_RuntimeError, "oskar_sky_create_copy() failed with code %d (%s).", status, oskar_get_error_string(status)); oskar_sky_free(t, &status); return 0; } capsule = PyCapsule_New((void*)t, name, (PyCapsule_Destructor)sky_free); return Py_BuildValue("N", capsule); /* Don't increment refcount. */ }
void oskar_evaluate_jones_Z(oskar_Jones* Z, const oskar_Sky* sky, const oskar_Telescope* telescope, const oskar_SettingsIonosphere* settings, double gast, double frequency_hz, oskar_WorkJonesZ* work, int* status) { int i, num_sources, num_stations; /* Station position in ECEF frame */ double station_x, station_y, station_z, wavelength; oskar_Mem *Z_station; int type; oskar_Sky* sky_cpu; /* Copy of the sky model on the CPU */ /* Check if safe to proceed. */ if (*status) return; /* Check data types. */ type = oskar_sky_precision(sky); if (oskar_telescope_precision(telescope) != type || oskar_jones_type(Z) != (type | OSKAR_COMPLEX) || oskar_work_jones_z_type(work) != type) { *status = OSKAR_ERR_BAD_DATA_TYPE; return; } /* For now, this function requires data is on the CPU .. check this. */ /* Resize the work array (if needed) */ num_stations = oskar_telescope_num_stations(telescope); num_sources = oskar_sky_num_sources(sky); oskar_work_jones_z_resize(work, num_sources, status); /* Copy the sky model to the CPU. */ sky_cpu = oskar_sky_create_copy(sky, OSKAR_CPU, status); Z_station = oskar_mem_create_alias(0, 0, 0, status); wavelength = 299792458.0 / frequency_hz; /* Evaluate the ionospheric phase screen for each station at each * source pierce point. */ for (i = 0; i < num_stations; ++i) { double last, lon, lat; const oskar_Station* station; station = oskar_telescope_station_const(telescope, i); lon = oskar_station_lon_rad(station); lat = oskar_station_lat_rad(station); last = gast + lon; /* Evaluate horizontal x,y,z source positions (for which to evaluate * pierce points) */ oskar_convert_relative_directions_to_enu_directions( work->hor_x, work->hor_y, work->hor_z, num_sources, oskar_sky_l_const(sky_cpu), oskar_sky_m_const(sky_cpu), oskar_sky_n_const(sky_cpu), last - oskar_sky_reference_ra_rad(sky_cpu), oskar_sky_reference_dec_rad(sky_cpu), lat, status); /* Obtain station coordinates in the ECEF frame. */ evaluate_station_ECEF_coords(&station_x, &station_y, &station_z, i, telescope); /* Obtain the pierce points. */ /* FIXME(BM) this is current hard-coded to TID height screen 0 * this fix is only needed to support multiple screen heights. */ oskar_evaluate_pierce_points(work->pp_lon, work->pp_lat, work->pp_rel_path, station_x, station_y, station_z, settings->TID[0].height_km * 1000., num_sources, work->hor_x, work->hor_y, work->hor_z, status); /* Evaluate TEC values for the pierce points */ oskar_evaluate_TEC(work, num_sources, settings, gast, status); /* Get a pointer to the Jones matrices for the station */ oskar_jones_get_station_pointer(Z_station, Z, i, status); /* Populate the Jones matrix with ionospheric phase */ evaluate_jones_Z_station(Z_station, wavelength, work->total_TEC, work->hor_z, settings->min_elevation, num_sources, status); } oskar_sky_free(sky_cpu, status); oskar_mem_free(Z_station, status); }