miriad 4.1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- data/README +103 -0
- data/Rakefile +82 -0
- data/ext/bug.c +341 -0
- data/ext/dio.c +317 -0
- data/ext/extconf.rb +49 -0
- data/ext/headio.c +835 -0
- data/ext/hio.c +1515 -0
- data/ext/hio.h +48 -0
- data/ext/interface.c +74 -0
- data/ext/io.h +56 -0
- data/ext/key.c +934 -0
- data/ext/maskio.c +398 -0
- data/ext/maxdimc.h.in +9 -0
- data/ext/miriad.h +371 -0
- data/ext/miriad.i +464 -0
- data/ext/miriad_ruby.c +602 -0
- data/ext/miriad_ruby.i +443 -0
- data/ext/miriad_wrap.c +4210 -0
- data/ext/narray_ruby.swg +59 -0
- data/ext/pack.c +639 -0
- data/ext/scrio.c +132 -0
- data/ext/sysdep.h +185 -0
- data/ext/uvio.c +4934 -0
- data/ext/xyio.c +476 -0
- data/ext/xyzio.c +2020 -0
- data/lib/miriad.rb +564 -0
- metadata +93 -0
data/ext/miriad.i
ADDED
@@ -0,0 +1,464 @@
|
|
1
|
+
/* $Id: miriad.i 899 2008-04-17 21:51:06Z davidm $ */
|
2
|
+
|
3
|
+
/* MIRIAD Swig wrapper */
|
4
|
+
|
5
|
+
%module(docstring="Scripting interface to MIRIAD I/O routines") miriad
|
6
|
+
%feature("autodoc","");
|
7
|
+
%include "exception.i"
|
8
|
+
|
9
|
+
// This specifies the name for mirlib error messages.
|
10
|
+
%init %{
|
11
|
+
buglabel_c("mirlib");
|
12
|
+
%}
|
13
|
+
|
14
|
+
%{
|
15
|
+
#include "miriad.h"
|
16
|
+
#define MAX_STRLEN (255)
|
17
|
+
|
18
|
+
typedef struct {
|
19
|
+
int fd;
|
20
|
+
} uvio;
|
21
|
+
%}
|
22
|
+
|
23
|
+
// Language specific includes
|
24
|
+
//TODO %include miriad_tcl.i
|
25
|
+
//TODO %include miriad_java.i
|
26
|
+
//TODO %include miriad_python.i
|
27
|
+
%include miriad_ruby.i // Typemaps
|
28
|
+
|
29
|
+
typedef struct {} uvio;
|
30
|
+
|
31
|
+
%extend uvio {
|
32
|
+
|
33
|
+
// uvio.c
|
34
|
+
|
35
|
+
//void uvopen_c (int *tno, Const char *name, Const char *status);
|
36
|
+
// status is either "old" (to read), "new" (to create), or "append" (to
|
37
|
+
// append)
|
38
|
+
uvio(char * name, char * status) {
|
39
|
+
char * his_status = "append";
|
40
|
+
uvio * self;
|
41
|
+
if(name == NULL) {
|
42
|
+
SWIG_exception(SWIG_NullReferenceError,"invalid name");
|
43
|
+
}
|
44
|
+
if(status == NULL) {
|
45
|
+
SWIG_exception(SWIG_NullReferenceError,"invalid status");
|
46
|
+
}
|
47
|
+
switch(status[0]) {
|
48
|
+
case 'o':
|
49
|
+
case 'r': status = "old";
|
50
|
+
his_status = "read";
|
51
|
+
break;
|
52
|
+
case 'n':
|
53
|
+
case 'w': status = "new";
|
54
|
+
break;
|
55
|
+
case 'a': status = "append";
|
56
|
+
break;
|
57
|
+
default: SWIG_exception(SWIG_ValueError,"invalid status");
|
58
|
+
break;
|
59
|
+
}
|
60
|
+
self = malloc(sizeof(uvio));
|
61
|
+
uvopen_c(&(self->fd), name, status);
|
62
|
+
// TODO Error check
|
63
|
+
hisopen_c(self->fd,his_status);
|
64
|
+
uvset_c(self->fd, "preamble", "uvw/time/baseline", 0, 0.0, 0.0, 0.0);
|
65
|
+
uvset_c(self->fd, "coord", "nanosec", 0, 0.0, 0.0, 0.0);
|
66
|
+
if(status[0] == 'o') {
|
67
|
+
// To read initial values of uv vars
|
68
|
+
uvnext_c(self->fd);
|
69
|
+
uvrewind_c(self->fd);
|
70
|
+
}
|
71
|
+
return self;
|
72
|
+
}
|
73
|
+
|
74
|
+
~uvio() {
|
75
|
+
if(self->fd != -1) {
|
76
|
+
hisclose_c(self->fd);
|
77
|
+
uvflush_c(self->fd);
|
78
|
+
uvclose_c(self->fd);
|
79
|
+
self->fd = -1;
|
80
|
+
}
|
81
|
+
free(self);
|
82
|
+
}
|
83
|
+
|
84
|
+
//void uvclose_c (int tno);
|
85
|
+
void close() {
|
86
|
+
hisclose_c(self->fd);
|
87
|
+
uvflush_c(self->fd);
|
88
|
+
uvclose_c(self->fd);
|
89
|
+
self->fd = -1;
|
90
|
+
}
|
91
|
+
|
92
|
+
//void uvflush_c (int tno);
|
93
|
+
void flush() {
|
94
|
+
uvflush_c(self->fd);
|
95
|
+
}
|
96
|
+
|
97
|
+
//void uvnext_c (int tno);
|
98
|
+
void uvnext() {
|
99
|
+
uvnext_c(self->fd);
|
100
|
+
}
|
101
|
+
|
102
|
+
//void uvrewind_c (int tno);
|
103
|
+
void rewind() {
|
104
|
+
uvrewind_c(self->fd);
|
105
|
+
}
|
106
|
+
|
107
|
+
//void uvprobvr_c (int tno, Const char *var, char *type, int *length, int *updated);
|
108
|
+
void probvr(char *var, char *type, int *length, int *updated) {
|
109
|
+
uvprobvr_c(self->fd, var, type, length, updated);
|
110
|
+
}
|
111
|
+
|
112
|
+
//void uvputvr_c (int tno, int type, Const char *var, Const char *data, int n);
|
113
|
+
// NB: Swapped order of var and type parameters!
|
114
|
+
// (For simpler SWIG typemaps.)
|
115
|
+
void putvr(char *var, char *data, int n, int type = -1) {
|
116
|
+
uvputvr_c(self->fd, type, var, data, n);
|
117
|
+
}
|
118
|
+
|
119
|
+
//void uvscan_c (int tno, Const char *var);
|
120
|
+
void scan(char *var) {
|
121
|
+
uvscan_c(self->fd, var);
|
122
|
+
}
|
123
|
+
|
124
|
+
//void uvwrite_c (int tno, Const double *preamble, Const float *data, Const int *flags, int n);
|
125
|
+
void write(double *preamble, float *data, int *flags, int n) {
|
126
|
+
uvwrite_c(self->fd, preamble, data, flags, n);
|
127
|
+
}
|
128
|
+
|
129
|
+
//void uvwwrite_c (int tno, Const float *data, Const int *flags, int n);
|
130
|
+
void wwrite(float *data, int *flags, int n) {
|
131
|
+
uvwwrite_c(self->fd, data, flags, n);
|
132
|
+
}
|
133
|
+
|
134
|
+
//void uvset_c(int tno, Const char *object, Const char *type, int n, double p1,double p2,double p3);
|
135
|
+
void set(char *object, char *type, int n = 0,
|
136
|
+
double p1 = 0.0, double p2 = 0.0, double p3 = 0.0) {
|
137
|
+
uvset_c(self->fd, object, type, n, p1, p2, p3);
|
138
|
+
}
|
139
|
+
|
140
|
+
//void uvread_c (int tno, double *preamble, float *data, int *flags, int n, int *nread);
|
141
|
+
// Named uvread to allow for a higher level read method
|
142
|
+
void uvread(double *preamble, float *data, int *flags, int n, int *nread) {
|
143
|
+
uvread_c(self->fd, preamble, data, flags, n, nread);
|
144
|
+
}
|
145
|
+
|
146
|
+
//void uvwread_c (int tno, float *data, int *flags, int n, int *nread);
|
147
|
+
void uvwread(float *data, int *flags, int n, int *nread) {
|
148
|
+
uvwread_c(self->fd, data, flags, n, nread);
|
149
|
+
}
|
150
|
+
|
151
|
+
#if 0
|
152
|
+
void putvra(char * name, char * value) {
|
153
|
+
uvputvra_c(self->fd,name,value);
|
154
|
+
}
|
155
|
+
|
156
|
+
void putvrj(char * name, short * value, int n) {
|
157
|
+
uvputvrj_c(self->fd,name,value,n);
|
158
|
+
}
|
159
|
+
|
160
|
+
void putvri(char * name, int * value, int n) {
|
161
|
+
uvputvri_c(self->fd,name,value,n);
|
162
|
+
}
|
163
|
+
|
164
|
+
void putvrr(char * name, float * value, int n) {
|
165
|
+
uvputvrr_c(self->fd,name,value,n);
|
166
|
+
}
|
167
|
+
|
168
|
+
void putvrd(char * name, double * value, int n) {
|
169
|
+
uvputvrd_c(self->fd,name,value,n);
|
170
|
+
}
|
171
|
+
|
172
|
+
void putvrc(char * name,value,n) {
|
173
|
+
uvputvrc_c(self->fd,name,value,n);
|
174
|
+
}
|
175
|
+
#endif // 0
|
176
|
+
|
177
|
+
#if 0
|
178
|
+
// This is redundant; use more general getvr
|
179
|
+
char * getvra(char * name) {
|
180
|
+
char *value = NULL;
|
181
|
+
char type = 'c';
|
182
|
+
int n = 0;
|
183
|
+
int updated = 0;
|
184
|
+
uvprobvr_c(self->fd,name,&type,&n,&updated);
|
185
|
+
if(n > 0) {
|
186
|
+
if(type != 'c') {
|
187
|
+
rb_raise(rb_eArgError,
|
188
|
+
"variable %s is not an ASCII string, it is type '%c'",
|
189
|
+
name, type);
|
190
|
+
}
|
191
|
+
value = malloc(sizeof(char)*n);
|
192
|
+
uvgetvr_c(self->fd,H_BYTE,name,value,n);
|
193
|
+
}
|
194
|
+
return value;
|
195
|
+
}
|
196
|
+
#endif
|
197
|
+
|
198
|
+
#if 0
|
199
|
+
// TODO TODO TODO
|
200
|
+
void getvrj(char * name,value,n) {
|
201
|
+
uvgetvr_c(tno,H_INT2,name,(char *)(value),n)
|
202
|
+
}
|
203
|
+
#endif
|
204
|
+
void getvr(char * name, void ** value, int * n, char *type) {
|
205
|
+
int updated = 0;
|
206
|
+
*n = 0;
|
207
|
+
*type = ' ';
|
208
|
+
uvprobvr_c(self->fd,name,type,n,&updated);
|
209
|
+
if(*n > 0) {
|
210
|
+
switch(*type) {
|
211
|
+
case 'a': *value = malloc(sizeof(char)*((*n)+1));
|
212
|
+
uvgetvr_c(self->fd,H_BYTE,name,(char *)(*value),((*n)+1));
|
213
|
+
break;
|
214
|
+
case 'i': *value = malloc(sizeof(int)*(*n));
|
215
|
+
uvgetvr_c(self->fd,H_INT,name,(char *)(*value),*n);
|
216
|
+
break;
|
217
|
+
case 'r': *value = malloc(sizeof(float)*(*n));
|
218
|
+
uvgetvr_c(self->fd,H_REAL,name,(char *)(*value),*n);
|
219
|
+
break;
|
220
|
+
case 'd': *value = malloc(sizeof(double)*(*n));
|
221
|
+
uvgetvr_c(self->fd,H_DBLE,name,(char *)(*value),*n);
|
222
|
+
break;
|
223
|
+
case ' ': // Variable not present
|
224
|
+
case 'j': // Unsuported
|
225
|
+
// Return NULL, but don't raise exception
|
226
|
+
break;
|
227
|
+
default: // TODO Raise exception
|
228
|
+
break;
|
229
|
+
}
|
230
|
+
}
|
231
|
+
}
|
232
|
+
#if 0
|
233
|
+
void getvrr(char * name,value,n) {
|
234
|
+
uvgetvr_c(tno,H_REAL,name,(char *)(value),n)
|
235
|
+
}
|
236
|
+
void getvrd(char * name,value,n) {
|
237
|
+
uvgetvr_c(tno,H_DBLE,name,(char *)(value),n)
|
238
|
+
}
|
239
|
+
void getvrc(char * name,value,n) {
|
240
|
+
uvgetvr_c(tno,H_CMPLX,name,(char *)(value),n)
|
241
|
+
}
|
242
|
+
|
243
|
+
// TODO Typemaps!!!
|
244
|
+
void rdvra(char * name, char * data, char * def, int n) {
|
245
|
+
uvrdvr_c(self->fd,H_BYTE,name,data,def,n);
|
246
|
+
if(n > 0) {
|
247
|
+
data[n-1] = '\0';
|
248
|
+
}
|
249
|
+
return data;
|
250
|
+
}
|
251
|
+
|
252
|
+
int rdvri(char * name, int def) {
|
253
|
+
int data = 0;
|
254
|
+
uvrdvr_c(self->fd,H_INT,name,(char *)(&data),(char *)(&def),1);
|
255
|
+
return data;
|
256
|
+
}
|
257
|
+
|
258
|
+
float rdvrf(char * name, float def) {
|
259
|
+
float data = 0.0;
|
260
|
+
uvrdvr_c(self->fd,H_REAL,name,(char *)(&data),(char *)(&def),1);
|
261
|
+
return data;
|
262
|
+
}
|
263
|
+
|
264
|
+
double rdvrd(char * name, double def) {
|
265
|
+
double * data = 0.0;
|
266
|
+
uvrdvr_c(self->fd,H_DBLE,name,(char *)(&data),(char *)(&def),1);
|
267
|
+
return data;
|
268
|
+
}
|
269
|
+
|
270
|
+
void rdvrc(char * name, float * cdata, float * cdef) {
|
271
|
+
uvrdvr_c(self->fd,H_CMPLX,name,(char *)(cdata),(char *)(cdef),1);
|
272
|
+
}
|
273
|
+
|
274
|
+
//TODO void uvcopyvr_c (int tin, int tout);
|
275
|
+
#endif // 0
|
276
|
+
|
277
|
+
// int uvupdate_c (int tno);
|
278
|
+
int updated() {
|
279
|
+
return uvupdate_c(self->fd);
|
280
|
+
}
|
281
|
+
|
282
|
+
#if 0
|
283
|
+
//TODO void uvvarini_c (int tno, int *vhan);
|
284
|
+
//TODO void uvvarset_c (int vhan, Const char *var);
|
285
|
+
//TODO void uvvarcpy_c (int vhan, int tout);
|
286
|
+
//TODO int uvvarupd_c (int vhan);
|
287
|
+
#endif // 0
|
288
|
+
|
289
|
+
// void uvtrack_c (int tno, Const char *name, Const char *switches);
|
290
|
+
void track(char *name, char *switches) {
|
291
|
+
uvtrack_c(self->fd, name, switches);
|
292
|
+
}
|
293
|
+
|
294
|
+
// void uvsela_c (int tno, Const char *object, Const char *string, int datasel);
|
295
|
+
void sela(char *object, int datasel, char *string) {
|
296
|
+
uvsela_c(self->fd, object, string, datasel);
|
297
|
+
}
|
298
|
+
|
299
|
+
// void uvselect_c (int tno, Const char *object, double p1, double p2, int datasel);
|
300
|
+
void select(char *object, int datasel, double p1=0.0, double p2=0.0) {
|
301
|
+
uvselect_c(self->fd, object, p1, p2, datasel);
|
302
|
+
}
|
303
|
+
|
304
|
+
// TODO Needs static nread (maintained by uvread)
|
305
|
+
#if 0
|
306
|
+
// void uvinfo_c (int tno, Const char *object, double *data);
|
307
|
+
void info(char *object, double *data) {
|
308
|
+
uvinfo_c(self->fd, object, data);
|
309
|
+
}
|
310
|
+
#endif
|
311
|
+
|
312
|
+
// void uvflgwr_c (int tno, Const int *flags);
|
313
|
+
void flagwr(int *flags) {
|
314
|
+
uvflgwr_c(self->fd, flags);
|
315
|
+
}
|
316
|
+
|
317
|
+
// void uvwflgwr_c (int tno, Const int *flags);
|
318
|
+
void wflagwr(int *flags) {
|
319
|
+
uvwflgwr_c(self->fd, flags);
|
320
|
+
}
|
321
|
+
|
322
|
+
/* hio.c */
|
323
|
+
|
324
|
+
#if 0
|
325
|
+
void hopen_c(int *tno, Const char *name, Const char *status, int *iostat);
|
326
|
+
void hflush_c(int tno, int *iostat);
|
327
|
+
void habort_c(void);
|
328
|
+
void hrm_c(int tno);
|
329
|
+
void hclose_c(int tno);
|
330
|
+
void hdelete_c(int tno, Const char *keyword, int *iostat);
|
331
|
+
#endif
|
332
|
+
|
333
|
+
//void haccess_c(int tno, int *ihandle, Const char *keyword, Const char *status, int *iostat);
|
334
|
+
int haccess(char *keyword, char *status) {
|
335
|
+
int ihandle;
|
336
|
+
int iostat;
|
337
|
+
|
338
|
+
if(keyword == NULL) {
|
339
|
+
SWIG_exception(SWIG_NullReferenceError,"invalid item name");
|
340
|
+
}
|
341
|
+
if(status == NULL) {
|
342
|
+
SWIG_exception(SWIG_NullReferenceError,"invalid status");
|
343
|
+
}
|
344
|
+
switch(status[0]) {
|
345
|
+
case 'r': status = "read";
|
346
|
+
break;
|
347
|
+
case 'w': status = "write";
|
348
|
+
break;
|
349
|
+
case 'a': status = "append";
|
350
|
+
break;
|
351
|
+
case 's': status = "scratch";
|
352
|
+
break;
|
353
|
+
default: SWIG_exception(SWIG_ValueError,"invalid status");
|
354
|
+
break;
|
355
|
+
}
|
356
|
+
|
357
|
+
haccess_c(self->fd,&ihandle,keyword,status,&iostat);
|
358
|
+
|
359
|
+
if(iostat != 0) {
|
360
|
+
SWIG_exception(SWIG_IOError, "error opening item");
|
361
|
+
}
|
362
|
+
return ihandle;
|
363
|
+
}
|
364
|
+
|
365
|
+
#if 0
|
366
|
+
void hmode_c(int tno, char *mode);
|
367
|
+
int hexists_c(int tno, Const char *keyword);
|
368
|
+
#endif
|
369
|
+
|
370
|
+
//void hdaccess_c(int ihandle, int *iostat);
|
371
|
+
void hdaccess(int ihandle) {
|
372
|
+
int iostat;
|
373
|
+
hdaccess_c(ihandle,&iostat);
|
374
|
+
if(iostat != 0 && iostat != -1) {
|
375
|
+
SWIG_exception(SWIG_IOError, "error closing item");
|
376
|
+
}
|
377
|
+
}
|
378
|
+
|
379
|
+
#if 0
|
380
|
+
off_t hsize_c(int ihandle);
|
381
|
+
void hio_c(int ihandle, int dowrite, int type, char *buf, off_t offset, size_t length, int *iostat);
|
382
|
+
void hseek_c(int ihandle, off_t offset);
|
383
|
+
off_t htell_c(int ihandle);
|
384
|
+
#endif
|
385
|
+
|
386
|
+
//void hreada_c(int ihandle, char *line, size_t length, int *iostat);
|
387
|
+
void hreadln(int ihandle, char *linein, size_t length, int *iostat) {
|
388
|
+
if(linein == NULL) {
|
389
|
+
SWIG_exception(
|
390
|
+
SWIG_NullReferenceError, "no buffer to receive line from item");
|
391
|
+
}
|
392
|
+
if(length < 1) {
|
393
|
+
SWIG_exception(
|
394
|
+
SWIG_ValueError, "invalid buffer length to receive line from item");
|
395
|
+
}
|
396
|
+
|
397
|
+
hreada_c(ihandle, linein, length, iostat);
|
398
|
+
linein[length-1] = '\0';
|
399
|
+
|
400
|
+
if(*iostat != 0 && *iostat != -1) {
|
401
|
+
SWIG_exception(SWIG_IOError, "error reading item");
|
402
|
+
}
|
403
|
+
}
|
404
|
+
|
405
|
+
//void hwritea_c(int ihandle, Const char *line, size_t length, int *iostat);
|
406
|
+
void hwriteln(int ihandle, char *lineout, size_t length) {
|
407
|
+
int iostat;
|
408
|
+
if(lineout == NULL) {
|
409
|
+
SWIG_exception(
|
410
|
+
SWIG_NullReferenceError, "no line to write to item");
|
411
|
+
}
|
412
|
+
if(length < 1) {
|
413
|
+
SWIG_exception(
|
414
|
+
SWIG_ValueError, "invalid line length to write to item");
|
415
|
+
}
|
416
|
+
|
417
|
+
hwritea_c(ihandle, lineout, length, &iostat);
|
418
|
+
|
419
|
+
if(iostat != 0 && iostat != -1) {
|
420
|
+
SWIG_exception(SWIG_IOError, "error writing item");
|
421
|
+
}
|
422
|
+
}
|
423
|
+
|
424
|
+
/* headio.c */
|
425
|
+
|
426
|
+
#if 0 // TODO TODO TODO
|
427
|
+
void hisopen_c (int tno, Const char *status);
|
428
|
+
#endif // 0
|
429
|
+
|
430
|
+
//void hiswrite_c (int tno, Const char *text);
|
431
|
+
void hiswrite(char *text) {
|
432
|
+
hiswrite_c(self->fd, text);
|
433
|
+
}
|
434
|
+
|
435
|
+
#if 0 // TODO TODO TODO
|
436
|
+
void hisread_c (int tno, char *text, size_t length, int *eof);
|
437
|
+
void hisclose_c (int tno);
|
438
|
+
void wrhdr_c (int tno, Const char *keyword, double value);
|
439
|
+
void wrhdd_c (int tno, Const char *keyword, double value);
|
440
|
+
void wrhdi_c (int tno, Const char *keyword, int value);
|
441
|
+
void wrhdl_c (int tno, Const char *keyword, int8 value);
|
442
|
+
void wrhdc_c (int tno, Const char *keyword, Const float *value);
|
443
|
+
#endif // 0
|
444
|
+
|
445
|
+
//void wrhda_c (int tno, Const char *keyword, Const char *value);
|
446
|
+
void wrhda(char *keyword, char *value) {
|
447
|
+
wrhda_c (self->fd, keyword, value);
|
448
|
+
}
|
449
|
+
|
450
|
+
#if 0 // TODO TODO TODO
|
451
|
+
void rdhdr_c (int tno, Const char *keyword, float *value, double defval);
|
452
|
+
void rdhdi_c (int tno, Const char *keyword, int *value, int defval);
|
453
|
+
void rdhdl_c (int tno, Const char *keyword, int8 *value, int8 defval);
|
454
|
+
void rdhdd_c (int tno, Const char *keyword, double *value, double defval);
|
455
|
+
void rdhdc_c (int tno, Const char *keyword, float *value, Const float *defval);
|
456
|
+
void rdhda_c (int tno, Const char *keyword, char *value, Const char *defval, int len);
|
457
|
+
void hdcopy_c (int tin, int tout, Const char *keyword);
|
458
|
+
int hdprsnt_c (int tno, Const char *keyword);
|
459
|
+
void hdprobe_c (int tno, Const char *keyword, char *descr, size_t length, char *type, int *n);
|
460
|
+
#endif // 0
|
461
|
+
|
462
|
+
};
|
463
|
+
|
464
|
+
/* vim: set expandtab ts=2 sw=2 smarttab syntax=c cindent fo+=tcroq : */
|