31 #include "muse_cplwrappers.h"
32 #include "muse_datacube.h"
33 #include "muse_pixtable.h"
34 #include "muse_resampling.h"
41 #define MUSE_WCS_KEYS "^C(TYPE|UNIT|RPIX|RVAL|DELT|SYER)|^CD[0-9]+_[0-9]+|" \
42 "^WCSAXES$|^L[OA][NT]POLE$"
62 double xcenter, ycenter;
66 double crpix1, crpix2;
70 cpl_propertylist *wcs;
96 double cd11, cd12, cd21,
cd22;
127 double *aRA,
double *aDEC)
130 double x = aWCS->cd11 * (aX - aWCS->crpix1) + aWCS->cd12 * (aY - aWCS->
crpix2),
131 y = aWCS->
cd22 * (aY - aWCS->
crpix2) + aWCS->cd21 * (aX - aWCS->crpix1);
133 double phi = atan2(x, -y),
134 theta = atan(CPL_MATH_DEG_RAD / sqrt(x*x + y*y));
137 double dec = aWCS->
crval2 / CPL_MATH_DEG_RAD;
138 *aRA = aWCS->crval1 + atan2(cos(theta) * sin(phi),
139 sin(theta) * cos(dec) + cos(theta) * sin(dec) * cos(phi))
141 *aDEC = asin(sin(theta) * sin(dec) - cos(theta) * cos(dec) * cos(phi))
165 double *aX,
double *aY)
170 double phi = atan2(-cos(aDEC) * sin(aRA - aWCS->crval1),
171 sin(aDEC) * cos(aWCS->
crval2)
172 - cos(aDEC) * sin(aWCS->
crval2) * cos(aRA - aWCS->crval1))
173 + 180 / CPL_MATH_DEG_RAD,
174 theta = asin(sin(aDEC) * sin(aWCS->
crval2)
175 + cos(aDEC) * cos(aWCS->
crval2) * cos(aRA - aWCS->crval1)),
176 R_theta = CPL_MATH_DEG_RAD / tan(theta);
178 double x = R_theta * sin(phi),
179 y = -R_theta * cos(phi);
181 *aX = (aWCS->
cd22 * x - aWCS->cd12 * y) / aWCS->
cddet + aWCS->crpix1;
182 *aY = (aWCS->cd11 * y - aWCS->cd21 * x) / aWCS->
cddet + aWCS->
crpix2;
205 double *aXOut,
double *aYOut)
208 *aXOut = aWCS->cd11 * (aX - aWCS->crpix1) + aWCS->cd12 * (aY - aWCS->
crpix2)
210 *aYOut = aWCS->
cd22 * (aY - aWCS->
crpix2) + aWCS->cd21 * (aX - aWCS->crpix1)
234 double *aXOut,
double *aYOut)
237 *aXOut = (aWCS->
cd22 * (aX - aWCS->crval1) - aWCS->cd12 * (aY - aWCS->
crval2))
238 / aWCS->
cddet + aWCS->crpix1;
239 *aYOut = (aWCS->cd11 * (aY - aWCS->
crval2) - aWCS->cd21 * (aX - aWCS->crval1))
254 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.
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.
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.
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.