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

« back to all changes in this revision

Viewing changes to gui/XIrspec/src/midasutil.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
  Copyright (C) 1993-2009 European Southern Observatory (ESO)
 
3
 
 
4
  This program is free software; you can redistribute it and/or 
 
5
  modify it under the terms of the GNU General Public License as 
 
6
  published by the Free Software Foundation; either version 2 of 
 
7
  the License, or (at your option) any later version.
 
8
 
 
9
  This program is distributed in the hope that it will be useful,
 
10
  but WITHOUT ANY WARRANTY; without even the implied warranty of
 
11
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
12
  GNU General Public License for more details.
 
13
 
 
14
  You should have received a copy of the GNU General Public 
 
15
  License along with this program; if not, write to the Free 
 
16
  Software Foundation, Inc., 675 Massachusetss Ave, Cambridge, 
 
17
  MA 02139, USA.
 
18
 
 
19
  Corresponding concerning ESO-MIDAS should be addressed as follows:
 
20
        Internet e-mail: midas@eso.org
 
21
        Postal address: European Southern Observatory
 
22
                        Data Management Division 
 
23
                        Karl-Schwarzschild-Strasse 2
 
24
                        D 85748 Garching bei Muenchen 
 
25
                        GERMANY
 
26
===========================================================================*/
 
27
 
 
28
/* +++++++++++++++++++++++++++++++++++++++++++++++++++++++ */
 
29
/* .IDENT       midasutil.c                                */
 
30
/* .AUTHORS     Cristian Levin   (ESO/La Silla)            */
 
31
/* .KEYWORDS    XIrspec                                    */
 
32
/* .PURPOSE                                                */
 
33
/* .VERSION     1.0  Package Creation  27-OCT-1993  
 
34
    090828      last modif                                 */
 
35
/* ------------------------------------------------------- */
 
36
 
 
37
#include <gl_defs.h>
 
38
#include <xm_defs.h>
 
39
#include <midas_def.h>
 
40
#include <irspec_defs.h>
 
41
#include <irspec_comm.h>
 
42
 
 
43
#include <UxLib.h>
 
44
 
 
45
 
 
46
extern int AppendDialogText(), exist_descriptor(), file_exists();
 
47
 
 
48
extern void WriteKeyword();
 
49
 
 
50
 
 
51
 
 
52
void ReadDefaultsIrspec()
 
53
{
 
54
}
 
55
 
 
56
void DisplayParamsIrspec()
 
57
{
 
58
}
 
59
 
 
60
void InitIrspec()
 
61
{
 
62
    ReadDefaultsIrspec();
 
63
    DisplayParamsIrspec();
 
64
}
 
65
 
 
66
int GetRespCoords( frame, data )
 
67
char *frame;
 
68
float data[];
 
69
{
 
70
    int nulval, actval, id;
 
71
    int unit;
 
72
 
 
73
    if ( !exist_descriptor(frame, "IRS_YROWS") )
 
74
        return(FALSE);
 
75
 
 
76
    SCFOPN(frame, D_R4_FORMAT, 0, F_IMA_TYPE, &id);
 
77
    SCDRDR(id, "IRS_YROWS", 1, 4, &actval, data, &unit, &nulval);
 
78
    SCFCLO(id);
 
79
 
 
80
    return(TRUE);
 
81
}
 
82
 
 
83
int GetCoords( coorfil, data, ncoords )
 
84
char coorfil[];
 
85
int data[];
 
86
int ncoords;
 
87
{
 
88
    int nulval, sortcol, aw, ar, ncols, nrows;
 
89
    char str[MAXLINE];
 
90
    int aux, i, id, col_yw;
 
91
 
 
92
    if ( ! file_exists( coorfil, ".tbl" ) ) {  /* do nothing */
 
93
        sprintf(str, "*** Error: table %s could not be opened ***", coorfil);
 
94
        SCTPUT(str);
 
95
        return FALSE;
 
96
    }
 
97
 
 
98
    TCTOPN(coorfil, F_I_MODE, &id);
 
99
 
 
100
    TCIGET(id, &ncols, &nrows, &sortcol, &aw, &ar);
 
101
    if ( nrows < ncoords ) {
 
102
        sprintf(str, "*** Error: only %d points given ***", nrows);
 
103
        SCTPUT(str);
 
104
        TCTCLO(id);
 
105
        return FALSE;
 
106
    }
 
107
    TCCSER(id, ":y_wcoord", &col_yw);
 
108
    if ( col_yw == -1 ) {
 
109
        SCTPUT("*** Error: missing column :y_wcoord in 'COORTAB' ***");
 
110
        TCTCLO(id);
 
111
        return FALSE;
 
112
    }
 
113
 
 
114
    for ( i = 0; i < ncoords; i++ )
 
115
        TCERDI(id, i+1, col_yw, &data[i], &nulval);
 
116
 
 
117
    /* Now order from less to greater by pairs */
 
118
    for ( i = 0; i < ncoords - 1; i += 2 )
 
119
        if ( data[i] > data[i+1] ) {
 
120
            aux = data[i+1];
 
121
            data[i+1] = data[i];
 
122
            data[i] = aux;
 
123
        }
 
124
 
 
125
    TCTCLO(id);
 
126
 
 
127
    return TRUE;
 
128
}
 
129
 
 
130
void WriteKeyword( text, keyword_cmd )
 
131
char *text;
 
132
char *keyword_cmd;
 
133
{
 
134
    char command[MAXLINE];
 
135
 
 
136
    sprintf(command, "%s%s", keyword_cmd, text);
 
137
    AppendDialogText(command);
 
138
}
 
139
 
 
140
/****************************************************************************
 
141
 exist_descriptor(): checks if the descriptor 'desc' exists in 'image'.
 
142
*/
 
143
int exist_descriptor( image, desc )
 
144
char *image;    /* name of the image */
 
145
char *desc;     /* descriptor name */
 
146
{
 
147
    int nulval, id;
 
148
    char type;
 
149
 
 
150
    if ( file_exists( image, ".bdf" ) ) {
 
151
        SCFOPN( image, D_R4_FORMAT, 0, F_IMA_TYPE, &id );
 
152
        SCDFND( id, desc, &type, &nulval, &nulval );
 
153
        if ( type != ' ' ) {
 
154
            SCFCLO(id);
 
155
            return(TRUE);
 
156
        }
 
157
        SCFCLO(id);
 
158
    }
 
159
    return(FALSE);
 
160
}