File: flames_ordselect.c

package info (click to toggle)
cpl-plugin-uves 6.1.3+dfsg-2
  • links: PTS, VCS
  • area: main
  • in suites: bullseye, sid
  • size: 23,128 kB
  • sloc: ansic: 171,056; sh: 4,359; python: 3,002; makefile: 1,322
file content (169 lines) | stat: -rw-r--r-- 7,772 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
/*===========================================================================
  Copyright (C) 2001 European Southern Observatory (ESO)
 
  This program is free software; you can redistribute it and/or 
  modify it under the terms of the GNU General Public License as 
  published by the Free Software Foundation; either version 2 of 
  the License, or (at your option) any later version.
 
  This program is distributed in the hope that it will be useful,
  but WITHOUT ANY WARRANTY; without even the implied warranty of
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  GNU General Public License for more details.
 
  You should have received a copy of the GNU General Public 
  License along with this program; if not, write to the Free 
  Software Foundation, Inc., 675 Massachusetss Ave, Cambridge, 
  MA 02139, USA.
 
  Corresponding concerning ESO-MIDAS should be addressed as follows:
  Internet e-mail: midas@eso.org
  Postal address: European Southern Observatory
  Data Management Division 
  Karl-Schwarzschild-Strasse 2
  D 85748 Garching bei Muenchen 
  GERMANY
  ===========================================================================*/
/* Program  : ordselect.c                                                  */
/* Author   : G. Mulas  -  ITAL_FLAMES Consortium                          */
/* Date     :                                                              */
/*                                                                         */
/* Purpose  : Missing                                                      */
/*                                                                         */
/*                                                                         */
/* Input:  see interface                                                   */ 
/*                                                                      */
/* Output:                                                              */
/*                                                                         */
/* DRS Functions called:                                                   */
/* none                                                                    */ 
/*                                                                         */ 
/* Pseudocode:                                                             */
/* Missing                                                                 */ 
/*                                                                         */ 
/* Version  :                                                              */
/* Last modification date: 2002/08/05                                      */
/* Who     When        Why                Where                            */
/* AMo     02-08-05   Add header         header                            */
/*-------------------------------------------------------------------------*/
#ifdef HAVE_CONFIG_H
#  include <config.h>
#endif



/* MIDAS include files */
#include <flames_midas_def.h>
/* FLAMES-UVES include files */ 
#include <flames_ordselect.h>
#include <flames_uves.h>
#include <uves_msg.h>

flames_err 
ordselect(
                orderpos *Order,
                flames_frame *ScienceFrame,
                allflats *Shifted_FF,
                int32_t *ordend)
{

    int32_t j=0;
    int32_t myorder=0;
    int32_t n=0;
    int32_t lowlimglobal=0;
    int32_t highlimglobal=0;
    int32_t lowlimthis=0;
    int32_t highlimthis=0;
    char overlap=0;

    frame_mask *fmvecbuf1=0;
    int32_t *lvecbuf1=0;
    int32_t *lvecbuf2=0;
    int32_t myorderifibreoffset=0;
    int32_t ifibre=0;
    int32_t myorderifibrejindex=0;

    fmvecbuf1 = Shifted_FF->goodfibres[0][0];
    lvecbuf1 = Shifted_FF->lowfibrebounds[0][0];
    lvecbuf2 = Shifted_FF->highfibrebounds[0][0];

    for (j=0; j<=(ScienceFrame->subcols-1); j++) {
        /* find the upper and lower limits of the set of slices to be
       extracted at this x and order */
        myorder = *ordend-Order->firstorder;
        myorderifibreoffset = myorder*Shifted_FF->maxfibres;
        for (n=0; (n<=(ScienceFrame->num_lit_fibres-1)) &&
        fmvecbuf1[myorderifibrejindex=
                        ((myorderifibreoffset+
                                        (ifibre=ScienceFrame->ind_lit_fibres[n]))*
                                        ScienceFrame->subcols)+j]==BADSLICE;
        n++);
        if (n<=(ScienceFrame->num_lit_fibres-1)) {
            /* I found the first extractable one */
            lowlimglobal = lvecbuf1[myorderifibrejindex];
            highlimglobal = lvecbuf2[myorderifibrejindex];
            /* find any other extractable slices */
            for (n++; n<=(ScienceFrame->num_lit_fibres-1); n++) {
                ifibre=ScienceFrame->ind_lit_fibres[n];
                myorderifibrejindex=
                                ((myorderifibreoffset+ifibre)*ScienceFrame->subcols)+j;
                if (fmvecbuf1[myorderifibrejindex]!=BADSLICE) {
                    if (lowlimglobal > lvecbuf1[myorderifibrejindex])
                        lowlimglobal = lvecbuf1[myorderifibrejindex];
                    if (highlimglobal < lvecbuf2[myorderifibrejindex])
                        highlimglobal = lvecbuf2[myorderifibrejindex];
                }
            }

            /* are there any more overlapping orders? */
            overlap=1;
            while (*ordend<Order->lastorder && overlap==1) {
                overlap=0;
                myorder++;
                myorderifibreoffset = myorder*Shifted_FF->maxfibres;
                /* find the upper and lower limits of the set of slices to be
	   extracted at this x and order */
                for (n=0; (n<=(ScienceFrame->num_lit_fibres-1)) &&
                fmvecbuf1[myorderifibrejindex=
                                ((myorderifibreoffset+
                                                (ifibre=ScienceFrame->ind_lit_fibres[n]))*
                                                ScienceFrame->subcols)+j]==BADSLICE;
                n++);
                if (n<=(ScienceFrame->num_lit_fibres-1)) {
                    /* I found the first extractable one */
                    lowlimthis = lvecbuf1[myorderifibrejindex];
                    highlimthis = lvecbuf2[myorderifibrejindex];
                    for (n++; n<=(ScienceFrame->num_lit_fibres-1); n++) {
                        ifibre=ScienceFrame->ind_lit_fibres[n];
                        myorderifibrejindex=
                                        ((myorderifibreoffset+ifibre)*ScienceFrame->subcols)+j;
                        if (fmvecbuf1[myorderifibrejindex]!=BADSLICE) {
                            if (lowlimthis > lvecbuf1[myorderifibrejindex])
                                lowlimthis = lvecbuf1[myorderifibrejindex];
                            if (highlimthis < lvecbuf2[myorderifibrejindex])
                                highlimthis = lvecbuf2[myorderifibrejindex];
                        }
                    }
                    /* do the new orders overlap the global ones? */

                    /*
          uves_msg_warning("low=%d high=%d lowlimglobal=%d highlimglobal=%d",
			    lowlimthis,highlimthis,lowlimglobal,highlimglobal);
                     */
                    if ((lowlimthis>=lowlimglobal && lowlimthis<=highlimglobal) ||
                                    (highlimthis>=lowlimglobal && highlimthis<=highlimglobal)) {
                        /* yes, they do */
                        (*ordend)++;
                        overlap=1;
                        if (lowlimthis<lowlimglobal) lowlimglobal=lowlimthis;
                        if (highlimthis>highlimglobal) highlimglobal=highlimthis;
                    }
                }
            }
        }
    }

    return NOERR;

}