/* read_mfi_asc_1h.c Purpose: provide an example of how to read Wind/mfi hourly ascii files Content of the ascii files in each recod: int yr Year (e.g., 1996) int mon Month (e.g. 1-January...12-December) int day Day of Month (1...28/29/30/31) int hr Hour (1 -24) int min Minute (0-59) float bgse[0] X component of B in GSE coordinate in nT float bgse[1] Y component of B in GSE coordinate in nT float bgse[2] Z component of B in GSE coordinate in nT float bgsm[0] X component of B in GSM coordinate in nT float bgsm[1] Y component of B in GSM coordinate in nT float bgsm[2] Z component of B in GSM coordinate in nT float bt Total magnetic flux in nT float brmsgsm[0] X component of the rms of B in nT float brmsgsm[1] Y component of the rms of B in nT float brmsgsm[2] Z component of the rms of B in nT float brmst Total magnitude of the rms of B in nT int npts No. of Points used in averaging float pgse[0] X component of s/c position in GSE coordinate in Re float pgse[1] Y component of s/c position in GSE coordinate in Re float pgse[2] Z component of s/c position in GSE coordinate in Re float pgsm[0] X component of s/c position in GSM coordinate in Re float pgsm[1] Y component of s/c position in GSM coordinate in Re float pgsm[2] Z component of s/c position in GSM coordinate in Re Note: (1) Format used to write the record: "%d %d %d %d %d %.6g %.6g %.6g %.6g %.6g %.6g %.6g %.6g %.6g %.6g %d %.6g %.6g %.6g %.6g %.6g\n" Create by, Sean Chen, HSTX 10/17/97 */ #include main() { int yr,mon,day,hr,min,npts; float bgse[3],bgsm[3],bt,brmsgsm[3],brmst,pgse[3],pgsm[3]; unsigned long i=0; char filename[80]; FILE *fr; printf("input file? "); scanf("%s",filename); fr=fopen(filename,"r"); while(fscanf(fr, "%d %d %d %d %d %f %f %f %f %f %f %f %f %f %f %d %f %f %f %f %f", &yr,&mon,&day,&hr,&min, &bgse[0],&bgse[1],&bgse[2],&bgsm[1],&bgsm[2],&bt, &brmsgsm[0],&brmsgsm[1],&brmsgsm[2],&brmst,&npts, &pgse[0],&pgse[1],&pgse[2],&pgsm[1],&pgsm[2])!=EOF){ i++; bgsm[0]=bgse[0]; pgsm[0]=pgse[0]; printf("(Year,mon,day,hr,min)=%d %d %d %d %d", yr,mon,day,hr,min); printf(" BGSE=(%.6g %.6g %.6g) BGSM=(%.6g %.6g %.6g) Bt=%.6g", bgse[0],bgse[1],bgse[2],bgsm[0],bgsm[1],bgsm[2],bt); printf(" BRMSGSM=(%.6g %.6g %.6g) BRMST=%.6g %d", brmsgsm[0],brmsgsm[1],brmsgsm[2],brmst,npts); printf(" PGSE=(%.6g %.6g %.6g) PGSM=(%.6g %.6g %.6g)\n", pgse[0],pgse[1],pgse[2],pgsm[0],pgsm[1],pgsm[2]); } fclose(fr); printf("Total number of records: %lu\n",i); }