8 * get grid size from GDS
10 * added calculation of nxny of spectral data and clean up of triangular
11 * grid nnxny calculation l. kornblueh
12 * 7/25/03 wind fix Dusan Jovic
13 * 9/17/03 fix scan mode
16 int GDS_grid(unsigned char *gds
, unsigned char *bds
, int *nx
, int *ny
,
22 *nx
= ix
= GDS_LatLon_nx(gds
);
23 *ny
= iy
= GDS_LatLon_ny(gds
);
28 if (GDS_Gaussian(gds
) || GDS_LatLon(gds
)) {
34 for (i
= 0; i
< iy
; i
++) {
35 isum
+= gds
[pl
+i
*2]*256 + gds
[pl
+i
*2+1];
41 if (GDS_Triangular(gds
)) {
42 i
= GDS_Triangular_ni(gds
);
43 d
= GDS_Triangular_nd(gds
);
44 *nx
= *nxny
= d
* (i
+ 1) * (i
+ 1);
48 if (GDS_Harmonic(gds
)) {
49 /* this code assumes j, k, m are consistent with bds */
50 *nx
= *nxny
= (8*(BDS_LEN(bds
)-15)-BDS_UnusedBits(bds
))/
52 if ((8*(BDS_LEN(bds
)-15)-BDS_UnusedBits(bds
)) % BDS_NumBits(bds
)) {
53 fprintf(stderr
,"inconsistent harmonic BDS\n");
61 void GDS_prt_thin_lon(unsigned char *gds
) {
64 iy
= GDS_LatLon_ny(gds
);
66 iy
= GDS_LatLon_ny(gds
);
68 if ((pl
= GDS_PL(gds
)) == -1) {
69 fprintf(stderr
,"\nprogram error: GDS_prt_thin\n");
72 for (col
= i
= 0; i
< iy
; i
++) {
73 if (col
== 0) printf(" ");
74 printf("%5d", (gds
[pl
+i
*2] << 8) + gds
[pl
+i
*2+1]);
81 if (col
!= 0) printf("\n");
85 * prints out wind rel to grid or earth
88 static char *scan_mode
[8] = {
102 void GDS_winds(unsigned char *gds
, int verbose
) {
103 int scan
= -1, mode
= -1;
106 if (GDS_LatLon(gds
)) {
107 scan
= GDS_LatLon_scan(gds
);
108 mode
= GDS_LatLon_mode(gds
);
110 else if (GDS_Mercator(gds
)) {
111 scan
=GDS_Merc_scan(gds
);
112 mode
=GDS_Merc_mode(gds
);
114 /* else if (GDS_Gnomonic(gds)) { */
115 else if (GDS_Lambert(gds
)) {
116 scan
= GDS_Lambert_scan(gds
);
117 mode
= GDS_Lambert_mode(gds
);
119 else if (GDS_Gaussian(gds
)) {
120 scan
= GDS_LatLon_scan(gds
);
121 mode
= GDS_LatLon_mode(gds
);
123 else if (GDS_Polar(gds
)) {
124 scan
= GDS_Polar_scan(gds
);
125 mode
= GDS_Polar_mode(gds
);
127 else if (GDS_RotLL(gds
)) {
128 scan
= GDS_RotLL_scan(gds
);
129 mode
= GDS_RotLL_mode(gds
);
131 /* else if (GDS_Triangular(gds)) { */
132 else if (GDS_ssEgrid(gds
)) {
133 scan
= GDS_ssEgrid_scan(gds
);
134 mode
= GDS_ssEgrid_mode(gds
);
136 else if (GDS_fEgrid(gds
)) {
137 scan
= GDS_fEgrid_scan(gds
);
138 mode
= GDS_fEgrid_mode(gds
);
140 else if (GDS_ss2dEgrid(gds
)) {
141 scan
= GDS_ss2dEgrid_scan(gds
);
142 mode
= GDS_ss2dEgrid_mode(gds
);
147 if (mode
& 8) printf("winds in grid direction:");
148 else printf("winds are N/S:");
151 else if (verbose
== 2) {
153 printf(" scan: %s", scan_mode
[(scan
>> 5) & 7]);
156 if (mode
& 8) printf(" winds(grid) ");
157 else printf(" winds(N/S) ");