31 #include "muse_cplwrappers.h" 32 #include "muse_datacube.h" 33 #include "muse_pixtable.h" 34 #include "muse_resampling.h" 48 #define MUSE_WCS_KEYS "^C(TYPE|UNIT|RPIX|RVAL|DELT|SYER|RDER)|^CD[0-9]+_[0-9]+|" \ 49 "^WCSAXES$|^L[OA][NT]POLE$" 56 #define MUSE_WCS_DETIMAGE_EXTNAME "ASTROMETRY_DETECTION" 74 double xcenter, ycenter;
78 double crpix1, crpix2;
82 cpl_propertylist *wcs;
139 double *aRA,
double *aDEC)
142 double x = aWCS->cd11 * (aX - aWCS->crpix1) + aWCS->cd12 * (aY - aWCS->
crpix2),
143 y = aWCS->
cd22 * (aY - aWCS->
crpix2) + aWCS->cd21 * (aX - aWCS->crpix1);
145 double phi = atan2(x, -y),
146 theta = atan(CPL_MATH_DEG_RAD / sqrt(x*x + y*y));
149 double dec = aWCS->
crval2 / CPL_MATH_DEG_RAD;
150 *aRA = aWCS->crval1 + atan2(cos(theta) * sin(phi),
151 sin(theta) * cos(dec) + cos(theta) * sin(dec) * cos(phi))
153 *aDEC = asin(sin(theta) * sin(dec) - cos(theta) * cos(dec) * cos(phi))
177 double *aX,
double *aY)
182 double phi = atan2(-cos(aDEC) * sin(aRA - aWCS->crval1),
183 sin(aDEC) * cos(aWCS->
crval2)
184 - cos(aDEC) * sin(aWCS->
crval2) * cos(aRA - aWCS->crval1))
185 + 180 / CPL_MATH_DEG_RAD,
186 theta = asin(sin(aDEC) * sin(aWCS->
crval2)
187 + cos(aDEC) * cos(aWCS->
crval2) * cos(aRA - aWCS->crval1)),
188 R_theta = CPL_MATH_DEG_RAD / tan(theta);
190 double x = R_theta * sin(phi),
191 y = -R_theta * cos(phi);
193 *aX = (aWCS->
cd22 * x - aWCS->cd12 * y) / aWCS->
cddet + aWCS->crpix1;
194 *aY = (aWCS->cd11 * y - aWCS->cd21 * x) / aWCS->
cddet + aWCS->
crpix2;
217 double *aXOut,
double *aYOut)
220 *aXOut = aWCS->cd11 * (aX - aWCS->crpix1) + aWCS->cd12 * (aY - aWCS->
crpix2)
222 *aYOut = aWCS->
cd22 * (aY - aWCS->
crpix2) + aWCS->cd21 * (aX - aWCS->crpix1)
246 double *aXOut,
double *aYOut)
249 *aXOut = (aWCS->
cd22 * (aX - aWCS->crval1) - aWCS->cd12 * (aY - aWCS->
crval2))
250 / aWCS->
cddet + aWCS->crpix1;
251 *aYOut = (aWCS->cd11 * (aY - aWCS->
crval2) - aWCS->cd21 * (aX - aWCS->crval1))
268 cpl_propertylist *
muse_wcs_apply_cd(
const cpl_propertylist *,
const cpl_propertylist *);
Structure definition of a MUSE datacube.
cpl_error_code muse_wcs_get_scales(cpl_propertylist *, double *, double *)
Compute the spatial scales (in degrees) from the FITS header WCS.
cpl_error_code muse_wcs_pixel_from_projplane(cpl_propertylist *, double, double, double *, double *)
Convert from projection plane coordinates to pixel coordinates.
A structure containing a spatial two-axis WCS.
static void muse_wcs_pixel_from_projplane_fast(muse_wcs *aWCS, double aX, double aY, double *aXOut, double *aYOut)
Convert from projection plane coordinates to pixel coordinates.
cpl_error_code muse_wcs_projplane_from_celestial(cpl_propertylist *, double, double, double *, double *)
Convert from celestial spherical coordinates to projection plane coordinates.
WCS object to store data needed while computing the astrometric solution.
Structure definition of MUSE three extension FITS file.
cpl_error_code muse_wcs_project_tan(muse_pixtable *, const cpl_propertylist *)
Carry out a gnomonic projection of a pixel table into native spherical coordinates.
cpl_table * muse_wcs_centroid_stars(muse_image *, float, muse_wcs_centroid_type)
Detect and centroid stars on an image of an astrometric exposure.
const muse_cpltable_def muse_wcs_reference_def[]
Definition of the table structure for the astrometric reference sources.
muse_wcs * muse_wcs_new(cpl_propertylist *)
Create a new WCS structure from a given FITS header.
muse_wcs_centroid_type
Type of centroiding algorithm to use.
Structure definition of MUSE pixel table.
cpl_error_code muse_wcs_celestial_from_pixel(cpl_propertylist *, double, double, double *, double *)
Convert from pixel coordinates to celestial spherical coordinates.
static void muse_wcs_pixel_from_celestial_fast(muse_wcs *aWCS, double aRA, double aDEC, double *aX, double *aY)
Convert from celestial spherical coordinates to pixel coordinates.
static void muse_wcs_celestial_from_pixel_fast(muse_wcs *aWCS, double aX, double aY, double *aRA, double *aDEC)
Convert from pixel coordinates to celestial spherical coordinates.
cpl_error_code muse_wcs_solve(muse_wcs_object *, cpl_table *, float, float, int, float)
Find the world coordinate solution for a given field using coordinates of detected sources and coordi...
muse_wcs_object * muse_wcs_object_new(void)
Allocate memory for a new muse_wcs_object object.
cpl_error_code muse_wcs_projplane_from_pixel(cpl_propertylist *, double, double, double *, double *)
Convert from pixel coordinates to projection plane coordinates.
cpl_error_code muse_wcs_pixel_from_celestial(cpl_propertylist *, double, double, double *, double *)
Convert from celestial spherical coordinates to pixel coordinates.
cpl_error_code muse_wcs_optimize_solution(muse_wcs_object *, float, muse_wcs_centroid_type, cpl_table *, float, float, int, float)
Find an optimal astrometry solution given a detection image.
static void muse_wcs_projplane_from_pixel_fast(muse_wcs *aWCS, double aX, double aY, double *aXOut, double *aYOut)
Convert from pixel coordinates to projection plane coordinates.
cpl_propertylist * muse_wcs_apply_cd(const cpl_propertylist *, const cpl_propertylist *)
Apply the CDi_j matrix of an astrometric solution to an observation.
Definition of a cpl table structure.
cpl_error_code muse_wcs_get_angles(cpl_propertylist *, double *, double *)
Compute the rotation angles (in degrees) from the FITS header WCS.
void muse_wcs_object_delete(muse_wcs_object *)
Deallocate memory associated to a muse_wcs_object.
cpl_error_code muse_wcs_position_celestial(muse_pixtable *, double, double)
Convert native to celestial spherical coordinates in a pixel table.
cpl_error_code muse_wcs_locate_sources(muse_pixtable *, float, muse_wcs_centroid_type, muse_wcs_object *)
Determine the centers of stars on an astrometric exposure.
cpl_propertylist * muse_wcs_create_default(void)
Create FITS headers containing a default (relative) WCS.