vtsuperdarn/davitpy — pull request #34 by mrwessel (2014-06-06 20:44:57+00:00)
Title: Negative sign moved to better place in calcFitCnvVel. Also comment added to axisHandle documentation.

The plasma velocity is calculated from v=ExB/|B|^2 in calcFitCnvVel (|B| is called bFldMagn). We assume E_r = v_r = B_phi = 0 and the result is that v_theta and v_phi both include B_r/|B|^2, and B_r/|B| = -2cos(theta)/sqrt(3cos^2(theta)+1). For theta near either pole (where we operate) B_r/|B| is close to -1 and that approximation was implemented by including a negative in the remaining factor of 1/|B| (specifically it was rolled into the constant bFldPolar and thereby into |B|), which had the effect of making |B| < 0. Clearly that could cause problems for any future use of |B| if it were not noticed. The negative has now been moved to a more proper place (the calculations of v_theta and v_phi: velFitVecs[0,:] and [1,:]) and |B| > 0 as it should be. The negative constant implementation goes back at least as far as the Go libraries and propagated this far, but this is as good a time as any to stop the spread.