]> Pileus Git - ~andy/rsl/blob - lassen.h
RSL v1.42
[~andy/rsl] / lassen.h
1 /*
2     NASA/TRMM, Code 910.1.
3     This is the TRMM Office Radar Software Library.
4     Copyright (C) 1996  John H. Merritt of Applied Research Corporation,
5                         Landover, Maryland, a NASA/GSFC on-site contractor.
6
7     This library is free software; you can redistribute it and/or
8     modify it under the terms of the GNU Library General Public
9     License as published by the Free Software Foundation; either
10     version 2 of the License, or (at your option) any later version.
11
12     This library is distributed in the hope that it will be useful,
13     but WITHOUT ANY WARRANTY; without even the implied warranty of
14     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
15     Library General Public License for more details.
16
17     You should have received a copy of the GNU Library General Public
18     License along with this library; if not, write to the Free
19     Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20  */
21 #ifndef _lassen_h_
22 #define _lassen_h_
23
24 typedef struct {
25   short degree;  /* Geographic position: lat or lon */
26   short minute;  /* + above equator, - below,       */
27   short second;     /* - Western hemi, + Eastern hemi. */
28   short spare;
29 } Lassen_radar_position;
30
31 typedef struct {
32   char           radar_name[8]; /* Radar name. */
33   char           site_name[8];  /* Site name.  */
34   unsigned short antenna_height;/* In meters above sea level. */
35   unsigned short spare;
36   Lassen_radar_position latitude; /* Latitude or radar  */
37   Lassen_radar_position longitude; /* Longitude of radar.*/
38 } Lassen_radar_info;
39
40 /* This is for Lassen files version 1.3 (coded as 13) and
41  * files version 1.4 (coded 14)
42  */
43
44 /* The maximum number of offsets is 10.  The LASSEN file will
45  * have written data (space) for all 10 fields even when there is no field.
46  */
47 #define NUMOFFSETS 10
48 #define OFF_UZ 0
49 #define OFF_CZ 1
50 #define OFF_VEL 2
51 #define OFF_WID 3
52 #define OFF_ZDR 4
53 #define OFF_PHI 5
54 #define OFF_RHO 6
55 #define OFF_LDR 7
56 #define OFF_KDP 8
57 #define OFF_TIME 9
58
59 /* This is absolute and cannot be changed.  The LASSEN file is 
60  * written with this number specified.  It is used during the 
61  * XDR decode process.
62  */
63 #define LASSEN_MAX_SWEEPS 30
64
65 /* Sweep types (modes) are:
66  *   POINT = 0
67  *   PPI   = 1
68  *   RHI   = 2
69  *   SECTOR= 3
70  *
71  *   STOP  = 7  - Flag the end of the scan mode.
72  */
73
74 /*
75  * The Lassen_ray:
76  * 
77  * The Lassen_sweep contains 360 pointers to Lassen_rays.
78  * Each Lassen_ray is dynamically allocated and the pointer inserted
79  * into the Lassen_sweep.  The 'offsets' array contains indexes to
80  * the field type.  When an index value is 0, then there is no data
81  * available for that field type.  The order hard-coded and matches
82  * the order given by OFF_* variables in the #define above.  Checking
83  * for a non-zero index value seems to be the most reliable method
84  * to determine the existance of a field type.  Using 'flags' is
85  * problematic when there is no field of that type (ie. you get a 
86  * false positive).
87  *
88  * Use the 'offset' array to jump to the field type.
89  *
90  */
91 typedef struct {
92   unsigned short vangle;    /* Azimuth angle.           */
93   unsigned short fanglet;   /* Target fixed angle.  */
94   unsigned short fanglea;   /* Actual fixed angle.  */
95   unsigned short a_start;   /* Azimuth angle start.  */
96   unsigned short a_stop;    /* Azimuth angle stop.  */
97   unsigned short status;    /* Hardware status word. */
98   unsigned char  max_height;/* Maximum height, km.  */
99   unsigned char  volume;    /* Volume serial number. */
100   unsigned char  sweep;     /* Sweep number 1..LASSEN_MAX_SWEEPS       */
101   unsigned char  sweep_type;/* Sweep type.              */
102   unsigned short gatewid;   /* Gate width, meters.  */
103   unsigned short rangeg1;   /* Range to gate 1, meters. */
104   unsigned short numgates;  /* Number of gates.         */
105   unsigned short prf;       /* Primary prf, hz.      */
106   unsigned short prflow;    /* Secondary prf, hz.  */
107   unsigned short n_pulses;  /* Sample size in pulses. */
108   unsigned char  p_width;   /* Pulse width, .05 us units.*/
109   unsigned char  cfilter;   /* Clutter filter code.   */
110   unsigned char  spare[2];
111     
112   /*
113    * Like I said before, don't trust these values.  Trust
114    * the 'offset' instead -- offset in the ray.
115    */
116   
117   /* flags is 'short' -- I hope it never becomes 'long' */
118   struct {
119         unsigned int packed     : 1; /* Is the data packed? */
120         unsigned int good_data  : 1; /* Is the data good? */
121         unsigned int uz         : 1; /* UZ  present. */
122         unsigned int cz         : 1; /* CZ  present. */
123         unsigned int vel        : 1; /* VEL present. */
124         unsigned int wid        : 1; /* WID present. */
125         unsigned int zdr        : 1; /* ZDR present. */
126         unsigned int phi        : 1; /* PHI present. */
127         unsigned int rho        : 1; /* RHO present. */
128         unsigned int ldr        : 1; /* LDR present. */
129         unsigned int kdp        : 1; /* KDP present. */
130         unsigned int time       : 1; /* TIME series present. */
131         unsigned int spares     : 4;
132   } flags;
133   
134   
135   /*
136    * Here is where you get to the data for a field type.
137    * If offset[OFF_CZ] is non-zero, for instance, then
138    * CZ exists and is located that many bytes into
139    * the data array.  The data array is in the ray pointer
140    * which is in the Lassen_sweep.
141    */
142   unsigned short offset[NUMOFFSETS];
143
144   unsigned char year;   /* year-1900   */
145   unsigned char month;  /* month  1-12 */
146   unsigned char day;    /* day    1-31 */
147   unsigned char hour;   /* hour   0-23 */
148   unsigned char minute; /* minute 0-59 */
149   unsigned char second; /* second 0-59 */
150   unsigned char spare2[2];
151 } Lassen_ray;
152
153 /*
154  * The Lassen_sweep:
155  *
156  * This structure contains information for an entire sweep for a possible
157  * 360 rays.  These will be pointers to Lassen_ray.
158  * The Lassen_volume may have up to 30 pointers to Lassen_sweep.
159  * The '30' is mandatory and not adjustable because of how the LASSEN
160  * file is written.  The LASSEN file writes 30 angles, gates, and
161  * 300 offset values (30*NUMOFFSETS).  LASSEN_MAX_SWEEPS = 30.
162  * The number of rays in a Lassen_sweep is 'numrays'.
163  *
164  * The 'offset' is copied from the one in Lassen_ray.
165  */
166 typedef struct {
167   unsigned short volume;     /* Volume serial number. */
168   unsigned short sweep;      /* Sweep index. */
169   unsigned short sweep_type; /* Sweep type code.  */
170   unsigned short max_height; /* Maximum height, km. */
171
172   unsigned short fangle;  /* Fixed, azimuth angle.  */
173   unsigned short min_var; /* 'leftmost' variable angle. */
174   unsigned short max_var; /* 'rightmost' variable angle. */
175   unsigned short a_start; /* Azimuth angle start.  */
176   unsigned short a_stop;  /* Azimuth angle stop.  */
177
178   unsigned short gatewid;  /* Gate width, meters.  */
179   unsigned short rangeg1;  /* Range to gate 1, meters. */
180   unsigned short numgates; /* Number of gates.  */
181   unsigned short numrays;  /* Number of rays this sweep. */
182   
183   unsigned short prf;     /* Primary prf, hz.  */
184   unsigned short prflow;  /* Secondary prf, hz.  */
185   unsigned short n_pulses;/* Sample size in pulses. */
186   unsigned short p_width; /* Pulse width, .05 us units. */
187   unsigned short cfilter; /* Clutter filter code.  */
188   
189   unsigned short offset[NUMOFFSETS];
190   
191   unsigned char year;    /* Year - 1900. */
192   unsigned char month;   /* Month 1-12 */
193   unsigned char day;     /* Day   1-31 */
194   unsigned char shour;   /* Start hour   0-23 */
195   unsigned char sminute; /* Start minute 0-59 */
196   unsigned char ssecond; /* Start second 0-59 */
197   unsigned char ehour;   /* End hour   0-23  */
198   unsigned char eminute; /* End minute 0-59  */
199   unsigned char esecond; /* End second 0-59  */
200   unsigned char spare1[3];
201   
202   unsigned short status;  /* Status word. */
203   unsigned short spare2;
204
205   Lassen_ray *ray[360]; /* The Lassen_ray pointers. */
206 } Lassen_sweep;
207
208 /*
209  * Lassen_volume:
210  *
211  * A volume can contain a maximum of LASSEN_MAX_SWEEPS sweeps.
212  * The value for LASSEN_MAX_SWEEPS *MUST* be 30.  This cannot change,
213  * otherwise, you'll not be able to read the file.
214  * The number of sweeps is in the member 'numsweeps'.
215  *
216  */
217
218 typedef struct {
219   unsigned short version; /* Raw version number.  */
220   short          filled;  /* <0=empty 0=filling >0=full. */
221   
222   unsigned int   volume;     /* Volume serial number.  */
223   unsigned short sweep;      /* Sweep index 1 -> max. */
224   unsigned short sweep_type; /* Sweep type code.   */
225   unsigned short max_height; /* Maximum height, km.  */
226   unsigned short status;     /* Status word. */
227   
228   unsigned short min_fangle; /* Minimum fixed angle.  */
229   unsigned short max_fangle; /* Maximum fixed angle.  */
230   unsigned short min_var;    /* Minimum variable angle. */
231   unsigned short max_var;    /* Maximum variable angle. */
232   unsigned short a_start;    /* Variable angle start. */
233   unsigned short a_stop;     /* Variable angle stop.  */
234   unsigned short numsweeps;  /* Number of sweeps in volume. */
235   unsigned short fangles[LASSEN_MAX_SWEEPS]; /* Fixed angles for each sweep. */
236   
237   unsigned short gatewid; /* Gate width, meters.  */
238   unsigned short rangeg1; /* Range to gate 1, meters. */
239   unsigned short numgates[LASSEN_MAX_SWEEPS]; /* Gates for each sweep. */
240   unsigned short maxgates; /* Max # of gates in volume. */
241   
242   unsigned short prf;      /* Primary prf, hz. */
243   unsigned short prflow;   /* Secondary prf, hz. */
244   unsigned short n_pulses; /* Sample size in pulses. */
245   unsigned short p_width;  /* Pulse width, .05 us units. */
246   unsigned short cfilter;  /* Clutter filter code. */
247   unsigned short local;    /* Used as volume lock: nonzero. */
248   
249   unsigned int freq;  /* Mhz * 10   */
250   
251   unsigned short offset[LASSEN_MAX_SWEEPS][NUMOFFSETS];
252   
253   unsigned char year;    /* Year - 1900      */
254   unsigned char month;   /* Month 1-12        */
255   unsigned char day;     /* Day   1-31        */
256   unsigned char shour;   /* Start hour   0-23 */
257   unsigned char sminute; /* Start minute 0-59 */
258   unsigned char ssecond; /* Start second 0-59 */
259   unsigned char ehour;   /* End hour   0-23   */
260   unsigned char eminute; /* End minute 0-59   */
261   unsigned char esecond; /* End second 0-59   */
262   unsigned char spare[3];
263   
264   struct {   /* Software status flags. Length of volflags is 'short' */
265  unsigned int compress : 1;
266  unsigned int spares : 15;
267   } volflags;
268   
269   Lassen_radar_info  radinfo; /* Radar information. */
270   
271   Lassen_sweep *index[LASSEN_MAX_SWEEPS]; /* The Lassen_sweep pointers. */
272 } Lassen_volume;
273
274 typedef struct {
275   unsigned char year;   /* year - 1900 */
276   unsigned char month;  /* 1-12  */
277   unsigned char day;    /* 1-31  */
278   unsigned char hour;   /* 0-23  */
279   unsigned char minute; /* 0-59  */
280   unsigned char second; /* 0-59  */
281   unsigned char dummy[2];
282 } Lassen_time;
283
284 typedef struct {
285   char magic[8];     /* Magic number.  This must be 'SUNRISE'. */
286   Lassen_time mdate; /* Last modification. */
287   Lassen_time cdate; /* Creation date.     */
288   int  type;         /* See #defines above.*/
289   char mwho[16];     /* Last person to modify.   */
290   char cwho[16];     /* Person who created file. */
291   int  protection;   /* Is file protected? */
292   int  checksum;     /* Data bcc.   */
293   char description[40]; /* File description. */
294   int  id;
295   int  spare[12];
296 } Lassen_head;
297
298 #define ANGLE_CONVERT(X)  ((unsigned short) ((((unsigned int)X+22)*360) >> 14))
299 #endif