示例#1
0
文件: formBats.C 项目: zhuww/tempo2
void formBats(pulsar *psr,int npsr)
{
  int i,p;
  //  double etatdm;
  double shapiroDelay;
  const char *CVS_verNum = "$Revision: 1.8 $";

  if (displayCVSversion == 1) CVSdisplayVersion("formBats.C","formBats()",CVS_verNum);

  logdbg("In formBats");

  for (p=0;p<npsr;p++)
    {
      for (i=0;i<psr[p].nobs;i++)
	{
	  //	  if (psr[p].obsn[i].clockCorr==0 || psr[p].obsn[i].delayCorr==0)
	  if (psr[p].obsn[i].delayCorr==0)
	    psr[p].obsn[i].bat = psr[p].obsn[i].sat;
	  else
	    {
	      /* ORIGINAL TEMPO calculation */
	      if (psr[p].calcShapiro==-1)
		shapiroDelay = 0.0;
	      else
		shapiroDelay = psr[p].obsn[i].shapiroDelaySun + psr[p].planetShapiro*
		  (psr[p].obsn[i].shapiroDelayVenus+
		   psr[p].obsn[i].shapiroDelayJupiter+psr[p].obsn[i].shapiroDelaySaturn
		   +psr[p].obsn[i].shapiroDelayUranus + psr[p].obsn[i].shapiroDelayNeptune);
	     	   //if(i==0){printf("Forming bat with sat = %.15g TT = %.15g TT_TB = %.15g trop = %.15g roemer = %.15g shap = %.15g tdis1 = %.15g tdis2 = %.15g\n",(double)psr[p].obsn[i].sat,(double)getCorrectionTT(psr[p].obsn+i),(double)psr[p].obsn[i].correctionTT_TB,(double)psr[p].obsn[i].troposphericDelay,(double)psr[p].obsn[i].roemer,(double)shapiroDelay,(double)psr[p].obsn[i].tdis1,(double)psr[p].obsn[i].tdis2);}
		     

		long double batcorr=getCorrectionTT(psr[p].obsn+i)/SECDAY
                + (psr[p].obsn[i].correctionTT_TB
                   -psr[p].obsn[i].troposphericDelay
                   +psr[p].obsn[i].roemer -
                   shapiroDelay - psr[p].obsn[i].tdis1 - psr[p].obsn[i].tdis2)/SECDAY;

                psr[p].obsn[i].batCorr = batcorr;

	      psr[p].obsn[i].bat = psr[p].obsn[i].sat + 
		getCorrectionTT(psr[p].obsn+i)/SECDAY 
		+ (psr[p].obsn[i].correctionTT_TB
		   -psr[p].obsn[i].troposphericDelay
		   +psr[p].obsn[i].roemer - 
		   shapiroDelay - psr[p].obsn[i].tdis1 - psr[p].obsn[i].tdis2)/SECDAY;

	      /* Now calculate binary barycentric arrival time (bbat) */
	      psr[p].obsn[i].bbat = psr[p].obsn[i].bat - (psr[p].obsn[i].shklovskii)/SECDAY;
	    }
	}
    }
  logdbg("Leaving formBats");
}
示例#2
0
/* ******************************************** */
void displayParameters(int pos,char timFile[][MAX_FILELEN],char parFile[][MAX_FILELEN],pulsar *psr,int npsr)
{
  int i, ic, p;
  const char *CVS_verNum = "$Revision: 1.5 $";

  if (displayCVSversion == 1) CVSdisplayVersion("displayParameters.C","displayParameters()",CVS_verNum);
  
  printf("\n\n");
  if (pos==1) printf("Parameter values after getInputs from command line\n");
  if (pos==2) printf("Parameter values after reading of .par file\n");
  if (pos==3) printf("Parameter values after reading of .tim file\n");
  if (pos==4) printf("After obtaining correction between observatory UTC and UTC(NIST)\n");
  if (pos==5) printf("After calculating correction between UTC and TAI\n");
  if (pos==6) printf("After calculating correction between TAI and TB\n");
  if (pos==7) printf("After calculating vector pointing at pulsar\n");

  printf("\n\n");
  printf("lobal definitions:\n\n");
  printf("MAX_FREQ_DERIVATIVES = %d\n",MAX_FREQ_DERIVATIVES);
  printf("MAX_DM_DERIVATIVES   = %d\n",MAX_DM_DERIVATIVES);
  printf("MAX_FILELEN          = %d\n",MAX_FILELEN);
  printf("\n\n");
  for (p=0;p<npsr;p++)
    {
      printf("Command line inputs:\n\n");
      printf("Pulse arrival time file[0] = %s\n",timFile[0]);
      printf("Pulsar parameter file[0]   = %s\n",parFile[0]);
      
      printf("\n\n");
      printf("Pulsar Parameters:\n\n");
      printf("Pulsar name          = %s\n",psr[p].name);
      if (pos>2) /* Have .tim file data */
	{
	  printf("\n\nObservations:\n\n");
	  printf("Number of observations = %d\n",psr[p].nobs);
	  printf("--------------------------------------------------------------------------------\n");
	  printf("   #  | SAT                   | Clock corrections(s)     |\n");
	  printf("--------------------------------------------------------------------------------\n");
	  for (i=0;i<psr[p].nobs;i++)
	  {
	    printf("|%4d | %s |", i+1, print_longdouble(psr[p].obsn[i].sat).c_str());
	    for (ic=0; ic < psr[p].obsn[i].nclock_correction; ic++)
	      printf(" %-14.7g(->%s)", 
		     (double)psr[p].obsn[i].correctionsTT[ic].correction,
		     psr[p].obsn[i].correctionsTT[ic].corrects_to);
	    printf("\n");
	  }
 	  printf("--------------------------------------------------------------------------------\n");
	  printf("   #   TAI->TB   | SAT->UT1      |\n");
	  printf("--------------------------------------------------------------------------------\n");
	  for (i=0;i<psr[p].nobs;i++)
	    printf("|%4d | %-10.9g | %-16.9e |\n",
		   i+1,
		   (double)psr[p].obsn[i].correctionTT_TB,
		   (double)psr[p].obsn[i].correctionUT1);
	  printf("--------------------------------------------------------------------------------\n");
	}
      if (pos>6)  /* Ephemeris information */
	{
	  printf("\n\nEphemeris information:\n\n");
	  printf("3-vector pointing at pulsar       = (%-13.13f,%-13.13f,%13.13f)\n",
		 psr[p].posPulsar[0],psr[p].posPulsar[1],psr[p].posPulsar[2]);
	  printf("3-vector giving pulsar's velocity = (%-13.8e,%13.8e,%13.8e)\n",
		 psr[p].velPulsar[0],psr[p].velPulsar[1],psr[p].velPulsar[2]);
	}
      if (pos>7)
	{
	  printf("\n\n");
	  printf("--------------------------------------------------------------------------------------------------------------\n");
	  printf("   JD            RCS(1)   RCS(2)     RCS(3)      RCB(1)     RCB(2)     RCB(3)    RBE(1)    RBE(2)    RBE(3)\n");
	  printf("--------------------------------------------------------------------------------------------------------------\n");
	  for (i=0;i<psr[p].nobs;i++)
	    {
	      printf("%-.5f %10.5f %-10.5f %-10.5f %-10.5f %-10.5f %-10.5f %-10.5f %-10.5f %-10.5f\n",
		     (double)(psr[p].obsn[i].sat + getCorrectionTT(psr[p].obsn+i)/SECDAY +
		     psr[p].obsn[i].correctionTT_TB/SECDAY 
		     + 2400000.5),
		     (double)psr[p].obsn[i].sun_ssb[0],
		     (double)psr[p].obsn[i].sun_ssb[1],
		     (double)psr[p].obsn[i].sun_ssb[2],
		     (double)psr[p].obsn[i].earthMoonBary_ssb[0],
		     (double)psr[p].obsn[i].earthMoonBary_ssb[1],
		     (double)psr[p].obsn[i].earthMoonBary_ssb[2],
		     (double)psr[p].obsn[i].earthMoonBary_earth[0],
		     (double)psr[p].obsn[i].earthMoonBary_earth[1],
		     (double)psr[p].obsn[i].earthMoonBary_earth[2]);
	    }
	  printf("--------------------------------------------------------------------------------------------------------------\n");
	  
	  printf("\n\n");
	  printf("--------------------------------------------------------------------------------------------------------------\n");
	  printf("   JD            RCS(4)   RCS(5)     RCS(6)      RCB(4)     RCB(5)     RCB(6)    RBE(4)    RBE(5)    RBE(6)\n");
	  printf("--------------------------------------------------------------------------------------------------------------\n");
	  for (i=0;i<psr[p].nobs;i++)
	    {
	      printf("%-.5lf %10.3e %-10.3e %-10.3e %-10.3e %-10.3e %-10.3e %-10.3e %-10.3e %-10.3e\n",
		     (double)(psr[p].obsn[i].sat + 
		     getCorrectionTT(psr[p].obsn+i)/SECDAY + 
		      psr[p].obsn[i].correctionTT_TB/SECDAY 
		     + 2400000.5),
		     (double)psr[p].obsn[i].sun_ssb[3],
		     (double)psr[p].obsn[i].sun_ssb[4],
		     (double)psr[p].obsn[i].sun_ssb[5],
		     (double)psr[p].obsn[i].earthMoonBary_ssb[3],
		     (double)psr[p].obsn[i].earthMoonBary_ssb[4],
		     (double)psr[p].obsn[i].earthMoonBary_ssb[5],
		     (double)psr[p].obsn[i].earthMoonBary_earth[3],
		     (double)psr[p].obsn[i].earthMoonBary_earth[4],
		     (double)psr[p].obsn[i].earthMoonBary_earth[5]);
	    }
	  printf("--------------------------------------------------------------------------------------------------------------\n");
	  printf("MJD         OBS->EARTH1   OBS->EARTH2  OBS->EARTH3  SITEVEL1    SITEVEL2     SITEVEL3\n");
	  printf("--------------------------------------------------------------------------------------------------------------\n");

	  for (i=0;i<psr[p].nobs;i++)
	    {
	      printf("%-.5lf %12.5e %-12.5e %-12.5e %-12.5e %-12.5e %-12.5e\n",
		     (double)psr[p].obsn[i].sat + 
		     getCorrectionTT(psr[p].obsn+i)/SECDAY,
		     psr[p].obsn[i].observatory_earth[0],psr[p].obsn[i].observatory_earth[1],
		     psr[p].obsn[i].observatory_earth[2],
		     psr[p].obsn[i].siteVel[0],psr[p].obsn[i].siteVel[1],psr[p].obsn[i].siteVel[2]);
	    }
	  printf("--------------------------------------------------------------------------------------------------------------\n");

	}
      if (pos>9) /* Extra Delays */
	{
	  printf("\n\nExtra Delays:\n\n");
	  
	  printf("--------------------------------------------------------------------------------------------------------------\n"); 
	  printf("MJD          ShapiroSun          TDIS               Roemer           BAT\n");
	  printf("--------------------------------------------------------------------------------------------------------------\n");
	  for (i=0;i<psr[p].nobs;i++)
	    {
	      printf("%s %.12e %.12e %.10Lf %.10f\n",print_longdouble(psr[p].obsn[i].sat).c_str(),psr[p].obsn[i].shapiroDelaySun,
		     psr[p].obsn[i].tdis1+psr[p].obsn[i].tdis2,psr[p].obsn[i].roemer,(double)psr[p].obsn[i].bat);
	    }
	  printf("--------------------------------------------------------------------------------------------------------------\n");
    }
    }

}
示例#3
0
void tt2tb(pulsar *psr,int npsr)
{
  int i, p,k;
  longdouble mjd_tt, mjd_teph;
  double deltaT=0.0, obsTerm, earthVel[3];
  double deltaTDot, obsTermDot, earthVelDot[3];
  int first=1;
  const char *CVS_verNum = "$Revision: 1.11 $";

  if (displayCVSversion == 1) CVSdisplayVersion("tt2tdb.C","tt2tdb()",CVS_verNum);

  init_ifte();
  for (p=0;p<npsr;p++)
  {
    for (i=0;i<psr[p].nobs;i++)
    {
      if (psr[p].obsn[i].clockCorr==0 && strcmp(psr[p].obsn[i].telID,"STL")!=0)
	psr[p].obsn[i].correctionTT_TB = 0.0;
      else
      {
	if (strcmp(psr[p].obsn[i].telID,"STL")==0)
	  mjd_tt = psr[p].obsn[i].sat;
	else
	  mjd_tt = psr[p].obsn[i].sat + getCorrectionTT(psr[p].obsn+i)/SECDAY;
	/* Evaluate the time ephemeris and its derivative */
	if (psr[p].timeEphemeris == IF99_TIMEEPH)
	  {
	    deltaT = IF_deltaT(mjd_tt);
	  }
	if (psr[p].timeEphemeris == FB90_TIMEEPH)
	  {
	    deltaT = FB_deltaT(mjd_tt) - IFTE_TEPH0; /* FB code returns Teph-TDB not TT-TDB */
	  }
	/* Get term involving observatory position (if known) */

	/*	for (k=0;k<3;k++)
		varray[k] = -psr[p].obsn[i].earthMoonBary_earth[k+3];
		vectorsum(earthVel, 
		psr[p].obsn[i].earthMoonBary_ssb+3,
		varray);   */
	for (k=0;k<3;k++)
	  earthVel[k] = psr[p].obsn[i].earth_ssb[k+3];
	obsTerm = dotproduct(earthVel, psr[p].obsn[i].observatory_earth)
	  /  (1.0-IFTE_LC) ;
	/* both vectors were meant to be defined in Ephemeris units ...
	 This correction is neglible but worth doing so we can test with K=2*/
	if (psr[p].units == SI_UNITS)
	  obsTerm /= (double)(IFTE_K*IFTE_K); // both were in SI 
	else
	  obsTerm /= (double)IFTE_K;  // obs_earth was in SI
	//	printf("obsTerm = %g\n",(double)obsTerm);
	/* Compute Teph : Irwin & Fukushima (1999) eq 13*/	
	/* Note, DeltaT(Teph0) ~ -2x10^-14 s so is neglected */
	psr[p].obsn[i].correctionTT_Teph = IFTE_TEPH0 + obsTerm
	  + deltaT / (1.0-IFTE_LC);
	/* Compute TCB or TDB as requested */
	if (psr[p].units == TDB_UNITS)
	  {
	    psr[p].obsn[i].correctionTT_TB = 
	      psr[p].obsn[i].correctionTT_Teph - (1? 0.0 : IFTE_TEPH0); 
	  }
	else
	  {
	    psr[p].obsn[i].correctionTT_TB = 
	      IFTE_KM1 * (double)(mjd_tt-IFTE_MJD0)*86400.0/* linear drift term */
	      + IFTE_K * (psr[p].obsn[i].correctionTT_Teph-(longdouble)IFTE_TEPH0);
	  }
	/* Compute dTB/dTT for correct frequency transfer if needed */
	if (psr[p].dilateFreq==1)
	{
	  if (first==1)
	    {
	      //	      init_ifte();
	      first=0;

	    }
	  mjd_teph = mjd_tt + psr[p].obsn[i].correctionTT_Teph/86400.0;

	  deltaTDot = IFTE_DeltaTDot(2400000.0+(int)mjd_teph, 
				     0.5+(mjd_teph-(int)mjd_teph));
	  // XXX seems deltaTDot is coming out too big
	  IFTE_get_vEDot(2400000.0+(int)mjd_teph, 
			 0.5+(mjd_teph-(int)mjd_teph), earthVelDot);
	  vectorscale(earthVelDot, 1.0/86400.0);
	  obsTermDot = 
	    (dotproduct(earthVelDot, psr[p].obsn[i].observatory_earth)
	     + dotproduct(earthVel, psr[p].obsn[i].siteVel))
	    /  (1.0-IFTE_LC) ;
	  if (psr[p].units == SI_UNITS)
	    obsTerm /= (double) (IFTE_K*IFTE_K); // both were in SI 
	  else
	    obsTerm /= (double)IFTE_K;  // obs_earth was in SI
	  
	  if (psr[p].units == TDB_UNITS)	    
	    psr[p].obsn[i].einsteinRate = 
	      1.0 + obsTermDot + deltaTDot/(1.0-IFTE_LC);
	  else
	    {
	      psr[p].obsn[i].einsteinRate = 
		IFTE_K * (1.0 + obsTermDot + deltaTDot/(1.0-IFTE_LC));
	      //	  obsTermDot = 
	      //	    (dotproduct(earthVelDot, psr[p].obsn[i].observatory_earth)
	      //	     + dotproduct(earthVel, psr[p].obsn[i].siteVel))
	      //	    /  (1.0-IFTE_LC) ;

							   
	    }
// 	  if (!first) printf("%g %g %g %g %g Einstein\n", (double)mjd_tt,
// 		 deltaT, deltaTDot, obsTerm, obsTermDot);
//	  if (!first)
//	    printf("ER-1 %lg\n", psr[p].obsn[i].einsteinRate-1.0);
	}	  
      }
    }
  }
  IFTE_close_file();
}
示例#4
0
void get_obsCoord(pulsar *psr,int npsr)
{
  double ph,eeq[3];
  int i,j,k; 
  double prn[3][3];
  double pc,oblq,toblq;
  double siteCoord[3];
  double erad,hlt,alng,hrd,tsid,sdd,speed,sitera;
  int p;
  observatory *obs;
  const char *CVS_verNum = "$Revision: 1.8 $";

  if (displayCVSversion == 1) CVSdisplayVersion("get_obsCoord.C","get_obsCoord()",CVS_verNum);

  for (p=0;p<npsr;p++)
    {
       for (i=0;i<psr[p].nobs;i++)
	{ 
	  if (psr[p].obsn[i].delayCorr!=0)
	    {	     
	      if (strcmp(psr[p].obsn[i].telID,"STL")==0 ||
		  strcmp(psr[p].obsn[i].telID,"STL_FBAT")==0) // Satellite
		{
		  psr[p].obsn[i].siteVel[0] = 0.0;
		  psr[p].obsn[i].siteVel[1] = 0.0;
		  psr[p].obsn[i].siteVel[2] = 0.0;		  

		  // Set from the TELX, TELY, TELZ parameters
		  if (psr[p].param[param_telx].paramSet[0] == 1)
		    {
		      longdouble arg,deltaT,t0,pos;

		      if (psr[p].param[param_telEpoch].paramSet[0]==1)
			t0 = psr[p].param[param_telEpoch].val[0];
		      else
			t0 = 0.0L;

		      deltaT = (psr[p].obsn[i].sat - t0)*SECDAY;		
		      arg = deltaT;
		      pos = psr[p].param[param_telx].val[0];
		      if (psr[p].param[param_telx].paramSet[1] == 1) {
			pos += psr[p].param[param_telx].val[1]*arg;
			if (psr[p].param[param_telEpoch].paramSet[0]==0)
			  {
			    printf("ERROR: Using telescope velocity without setting telEpoch\n");
			    exit(1);
			  }
		      }
		      arg *= deltaT; if (psr[p].param[param_telx].paramSet[2] == 1) pos += (0.5*psr[p].param[param_telx].val[2]*arg);
		      arg *= deltaT; if (psr[p].param[param_telx].paramSet[3] == 1) pos += (1.0L/6.0L*psr[p].param[param_telx].val[3]*arg);
		      psr[p].obsn[i].observatory_earth[0] = (double)pos;
		      printf("Setting x to %g\n",(double)psr[p].obsn[i].observatory_earth[0]);
		    }
		  if (psr[p].param[param_tely].paramSet[0] == 1)
		    {
		      longdouble arg,deltaT,t0,pos;

		      if (psr[p].param[param_telEpoch].paramSet[0]==1)
			t0 = psr[p].param[param_telEpoch].val[0];
		      else
			t0 = 0.0L;

		      deltaT = (psr[p].obsn[i].sat - t0)*SECDAY;		
		      arg = deltaT;
		      pos = psr[p].param[param_tely].val[0];
		      if (psr[p].param[param_tely].paramSet[1] == 1) pos += psr[p].param[param_tely].val[1]*arg;
		      arg *= deltaT; if (psr[p].param[param_tely].paramSet[2] == 1) pos += (0.5*psr[p].param[param_tely].val[2]*arg);
		      arg *= deltaT; if (psr[p].param[param_tely].paramSet[3] == 1) pos += (1.0L/6.0L*psr[p].param[param_tely].val[3]*arg);
		      psr[p].obsn[i].observatory_earth[1] = (double)pos;
		      printf("Setting y to %g\n",(double)psr[p].obsn[i].observatory_earth[1]);
		    }
		  if (psr[p].param[param_telz].paramSet[0] == 1)
		    {
		      longdouble arg,deltaT,t0,pos;

		      if (psr[p].param[param_telEpoch].paramSet[0]==1)
			t0 = psr[p].param[param_telEpoch].val[0];
		      else
			t0 = 0.0L;

		      deltaT = (psr[p].obsn[i].sat - t0)*SECDAY;		
		      arg = deltaT;
		      pos = psr[p].param[param_telz].val[0];
		      if (psr[p].param[param_telz].paramSet[1] == 1) pos += psr[p].param[param_telz].val[1]*arg;
		      arg *= deltaT; if (psr[p].param[param_telz].paramSet[2] == 1) pos += (0.5*psr[p].param[param_telz].val[2]*arg);
		      arg *= deltaT; if (psr[p].param[param_telz].paramSet[3] == 1) pos += (1.0L/6.0L*psr[p].param[param_telz].val[3]*arg);
		      psr[p].obsn[i].observatory_earth[2] = (double)pos;
		      printf("Setting z to %g\n",(double)psr[p].obsn[i].observatory_earth[2]);
		    }



		  //		  printf("Setting observatory coordinates for TOA %d\n",i);
		  // Now check flags to obtain the telescope coordinates for this time
		  for (k=0;k<psr[p].obsn[i].nFlags;k++)
		    {
		      //
		      // NOTE: For a STL_FBAT setting OBSERVATORY->BAT not OBSERVATORY->EARTH
		      // The terminology is misleading
		      //
		      if (strcmp(psr[p].obsn[i].flagID[k],"-telx")==0){
			sscanf(psr[p].obsn[i].flagVal[k],"%lf",&psr[p].obsn[i].observatory_earth[0]);
			if (strcmp(psr[p].obsn[i].telID,"STL")==0) psr[p].obsn[i].observatory_earth[0]/=SPEED_LIGHT;
		      }
		      if (strcmp(psr[p].obsn[i].flagID[k],"-tely")==0){
			sscanf(psr[p].obsn[i].flagVal[k],"%lf",&psr[p].obsn[i].observatory_earth[1]);
			if (strcmp(psr[p].obsn[i].telID,"STL")==0) psr[p].obsn[i].observatory_earth[1]/=SPEED_LIGHT;
		      }
		      if (strcmp(psr[p].obsn[i].flagID[k],"-telz")==0){
			sscanf(psr[p].obsn[i].flagVal[k],"%lf",&psr[p].obsn[i].observatory_earth[2]);		      
			if (strcmp(psr[p].obsn[i].telID,"STL")==0) psr[p].obsn[i].observatory_earth[2]/=SPEED_LIGHT;
		      }
			
		    }
		}
	      else if (strcmp(psr[p].obsn[i].telID,"STL_BAT")==0) // Satellite in barycentric coordinates
		{
		  psr[p].obsn[i].siteVel[0] = 0.0;
		  psr[p].obsn[i].siteVel[1] = 0.0;
		  psr[p].obsn[i].siteVel[2] = 0.0;
		  psr[p].obsn[i].observatory_earth[0] = 0.0;
		  psr[p].obsn[i].observatory_earth[1] = 0.0;
		  psr[p].obsn[i].observatory_earth[2] = 0.0;
		  psr[p].correctTroposphere = 0;
		}
	      else
		{
		  obs = getObservatory(psr[p].obsn[i].telID);
		  // Check for override:
		  if (strcmp(psr[p].obsn[i].telID,"IMAG")==0)
		    {
		      //
		      // Must check what is happening to other parameters - such as velocities
		      //
		      for (k=0;k<psr[p].obsn[i].nFlags;k++)
			{
			  if (strcmp(psr[p].obsn[i].flagID[k],"-telx")==0){
			    sscanf(psr[p].obsn[i].flagVal[k],"%lf",&obs->x);
			  }
			  if (strcmp(psr[p].obsn[i].flagID[k],"-tely")==0){
			    sscanf(psr[p].obsn[i].flagVal[k],"%lf",&obs->y);
			  }
			  if (strcmp(psr[p].obsn[i].flagID[k],"-telz")==0){
			    sscanf(psr[p].obsn[i].flagVal[k],"%lf",&obs->z);		      
			  }
			}		
		    }
		  // New way
		  if (psr[p].t2cMethod == T2C_IAU2000B)
		    {
		      double trs[3], zenith_trs[3];
		      trs[0]=obs->x;
		      trs[1]=obs->y;
		      trs[2]=obs->z;
		      zenith_trs[0]= obs->height_grs80 
			* cos(obs->longitude_grs80) * cos(obs->latitude_grs80);
		      zenith_trs[1]= obs->height_grs80 
			* sin(obs->longitude_grs80) * cos(obs->latitude_grs80);
		      zenith_trs[2] = obs->height_grs80*sin(obs->latitude_grs80);
		      long double utc = psr[p].obsn[i].sat;
		      if (psr[p].obsn[i].clockCorr!=0 && psr[p].obsn[i].clockCorr!=2)
			utc += getCorrection(psr[p].obsn+i, 
					     psr[p].clockFromOverride,
					     "UTC", psr[p].noWarnings)/SECDAY;
		      get_obsCoord_IAU2000B(trs, zenith_trs,
					    psr[p].obsn[i].sat
					    +getCorrectionTT(psr[p].obsn+i)/SECDAY,
					    utc,
					    psr[p].obsn[i].observatory_earth,
					    psr[p].obsn[i].zenith,
					    psr[p].obsn[i].siteVel);
		    }
		  else {
		    psr[p].obsn[i].zenith[0]=psr[p].obsn[i].zenith[1]=psr[p].obsn[i].zenith[2]=0.0; // Only calc'd by IAU code
		    //	      if (	psr[p].obsn[i].zenith[2]==0.0)
		    erad = sqrt(obs->x*obs->x+obs->y*obs->y+obs->z*obs->z);//height(m)
		    hlt  = asin(obs->z/erad); // latitude
		    alng = atan2(-obs->y,obs->x); // longitude
		    hrd  = erad/(2.99792458e8*499.004786); // height (AU)
		    siteCoord[0] = hrd * cos(hlt) * 499.004786; // dist from axis (lt-sec)
		    siteCoord[1] = siteCoord[0]*tan(hlt); // z (lt-sec)
		    siteCoord[2] = alng; // longitude
		    
		    /* PC,PS equatorial and meridional components of nutations of longitude */      
		    toblq = (psr[p].obsn[i].sat+2400000.5-2451545.0)/36525.0;
		    oblq = (((1.813e-3*toblq-5.9e-4)*toblq-4.6815e1)*toblq +84381.448)/3600.0;
		    
		    pc = cos(oblq*M_PI/180.0+psr[p].obsn[i].nutations[1])*psr[p].obsn[i].nutations[0];
		    
		    /* TSID = sidereal time (lmst, timcalc -> obsite) */
		    
		    lmst(psr[p].obsn[i].sat+psr[p].obsn[i].correctionUT1/SECDAY
			 ,0.0,&tsid,&sdd);
		    tsid*=2.0*M_PI;
		    
		    /* Compute the local, true sidereal time */
		    ph = tsid+pc-siteCoord[2];  
		    /* Get X-Y-Z coordinates taking out earth rotation */
		    eeq[0] = siteCoord[0]*cos(ph); 
		    eeq[1] = siteCoord[0]*sin(ph);
		    eeq[2] = siteCoord[1];
		    
		    /* Now obtain PRN -- the precession matrix */
		    get_precessionMatrix(prn,(double)psr[p].obsn[i].sat
					 +psr[p].obsn[i].correctionUT1/SECDAY
					 ,psr[p].obsn[i].nutations[0],
					 psr[p].obsn[i].nutations[1]);
		    /* Calculate the position after precession/nutation*/
		    for (j=0;j<3;j++)
		      psr[p].obsn[i].observatory_earth[j]=prn[j][0]*eeq[0]+prn[j][1]*eeq[1]+prn[j][2]*eeq[2]; 
		    /* Rotate vector if we are working in ecliptic coordinates */
		    if (psr[p].eclCoord==1) equ2ecl(psr[p].obsn[i].observatory_earth);
		    
		    /* Calculate observatory velocity w.r.t. geocentre (1950.0)!!!! <<<<<<< */
		    speed = 2.0*M_PI*siteCoord[0]/(86400.0/1.00273);
		    sitera = 0.0;
		    if (speed>1.0e-10) sitera = atan2(psr[p].obsn[i].observatory_earth[1],
						      psr[p].obsn[i].observatory_earth[0]);
		    psr[p].obsn[i].siteVel[0] = -sin(sitera)*speed;
		    psr[p].obsn[i].siteVel[1] =  cos(sitera)*speed;
		    psr[p].obsn[i].siteVel[2] =  0.0;
		    if (psr[p].eclCoord==1) equ2ecl(psr[p].obsn[i].siteVel);
		    
		    /* Technically if using TDB these coordinates should be 
		       transformed to that frame. In practise it doesn't matter,
		       we're only talking about 0.3 ns, or 2.5e-14 in v/c */
		    
		    /* hack to transform for faked values of "K" */
		    //  	      vectorscale(psr[p].obsn[i].observatory_earth, 1.15505);
		    //  	      vectorscale(psr[p].obsn[i].siteVel, 1.15505);
		  }
		}
	    }
	  else if (i==0)
	    printf("Delay correction turned off for psr %d\n", p);
	}
    }
}