Mapper
get_data.c
Go to the documentation of this file.
1 #include <stdio.h>
2 #include <string.h>
3 #include <stdlib.h>
4 #define MISSING "---"
5 
6 get_data(char month[4], FILE *fp, FILE *fq,int year, char id[9], int numpe,
7  int s_day, int e_day, int divide[10], int conver[10])
8 
9 {
10 
11 char buffer[131];
12 char mon[12][4] = {"JAN","FEB","MAR","APR","MAY","JUN","JUL","AUG","SEP",
13  "OCT","NOV","DEC"};
14 int day[12] = {31,28,31,30,31,30,31,31,30,31,30,31};
15 int i,j,k,l,date,count,iyr,data_day,dday;
16 float divalue;
17 char value[11][12];
18 
19 iyr = year/4*4;
20 if (iyr == year)
21  day[1]=29;
22 
23 for(j=0;j<12;j++)
24  if(strcmp(month,mon[j]) == 0)
25  count = j + 1;
26 
27 date = count*100 + 1;
28 
29 for(j=1;j<=e_day+1;j++,date++)
30 {
31  if(date - date/100*100 > day[count-1])
32  {
33  date = ((count+1) * 100) + 1;
34  if(count > 11)
35  date = 101;
36  }
37  fgets(buffer,131,fp);
38  if(strlen(buffer) > 4)
39  {
40  /* init values to missing */
41  for(i=0;i<8;i++)
42  strcpy(value[i],MISSING);
43 
44  sscanf(buffer,"%d %s %s %s %s %s %s %s %s %s %s %s",
45  &dday,value[0],value[1],value[2],value[3],
46  value[4],value[5],value[6],value[7],value[8],
47  value[9],value[10]);
48 
49  for(i=0,l=0;i<numpe;i++)
50  if(strcmp(value[i],MISSING) == 0)
51  l++;
52 
53  if(l >= numpe)
54  break;
55 
56  if(dday >= s_day && dday <= e_day)
57  {
58  fprintf(fq,"%s DM%4.4d",id,date);
59  for(i=0;i<numpe;i++)
60  {
61  if(strcmp(value[i],MISSING) == 0)
62  fprintf(fq," / M ");
63  else if(divide[i] == 1 && conver[i] == 0)
64  fprintf(fq," / %.2f",atof(value[i])/1000.);
65  else if(divide[i] == 1 && conver[i] == 1)
66  fprintf(fq," / %.2f",atof(value[i])/1000.0 * 0.504);
67  else
68  fprintf(fq," / %.2f",atof(value[i]));
69  }
70  fprintf(fq,"\n");
71  }
72  }
73 }
74 
75 fprintf(fq,".END\n");
76 }
77 
static int i
int day
Definition: display_data.c:26
int year
Definition: display_data.c:26
int month
Definition: display_data.c:26
get_data(char month[4], FILE *fp, FILE *fq, int year, char id[9], int numpe, int s_day, int e_day, int divide[10], int conver[10])
Definition: get_data.c:6
#define MISSING
Definition: get_data.c:4
char * mon[]
fp
Definition: make_NEXRAD.c:339
fprintf(fp,"%d %d %d %d 1\n", iminx, iminy, maxi, maxj)
int j
Definition: mapp2h.h:48
int count[131][131]
Definition: mapp2h.h:50
int k
Definition: mapp2h.h:48
float value