Go to the documentation of this file.
7 int *month,
int *
day,
int *hour)
42 int rd_grib_pds(FILE *,
int *,
int *,
int *,
int *);
48 if ((stream = fopen(
file,
"r")) ==
NULL) {
49 printf(
"Unable to open GRIB file: %s, Exiting\n",
file);
57 "Error on PDS portion of grib file read for file: %s, Exiting\n",
file);
64 printf(
"%s: rd_grib_grid failed for file: %s\n", __FILE__,
file);
118 if ((stream = fopen(
file,
"r")) ==
NULL) {
119 printf(
"Unable to open GRIB file: %s, Exiting\n",
file);
126 printf(
"%s: rd_grib_grid failed for file: %s\n", __FILE__,
file);
138 if ((rgmode == 1) && (retcode == 0)) {
139 if ((xfr_arr = (
float *) malloc(
npix *
sizeof (
float))) ==
NULL) {
140 printf(
"%s: Transfer space allocation failed\n", __FILE__);
143 for (ilin = 0; ilin <
nlin / 2; ilin++) {
144 memcpy((
void *) xfr_arr, (
void *) (
data + ilin *
npix),
145 npix *
sizeof (
float));
146 memcpy((
void *) (
data + ilin *
npix),
148 npix *
sizeof (
float));
150 (
void *) xfr_arr,
npix *
sizeof (
float));
159 int *
nlin,
int *h_fcst)
193 int retcode, nchr, month,
day;
194 char *equal_ptr, *nex_ptr, *nex_ptr2, tmp_str[200];
206 if ((equal_ptr = strrchr(grib2_t_str,
'=')) ==
NULL) {
207 printf(
"%s: Unable to find start of time in GRIB 2 time string of: %s\n",
208 __FILE__, grib2_t_str);
211 if (sscanf(equal_ptr,
"=%4d%2d%2d%2d",
year, &month, &
day, hour) != 4) {
212 printf(
"%s: Unable to decode time in GRIB 2 time string of: %s\n",
213 __FILE__, grib2_t_str);
220 if ((nex_ptr = strchr(equal_ptr,
'(')) ==
NULL) {
226 if ((nex_ptr2 = strchr(nex_ptr,
')')) ==
NULL) {
227 printf(
"%s, %d: wgrib2 info string has no ')' in grid size portion\n",
231 nchr = nex_ptr2 - nex_ptr + 1;
232 strncpy(tmp_str, nex_ptr, nchr);
233 if (sscanf(tmp_str,
"(%d x %d)",
npix,
nlin) != 2) {
234 printf(
"%s, %d: Unable to convert grid size info\n",
239 if ((nex_ptr = strchr(nex_ptr2,
':')) ==
NULL) {
240 printf(
"%s, %d: wgrib2 info string has no forecast time info\n",
244 if (strcmp(nex_ptr,
":anl") == 0)
247 if (sscanf(nex_ptr,
":%d", h_fcst) != 1) {
248 printf(
"%s, %d: Unable to convert forecast time info\n",
258 sec = (
double) *hour * 3600;
260 unix_t += (
double) *h_fcst * 3600;
268 float *
data,
int nprfl,
int *
year,
int *month,
int *
day,
int *hour)
305 int retcode, iprfl,
offset,
doy, npix_n, nlin_n, h_fcst;
307 int grib2_t(
char *,
int *,
int *,
int *,
int *,
int *,
int *);
312 if ((stream = fopen(
file,
"r")) ==
NULL) {
313 printf(
"Unable to open GRIB file: %s, Exiting\n",
file);
319 if (
grib2_t(grib2_t_str,
year, &
doy, hour, &npix_n, &nlin_n, &h_fcst) != 0)
327 for (iprfl = 0; iprfl < nprfl; iprfl++) {
329 printf(
"%s: rd_grib_grid failed for file: %s\n", __FILE__,
file);
369 int expect_ct, retcode, in_nbyt, nbyt;
380 if ((rd_count = fread(&in_nbyt,
sizeof (
int), expect_ct, stream))
382 printf(
"Error on header read of GRIB file, Exiting\n");
389 if (in_nbyt != nbyt) {
390 printf(
"current grid size of %d bytes is not the expected size of 144 X 73 = %d bytes, Exiting\n", in_nbyt, nbyt);
397 if ((rd_count = fread(
data,
sizeof (
float), npt_grid, stream)) != npt_grid) {
398 printf(
"Error reading grid from GRIB file, Exiting\n");
404 if ((rd_count = fread(&in_nbyt,
sizeof (
int), expect_ct, stream))
406 printf(
"Error on footer read of GRIB file, Exiting\n");
440 int retcode, expect_ct, rd_count, lenarr[2];
441 unsigned char pds_gds[100];
449 if ((rd_count = fread(lenarr,
sizeof (
int), expect_ct, stream)) !=
451 printf(
"Error on 1st PDS read\n");
459 expect_ct = lenarr[0];
461 fread(pds_gds,
sizeof (
unsigned char), expect_ct, stream))
463 printf(
"Error on 2nd PDS read\n");
471 *month = pds_gds[13];
478 if ((rd_count = fread(lenarr,
sizeof (
int), expect_ct, stream)) !=
480 printf(
"Error on 3rd PDS read\n");
484 expect_ct = lenarr[0];
486 fread(pds_gds,
sizeof (
unsigned char), expect_ct, stream))
488 printf(
"Error on 4th PDS read\n");
516 if ((errcod = ferror(stream)) != 0) {
517 printf(
"Error code of %d encountered\n", errcod);
518 }
else if (feof(stream) != 0) {
519 printf(
"EOF encountered\n");
521 printf(
"Only %d values were read instead of the expected %d values\n",
522 rd_count, expect_ct);
int readgrib2_3d(char *file, char *grib2_t_str, int npix, int nlin, float *data, int nprfl, int *year, int *month, int *day, int *hour)
int rd_grib_grid(FILE *stream, int npix, int nlin, float *data)
no change in intended resolving MODur00064 Corrected handling of bad ephemeris attitude resolving resolving GSFcd00179 Corrected handling of fill values for[Sensor|Solar][Zenith|Azimuth] resolving MODxl01751 Changed to validate LUT version against a value retrieved from the resolving MODxl02056 Changed to calculate Solar Diffuser angles without adjustment for estimated post launch changes in the MODIS orientation relative to incidentally resolving defects MODxl01766 Also resolves MODxl01947 Changed to ignore fill values in SCI_ABNORM and SCI_STATE rather than treating them as resolving MODxl01780 Changed to use spacecraft ancillary data to recognise when the mirror encoder data is being set by side A or side B and to change calculations accordingly This removes the need for seperate LUTs for Side A and Side B data it makes the new LUTs incompatible with older versions of the and vice versa Also resolves MODxl01685 A more robust GRing algorithm is being which will create a non default GRing anytime there s even a single geolocated pixel in a granule Removed obsolete messages from seed file
int grib2_t(char *grib2_t_str, int *year, int *doy, int *hour, int *npix, int *nlin, int *h_fcst)
void yd2md(int16_t year, int16_t doy, int16_t *month, int16_t *dom)
void rpt_err_typ(int rd_count, int expect_ct, FILE *stream)
int readgrib2(char *file, int npix, int nlin, int rgmode, float *data)
void unix2yds(double usec, short *year, short *day, double *secs)
integer, parameter double
int readgrib(char *file, int npix, int nlin, float *data, int *year, int *month, int *day, int *hour)
no change in intended resolving MODur00064 Corrected handling of bad ephemeris attitude data
int rd_grib_pds(FILE *stream, int *year, int *month, int *day, int *hour)
PARAM_TYPE_NONE Default value No parameter is buried in the product name name_prefix is case insensitive string compared to the product name PARAM_TYPE_VIS_WAVE The visible wavelength bands from the sensor are buried in the product name The product name is compared by appending and name_suffix ie aph_412_giop where prod_ix will be set to PARAM_TYPE_IR_WAVE same search method as PARAM_TYPE_VIS_WAVE except only wavelength above are looped through but prod_ix is still based ie aph_2_giop for the second and prod_ix set to PARAM_TYPE_INT name_prefix is compared with the beginning of the product name If name_suffix is not empty the it must match the end of the product name The characters right after the prefix are read as an integer and prod_ix is set to that number strncpy(l2prod->name_prefix, "myprod", UNITLEN)
double ymds2unix(short year, short month, short day, double secs)