def aspect_angle(year,xyz): # returns the magnetic aspect angle (rad) of a target with # geocentric vector xyz defined in geocentric coordinates r=sqrt(dot(xyz,xyz)) p=sqrt(xyz[0]**2+xyz[1]**2) lat=arctan2(xyz[2],p) lon=arctan2(xyz[1],xyz[0]) radial=xyz/r; # directions from target east=array([-xyz[1],xyz[0],0])/p north=-cross(east,radial) rr=xyz-xyz0 u_rr=rr/sqrt(dot(rr,rr)) # unit vector from radar to target [bX,bY,bZ,bB]=igrf_B(year,r-a_igrf,lon/deg,lat/deg) bfield=array([bX,bY,bZ]) B=bX*north+bY*east-bZ*radial u_B=B/sqrt(dot(B,B)) aspect=arccos(dot(u_B,u_rr)) return r,lat,lon,aspect
def aspect_angle(year, xyz): # returns the magnetic aspect angle (rad) of a target with # geocentric vector xyz defined in geocentric coordinates r = sqrt(dot(xyz, xyz)) p = sqrt(xyz[0]**2 + xyz[1]**2) lat = arctan2(xyz[2], p) lon = arctan2(xyz[1], xyz[0]) radial = xyz / r # directions from target east = array([-xyz[1], xyz[0], 0]) / p north = -cross(east, radial) rr = xyz - xyz0 u_rr = rr / sqrt(dot(rr, rr)) # unit vector from radar to target [bX, bY, bZ, bB] = igrf_B(year, r - a_igrf, lon / deg, lat / deg) bfield = array([bX, bY, bZ]) B = bX * north + bY * east - bZ * radial u_B = B / sqrt(dot(B, B)) aspect = arccos(dot(u_B, u_rr)) return r, lat, lon, aspect