コード例 #1
0
ファイル: trace_conf.c プロジェクト: nfourmanoit/TIPS
/**
 * @param filename filename of the configuration file
 * @param beamID beamID of the beam of interest (A=0, B=1, etc...)
 *
 *   @return res The value of the y-offset of beamID computed at detector pixel p.
 */
float get_trace_yoff_at_pos(char *filename, int beamID, d_point p)
  {
    gsl_vector *v;
    float n, c, res;
    int i, j, k;

    v = get_beam_trace_yoff(filename, beamID);
    n = 0.5 * (-1.0 + sqrt(1 + 8 * v->size));
    if ((floor(n) - n) != 0)
      {
        aXe_message(aXe_M_FATAL, __FILE__, __LINE__,
        "get_trace_yoff_at_pos: "
        "Beam %d in %s does not contain a correct number of entries (i.e. "
        "1,3,6,10,15...,n^2/2+n/2", beamID, filename);
      }

    i = 0;
    res = 0;
    for (j = 0; j < n; j++)
      {
        for (k = 0; k < (j + 1); k++)
          {
            c = gsl_vector_get(v, i);
            res = res + c * pow(p.x, (j - k)) * pow(p.y, k);
            i++;
          }
      }

    return res;
  }
コード例 #2
0
/**
 * The function computes and stores at the according position
 * the xy offsets of a direct image. This is only important
 * in the fluxcube emission model, since the image coordinates
 * in fluxcubes are 'filter' coordinates and do not take into
 * account the offsets introduce by the grism.
 * For each object and beam those offsets are evaluated
 * and stored in the direct object structure.
 *
 * @param dirlist   - the direct object
 * @param CONF_file - the new coordinate point
 *
 */
void fill_xy_offsets(dirobject **dirlist, char CONF_file[])
{
  aperture_conf   *conf;

  gsl_vector *x_coeffs;
  gsl_vector *y_coeffs;

  d_point m_point;

  double xoffs, yoffs;

  int beamID=0;
  int i;

  // load the configuration file
  conf = get_aperture_descriptor (CONF_file);

  // go over each beam defined in the configuration
  // file
  for (beamID=0; beamID < conf->nbeams; beamID++)
    {

      // determine the coeeficients for the offsets
      // in x and in y
      x_coeffs = get_beam_trace_xoff (CONF_file, beamID);
      y_coeffs = get_beam_trace_yoff (CONF_file, beamID);

      // go over each direct object
      i=0;
      while (dirlist[i] !=NULL)
        {

          // get the mean direct object position
          m_point = get_dirobject_meanpos(dirlist[i]);

          // evaluate the coefficients for the 2D variable offsets
          // at the mean position
          dirlist[i]->xy_off[beamID].x = eval_trace_off_at_pos (x_coeffs, m_point, beamID);
          dirlist[i]->xy_off[beamID].y = eval_trace_off_at_pos (y_coeffs, m_point, beamID);

          // iterate the counter
          i++;
        }

      // free the vectors for the coefficients
      gsl_vector_free(x_coeffs);
      gsl_vector_free(y_coeffs);
    }
        // release memory
        free_aperture_conf(conf);
}