1
/*===========================================================================
2
Copyright (C) 1993-2009 European Southern Observatory (ESO)
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.
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.
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,
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
26
===========================================================================*/
28
/* +++++++++++++++++++++++++++++++++++++++++++++++++++++++ */
29
/* .IDENT midasutil.c */
30
/* .AUTHORS Cristian Levin (ESO/La Silla) */
31
/* .KEYWORDS XIrspec */
33
/* .VERSION 1.0 Package Creation 27-OCT-1993
35
/* ------------------------------------------------------- */
39
#include <midas_def.h>
40
#include <irspec_defs.h>
41
#include <irspec_comm.h>
46
extern int AppendDialogText(), exist_descriptor(), file_exists();
48
extern void WriteKeyword();
52
void ReadDefaultsIrspec()
56
void DisplayParamsIrspec()
63
DisplayParamsIrspec();
66
int GetRespCoords( frame, data )
70
int nulval, actval, id;
73
if ( !exist_descriptor(frame, "IRS_YROWS") )
76
SCFOPN(frame, D_R4_FORMAT, 0, F_IMA_TYPE, &id);
77
SCDRDR(id, "IRS_YROWS", 1, 4, &actval, data, &unit, &nulval);
83
int GetCoords( coorfil, data, ncoords )
88
int nulval, sortcol, aw, ar, ncols, nrows;
90
int aux, i, id, col_yw;
92
if ( ! file_exists( coorfil, ".tbl" ) ) { /* do nothing */
93
sprintf(str, "*** Error: table %s could not be opened ***", coorfil);
98
TCTOPN(coorfil, F_I_MODE, &id);
100
TCIGET(id, &ncols, &nrows, &sortcol, &aw, &ar);
101
if ( nrows < ncoords ) {
102
sprintf(str, "*** Error: only %d points given ***", nrows);
107
TCCSER(id, ":y_wcoord", &col_yw);
108
if ( col_yw == -1 ) {
109
SCTPUT("*** Error: missing column :y_wcoord in 'COORTAB' ***");
114
for ( i = 0; i < ncoords; i++ )
115
TCERDI(id, i+1, col_yw, &data[i], &nulval);
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] ) {
130
void WriteKeyword( text, keyword_cmd )
134
char command[MAXLINE];
136
sprintf(command, "%s%s", keyword_cmd, text);
137
AppendDialogText(command);
140
/****************************************************************************
141
exist_descriptor(): checks if the descriptor 'desc' exists in 'image'.
143
int exist_descriptor( image, desc )
144
char *image; /* name of the image */
145
char *desc; /* descriptor name */
150
if ( file_exists( image, ".bdf" ) ) {
151
SCFOPN( image, D_R4_FORMAT, 0, F_IMA_TYPE, &id );
152
SCDFND( id, desc, &type, &nulval, &nulval );