1 | #define STRINGSIZE 160 |
---|
2 | |
---|
3 | /* The value used to fill missing data points */ |
---|
4 | #define FILL_VALUE -9999999. |
---|
5 | |
---|
6 | typedef struct { |
---|
7 | int usGrid_id; |
---|
8 | int usParm_id; |
---|
9 | int usLevel_id; |
---|
10 | int usHeight1; |
---|
11 | int usHeight2; |
---|
12 | int offset; |
---|
13 | int end; |
---|
14 | char filename[200]; |
---|
15 | FILE *fp; |
---|
16 | char initdate[15]; |
---|
17 | char valid_time[15]; |
---|
18 | int date; |
---|
19 | int century; |
---|
20 | int fcsttime1; |
---|
21 | int fcsttime2; |
---|
22 | int center_id; |
---|
23 | int parmtbl; |
---|
24 | int proc_id; |
---|
25 | int subcenter_id; |
---|
26 | PDS_INPUT *pds; |
---|
27 | grid_desc_sec *gds; |
---|
28 | BMS_INPUT *bms; |
---|
29 | BDS_HEAD_INPUT *bds_head; |
---|
30 | } Elements; |
---|
31 | |
---|
32 | typedef struct { |
---|
33 | int num_elements; |
---|
34 | Elements *elements; |
---|
35 | } GribInfo; |
---|
36 | |
---|
37 | typedef struct { |
---|
38 | char initdate[100]; |
---|
39 | char validdate[100]; |
---|
40 | int parmid; |
---|
41 | int leveltype; |
---|
42 | int level1; |
---|
43 | int level2; |
---|
44 | int fcsttime1; |
---|
45 | int fcsttime2; |
---|
46 | int center_id; |
---|
47 | int subcenter_id; |
---|
48 | int parmtbl_version; |
---|
49 | } FindGrib; |
---|
50 | |
---|
51 | typedef struct { |
---|
52 | int center; |
---|
53 | int subcenter; |
---|
54 | int table; |
---|
55 | int parmid; |
---|
56 | char name[STRINGSIZE]; |
---|
57 | char comment[STRINGSIZE]; |
---|
58 | } GribTableEntry; |
---|
59 | |
---|
60 | typedef struct { |
---|
61 | int num_entries; |
---|
62 | GribTableEntry *parms; |
---|
63 | } GribParameters; |
---|
64 | |
---|
65 | typedef struct { |
---|
66 | float column; |
---|
67 | float row; |
---|
68 | float value; |
---|
69 | char id[20]; |
---|
70 | } PointData; |
---|
71 | |
---|
72 | typedef struct { |
---|
73 | char prjnmm[24], stordsc[24]; |
---|
74 | int colcnt, rowcnt; |
---|
75 | float origlat, origlon, origx, origy; |
---|
76 | float xintdis, yintdis, parm1, parm2, parm3; |
---|
77 | } GRIB_PROJECTION_INFO_DEF; |
---|
78 | |
---|
79 | /* Public function definitions */ |
---|
80 | |
---|
81 | int rg_setup_gribmap(GribParameters *gribmap, char file[]); |
---|
82 | int rg_gribmap_parameter(GribParameters *gribmap, char name[], int table, |
---|
83 | GribTableEntry *gribmap_parms); |
---|
84 | void rg_free_gribmap_elements(GribParameters *gribmap); |
---|
85 | |
---|
86 | int rg_setup_gribinfo(GribInfo *gribinfo, char files[][STRINGSIZE], |
---|
87 | int use_fcst); |
---|
88 | int rg_setup_gribinfo_f(GribInfo *gribinfo, FILE *fp, int use_fcst); |
---|
89 | int rg_setup_gribinfo_i(GribInfo *gribinfo, int fid, int use_fcst); |
---|
90 | |
---|
91 | int rg_get_index(GribInfo *gribinfo, FindGrib *find_grib); |
---|
92 | |
---|
93 | int rg_get_index_guess(GribInfo *gribinfo, FindGrib *findgrib, int guess_index); |
---|
94 | |
---|
95 | int rg_get_indices(GribInfo *gribinfo, FindGrib *find_grib, int *indices); |
---|
96 | |
---|
97 | int rg_init_findgrib(FindGrib *findgrib); |
---|
98 | |
---|
99 | int rg_get_grib_header(GribInfo *gribinfo, int index, PDS_INPUT *pds, |
---|
100 | grid_desc_sec *gds,BMS_INPUT *bms); |
---|
101 | |
---|
102 | int rg_num_elements(GribInfo *gribinfo); |
---|
103 | |
---|
104 | void rg_free_gribinfo_elements(GribInfo *gribinfo); |
---|
105 | |
---|
106 | int rg_get_numrows(GribInfo *gribinfo,int index); |
---|
107 | |
---|
108 | int rg_get_numcols(GribInfo *gribinfo,int index); |
---|
109 | |
---|
110 | int rg_get_level1(GribInfo *gribinfo, int index); |
---|
111 | |
---|
112 | int rg_get_level2(GribInfo *gribinfo, int index); |
---|
113 | |
---|
114 | int rg_get_center_id(GribInfo *gribinfo, int index); |
---|
115 | |
---|
116 | int rg_get_subcenter_id(GribInfo *gribinfo, int index); |
---|
117 | |
---|
118 | int rg_get_proc_id(GribInfo *gribinfo, int index); |
---|
119 | |
---|
120 | int rg_get_tblversion(GribInfo *gribinfo, int index); |
---|
121 | |
---|
122 | float rg_get_point(GribInfo *gribinfo, int index, float column, float row); |
---|
123 | |
---|
124 | int rg_get_points(GribInfo *gribinfo, int index, PointData *pointdata, |
---|
125 | int numpoints); |
---|
126 | |
---|
127 | int rg_get_offset(GribInfo *gribinfo, int index); |
---|
128 | |
---|
129 | int rg_get_end(GribInfo *gribinfo, int index); |
---|
130 | |
---|
131 | int rg_get_valid_time(GribInfo *gribinfo, int index, char valid_time[]); |
---|
132 | |
---|
133 | int rg_get_data(GribInfo *gribinfo, int index, float **data); |
---|
134 | |
---|
135 | int rg_get_data_1d(GribInfo *gribinfo, int index, float *data); |
---|
136 | |
---|
137 | int rg_write_grib(PDS_INPUT *pds, grid_desc_sec *gds, char filename[], |
---|
138 | float **data); |
---|
139 | int rg_fwrite_grib(PDS_INPUT *pds, grid_desc_sec *gds, float **data, |
---|
140 | FILE *fid); |
---|
141 | |
---|
142 | |
---|
143 | |
---|
144 | /* The following are public functions also. However, the interface to many |
---|
145 | * of them needs to be reworked. For example, it is not possible to specify |
---|
146 | * a secondary height or forecast time with many of them. |
---|
147 | * Note: As of 11/11/04, the functions listed above have already been reworked. |
---|
148 | */ |
---|
149 | |
---|
150 | int rg_get_pressure_levels(GribInfo *gribinfo, int dates[], int centuries[], |
---|
151 | int parm_id[], int finallevels[],int min_pres, |
---|
152 | int numparms); |
---|
153 | int rg_get_msl_indices(GribInfo *gribinfo, char dates[][STRINGSIZE], |
---|
154 | int centuries[], int usParm_id[],int usLevel_id[], |
---|
155 | int usHeight1[],int infactor[],int numparms, |
---|
156 | int grib_index[],int outfactor[]); |
---|
157 | int rg_get_grib(GribInfo *gribinfo, int index,int scale, |
---|
158 | float **grib_out,int *vect_comp_flag, |
---|
159 | GRIB_PROJECTION_INFO_DEF *Proj, BDS_HEAD_INPUT *bds_head); |
---|
160 | int rg_get_dates(GribInfo *gribinfo,int usParm_id[],int usLevel_id[], |
---|
161 | int usHeight1[],int numparms,int dates[],int century[], |
---|
162 | int indices[]); |
---|
163 | int rg_get_index_near_date(GribInfo *gribinfo,char targetdate[STRINGSIZE], |
---|
164 | int century,int hours_before,int hours_after, |
---|
165 | int usParm_id[],int usLevel_id[],int usHeight1[], |
---|
166 | int numparms); |
---|
167 | int rg_get_date(GribInfo *gribinfo,int index); |
---|
168 | int rg_get_century(GribInfo *gribinfo,int index); |
---|
169 | int rg_get_forecast_time(GribInfo *gribinfo,int index); |
---|