Skip to content

srf.py: strike direction for nstk == 1 segments uses degrees as radians #84

Description

@lispandfound

Location: source_modelling/srf.py:615

What happens: In SrfFile.planes, the single-strike-point branch builds the along-strike offset as np.array([np.cos(strike_nztm), np.sin(strike_nztm), 0]). strike_nztm is returned by qcore.coordinates.great_circle_bearing_to_nztm_bearing in degrees, but it is passed to np.cos/np.sin without np.radians, so the value is interpreted as radians. The resulting plane corners point in an essentially arbitrary direction.

Why that is wrong: great_circle_bearing_to_nztm_bearing returns degrees — it ends in geo.oriented_bearing_wrt_normal(...), and a great-circle bearing of 45 deg comes back as 44.8266, not 0.782. Every other caller in this repo converts before use: fsp.py:124-125 does np.cos(np.radians(dip_dir)) on dip_dir = strike_nztm + 90 (fsp.py:122). Only srf.py:615 omits the conversion.

Measured angular error of the resulting strike unit vector at origin (-43.5, 172.6):

input strike (deg) correct unit vec as-coded unit vec error
0 +1.0000, -0.0048 -0.0125, +0.9999 90.99 deg
20 +0.9409, +0.3386 +0.5893, +0.8079 34.10 deg
90 +0.0048, +1.0000 -0.1883, +0.9821 11.13 deg
200 -0.9409, -0.3386 +0.2941, -0.9558 87.31 deg
330 +0.8628, -0.5055 -0.9736, +0.2283 162.83 deg

How to reproduce: Read any SRF whose header reports nstk == 1 and ndip > 1 for a segment, then inspect SrfFile.planes for that segment: the two top corners are displaced along a bearing unrelated to stk. The unit-vector discrepancy above is reproduced standalone with:

import numpy as np
from qcore import coordinates
b = coordinates.great_circle_bearing_to_nztm_bearing(np.array([-43.5, 172.6]), 10.0, 330.0)
print(np.array([np.cos(np.radians(b)), np.sin(np.radians(b))]))  # correct
print(np.array([np.cos(b), np.sin(b)]))                          # as coded at srf.py:615

Suggested direction: Wrap strike_nztm in np.radians at the trig call, matching the convention already used in fsp.py:124-125, and consider a regression test over an nstk == 1 SRF fixture since this branch appears to be untested.

Confidence: high

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    ai-sweepFiled by an automated /bug-sweep runbugSomething isn't workingimpact:lowscope:source_modellingSweep scope: source_modelling package

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions