예제 #1
0
void CnvMapEvalEfield(int Lmax,double *coef,double *plm,
		      struct CnvGrid *vptr,
		      double latmin,struct CnvMapData *ptr) {

  int i;
  double *theta,*phi;
  double *etc,*epc;
  double lon,lat,tmp=0;

  theta=malloc(vptr->num*sizeof(double));
  phi=malloc(vptr->num*sizeof(double));
 
  if ((theta==NULL) || (phi==NULL)) return;

  for (i=0;i<vptr->num;i++) {
     lat=fabs(vptr->lat[i]);
     lon=vptr->lon[i];
     if ((ptr->lat_shft !=0) || (ptr->lon_shft !=0)) 
       CnvMapCrdShft(&lat,&lon,&tmp,ptr->lat_shft,ptr->lon_shft);
     theta[i]=(90.0-lat)*PI/180.0;
     phi[i]=lon*PI/180.0;
  }
  epc=CnvMapEvalPhiCoef(Lmax,coef,theta,vptr->num);
  etc=CnvMapEvalThetaCoef(Lmax,coef,theta,vptr->num,fabs(latmin));
  CnvMapEvalComponent(Lmax,etc,plm,phi,vptr->num,vptr->ex);
  CnvMapEvalComponent(Lmax,epc,plm,phi,vptr->num,vptr->ey);
   
  free(phi);
  free(theta); 
  free(epc);
  free(etc);

}
예제 #2
0
void CnvMapEvalVelocity(int Lmax,double *coef,double *plm,
			struct CnvGrid *vptr,
		        double latmin,struct CnvMapData *ptr) {

  int i;
  double *theta,*phi;
  double *etc,*epc;
  double bpolar;
  double bmag=-0.5e-4;
  double *ex; 
  double *ey;
  double lon,lat,tmp=0;

  double vx,vy;  

  theta=malloc(vptr->num*sizeof(double));
  phi=malloc(vptr->num*sizeof(double));
  ex=malloc(vptr->num*sizeof(double));
  ey=malloc(vptr->num*sizeof(double));

  if ((theta==NULL) || (phi==NULL)) return;

  for (i=0;i<vptr->num;i++) {
     lat=fabs(vptr->lat[i]);
     lon=vptr->lon[i];
     if ((ptr->lat_shft !=0) || (ptr->lon_shft !=0)) 
       CnvMapCrdShft(&lat,&lon,&tmp,ptr->lat_shft,ptr->lon_shft);
     theta[i]=(90.0-lat)*PI/180.0;
     phi[i]=lon*PI/180.0;
  }
  epc=CnvMapEvalPhiCoef(Lmax,coef,theta,vptr->num);
  etc=CnvMapEvalThetaCoef(Lmax,coef,theta,vptr->num,fabs(latmin));
  CnvMapEvalComponent(Lmax,etc,plm,phi,vptr->num,ex);
  CnvMapEvalComponent(Lmax,epc,plm,phi,vptr->num,ey);
  
  for (i=0;i<vptr->num;i++) {

    if (ptr->hemisphere == -1) bpolar = BNorth;
    else bpolar = BSouth;

    bmag = bpolar*(1.0 - 3.0 * Altitude/Re)*
           sqrt(3.0*(cos(theta[i])*cos(theta[i])) + 1.0)/2.0;


    vx=ey[i]/bmag;
    vy=-ex[i]/bmag;

  
    vptr->mag[i]=sqrt(vx*vx+vy*vy);
    vptr->azm[i]=atan2(vy,-vx)*180.0/PI;
    
    if (ptr->hemisphere==-1) vptr->azm[i]=atan2(vy,vx)*180.0/PI;
    
  }
  free(ex);
  free(ey);
  free(phi);
  free(theta); 
  free(epc);
  free(etc);

}