/** read new sekibunkyu spectrum data **/ /** 2013.12/18 by Akira Kadokura **/ #include #include #include #include static char in_dir[] ="/data/aurora/amuaurora/Syowa/Syowa_WMI/CAL/integrating_sphere_spectrum_data"; static char out_dir[] ="/data/aurora/amuaurora/Syowa/Syowa_WMI/CAL/integrating_sphere_spectrum_data"; main(argc,argv) int argc; char *argv[]; { FILE *fin,*fout,*fopen(); char fin_name[200],fout_name[200]; static char chead[256]; static int iWL0; static float dat[10]; int i,j,iend,iref,nspe; float WL[8000],SR[10][8000],WL1,SR1[10]; /******************/ if(argc != 4){ printf("Please key-in (e.g. rdsekibunkyu (directory name & file name) (number of spectrum data) (wave length)\n"); exit(0); }; sprintf(fin_name,"%s/%s",in_dir,argv[1]); nspe = atoi(argv[2]); WL1 = atof(argv[3]); fin = fopen(fin_name,"r"); if(fin==0){ printf("%s does not exist !!\n",fin_name); exit(0); }; sprintf(fout_name,"%s/%s_intensity.txt",out_dir,argv[3]); fout = fopen(fout_name,"w"); /** dummy read **/ while(1){ fgets(chead,255,fin); if(chead[1]=='D' && chead[2]=='a' && chead[3]=='t' && chead[4]=='a') break; }; /** read wave_length & spectral radiance data **/ i=-1; while(fgets(chead,255,fin)!=NULL){ if(nspe==3) sscanf(chead,"%d,%f,%f,%f",&iWL0,&dat[0],&dat[1],&dat[2]); if(nspe==4) sscanf(chead,"%d,%f,%f,%f,%f",&iWL0,&dat[0],&dat[1],&dat[2],&dat[3]); if(nspe==5) sscanf(chead,"%d,%f,%f,%f,%f,%f",&iWL0,&dat[0],&dat[1],&dat[2],&dat[3],&dat[4]); if(nspe==6) sscanf(chead,"%d,%f,%f,%f,%f,%f,%f",&iWL0,&dat[0],&dat[1],&dat[2],&dat[3],&dat[4],&dat[5]); ++i; for(j=0;jWL1){ SR1[j] = (WL1 - WL[i-1])/(WL[i] - WL[i-1])*(SR[j][i] - SR[j][i-1]) + SR[j][i-1]; iref = i; break; }; }; printf("%02d: wave length(nm):%8.3f radiance(uW/m2/sr/nm):%f\n",j,WL1,SR1[j]); printf("WL(i-1)(nm):%8.3f SR(i-1)(uW/m2/sr/nm):%9.3e\n",WL[iref-1],SR[j][iref-1]); printf("WL(i)(nm):%8.3f SR(i)(uW/m2/sr/nm):%9.3e\n",WL[iref],SR[j][iref]); fprintf(fout,"%02d: wave length(nm):%8.3f radiance(uW/m2/sr/nm):%f\n",j,WL1,SR1[j]); }; printf("\n"); printf("wave length(nm):%8.3f\n",WL1); printf("radiance(uW/m2/sr/nm)\n"); for(j=0;j