Exemplo n.º 1
0
int getLookYaw(GEOLOCATE_REC *g,double range,double dop,  /*  Inputs.*/
               double *out_look,double *out_yaw)/* Outputs, in radians.*/
{
	int iterations=0,err=0,max_iter=10000;
	double yaw=0,deltaAz;
	double look=0;
	double dopGuess,dopDotGuess,deltaDop,prevDeltaDop=-9999999;
	vector target,vRel;

        while (1)
	{
		double relativeVelocity;
                //if (iterations>10) printf("GetLoc: Iteration %i, doppler=%f, yaw=%20.18f, look=%20.18f.\n",iterations,dopGuess,yaw*180/M_PI,look*180/M_PI);
		err=getLook(g,range,yaw,&look);
                if (err) break;
		getDoppler(g,look,yaw,&dopGuess,&dopDotGuess,&target,&vRel);
		deltaDop=dop-dopGuess;
		relativeVelocity=vecMagnitude(vRel);
		deltaAz=deltaDop*(g->lambda/(2*relativeVelocity));
                // handle the zero doppler case -- without this, we will
                // sometimes flip back&forth accross zero doppler, until max_iter
                if (fabs(deltaDop+prevDeltaDop)<.000001) deltaAz/=2.;
		if (fabs(deltaAz*range)<0.1)/*Require decimeter convergence*/
			break;
		yaw+=deltaAz;
                if (++iterations>max_iter) { /* Failed to converge */
                    err=1; break;
                }
                prevDeltaDop=deltaDop;
	}
	*out_look=look;
	*out_yaw=yaw;
        return err;
}
Exemplo n.º 2
0
int getLoc(GEOLOCATE_REC *g,double range,double dop,  /*  Inputs.*/
           double *latitude,double *phi,double *earthRadius) /*Outputs.*/
{
        int err;
	double yaw=0,look=0;
	vector target;
	err = getLookYaw(g,range,dop,&look,&yaw);
        if (err) return err;
	getDoppler(g,look,yaw,NULL,NULL,&target,NULL);
	cart2sph(target,earthRadius,latitude,phi);
        return 0;
}
Exemplo n.º 3
0
/*
 * Compute and manipulate range/velocity/antenna vectors
 */
void Plan13::rangevec(void)
{
   if (DEBUG) {Serial.println("Start rangevec()");}
   /* Range vector = sat vector - observer vector */
  Rx = Sx - Ox;
  Ry = Sy - Oy;
  Rz = Sz - Oz;

  R = sqrt(Rx * Rx + Ry * Ry + Rz * Rz);    /* Range Magnitute */

   /* Normalize range vector */
  Rx = Rx / R;
  Ry = Ry / R;
  Rz = Rz / R;
  U = Rx * Ux + Ry * Uy + Rz * Uz;
  E = Rx * Ex + Ry * Ey;
  N = Rx * Nx + Ry * Ny + Rz * Nz;

  AZ = deg(FNatn(E, N));
  EL = deg(asin(U));

   /* Solve antenna vector along unit range vector, -r.a = cos(SQ) */
/*    SQ = deg(acos(-(Ax * Rx + Ay * Ry + Az * Rz)));
*/
   /* Calculate sub-satellite Lat/Lon */
  SLON = deg(FNatn(Sy, Sx));   /* Lon, + East  */
  SLAT = deg(asin(Sz / RS));   /* Lat, + North */

   /* Resolve Sat-Obs velocity vector along unit range vector. (VOz = 0) */
  RR = (Vx - VOx) * Rx + (Vy - VOy) * Ry + Vz * Rz; /* Range rate, km/sec */
  //FR = rxFrequency * (1 - RR / 299792);
dopplerFactor = RR / 299792.0;
int rxDoppler = getDoppler(rxFrequencyLong);
int txDoppler = getDoppler(txFrequencyLong);
rxOutLong = rxFrequencyLong - rxDoppler;
txOutLong = txFrequencyLong + txDoppler;


   if (DEBUG) {Serial.println("End rangevec()");}
}
Exemplo n.º 4
0
void prep_specan_file(int nLooks,int quality,double aspect,
    struct ARDOP_PARAMS *g,meta_parameters *meta)
{
    getRec *inFile;
    FILE *outFile;
    int outLines,outSamples/*,x*/;
    /*char command[1024];*/
    int i;

    specan_struct rng={1.0/RFS,
        RSLOPE,
        RCEN,
        RBW,
        RLEN_INIT};

    specan_struct az={1.0/AFS,
        ASLOPE,
        ACEN,
        ABW,
        ALEN_INIT};

/*Set quality: longer FFT's -> bigger
image, better quality.*/
    for (i=0;i<quality;i++)
    {
        rng.fftLen*=2;
        az.fftLen*=2;
    }
    rng.fftLen=(int)(rng.fftLen*aspect);

/*Open files.*/
    if (!quietflag) printf("Opening input files...\n");
    inFile=fillOutGetRec(g->in1);
    outFile=fopenImage(g->out,"wb");

/*Init. Range Variables*/
    if (!quietflag) printf("Init SPECAN\n");
    rng.iSamp=1.0/g->fs;/*Sample size, range (s)= 1.0/sample freqency (Hz)*/
    rng.chirpSlope=g->slope;/*Range chirp slope (Hz/Sec)*/
    specan_init(&rng);

/*Init. Azimuth Variables*/
    if (!quietflag) printf("Estimate Doppler\n");
    az.iSamp=1.0/g->prf;/*Sample size, azimuth (s)=1.0/sample freqency (Hz)*/

    if (meta->stVec==NULL) {
        fprintf(stderr, "Can only quicklook scenes with state vectors!\n");
        exit(1);}
    else {  /*Find doppler rate (Hz/sec) <=> azimuth chirp slope*/
        double dopRate,yaw=0.0;
        GEOLOCATE_REC *g=init_geolocate_meta(&meta->stVec->vecs[0].vec,meta);
        double look;
                int ret;
                ret=getLook(g,meta->geo->slantFirst,yaw,&look);
                assert(ret==0);
        getDoppler(g,look,yaw,NULL,&dopRate,NULL,NULL);
        az.chirpSlope=dopRate;
        free_geolocate(g);
    }

    az.chirpCenter=g->fd*(1.0/az.iSamp);/*Convert doppler central freqency to Hz*/
    /*For de-scalloping, compute the most powerful doppler freqency.*/
    az.powerCenter=(1.0/az.iSamp)*
        fftEstDop(inFile,inFile->nLines/2,1,az.fftLen);

    if (!quietflag) printf("Doppler centroid at %.0f Hz, %.0f Hz/sec\n",az.chirpCenter,az.chirpSlope);
    specan_init(&az);

    if (!quietflag) printf("Efficiency: Range(%d): %.0f%%   Azimuth(%d): %.0f%%\n",
                           rng.fftLen,100.0*rng.oNum/rng.fftLen,
                           az.fftLen,100.0*az.oNum/az.fftLen);

/*Process image.*/
    specan_file(inFile,nLooks,outFile,&rng,&az,&outLines,&outSamples);
    FCLOSE(outFile);
    freeGetRec(inFile);

/*Create DDR for output file.*/
    {
        struct DDR ddr;/*Output DDR*/
        c_intddr(&ddr);
        ddr.dtype=DTYPE_FLOAT;
        ddr.nbands=1;
        ddr.nl=outLines;
        ddr.ns=outSamples;
        ddr.sample_inc=rng.oSamp/rng.iSamp;
        ddr.line_inc=az.oSamp/az.iSamp;
        c_putddr(g->out,&ddr);
    }
/*Copy over metadata*/
    if (meta->info)
        sprintf(meta->info->processor,"ASF/QUICKLOOK/%.2f",VERSION);
    meta_write(meta,g->out);
}