Skip to content

PyLAP changes to work with sigmond.#16

Open
mijahauan wants to merge 9 commits into
HamSCI:mainfrom
mijahauan:main
Open

PyLAP changes to work with sigmond.#16
mijahauan wants to merge 9 commits into
HamSCI:mainfrom
mijahauan:main

Conversation

@mijahauan

Copy link
Copy Markdown

Detailed in README.md

mijahauan and others added 9 commits March 15, 2026 20:26
setup.py:
- Cross-platform build: Darwin (maca/maci) + Linux support
- Detect gfortran runtime dir via 'gfortran -print-file-name'
- Link libgfortran + libgomp on macOS (required by maca/maci .a libs)
- Remove Intel Fortran runtime deps on macOS (ifcore/imf/irc/svml/iomp5)
- iri2016 -> iri2020 library name (PHaRLAP 4.7.4 consolidation)
- Skip modules whose required legacy libs are absent (iri2007/iri2012)
- Use setuptools instead of deprecated distutils
- Print BUILD/SKIP per module for diagnostics

modules/pylap/__init__.py:
- Soft imports for all modules; missing ones silently skipped

modules/source/igrf2016.c:
- igrf2016_calc_ -> igrf2020_calc_ (renamed in PHaRLAP 4.7.4)

modules/source/raytrace_2d.c:
- verifyIonoGrid: void -> int, ASSERT -> ASSERT_INT, add return 1
- buidlIonoStruct: void -> int, ASSERT -> ASSERT_INT, add return 1
- Call sites wrapped in checked-return pattern
- Fixes -Wreturn-mismatch errors under clang

modules/source/raytrace_3d.c:
- verifyIono: void -> int, ASSERT -> ASSERT_INT, add return 1
- buildIonoStruct: void -> int, ASSERT -> ASSERT_INT, add return 1
- clear_ionosphere: remove spurious return 1 (legitimately void)
- Call sites wrapped in checked-return pattern
modules/source/iri2016.c:
- iri2016_calc_ -> iri2020_calc_ (renamed Fortran symbol in PHaRLAP 4.7.4)
- check_ref_data("iri2016") -> check_ref_data("iri2020") (dat subdir renamed)

modules/source/common/check_ref_data.c:
- Add check_iri2020() function verifying dat/iri2020/ file layout:
  igrf2025.dat/s, dgrf1945-2010, apf107.dat, ig_rz.dat,
  mcsat11-22.dat, ccir11-22.asc, ursi11-22.asc
- Add "iri2020" dispatch case in check_ref_data()
…ays*9

The ray_data array is allocated as 19*nhops*num_rays doubles, so the
hop-to-hop stride must be num_rays*19. The previous stride of num_rays*9
caused ground_range to be read from wrong offsets for hops > 1.
PHaRLAP 4.7.4 outputs 24 doubles per hop in ray_data (up from 19).
The undersized allocation caused heap corruption ('double free or
corruption') and the wrong stride (num_rays*19 instead of num_rays*24)
produced garbled output fields.
…where

PHaRLAP 4.7.4 ships GCC-compiled static libs on all platforms (Linux,
macOS arm64, macOS x86_64).  The previous setup.py required Intel
Fortran (ifcore/imf/irc/svml/iomp5) and a LD_LIBRARY env var on Linux.

Now both platforms use the same gfortran/gomp linking path:
- Auto-detect gfortran via 'which gfortran'
- Locate libgfortran.so/.dylib via 'gfortran -print-file-name'
- Fallback to /opt/homebrew/lib/gcc/current on macOS only
- No LD_LIBRARY env var needed on any platform
GCC 14 (Debian 13/trixie) promotes -Wincompatible-pointer-types to
error. pylap C extensions return PyArrayObject* as PyObject* (safe
upcast via numpy API). This flag suppresses the false positive.
Add "About this fork" section to README listing the patches that
distinguish this fork from HamSCI/PyLap (PHaRLAP 4.7.4 support,
unified gfortran build, multi-hop stride fix, GCC 14+ compat,
IRI-2020 wrapper, Fortran SAVE/Ne-units caller notes).

Drop Intel Fortran redistributable from install flow — commit
d5d4e6e unified Linux/macOS on gfortran, but README and setup.sh
still required the Intel libs. Remove Intel lib detection,
LD_LIBRARY export, and compilervars.sh sourcing from setup.sh;
remove corresponding sections from README.

Add IRI build-verification smoke test to README so a collaborator
can confirm linkage before running the raytracing examples.

Ignore venv/ and the test-output PNG.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Add 'iri2020' profile type to gen_iono_grid_2d and gen_iono_grid_3d,
backed by the space-physics/iri2020 package. Works without PHaRLAP,
which lets collaborators verify the Python-side install before
PHaRLAP access lands.

Replace the string-of-ORs profile-type validation with a list
membership check. Along the way fix a latent bug: two branches
tested `profile_type.lower` (method reference — always truthy)
instead of `profile_type.lower()`. iri2007 and iri2012 branches
were therefore unreachable in the 2d path, and firi was
unreachable in the 3d path.

Add Examples/test_iri2020.py — smoke-test entry point referenced
by the README for pre-PHaRLAP verification.

Remove leftover `import ipdb` debug statements from five files
(broke imports for anyone without ipdb installed).

Fix requirements.txt: remove apt packages that never belonged in
a pip file, fix typos (pthon3-phil, python3-phil.imagetk), add
numpy and xarray (needed by iri2020), and add inline comments
pointing at the apt/gfortran prerequisites.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
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.

1 participant