Skip to content

Fix SkyCoord transformation and longitude offset in get_bvec - #160

Closed
sumitsaraswat362 wants to merge 4 commits into
sunpy:mainfrom
sumitsaraswat362:fix/magex-bvec
Closed

sumitsaraswat362 wants to merge 4 commits into
sunpy:mainfrom
sumitsaraswat362:fix/magex-bvec

Conversation

@sumitsaraswat362

Copy link
Copy Markdown

Fixes #152

Description

This PR addresses the bug reported in #152 where FieldLine.b_along_fline was returning different values for the same magnetogram depending on its rolling offset.

Cause:
In pfss.Output.get_bvec, the input SkyCoord was being transformed to the model's coordinate frame, but the result of coords.transform_to() was not being assigned back (it returned a copy). Additionally, the longitude passed to the internal interpolation function _brgi was not properly adjusted for the _lon0 offset (like it is handled inside tracing.py).

Fix:

  • Updated the transformation to save the transformed SkyCoord in-place.
  • Applied the coords.lon - (self._lon0 - 180 * u.deg) shift before generating the cartesian vector and interpolating.
  • Reassigned the shifted coordinates back to a new SkyCoord so the rotation matrices (which convert the cartesian output back to spherical coordinates) also operate on the correctly shifted longitude.

This aligns the behavior of get_bvec with the coordinate handling inside the PerformanceTracer, ensuring consistent B vectors regardless of the magnetogram roll.

@sumitsaraswat362

Copy link
Copy Markdown
Author

Closing this PR as I am focusing on other contributions.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

FieldLine.b_along_fline differs for the same magnetogram at different starting longitudes

1 participant