/* read_mfi_asc_3s.c Purpose: provide an example of how to read Wind/mfi 3 s 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 sec second of the minute (0.0-59.9999) 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 Note: (1) The orbital information is only provided with the 1-m or hourly average ascii files. These files can be obtained at the NASA Goddard Space Flight Center, National Space Science Data Center archive. (2) Format used to write the record: "%d %d %d %d %d %.1f %.6g %.6g %.6g %.6g %.6g %.6g %.6g %.6g %.6g %.6g %d\n" Created by, Sean Chen, HSTX 10/17/97 */ #include main() { int yr,mon,day,hr,min,npts; float sec,bgse[3],bgsm[3],bt,brmsgsm[3],brmst; 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 %f %d", &yr,&mon,&day,&hr,&min,&sec, &bgse[0],&bgse[1],&bgse[2],&bgsm[1],&bgsm[2],&bt, &brmsgsm[0],&brmsgsm[1],&brmsgsm[2],&brmst,&npts)!=EOF){ i++; bgsm[0]=bgse[0]; printf("(Year,mon,day,hr,min,sec)=%d %d %d %d %d %.1f", yr,mon,day,hr,min,sec); 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 npts:%d\n", brmsgsm[0],brmsgsm[1],brmsgsm[2],brmst,npts); } fclose(fr); printf("Total number of records: %lu\n",i); }