static void compute_relative_directions(oskar_Mem* l, oskar_Mem* m, oskar_Mem* n, int np, const oskar_Mem* x, const oskar_Mem* y, const oskar_Mem* z, const oskar_Station* station, double GAST, int* status) { double ha0, dec0, lat; int pointing_coord_type; if (*status) return; /* Resize work arrays if needed */ if ((int)oskar_mem_length(l) < np) oskar_mem_realloc(l, np, status); if ((int)oskar_mem_length(m) < np) oskar_mem_realloc(m, np, status); if ((int)oskar_mem_length(n) < np) oskar_mem_realloc(n, np, status); if (*status) return; /* Obtain ra0, dec0 of phase centre */ lat = oskar_station_lat_rad(station); pointing_coord_type = oskar_station_beam_coord_type(station); if (pointing_coord_type == OSKAR_SPHERICAL_TYPE_EQUATORIAL) { double ra0; ra0 = oskar_station_beam_lon_rad(station); ha0 = (GAST + oskar_station_lon_rad(station)) - ra0; dec0 = oskar_station_beam_lat_rad(station); } else if (pointing_coord_type == OSKAR_SPHERICAL_TYPE_AZEL) { /* TODO convert from az0, el0 to ha0, dec0 */ ha0 = 0.0; dec0 = 0.0; *status = OSKAR_FAIL; return; } else { *status = OSKAR_ERR_SETTINGS_TELESCOPE; return; } /* Convert from ENU to phase-centre-relative directions. */ oskar_convert_enu_directions_to_relative_directions( l, m, n, np, x, y, z, ha0, dec0, lat, status); }
static void compute_relative_directions(oskar_Mem* l, oskar_Mem* m, oskar_Mem* n, int np, const oskar_Mem* x, const oskar_Mem* y, const oskar_Mem* z, const oskar_Station* station, double GAST, int* status) { double ha0, dec0; oskar_mem_ensure(l, np, status); oskar_mem_ensure(m, np, status); oskar_mem_ensure(n, np, status); if (*status) return; /* Obtain ra0, dec0 of phase centre */ const double lat = oskar_station_lat_rad(station); const int pointing_coord_type = oskar_station_beam_coord_type(station); if (pointing_coord_type == OSKAR_SPHERICAL_TYPE_EQUATORIAL) { const double ra0 = oskar_station_beam_lon_rad(station); ha0 = (GAST + oskar_station_lon_rad(station)) - ra0; dec0 = oskar_station_beam_lat_rad(station); } else if (pointing_coord_type == OSKAR_SPHERICAL_TYPE_AZEL) { /* TODO convert from az0, el0 to ha0, dec0 */ ha0 = 0.0; dec0 = 0.0; *status = OSKAR_ERR_FUNCTION_NOT_AVAILABLE; return; } else { *status = OSKAR_ERR_SETTINGS_TELESCOPE; return; } oskar_convert_enu_directions_to_relative_directions( 0, np, x, y, z, ha0, dec0, lat, 0, l, m, n, status); }