34 #include "muse_rvcorrect.h" 36 #include "muse_astro.h" 51 const char *muse_rvcorrect_typestring[] = {
75 cpl_ensure(aTypeString, CPL_ERROR_NULL_INPUT, MUSE_RVCORRECT_UNKNOWN);
76 muse_rvcorrect_type type = MUSE_RVCORRECT_NONE;
77 if (!strncmp(aTypeString, muse_rvcorrect_typestring[MUSE_RVCORRECT_BARY],
78 strlen(muse_rvcorrect_typestring[MUSE_RVCORRECT_BARY]) + 1)) {
79 type = MUSE_RVCORRECT_BARY;
80 }
else if (!strncmp(aTypeString, muse_rvcorrect_typestring[MUSE_RVCORRECT_HELIO],
81 strlen(muse_rvcorrect_typestring[MUSE_RVCORRECT_HELIO]) + 1)) {
82 type = MUSE_RVCORRECT_HELIO;
83 }
else if (!strncmp(aTypeString, muse_rvcorrect_typestring[MUSE_RVCORRECT_GEO],
84 strlen(muse_rvcorrect_typestring[MUSE_RVCORRECT_GEO]) + 1)) {
85 type = MUSE_RVCORRECT_GEO;
86 }
else if (strncmp(aTypeString, muse_rvcorrect_typestring[MUSE_RVCORRECT_NONE],
87 strlen(muse_rvcorrect_typestring[MUSE_RVCORRECT_NONE]) + 1)) {
88 cpl_error_set_message(__func__, CPL_ERROR_ILLEGAL_INPUT,
"Unknown type of " 89 "radial velocity correction requested:" " \"%s\"",
91 type = MUSE_RVCORRECT_UNKNOWN;
122 cpl_ensure_code(aPixtable && aPixtable->
table && aPixtable->
header,
123 CPL_ERROR_NULL_INPUT);
124 if (aType == MUSE_RVCORRECT_NONE) {
125 return CPL_ERROR_NONE;
130 cpl_msg_info(__func__,
"pixel table already corrected: skipping radial " 131 "velocity correction");
132 return CPL_ERROR_NONE;
135 cpl_errorstate state = cpl_errorstate_get();
137 if (!cpl_errorstate_is_equal(state)) {
138 return cpl_error_set_message(__func__, cpl_error_get_code(),
"Computing " 139 "radial velocity correction failed: %s",
140 cpl_error_get_message());
142 double rvoffset = 0.;
143 if (aType == MUSE_RVCORRECT_BARY) {
144 rvoffset = rvcorr.
bary;
145 }
else if (aType == MUSE_RVCORRECT_HELIO) {
146 rvoffset = rvcorr.
helio;
147 }
else if (aType == MUSE_RVCORRECT_GEO) {
148 rvoffset = rvcorr.
geo;
150 return cpl_error_set_message(__func__, CPL_ERROR_ILLEGAL_INPUT,
"Unknown " 151 "type of radial velocity correction, no " 152 "correction performed!");
154 cpl_msg_info(__func__,
"Correcting data for %scentric radial velocity of %.2f" 155 " km/s", muse_rvcorrect_typestring[aType], rvoffset);
158 const double cinv = 1000. / CPL_PHYS_C;
161 #pragma omp parallel for default(none) \ 162 shared(lbda, nrow, rvoffset) 163 for (irow = 0; irow < nrow; irow++) {
165 lbda[irow] *= sqrt((1. + rvoffset * cinv) / (1. - rvoffset * cinv));
171 char *comment = cpl_sprintf(MUSE_HDR_PT_RVCORR_C,
172 muse_rvcorrect_typestring[aType]);
175 return CPL_ERROR_NONE;
cpl_error_code muse_rvcorrect(muse_pixtable *aPixtable, muse_rvcorrect_type aType)
Correct the wavelengths of all pixels of a given pixel table for radial velocity shift.
cpl_size muse_pixtable_get_nrow(const muse_pixtable *aPixtable)
get the number of rows within the pixel table
muse_rvcorrect_type muse_rvcorrect_select_type(const char *aTypeString)
Select type of radial velocity correction to be done from type string.
Structure to store bary-, helio-, and geocentric velocity corrections.
cpl_table * table
The pixel table.
Structure definition of MUSE pixel table.
muse_astro_rvcorr muse_astro_rvcorr_compute(const cpl_propertylist *aHeader)
Compute radial velocity corrections given the header of an exposure.
#define MUSE_PIXTABLE_LAMBDA
#define MUSE_HDR_PT_RVCORR
cpl_propertylist * header
The FITS header.