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;
118 cpl_ensure_code(aPixtable && aPixtable->
table && aPixtable->
header,
119 CPL_ERROR_NULL_INPUT);
120 if (aType == MUSE_RVCORRECT_NONE) {
121 return CPL_ERROR_NONE;
124 cpl_errorstate state = cpl_errorstate_get();
126 if (!cpl_errorstate_is_equal(state)) {
127 return cpl_error_set_message(__func__, cpl_error_get_code(),
"Computing "
128 "radial velocity correction failed: %s",
129 cpl_error_get_message());
131 double rvoffset = 0.;
132 if (aType == MUSE_RVCORRECT_BARY) {
133 rvoffset = rvcorr.
bary;
134 }
else if (aType == MUSE_RVCORRECT_HELIO) {
135 rvoffset = rvcorr.
helio;
136 }
else if (aType == MUSE_RVCORRECT_GEO) {
137 rvoffset = rvcorr.
geo;
139 return cpl_error_set_message(__func__, CPL_ERROR_ILLEGAL_INPUT,
"Unknown "
140 "type of radial velocity correction, no "
141 "correction performed!");
143 cpl_msg_info(__func__,
"Correcting data for %scentric radial velocity of %.2f"
144 " km/s", muse_rvcorrect_typestring[aType], rvoffset);
147 const double cinv = 1000. / CPL_PHYS_C;
148 float *lbda = cpl_table_get_data_float(aPixtable->
table, MUSE_PIXTABLE_LAMBDA);
150 #pragma omp parallel for default(none) \
151 shared(lbda, nrow, rvoffset)
152 for (irow = 0; irow < nrow; irow++) {
154 lbda[irow] *= sqrt((1. + rvoffset * cinv) / (1. - rvoffset * cinv));
160 char *comment = cpl_sprintf(MUSE_HDR_PT_RVCORR_C,
161 muse_rvcorrect_typestring[aType]);
164 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_HDR_PT_RVCORR
cpl_propertylist * header
The FITS header.