Linuxpops  3.01.04
Spectral Anaysis Package for Single Dish Data
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
survey.c
Go to the documentation of this file.
1 /*
2 Copyright 2021 Arizona Board of Regents on behalf of the University of Arizona.
3 
4 For commercial uses, to obtain a license to sell and or sublicense copies of
5 the Software please contact the University of Arizona at Tech Launch Arizona:
6 lewish@tla.arizona.edu.
7 
8 Permission is hereby granted, free of charge, to any person obtaining a copy
9 of this software and associated documentation files (the "Software"), to deal
10 in the Software without restriction for non-commercial use educational and
11 research purposes, including without limitation the rights to use, copy,
12 modify, merge, publish, distribute, and to permit persons to whom the Software
13 is furnished to do so, subject to the following conditions:
14 
15 The entire above copyright notice and this permission notice shall be included
16 in all copies or substantial portions of the Software.
17 
18 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
23 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
24 SOFTWARE.
25 
26 1. Additional Required Provisions
27 
28 1.1. Arbitration. The parties agree that if a dispute arises between them
29 concerning this Agreement, the parties may be required to submit the matter to
30 arbitration pursuant to Arizona law.
31 
32 1.2. Applicable Law and Venue. This Agreement shall be interpreted pursuant
33 to the laws of the State of Arizona. Any arbitration or litigation between the
34 Parties shall be conducted in Pima County, ARIZONA, and LICENSEE hereby
35 submits to venue and jurisdiction in Pima County, ARIZONA.
36 
37 1.3. Non-Discrimination. The Parties agree to be bound by state and federal
38 laws and regulations governing equal opportunity and non-discrimination and
39 immigration.
40 
41 1.4. Appropriation of Funds. The Parties recognize that performance by
42 ARIZONA may depend upon appropriation of funds by the State Legislature of
43 ARIZONA. If the Legislature fails to appropriate the necessary funds, or if
44 ARIZONA’S appropriation is reduced during the fiscal year, ARIZONA may cancel
45 this Agreement without further duty or obligation. ARIZONA will notify
46 LICENSEE as soon as reasonably possible after it knows of the loss of funds.
47 
48 1.5. Conflict of Interest. This Agreement is subject to the provisions of
49 A.R.S. 38-511 and other conflict of interest regulations. Within three years
50 of the EFFECTIVE DATE, ARIZONA may cancel this Agreement if any person
51 significantly involved in initiating, negotiating, drafting, securing, or
52 creating this Agreement for or on behalf of ARIZONA becomes an employee or
53 consultant in any capacity of LICENSEE with respect to the subject matter of
54 this Agreement.
55 
56  */
57 
58 
59 #include "extern.h"
60 
61 
62 int surveyWrite(fname)
63 char *fname;
64 {
65  int i, dlen;
66  FILE *fp;
67  struct HEADER *h;
68  double f0, f1, f2, fr, refpt, deltax, vel;
69  float *f3;
70  struct LP_IMAGE_INFO *image = h0;
71 
72  h = &image->head;
73 
74  f0 = h->restfreq;
75  fr = h->freqres;
76  refpt = h->refpt;
77  deltax = h->deltax;
78  vel = h->velocity;
79 
80  dlen = h->noint;
81 
82  if((fp = fopen(fname, "w")) == NULL)
83  {
84  st_fail("surveyWrite(): Unable to open file %s", fname);
85  return(0);
86  }
87 
88  fprintf(fp, "# %s ns %d\n", basename(env->filename), (int)h->align3[0]);
89  fprintf(fp, "# FREQ %.3f\n", f0);
90  fprintf(fp, "# TSYS %.2f\n", h->stsys);
91  fprintf(fp, "# TIME %.2f\n", h->inttime);
92  fprintf(fp, "# MHz, K, s\n");
93  fprintf(fp, "# RMS %.2f\n", env->rms);
94  fprintf(fp, "# %16.16s\n", h->object);
95  fprintf(fp, "# \n");
96 
97  if(h->sideband == 2)
98  {
99  f3 = &image->yplot1[0];
100  for(i=0;i<dlen;i++,f3++)
101  {
102  f1 = f0 - ((refpt - (double)(i+1)) * fr);
103  f2 = vel - ((refpt - (double)(i+1)) * deltax);
104 
105  if(fabs(*f3) < 0.5)
106  {
107  fprintf(fp, " %8.1f %10.4f %12.9E\n", f1, f2, *f3);
108  }
109  else
110  {
111  fprintf(fp, " %8.1f %10.4f %9.6f\n", f1, f2, *f3);
112  }
113  }
114  }
115  else
116  {
117  f3 = &image->yplot1[dlen-1];
118  for(i=dlen-1;i>-1;i--,f3--)
119  {
120  f1 = f0 - ((refpt - (double)(i+1)) * fr);
121  f2 = vel - ((refpt - (double)(i+1)) * deltax);
122 
123  if(fabs(*f3) < 0.5)
124  {
125  fprintf(fp, " %8.1f %10.4f %12.9E\n", f1, f2, *f3);
126  }
127  else
128  {
129  fprintf(fp, " %8.1f %10.4f %9.6f\n", f1, f2, *f3);
130  }
131  }
132  }
133 
134  fclose(fp);
135 
136  st_report("Wrote Survey File %s", fname);
137 
138  return(0);
139 }
140 
141 
142 
143 int doSurvey()
144 {
145  if(strlen(args->secondArg) > 2)
146  {
148  }
149  else
150  {
151  st_fail("Usage: survey filename");
152  return(1);
153  }
154 
155  return(0);
156 }
float yplot1[MAX_CHANS]
Definition: image.h:110
struct LP_IMAGE_INFO * h0
Definition: image.c:74
double rms
Definition: env.h:262
struct PARSE_STACK * args
Definition: parse.h:196
double noint
Definition: header.h:211
int surveyWrite(char *fname)
Definition: survey.c:62
FILE * fp
Definition: linuxpops.c:70
Definition: header.h:13
double align3[4]
Definition: header.h:230
double sideband
Definition: header.h:143
struct ENVIRONMENT * env
Definition: linuxpops.c:71
struct HEADER head
Definition: image.h:104
void st_fail()
double velocity
Definition: header.h:118
double stsys
Definition: header.h:203
double refpt
Definition: header.h:207
void st_report()
double deltax
Definition: header.h:209
double inttime
Definition: header.h:210
char * secondArg
Definition: parse.h:181
char object[16]
Definition: header.h:40
double restfreq
Definition: header.h:198
double freqres
Definition: header.h:199
char filename[256]
Definition: env.h:9
int doSurvey(void)
Definition: survey.c:143