Linuxpops  3.01.04
Spectral Anaysis Package for Single Dish Data
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
class.c
Go to the documentation of this file.
1 
2 /* class.c, write SMT data to a class data file */
3 
4 #include <stdio.h>
5 #include <stdlib.h>
6 #include <fcntl.h>
7 #include <malloc.h>
8 #include <math.h>
9 #include <unistd.h>
10 #include <string.h>
11 #include <sys/stat.h>
12 #include <sys/types.h>
13 
14 #include "global.h"
15 
16 #include "linuxlib_proto.h"
17 
18 
19 /* ---------------------------------------------------------------------- */
20 /* ASTRO Utility routine */
21 /* Returns Julian date of 1 day of Year */
22 /* Arguments */
23 /* NYR I Year Input */
24 /* JULDA I Date returned Output */
25 /* ---------------------------------------------------------------------- */
26 int julda(int nyr)
27 {
28  int nyrm1, ic, nadd, julday;
29  int izero = 2025;
30 
31  nyrm1 = nyr - 1 ;
32 
33  ic = nyrm1 / 100;
34 
35  nadd = nyrm1 / 4 - ic + ic / 4;
36 
37  julday = 365. * (nyrm1 - izero) + nadd;
38 
39  return(julday);
40 }
41 
42 
43 /* ---------------------------------------------------------------------- */
44 /* ASTRO Utility routine */
45 /* Convert a date (id/im/iy) in number of days till the */
46 /* 01/01/1984 (2025??) */
47 /* Arguments : */
48 /* ID I Day number Input */
49 /* IM I Month number Input */
50 /* IY I Year number Input */
51 /* JOUR I Elapsed day count Output */
52 /* ---------------------------------------------------------------------- */
53 void datj(int id,int im, int iy, int* jour)
54 {
55  int ibiss, jour4;
56  int ideb[13] = {0,31,59,90,120,151,181,212,243,273,304,334,365};
57 
58  if(im > 12 || im <= 0)
59  {
60  *jour = -99999; /* Bad month */
61 
62  return;
63  }
64 
65  jour4 = id + ideb[im-1];
66  ibiss = julda(iy+1) - julda(iy) - 365;
67 
68  if(im >= 3)
69  jour4 = jour4 + ibiss;
70 
71  if(im == 2)
72  {
73  if(id <= 0 || id > (ideb[im] - ideb[im-1] + ibiss))
74  {
75  *jour = -99999; /* Bad February day */
76 
77  return;
78  }
79  }
80  else
81  {
82  if(id <= 0 || id > (ideb[im] - ideb[im-1]))
83  {
84  *jour = -99999; /* Bad day of month */
85 
86  return;
87  }
88  }
89  jour4 = jour4 + julda(iy);
90 
91  *jour = jour4;
92 }
93 
94 
95 
96  /* convert pops date (yyyy.mmdd) into class day number */
97 int class_date(double pops_date)
98 {
99  int day, month, year;
100  double dd;
101  static int jour;
102 
103  dd = pops_date + 0.00005; /* round up */
104  year = (int)dd;
105  dd -= (int)dd;
106  dd *= 100.0;
107  month = (int)dd;
108  dd -= (int)dd;
109  dd *= 100.0;
110  day = (int)dd;
111 
112 
113  datj(day, month, year, &jour);
114 
115  return(jour);
116 }
117 
118 
119 void add_class_section(long *info, int num, int type, int length)
120 {
121  int i;
122 
123  if(num > 15)
124  {
125  st_fail("Scan header full, cannot add header section %d", type);
126  return;
127  }
128  /* make space for new section */
129  if(num == 1)
130  {
131  *(info + 2) = *info;
132  }
133  else
134  {
135  for(i= num - 2; i >= 0; i--) /* previous addrs */
136  {
137  *(info + 2 * num + i) = *(info + 2 * (num-1) + i);
138  }
139  for(i= num - 2; i >= 0; i--) /* previous lengths */
140  {
141  *(info + num + i) = *(info + (num-1) + i);
142  }
143  }
144  /* add section info */
145  *(info + num - 1) = type;
146 
147  *(info + 2 * num - 1) = length;
148 
149  if(num > 1)
150  {
151  *(info + 3 * num - 1) = *(info+ 3 * num - 2) + *(info + 2 * num - 2);
152  }
153 }
154 
155 
156  /* Convert (ra,dec) to galactic coordinats. All are in degrees */
157 int eqtogal(double ra, double dec, double *glong, double *glat)
158 {
159  double x, y, z, x0, z0, cosd;
160  static double sin626=0, cos626;
161 
162  if(sin626 == 0)
163  {
164  sin626 = deg_sin(62.6);
165  cos626 = deg_cos(62.6);
166  }
167 
168  ra = ra - 192.25;
169  cosd = deg_cos(dec);
170  x0 = cosd * deg_cos(ra);
171  x = cosd * deg_sin(ra);
172  z0 = deg_sin(dec);
173  y = -cos626 * x0 + sin626 * z0;
174  z = sin626 * x0 + cos626 * z0;
175 
176  *glat = (180./M_PI)*asin(z);
177  *glong = (180./M_PI)*atan2(y,x) + 33;
178 
179  if(*glong < 0.0)
180  {
181  *glong += 360.0;
182  }
183 
184  return(0);
185 }
186 
187 
188 int class_write(file, headp, datap, cname, verbose)
189 char *file, *cname;
190 struct HEADER *headp;
191 float *datap;
192 int verbose;
193 {
194  int fd, len_index, subscan;
195  long ent_off, scan_off, sect_off, data_off;
196  char sect_buf[REC_LEN];
197  char *cp, sourcename[256], srctmp[256], tmp[256], freqname[256],
198  tbuf[256], telescope[256];
199  double glong_pos, glat_pos;
200  struct scan_ent scan;
201  struct file_index index;
202  struct index_ent entry;
203  float scanFraction;
204  union {
205  struct general_descr general;
206  struct position_descr position;
207  struct spectro_descr spectro;
208  struct fswitch_descr fswitch;
209  struct calibration_descr calib;
210  }sect;
211 
212  scanFraction = headp->scan - floor(headp->scan);
213 
214  if(verbose)
215  st_report("class_write called");
216 
217  if(!strncmp(headp->obsmode, "LINEPCAL", 8))
218  {
219  /* don't record the normal cals, just the hot, cold and sky ones. */
220  if(scanFraction < 0.205)
221  {
222  st_report("Obs %8.8s not processed for class, skip %7.2f.",
223  headp->obsmode, headp->scan);
224 
225  return(0);
226  }
227  }
228 
229  fd = open(file, Oflag, Mode);
230 
231  if(fd == -1)
232  {
233  st_fail("Can't open class file: %s", file);
234 
235  return(0);
236  }
237 
238  lseek(fd, 0L, SEEK_SET);
239  len_index = read(fd, (char *) &index, sizeof (index));
240 
241  /* is extension full? */
242  if(((index.next_ent -1) != 0) && ((index.next_ent -1) % index.num_ent) == 0)
243  {
244  index.ext_addr[index.num_ext] = index.next_rec;
245  index.next_rec += index.num_ent * ENT_LEN / REC_LEN;
246  index.num_ext ++;
247  }
248 
249  /* check if we handle this type of observation, then fill index entry */
250  if(strncmp(headp->obsmode,"LINE", 4) == 0)
251  {
252  if(strncmp(&headp->obsmode[4], "OTF", 3) == 0)
253  {
254  st_report("CLASS_WRITER: Obs type %8.8s not processed, skip scan %7.2f.",
255  headp->obsmode, headp->scan);
256 
257  close(fd);
258 
259  return(0);
260  }
261  else
262  {
263  entry.obs_type = KIND_SPEC;
264  }
265  }
266  else
267  {
268  st_fail("CLASS_WRITER: Unknown Obs type %8.8s, skip scan %7.2f.",
269  headp->obsmode, headp->scan);
270 
271  close(fd);
272 
273  return(0);
274  }
275 
276  entry.addr = index.next_rec;
277  entry.obs = index.next_ent;
278  index.next_ent ++;
279  entry.version = 1;
280 
281  strncpy(srctmp, headp->object, 16);
282  srctmp[16] = '\0';
283 
284  cp = strtok(srctmp, " ");
285  if(cp)
286  {
287  sprintf(sourcename, "%-12.12s", cp);
288  }
289  else
290  {
291  strcpy(sourcename, "No Src Name ");
292  }
293 
294  bcopy (sourcename, entry.source, 12);
295 
296  sprintf(freqname, "%-12s", headp->linename);
297  bcopy (freqname, entry.line, 12);
298 
299  subscan = (int)(((headp->scan+0.005) - (int)headp->scan) * 100.0);
300 
301  strncpy(tmp, headp->backend, 8);
302  tmp[8] = 0; /* String terminated backend name */
303 
304  if(verbose)
305  st_report("Backend = %s, subscan %d", tmp, subscan );
306 
307  if(subscan < 20)
308  {
309  strcpy(telescope, "SMT-");
310  }
311  else
312  if(subscan > 20 && subscan < 40)
313  {
314  strcpy(telescope, "HOT-");
315  }
316  else
317  if(subscan > 40 && subscan < 60)
318  {
319  strcpy(telescope, "SKY-");
320  }
321  else
322  if(subscan > 60 && subscan < 80)
323  {
324  strcpy(telescope, "CLD-");
325  }
326  else
327  strcpy(telescope, "UNK-");
328 
329  sprintf(tbuf, "%s ", cname+4);
330 
331  strcat(telescope, tbuf);
332 
333  bcopy((char *)telescope, (char *)&entry.telescope, 12);
334 
335  entry.date_obs = class_date(headp->utdate);
336  entry.date_red = entry.date_obs;
337  entry.offsets[0] = 0; /* fill in below */
338  entry.offsets[1] = 0;
339 
340  if(!strncmp(&headp->coordcd[4],"RADC", 4) || !strncmp(headp->coordcd,"APPRADC",7))
341  {
342  if(strncmp(headp->frame, "RA_DEC", 6) && strncmp(headp->frame, " ", 6))
343  {
344  char cd[24], fr[24];
345 
346  strncpy( cd, headp->coordcd, 8 );
347  cd[8] = 0;
348 
349  strncpy( fr, headp->frame, 8 );
350  fr[8] = 0;
351 
352 // st_fail( "Inconsistent coordinate types: %s and %s", cd, fr );
353 // st_fail( "Assume %4.4s is correct.", cd );
354  }
355  entry.offset_type = EQUAT;
356  }
357  else
358  if(!strncmp(&headp->coordcd[0],"GALACTIC", 8))
359  {
360  entry.offset_type = GALAC;
361  }
362  else
363  {
364  st_fail("CLASS_WRITER: Unknown coordinate system %8.8s.", headp->coordcd);
365  entry.offset_type = UNKNOWN;
366  }
367 
368  entry.quality = 0;
369  entry.scan = headp->scan;
370  bzero((char *)entry.future, sizeof(entry.future));
371  /* fill scan header */
372  scan_off = REC_LEN * (entry.addr-1);
373  scan.entry = entry.obs;
374  bcopy (SPECTRUM, scan.code, 4);
375  scan.num_sec = 0;
376  scan.sect_info[0] = SCAN_LEN + 1;
377  scan.size = SCAN_LEN;
378  scan.data_size = headp->datalen/4;
379  /* fill and write sections */
380  /* general section */
381  scan.num_sec ++;
383  scan.size += scan.sect_info[2*scan.num_sec-1];
384 
385  sect.general.ut_time = 3600*headp->ut;
386  sect.general.lst_time = 3600*headp->lst;
387  sect.general.azimuth = DEGREES2RADIANS(headp->az);
388  sect.general.elevation = DEGREES2RADIANS(headp->el);
389  sect.general.tau = headp->tauh2o + headp->tauo2;
390  sect.general.tsys = headp->stsys;
391  sect.general.integration = headp->inttime;
392 
393  sect_off = scan_off + (scan.sect_info[3*scan.num_sec-1]-1)*4;
394  lseek(fd, sect_off, SEEK_SET);
395  write_general(fd, &sect.general, scan.sect_info[2*scan.num_sec-1]*4);
396 
397  /* position section */
398  scan.num_sec ++;
400  scan.size += scan.sect_info[2*scan.num_sec-1];
401 
402  bcopy(sourcename, sect.position.source, 12);
403 
404  if(strcmp(headp->coordcd, "GALACTIC") == 0)
405  {
406  sect.position.epoch = 0;
407  }
408  else
409  {
410  if(strncmp(headp->coordcd, "APPRADC", 7) != 0 &&
411  atoi(headp->coordcd) != (int)headp->epoch)
412  {
413  char cd[24];
414 
415  strncpy( cd, headp->coordcd, 8 );
416  cd[8] = 0;
417 
418  st_fail("Inconsistent coordinate epochs: %6.1f and %s", headp->epoch, cd);
419  st_fail("Assume %6.1f is correct.", headp->epoch);
420  }
421  sect.position.epoch = headp->epoch;
422  }
423  /* Put in RA & Dec offsets */
424  if(headp->openpar[8] != 9998.5 && headp->openpar[8] != 9999.5)
425  {
426  sect.position.lambda_off =
427  DEGREES2RADIANS((headp->xsource-headp->epocra)) * cos(sect.position.beta);
428 
429  sect.position.beta_off =
430  DEGREES2RADIANS((headp->ysource-headp->epocdec));
431  }
432  else /* Az-El 5 pt. Put in Az & El offsets */
433  {
434  sect.position.lambda_off = DEGREES2RADIANS(headp->az_offset);
435  sect.position.beta_off = DEGREES2RADIANS(headp->el_offset);
436  entry.offset_type = HORIZ;
437  }
438 
439  if(entry.offset_type == GALAC)
440  {
441  sect.position.lambda = DEGREES2RADIANS(headp->gallong); /* Galactic */
442  sect.position.beta = DEGREES2RADIANS(headp->gallat);
443 
444  /* Calculate Galactic offsets */
445  /* First get Galactic coordinates of the object + offsets */
446  if(headp->openpar[8] != 9998.5 && headp->openpar[8] != 9999.5)
447  {
448  eqtogal(headp->xsource, headp->ysource, &glong_pos, &glat_pos);
449 
450  sect.position.lambda_off =
451  DEGREES2RADIANS(glong_pos - headp->gallong) * deg_cos(headp->gallat);
452 
453  sect.position.beta_off =
454  DEGREES2RADIANS(glat_pos - headp->gallat);
455  }
456  }
457  else
458  {
459  sect.position.lambda = DEGREES2RADIANS(headp->epocra); /* RA & Dec */
460  sect.position.beta = DEGREES2RADIANS(headp->epocdec);
461 
462  /* Put in RA & Dec offsets */
463  if(headp->openpar[8] != 9998.5 && headp->openpar[8] != 9999.5)
464  {
465  sect.position.lambda_off =
466  DEGREES2RADIANS((headp->xsource-headp->epocra)) * cos(sect.position.beta);
467 
468  sect.position.beta_off =
469  DEGREES2RADIANS((headp->ysource-headp->epocdec));
470  }
471  else /* Az-El 5 pt. Put in Az & El offsets */
472  {
473  sect.position.lambda_off = DEGREES2RADIANS(headp->az_offset);
474  sect.position.beta_off = DEGREES2RADIANS(headp->el_offset);
475  entry.offset_type = HORIZ;
476  }
477  }
478 
479  entry.offsets[0] = sect.position.lambda_off;
480  entry.offsets[1] = sect.position.beta_off;
481  sect.position.projection = P_RADIO;
482 
483  sect_off = scan_off + (scan.sect_info[3*scan.num_sec-1]-1)*4;
484  lseek (fd, sect_off, SEEK_SET);
485  write_position(fd, &sect.position, scan.sect_info[2*scan.num_sec-1]*4);
486 
487  /* spectro section */
488  scan.num_sec ++;
490  scan.size += scan.sect_info[2*scan.num_sec-1];
491 
492  bcopy(freqname, sect.spectro.line, 12);
493  sect.spectro.rest = headp->restfreq;
494  sect.spectro.nchan = scan.data_size;
495  sect.spectro.reference = headp->refpt;
496  sect.spectro.fres = headp->freqres;
497  sect.spectro.foff = 0 ; /* what's proper interpretation ? */
498  sect.spectro.vres = headp->deltax;
499 
500  /* changed Apr 02, 2003: twf */
501  if(headp->refpt_vel == 0.0)
502  {
503  sect.spectro.voff = headp->velocity;
504  }
505  else
506  {
507  sect.spectro.voff = headp->refpt_vel;
508  }
509 
510  sect.spectro.bad = headp->badchv;
511  /* sect.spectro.image = 0 ; */
512  if(headp->sideband == 2.0) /* USB */
513  {
514  sect.spectro.image =
515  headp->restfreq - 2.0 * (headp->firstif + headp->openpar[0]);
516  }
517 
518  if(headp->sideband == 1.0) /* LSB */
519  {
520  sect.spectro.image =
521  headp->restfreq + 2.0 * (headp->firstif - headp->openpar[0]);
522  }
523  /* ignore radio/optical definitions */
524  if(!strncmp(&headp->veldef[4],"LSR", 3))
525  {
526  sect.spectro.velocity = VLSR;
527  }
528  else
529  if(!strncmp(&headp->veldef[4], "HELO", 4))
530  {
531  sect.spectro.velocity = VHEL;
532  }
533  else
534  if(!strncmp(&headp->veldef[4], "EART", 4))
535  {
536  sect.spectro.velocity = VEAR;
537  }
538  else
539  if(!strncmp(&headp->veldef[4], "OBS", 3))
540  {
541  sect.spectro.velocity = VOBS;
542  }
543  else
544  {
545  st_fail("CLASS_WRITER: Unknown velocity reference %8.8s", headp->veldef);
546  sect.spectro.velocity = VUNK;
547  }
548 
549  sect.spectro.sky = headp->obsfreq;
550  sect.spectro.vteles = headp->rvsys; /* ? */
551  /* fix byte alignment */
552  bcopy((char *)&sect.spectro.line, sect_buf, 3*4);
553  bcopy((char *)&sect.spectro.rest, &sect_buf[3*4], 2*4);
554  bcopy((char *)&sect.spectro.nchan, &sect_buf[(3+2)*4], 7*4);
555  bcopy((char *)&sect.spectro.image, &sect_buf[(3+2+7)*4], 3*4);
556  bcopy((char *)&sect.spectro.sky, &sect_buf[(3+2+7+3)*4], 3*4);
557 
558  sect_off = scan_off + (scan.sect_info[3*scan.num_sec-1]-1)*4;
559  lseek (fd, sect_off, SEEK_SET);
560  write(fd, (char *) &sect_buf, scan.sect_info[2*scan.num_sec-1]*4);
561 
562  /* frequency switching section */
563  if(!strncmp(&headp->obsmode[4], "FS", 2))
564  {
565  long nf;
566 
567  scan.num_sec ++;
569  scan.size += scan.sect_info[2*scan.num_sec-1];
570 
571  sect.fswitch.nphase = NPHASE;
572  sect.fswitch.decalage[0] = headp->foffsig;
573  sect.fswitch.decalage[1] = headp->foffref1;
574  sect.fswitch.duree[0] = headp->inttime/NPHASE;
575  sect.fswitch.duree[1] = headp->inttime/NPHASE;
576  sect.fswitch.poids[0] = 1;
577  sect.fswitch.poids[1] = -1;
578  sect.fswitch.mode = MOD_FREQ;
579  sect.fswitch.lamoff[0] = 0;
580  sect.fswitch.betoff[0] = 0;
581  sect.fswitch.lamoff[1] = 0;
582  sect.fswitch.betoff[1] = 0;
583  /* compress arrays & fix byte alignment */
584  nf = NPHASE;
585  bcopy((char *)&sect.fswitch.nphase, sect_buf, 4);
586  bcopy((char *)&sect.fswitch.decalage, &sect_buf[4], nf*2*4 );
587  bcopy((char *)&sect.fswitch.duree, &sect_buf[(1+nf*2)*4], nf*4);
588  bcopy((char *)&sect.fswitch.poids, &sect_buf[(1+nf*3)*4], nf*4);
589  bcopy((char *)&sect.fswitch.mode, &sect_buf[(1+nf*4)*4], 4);
590  bcopy((char *)&sect.fswitch.lamoff, &sect_buf[(2+nf*4)*4], nf*4);
591  bcopy((char *)&sect.fswitch.betoff, &sect_buf[(2+nf*5)*4], nf*4);
592 
593  sect_off = scan_off + (scan.sect_info[3*scan.num_sec-1]-1)*4;
594  lseek(fd, sect_off, SEEK_SET);
595  write(fd, (char *) &sect_buf, scan.sect_info[2*scan.num_sec-1]*4);
596  }
597 
598  /* calibration section */
599  scan.num_sec ++;
601  scan.size += scan.sect_info[2*scan.num_sec-1];
602 
603  sect.calib.beam_eff = headp->etal * headp->etafss;
604  sect.calib.forw_eff = headp->etal;
605  sect.calib.gain_im = headp->gaini;
606  sect.calib.h2omm = headp->mmh2o;
607  sect.calib.pamb = headp->pressure;
608  sect.calib.tamb = headp->tamb + ZEROC;
609  sect.calib.tatmsig = headp->tatms;
610  sect.calib.tchop = headp->tchop;
611  sect.calib.tcold = headp->tcold;
612  sect.calib.tausig = headp->taus; /* headp->tauh2o + headp->tauo2; */
613  sect.calib.tauima = headp->taui;
614  sect.calib.tatmima = 0;
615  sect.calib.trec = headp->trx;
616  sect.calib.mode = 0;
617  sect.calib.factor = headp->tcal;
618 
619  if(!strncmp(headp->telescop,"NRAO 12M", 8))
620  sect.calib.altitude = 1914; /* m */
621  else
622  sect.calib.altitude = 3186;
623 
624  sect.calib.counts[0] = headp->count[0];
625  sect.calib.counts[1] = headp->count[1];
626  sect.calib.counts[2] = headp->count[2];
627  sect.calib.lamoff = 0;
628  sect.calib.betoff = 0;
629 
630  sect_off = scan_off + (scan.sect_info[3*scan.num_sec-1]-1)*4;
631  lseek(fd, sect_off, SEEK_SET);
632  write(fd, (char *) &sect,scan.sect_info[2*scan.num_sec-1]*4);
633 
634  /* write data */
635  scan.data_addr = scan.sect_info[3*scan.num_sec-1] + scan.sect_info[2*scan.num_sec-1];
636  scan.size += scan.data_size;
637 
638  data_off = scan_off + (scan.data_addr-1)*4;
639  lseek(fd, data_off, SEEK_SET);
640  write(fd, (char *) datap, scan.data_size*4);
641 
642  /* update the headers and indicies and close the file*/
643  scan.size_rec = 1 + scan.size * 4 / REC_LEN;
644  index.next_rec += scan.size_rec;
645 
646  lseek(fd, scan_off, SEEK_SET);
647  write_scan(fd, &scan, sizeof (scan));
648 
649  ent_off = REC_LEN * (index.ext_addr [(scan.entry-1)/index.num_ent] +
650  ((scan.entry-1) % index.num_ent)/ENT_REC - 1) +
651  ((scan.entry-1) % ENT_REC) * ENT_LEN;
652  lseek(fd, ent_off, SEEK_SET);
653  write_index(fd, &entry, sizeof (entry));
654 
655  lseek(fd, 0L, SEEK_SET);
656  write_fileix(fd, &index, sizeof (index));
657  close(fd);
658 
659  if(verbose)
660  {
661  st_report("Class: Obs type %8.8s, scan %7.2f written.", headp->obsmode, headp->scan);
662  }
663 
664  return(1);
665 }
666 
667 
668 int class_init(file)
669 char *file;
670 {
671  int fd;
672  struct file_index index;
673  int len_index;
674 
675  if((fd = open(file, Oflag, Mode)) == -1)
676  {
677  st_fail("Can't open class file: %s", file);
678 
679  return(NOT_OK);
680  }
681 
682  lseek(fd, 0L, SEEK_SET);
683  len_index = read(fd, (char *) &index, sizeof (index));
684  if(len_index == 0)
685  { /* file is empty; initialize */
686  bcopy(EEEI_FILE, index.code, 4);
687  index.next_rec = EXT_LEN / REC_LEN + 2 + 1;
688  index.num_ent = ENT_EXT;
689  index.num_ext = 1;
690  index.next_ent = 1;
691  index.ext_addr[0] = 3;
692  bzero((char *) &index.ext_addr[1], sizeof (index.ext_addr)-4);
693  write_fileix(fd, &index, sizeof (index));
694  close(fd);
695 
696  return(NEW_OK);
697  }
698  else /* is file ok? */
699  if(len_index == sizeof(index) && !bcmp(index.code, EEEI_FILE, 4))
700  {
701  close(fd);
702 
703  return(OLD_OK);
704  }
705  else /* file is not ok */
706  {
707  close(fd);
708  st_fail("File %s isn't an EEEI CLASS file", file);
709 
710  return(NOT_OK);
711  }
712 }
713 
714 
715 
716 int write_index( fd, ix, len )
717 int fd;
718 struct index_ent *ix;
719 int len;
720 {
721  struct index_ent xx;
722 
723  bcopy( ix, &xx, sizeof(struct index_ent));
724 
725  return( write( fd, &xx, len ));
726 }
727 
728 int write_fileix( fd, ix, len )
729 int fd;
730 struct file_index *ix;
731 int len;
732 {
733  struct file_index xx;
734 
735  bcopy( ix, &xx, sizeof(struct file_index));
736 
737  return( write( fd, &xx, len ));
738 }
739 
740 int write_scan( fd, scan, len )
741 int fd;
742 struct scan_ent *scan;
743 int len;
744 {
745  struct scan_ent ss;
746 
747  bcopy( scan, &ss, sizeof(struct scan_ent));
748 
749  return( write( fd, &ss, len ));
750 }
751 
752 int write_general(fd, gen, len )
753 int fd;
754 struct general_descr *gen;
755 int len;
756 {
757  struct general_descr gg;
758 
759  bcopy( gen, &gg, sizeof(struct general_descr));
760 
761  return( write( fd, &gg, len ));
762 }
763 
764 int write_position(fd, gen, len )
765 int fd;
766 struct position_descr *gen;
767 int len;
768 {
769  struct position_descr gg;
770 
771  bcopy( gen, &gg, sizeof(struct position_descr));
772 
773  return( write( fd, &gg, len ));
774 }
#define NEW_OK
Definition: class.h:9
double deg_cos(double angle)
double tcold
Definition: header.h:171
char frame[8]
Definition: header.h:110
double az
Definition: header.h:82
double scan
Definition: header.h:35
char line[12]
Definition: structure.h:38
#define KIND_SPEC
Definition: structure.h:21
double badchv
Definition: header.h:116
int future[12]
Definition: structure.h:44
#define Mode
Definition: class.h:5
double datalen
Definition: header.h:34
double utdate
Definition: header.h:61
int next_ent
Definition: structure.h:14
int next_rec
Definition: structure.h:14
double rvsys
Definition: header.h:117
int scan
int quality
Definition: structure.h:44
#define CALIBRATION_SECT
Definition: structure.h:201
#define DEGREES2RADIANS(x)
Definition: class.h:19
double mmh2o
Definition: header.h:96
char code[4]
Definition: structure.h:13
#define SPECTRO_LEN
Definition: structure.h:132
#define SPECTRUM
Definition: structure.h:51
int num_ext
Definition: structure.h:14
double el_offset
Definition: header.h:184
Definition: header.h:13
double deg_sin(double angle)
int scan
Definition: structure.h:44
double xsource
Definition: header.h:74
double ysource
Definition: header.h:75
int version
Definition: structure.h:35
int julda()
void datj()
char coordcd[8]
Definition: header.h:87
double tcal
Definition: header.h:202
#define FSWITCH_SECT
Definition: structure.h:187
int date_obs
Definition: structure.h:41
char code[4]
Definition: structure.h:55
char telescop[8]
Definition: header.h:38
double openpar[10]
Definition: header.h:155
double gaini
Definition: header.h:172
#define NOT_OK
Definition: class.h:7
double sideband
Definition: header.h:143
int num_ent
Definition: structure.h:14
int data_size
Definition: structure.h:56
double foffref1
Definition: header.h:150
int class_write()
#define SPECTRO_SECT
Definition: structure.h:131
double foffsig
Definition: header.h:149
int ext_addr[251]
Definition: structure.h:14
#define VEAR
Definition: structure.h:128
double pressure
Definition: header.h:92
char linename[16]
Definition: header.h:174
double etafss
Definition: header.h:128
double tatms
Definition: header.h:166
double tauo2
Definition: header.h:215
#define GENERAL_SECT
Definition: structure.h:89
int data_addr
Definition: structure.h:56
int sect_info[45]
Definition: structure.h:56
double lst
Definition: header.h:63
float offsets[2]
Definition: structure.h:43
#define POSITION_SECT
Definition: structure.h:111
#define SCAN_LEN
Definition: structure.h:52
double refpt_vel
Definition: header.h:175
double epoch
Definition: header.h:73
double az_offset
Definition: header.h:183
#define UNKNOWN
Definition: structure.h:26
char obsmode[8]
Definition: header.h:41
double obsfreq
Definition: header.h:197
double etal
Definition: header.h:127
char backend[8]
Definition: header.h:43
void st_fail()
int entry
Definition: structure.h:56
#define VOBS
Definition: structure.h:127
int obs
Definition: structure.h:35
#define HORIZ
Definition: structure.h:29
int strcmp()
int offset_type
Definition: structure.h:44
int size_rec
Definition: structure.h:56
double firstif
Definition: header.h:136
double velocity
Definition: header.h:118
#define EXT_LEN
Definition: structure.h:7
#define VUNK
Definition: structure.h:124
#define VLSR
Definition: structure.h:125
double taui
Definition: header.h:168
int class_init()
int obs_type
Definition: structure.h:44
double count[3]
Definition: header.h:173
double taus
Definition: header.h:167
double stsys
Definition: header.h:203
int write_index()
double epocra
Definition: header.h:78
#define ENT_REC
Definition: structure.h:6
double refpt
Definition: header.h:207
double gallat
Definition: header.h:81
void st_report()
double el
Definition: header.h:83
#define ENT_LEN
Definition: structure.h:5
#define NPHASE
Definition: class.h:17
int class_date()
int num_sec
Definition: structure.h:56
#define VHEL
Definition: structure.h:126
double deltax
Definition: header.h:209
#define P_RADIO
Definition: structure.h:109
int addr
Definition: structure.h:35
double tchop
Definition: header.h:170
#define FSWITCH_LEN
Definition: structure.h:189
double gallong
Definition: header.h:80
#define POSITION_LEN
Definition: structure.h:112
double inttime
Definition: header.h:210
int date_red
Definition: structure.h:41
char veldef[8]
Definition: header.h:119
#define MOD_FREQ
Definition: structure.h:183
double tamb
Definition: header.h:91
#define GENERAL_LEN
Definition: structure.h:90
#define EEEI_FILE
Definition: structure.h:9
#define EQUAT
Definition: structure.h:27
void add_class_section()
#define ENT_EXT
Definition: structure.h:4
#define Oflag
Definition: class.h:4
#define CALIBRATION_LEN
Definition: structure.h:202
#define REC_LEN
Definition: structure.h:3
#define OLD_OK
Definition: class.h:8
int write_position()
int write_fileix()
char object[16]
Definition: header.h:40
double restfreq
Definition: header.h:198
char telescope[12]
Definition: structure.h:38
double freqres
Definition: header.h:199
char source[12]
Definition: structure.h:38
#define GALAC
Definition: structure.h:28
double tauh2o
Definition: header.h:213
double trx
Definition: header.h:201
double ut
Definition: header.h:62
int write_scan()
double epocdec
Definition: header.h:79
#define ZEROC
Definition: class.h:15
int eqtogal()
int write_general()
int size
Definition: structure.h:56