libipvlbi.h

来自「实现ipvlbi数据记录」· C头文件 代码 · 共 980 行 · 第 1/3 页

H
980
字号
       float f3;         // float work       float pcal,vbw;    // PCAL frequency, video width       double pi=3.14159265;  // PI       int len;       int idct;  // $STATION staion ID field counter (temporary use)       FILE *stream;       fpos_t pos;	printf("FILE : %s\n",fname);       if( (stream  = fopen( fname, "r" )) == NULL )       {          //perror( "擖椡僼傽僀儖偑奐偗傑偣傫" );          //exit( 1 );	   // return -1;          printf("File not found or Open Error! \n");          exit(1);	   //goto exitend2;        }        skd->nstar=0;        skd->nstation=0;        skd->nfreq=0;        skd->nobs=0;        idct=0;     loop1:       if( fgets( line, 500, stream ) == NULL)        {          //printf("File EOF or Read Error!\n");	   goto exitend;        }        /* Schedule File Analysis */    	if(line[0]=='*') {  goto loop1; } // this is comment line (nothing to do)         	if(line[0]=='$')  // this is command line         { loop2:          len = strlen(line);          //printf("len = %d\n",len);  // debug          if (len >= 5)          {           //strncpy(s1,line,5);          //strcpy(s2,"$EXPER");	     if(strncmp(line,"$EXPER",5)==0)        // 幚尡僐乕僪               {                    k=sscanf(line, "%s %s", cbuf, skd->expcode);               printf("$EXPER Detected! \n");              printf("EXPCODE = %s\n",skd->expcode);            }	     else if(strncmp(line,"$PARAM",5)==0)        // 僷儔儊乕僞               {                /* not used in IP-VLBI */                    //printf("$PARAM Detected! \n");            }	     else if(strncmp(line,"$SOURCES",5)==0)        // 揹攇惎忣曬               {                     printf("$SOURCES Detected! \n");  loop_star:               if( fgets( line, 500, stream ) == NULL)               {                 //printf("File EOF or Read Error!\n");	          goto exitend;               }	        if(line[0]=='*') {  goto loop_star; } // this is comment line (nothing to do)  	        if(line[0]=='$') {   goto loop2; } // this is command line                  //printf("%s\n",line);             //    k=sscanf(line, "%s %s %d %d %s %d %d %s %f",      // deleted on 2002-07-06             //      starnam,altnam,&i1,&i2,s1,&i3,&i4,s2,&f3);    //                  k=sscanf(line, "%s %s %d %d %s %s %d %s %f",      // 2002-07-06                   starnam,altnam,&i1,&i2,s1,s3,&i4,s2,&f3);    //                    d1=atof(s1);                 d2=atof(s2); 		  i3=atoi(s3);  //2002-07-06                //printf("%d %f %f\n",skd->nstar+1,d1,d2);               strcpy(skd->starnam1[skd->nstar],starnam);               strcpy(skd->starnam2[skd->nstar],altnam);               d3=(double)i1*15.0+(double)i2/4.0 + d1/240.0 ;               skd->ra[skd->nstar]=d3;               i5=abs(i3);               d3=(double)i5+(double)i4/60.0 + d2/3600.0 ;               //if (i3 <0) { d3 = -d3 ; }         // deleted  on 2002-07-06               if (strncmp(s3,"-",1) == 0) { d3 = -d3 ; }        // 2002-07-06               skd->dec[skd->nstar]=d3;               skd->epo[skd->nstar]=f3;               skd->nstar++;               if(skd->nstar >= MAXSTAR) {                   printf("Number of Stars exceeds limit (MAXSTAR)\n");                   skd->nstar -= 1;    // to avoid array overflow               }               goto loop_star;                           }	     else if(strncmp(line,"$STATIONS",5)==0)        // 嬊埵抲忣曬               {                     printf("$STATIONS Detected! \n");  loop_station:               if( fgets( line, 500, stream ) == NULL)               {                 //printf("File EOF or Read Error!\n");	          goto exitend;               }	        if(line[0]=='*') {  goto loop_station; } // this is comment line (nothing to do)  	        if(line[0]=='$') {   goto loop2; } // this is command line                   //printf("%s\n",line);               if(line[0]=='A')    // Station ID set               {                   k=sscanf(line, "%*s %s %s", s1,s2);                  //  printf("ID NAME length %d %d\n",strlen(s1),strlen(s2));                   strcpy(wstatid[idct],s1);                   strcpy(wstatnam[idct],s2);                   idct++;                }               if(line[0]=='P')    // Station XYZ               {                   k=sscanf(line, "%*s %*s %s %s %s %s", cbuf,s1,s2,s3);                    d1=atof(s1);                   d2=atof(s2);                   d3=atof(s3);                   strcpy(skd->statnam[skd->nstation],cbuf);                   skd->xyz[skd->nstation][0]=d1;                   skd->xyz[skd->nstation][1]=d2;                   skd->xyz[skd->nstation][2]=d3;                   skd->nstation++;                }                goto loop_station;                           }	     else if(strncmp(line,"$CODES",5)==0)        // 廃攇悢忣曬               {                     printf("$CODES Detected! \n");  loop_freq:               if( fgets( line, 500, stream ) == NULL)               {                 //printf("File EOF or Read Error!\n");	          goto exitend;               }	        if(line[0]=='*') {  goto loop_freq; } // this is comment line (nothing to do)  	        if(line[0]=='$') {   goto loop2; } // this is command line                   //printf("%s\n",line);               if(line[0]=='C')    // Frequency info               {                   k=sscanf(line, "%*s %*s %*s %s %f %d %*s %f", s1,&pcal,&i1,&vbw);                    //printf("%d %s %f %d %f %d\n",skd->nfreq,s1,pcal,i1,vbw,strlen(s1));                                 //strcat(s1,"\0");                   if(*s1 != 'x' && *s1 != 'X') {    // to avoid  xxxx.xx or XXXX.XX                      d1=atof(s1);                      //d1=atof("1234.567");  debug                      //printf("d1= %f\n",d1);                      //printf("d1= %f\n",atof("1234.567"));                      skd->freqtab[i1-1]=d1;                      skd->nfreq++;                   }                }                goto loop_freq;                           }	     else if(strncmp(line,"$SKED",5)==0)        // 僗働僕儏乕儖               {                     printf("$SKED Detected! \n");  loop_sked:               if( fgets( line, 500, stream ) == NULL)               {                 //printf("File EOF or Read Error!\n");	          goto exitend;               }	        if(line[0]=='*') {  goto loop_sked; } // this is comment line (nothing to do)  	        if(line[0]=='$') {   goto loop2; } // this is command line                   //printf("%s\n",line);               k=sscanf(line, "%s %*s %*s %*s %s %d %*s %*d %*s %s", s1,s2,&i1,s4);                skd->dura[skd->nobs]=i1;               strcpy(skd->obsstar[skd->nobs],s1);               strncpy(cbuf,spc,20); // set all space code               strncpy(cbuf,s2,2);               i1=atoi(cbuf);               strncpy(cbuf,spc,20); // set all space code               strncpy(cbuf,s2+2,3);               i2=atoi(cbuf);               strncpy(cbuf,spc,20); // set all space code               strncpy(cbuf,s2+5,2);               i3=atoi(cbuf);               strncpy(cbuf,spc,20); // set all space code               strncpy(cbuf,s2+7,2);               i4=atoi(cbuf);               strncpy(cbuf,spc,20); // set all space code               strncpy(cbuf,s2+9,2);               i5=atoi(cbuf);               skd->start[skd->nobs][0]=i1;               skd->start[skd->nobs][1]=i2;               skd->start[skd->nobs][2]=i3;               skd->start[skd->nobs][3]=i4;               skd->start[skd->nobs][4]=i5;               len=strlen(s4);               //printf("%d %s\n",len,s4);  // debug               //printf("%d %d %d %d %d\n",skd->start[skd->nobs][0],               //    skd->start[skd->nobs][1],               //    skd->start[skd->nobs][2],               //    skd->start[skd->nobs][3],               //    skd->start[skd->nobs][4]);  // debug               //strncpy(skd->obsid[skd->nobs],s4,len); // not good under WIN32 condition               strcpy(skd->obsid[skd->nobs],s4);  //2002-09-13               //printf("%s\n",skd->obsid[skd->nobs]);               skd->nobs++;               if(skd->nobs >= MAXOBS) {                     printf("Number of scans exceeds limit (MAXOBS)\n");                   skd->nobs -= 1;    // to avoid array overflow               }               goto loop_sked;                           }            /*	     else if(strncmp(line,"$HEAD",5)==0)        // head stack information              {                     printf("$HEAD Detected! \n");            }	     else if(strncmp(line,"$FLUX",5)==0)        // FLUX 忣曬               {               printf("$FLUX Detected! \n");            }	     else if(strncmp(line,"$PROC",5)==0)        // station procedure 忣曬               {               printf("$PROC Detected! \n");            }            */            else            {              /*              printf("Unknown $ parameter detected as follows\n");              printf("%s\n",line);              */            }         } else          {            /*            if (len >=3 && strncmp(line,"$OP",3)==0)        // $OP                  {                        printf("$OP Detected! \n");               }            else            {              printf("Unknown $ parameter detected as follows\n");              printf("%s\n",line);            }           */         }       }       goto loop1; exitend:       fgetpos(stream,&pos);  //debug	i=fclose( stream ) ;       //printf("%d bytes read\n",pos);        printf("Number of Sources = %d\n",skd->nstar);/*       for (i=0; i < skd->nstar; i++)       {          //strcpy(starnam,skd->starnam[i]);          printf("%d %s %s %f %f %f\n",i+1,skd->starnam1[i],skd->starnam2[i],             skd->ra[i],skd->dec[i],skd->epo[i]);          //printf("%d %s\n",i+1,starnam);       }*/            printf("Number of Stations = %d\n",skd->nstation);       /* Station ID table set up */              for (i=0; i < skd->nstation; i++)       {          strncpy(cbuf,spc,20); // set all space code          strcpy(cbuf,skd->statnam[i]);          for (k=0; k < idct; k++)          {               strncpy(s1,spc,20); // set all space code              strcpy(s1,wstatnam[k]);              len=strlen(s1);              //printf("len = %d\n",len);              if (strncmp(cbuf,s1,len)==0)              {                        //strncpy(skd->statid[i],' ',1);                      strcpy(skd->statid[i],wstatid[k]);                      goto exithere1; }           }           exithere1:           ;        }/*              for (i=0; i < skd->nstation; i++)       {          printf("%d %s %s %f %f %f\n",i+1,skd->statid[i],skd->statnam[i],               skd->xyz[i][0],skd->xyz[i][1],skd->xyz[i][2]);       }*/             printf("Number of Frequencies = %d\n",skd->nfreq);/*       for (i=0; i < skd->nfreq; i++)       {          printf("%d %f\n",i+1,skd->freqtab[i]);       }       */       /* Obs Star Index Table Setup */       if (skd->nstar > 0)        {           for (i=0; i < skd->nobs; i++)           {               strncpy(cbuf,spc,20); // set all space code               strcpy(cbuf,skd->obsstar[i]);               for (k=0; k < skd->nstar; k++)               {                   strcpy(s1,skd->starnam1[k]);                   len=strlen(s1);                   //printf("len = %d\n",len);                   if (strncmp(cbuf,s1,len)==0)                   {  skd->starid[i]=k;                      goto exithere; }                   strcpy(s1,skd->starnam2[k]);                   len=strlen(s1);                   if (strncmp(cbuf,s1,len)==0)                   {  skd->starid[i]=k;                      goto exithere; }                 }                 skd->starid[i]=-1;   exithere:   ;             }         }                printf("Number of Observations = %d\n",skd->nobs);

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?