~ubuntu-branches/debian/jessie/eso-midas/jessie

« back to all changes in this revision

Viewing changes to stdred/feros/src/ypos.c

  • Committer: Package Import Robot
  • Author(s): Ole Streicher
  • Date: 2014-04-22 14:44:58 UTC
  • Revision ID: package-import@ubuntu.com-20140422144458-okiwi1assxkkiz39
Tags: upstream-13.09pl1.2+dfsg
ImportĀ upstreamĀ versionĀ 13.09pl1.2+dfsg

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 
 
3
  Otmar Stahl
 
4
 
 
5
  ypos.c
 
6
 
 
7
  Compute yabs from yabs/order (in mm!) for rotation of CCD
 
8
  
 
9
  Input wavelemgth table needs two (R*4) columns:
 
10
  
 
11
  :XABS and :Y
 
12
  
 
13
  Parameters:
 
14
  
 
15
  1) Input / output wavelength table (line.tbl)
 
16
  2) Input table with coefficients of y-fit
 
17
  
 
18
  Algorithm:
 
19
  
 
20
  Compute yabs for (xabs/order)
 
21
 
 
22
.VERSION
 
23
 051014         last modif
 
24
 
 
25
*/
 
26
 
 
27
/* system includes */
 
28
 
 
29
#include <stdio.h>
 
30
 
 
31
/* general Midas includes */
 
32
 
 
33
#include <stdlib.h>
 
34
 
 
35
#include <tbldef.h>
 
36
#include <midas_def.h>
 
37
#include <ok.h>
 
38
 
 
39
/* FEROS specific includes */
 
40
 
 
41
#include <proto_nrutil.h>
 
42
#include <proto_mutil.h>
 
43
 
 
44
int main ()
 
45
{
 
46
 
 
47
  char wlc_table[60], pos_table[60], line[80];
 
48
 
 
49
  int i, j, iav, inull, tid1, tid2, ncol, nrow, nsort, acol, arow;
 
50
  int icol[3], null[2], select, nlast, nfirst, fit_deg;
 
51
  int dunit, dnul;
 
52
 
 
53
  float rnull, col[2], xabs, yabs;
 
54
 
 
55
  double *ad, dnull;
 
56
  
 
57
  SCSPRO ("ypos");
 
58
  
 
59
  TCMNUL(&inull,&rnull,&dnull);
 
60
  
 
61
  SCKGETC ("IN_A", 1, 60, &iav, wlc_table);
 
62
  SCKGETC ("IN_B", 1, 60, &iav, pos_table);
 
63
 
 
64
  TCTOPN (wlc_table, F_IO_MODE, &tid1);
 
65
 
 
66
  TCTOPN (pos_table, F_D_MODE, &tid2); 
 
67
  SCDRDI(tid2, "FIRSTORD", 1, 1, &iav, &nfirst, &dunit, &dnul);  
 
68
  SCDRDI(tid2, "ECHORD", 1, 1, &iav, &nlast, &dunit, &dnul); 
 
69
  SCDRDI(tid2, "FITORD", 1, 1, &iav, &fit_deg, &dunit, &dnul); 
 
70
 
 
71
  TCIGET (tid1, &ncol, &nrow, &nsort, &acol, &arow);
 
72
 
 
73
  /* columns :X and :Y must exist! */
 
74
 
 
75
  ad = dvector (1, fit_deg);
 
76
 
 
77
  TCCSER (tid1, ":X", &icol[0]);
 
78
  TCCSER (tid1, ":Y", &icol[1]);
 
79
  TCCSER(tid1, ":YABS", &icol[2]);
 
80
  if(icol[2] == -1)
 
81
    {
 
82
      TCCINI(tid1, D_R4_FORMAT, 1, "F8.4", "", ":YABS", &icol[2]);
 
83
      sprintf(line, "column YABS created %d",icol[2]);
 
84
      SCTPUT(line);
 
85
    }
 
86
  else
 
87
    {
 
88
      sprintf(line, "column YABS found");
 
89
      SCTPUT(line);
 
90
    }
 
91
 
 
92
  /* read input table */
 
93
 
 
94
  for (i = 1; i <= nrow; i++)
 
95
    {
 
96
      TCSGET(tid1, i, &select);
 
97
      if (select) {
 
98
        TCRRDR (tid1, i, 2, icol, col, null);
 
99
        xabs =  col[0];
 
100
        j =  (int) col[1];
 
101
        
 
102
        if(j>0) 
 
103
          {
 
104
            sprintf(line, "FIT%04i", nlast - (j - 1));
 
105
            
 
106
            SCDRDD(tid2, line, 1, fit_deg, &iav, &ad[1], &dunit, &dnul);
 
107
            yabs =  eval_dpoly (xabs, ad, fit_deg);
 
108
            TCEWRR(tid1, i, icol[2], &yabs);
 
109
          }
 
110
      }
 
111
    }
 
112
  TCTCLO (tid1);
 
113
  TCTCLO (tid2);
 
114
 
 
115
  /* release memory and exit */
 
116
 
 
117
  free_dvector(ad, 1, fit_deg);
 
118
  SCSEPI ();
 
119
  exit(0);
 
120
}