[MERGE] (master|issue7_refract): solve zero-offset scaling issues in refract
Merge branch 'issue7_refract' Advance refract version number to 4.14 This merge commit solves issues when scaling traces with an offset-dependent scaling factor. The modifications are prepared on branch issue7_refract. The issue observed with the previous version of refract was: Refract offers a power-law amplitude scaling. This must fail in cases where one of the traces is located at zero offset. In such cases the entire plot fails, which can confuse users not aware of this side-effect. This problem actually was caused by three problems in the code: 1 When using the zero offset (least offset) trace as a reference for offset dependent scaling (as is the default), a division by zero happens in subroutine mpcfactors. 2 Zero offset traces may come with an mpc-scaling factor equal to zero. This means, the trace should be down-scaled to a straight line in any case. The current concept of trace scaling does this by leaving the sample values of the trace as they are, by using a viewport for the trace according to current clipping (derived in function settracevp) and by setting the world coordinates for the trace's viewport appropriately (i.e. to infinity). In the latter step there happens the nasty division by zero (division by mpc factor). This problem is present, even if the zero offset trace is not used as a reference. 3 For a negative exponent the mpc factor of the zero offset trace would become infinite even for a finite reference value. These problems are addressed in the following way be this merge commit: 1 Problem is solved by referring amplitude scaling factors to the average scaled amplitude in a given offset range in scaling mode 2 and 3 (as was provided only in mode 3 so far), which now is the default way, the scaling reference is defined. 2 Problem is solved by setting an upper limit to the world coordinate range (in counts) in the trace's viewport, such that the trace is displayed as a straight line without causing numerical overflow. This is achieved by applying a lower limit ti mpc factors in subroutine refract_settracevp 3 Problem is solved by enforcing non-negative exponent value.