Skip to content

Photon shooting with OpticalPSF/InterpolatedImage gives different results on Mac ARM and Linux #1350

Open

Description

@aguinot

I noticed that I found different results depending if I run some code on Linux or on my laptop with Mac ARM. I tracedback the issue to photon shooting through OpticalPSF but at some point it gets transformed to an InterpolatedImage. I figure that the difference is at this line. I manage to figure that _xInterp is galsim._galsim.Quintic but I wasn't able to find the shoot method.
Here is simple code that returns different results on Mac ARM and Linux (galsim version: 2.9)

import galsim
import galsim.roman as roman

bp = roman.getBandpasses()["J129"]
psf = galsim.OpticalPSF(
    diam=roman.diameter,
    lam=bp.effective_wavelength,
)

psf.shoot(5, galsim.BaseDeviate(1234)).x

On my Mac I get:

array([ 0.00834068, -0.01800069, -0.10280517,  0.0007287 ,  0.05277417])

On Linux I get:

array([-0.00932278, -0.05793788, -0.10280517, -0.00044896,  0.02334157])

When drawing galaxy profile, the number of photons drawn is the same and the flux of the photons is the same but they end up at different locations.

Activity

  1. rmjarvis commented on Mar 4, 2026

    @rmjarvis
    Member

    Interesting. On my MacBook, I get

    [ 0.04602774 -0.01800069 -0.02743104  0.03841576 -0.02259996]
    

    So neither of your results. Is the installed version of GalSim the same on both systems? On my Mac it is 2.8.4.

    We don't guarantee that the results list this are the same across different versions. It may even depend on versions of dependencies like numpy, astropy, etc. So maybe compare the env on each system to see if you can spot differences in either GalSim or any dependencies. FWIW, here is my list (a clean conda env with only GalSim 2.8.4 and its dependencies):

    $ mamba list
    # packages in environment at /Users/Mike/miniforge3/envs/tmp:
    #
    # Name                    Version                   Build  Channel
    astropy-base              7.2.0           py312ha11c99a_0    conda-forge
    astropy-iers-data         0.2026.2.23.0.48.33 py312hca03da5_0  
    blas                      1.0                    openblas  
    bzip2                     1.0.8                h80987f9_6  
    ca-certificates           2025.12.2            hca03da5_0  
    cffi                      2.0.0           py312h73c2a22_1  
    eigen                     5.0.1                h9e3ec18_0  
    expat                     2.7.4                h50f4ffc_0  
    fftw                      3.3.10               he2faedd_0  
    future                    1.0.0           py312hca03da5_0  
    galsim                    2.8.4           py312h574b5d4_0    conda-forge
    icu                       78.2                 hef89b57_0    conda-forge
    libcxx                    21.1.8               hb4ce287_0  
    libexpat                  2.7.4                h50f4ffc_0  
    libffi                    3.4.4                hca03da5_1  
    libgfortran               15.2.0               h09d7db9_1  
    libgfortran5              15.2.0               hb654fa1_1  
    liblzma                   5.8.2                h8088a28_0    conda-forge
    libopenblas               0.3.31               h7813bb4_0  
    libsqlite                 3.51.2               h1ae2325_0    conda-forge
    libzlib                   1.3.1                h5f15de7_0  
    llvm-openmp               21.1.8               hfab7639_0  
    lsstdesc.coord            1.3.1           py312h766f71e_0    conda-forge
    ncurses                   6.5                  hee39554_0  
    numpy                     2.4.2           py312h4bb6f22_0  
    numpy-base                2.4.2           py312h23175f9_0  
    openssl                   3.5.5                ha0b305a_0  
    packaging                 25.0            py312hca03da5_1  
    pip                       26.0.1             pyhc872135_0  
    pybind11                  2.13.6          py312h48ca7d4_1  
    pybind11-global           2.13.6          py312h48ca7d4_1  
    pycparser                 2.23            py312hca03da5_0  
    pyerfa                    2.0.1.5         py312hbe26d11_1  
    python                    3.12.9          hc22306f_1_cpython    conda-forge
    python_abi                3.12                    3_cp312  
    pyyaml                    6.0.3           py312h091b9d3_0  
    readline                  8.3                  h0b18652_0  
    scipy                     1.17.0          py312h079a9ef_0  
    setuptools                80.10.2         py312hca03da5_0  
    sqlite                    3.51.1               hab6afd1_0  
    tk                        8.6.15               hcd8a7d5_0  
    tzdata                    2025c                he532380_0  
    wheel                     0.46.3          py312hca03da5_0  
    xz                        5.8.2                h8bbcb1d_0  
    yaml                      0.2.5                h1a28f6b_0  
    zlib                      1.3.1                h5f15de7_0  
    
  2. rmjarvis commented on Mar 4, 2026

    @rmjarvis
    Member

    Oh, I see above you said your GalSim is version 2.9. That's the main branch version. You should never be using that for anything except GalSim development. You should only use release versions.

  3. aguinot commented on Mar 4, 2026

    @aguinot
    Author

    Sorry I should have gave more details about the tests I did.
    I am using the same environment on both system installed like this:

    conda create -n roman_sim_test2 python=3.12.9 galsim=2.8.4 numpy=2.4.2 astropy-base=7.2.0

    (I switched to galsim 2.9 because I added some prints for debugging and didn't checkedout to a tagged version)

    I still get different results for both systems and same as the one quoted above.

    Env macOS

    # Name                     Version              Build                Channel
    _openmp_mutex              4.5                  7_kmp_llvm           conda-forge
    astropy-base               7.2.0                py312ha11c99a_0      conda-forge
    astropy-iers-data          0.2026.2.23.0.48.33  pyhd8ed1ab_0         conda-forge
    bzip2                      1.0.8                hd037594_9           conda-forge
    ca-certificates            2026.2.25            hbd8a1cb_0           conda-forge
    cffi                       2.0.0                py312h1b4d9a2_1      conda-forge
    eigen                      3.4.0                h784d473_2           conda-forge
    fftw                       3.3.10               nompi_haf1500d_112   conda-forge
    future                     1.0.0                pyhd8ed1ab_2         conda-forge
    galsim                     2.8.4                py312h574b5d4_0      conda-forge
    icu                        78.2                 hef89b57_0           conda-forge
    libblas                    3.11.0               5_h51639a9_openblas  conda-forge
    libcblas                   3.11.0               5_hb0561ab_openblas  conda-forge
    libcxx                     22.1.0               h55c6f16_1           conda-forge
    libexpat                   2.7.4                hf6b4638_0           conda-forge
    libffi                     3.5.2                hcf2aa1b_0           conda-forge
    libgcc                     15.2.0               hcbb3090_18          conda-forge
    libgfortran                15.2.0               h07b0088_18          conda-forge
    libgfortran5               15.2.0               hdae7583_18          conda-forge
    liblapack                  3.11.0               5_hd9741b5_openblas  conda-forge
    liblzma                    5.8.2                h8088a28_0           conda-forge
    libopenblas                0.3.30               openmp_ha158390_4    conda-forge
    libsqlite                  3.51.2               h1ae2325_0           conda-forge
    libzlib                    1.3.1                h8359307_2           conda-forge
    llvm-openmp                22.1.0               hc7d1edf_0           conda-forge
    lsstdesc.coord             1.3.1                py312h766f71e_0      conda-forge
    ncurses                    6.5                  h5e97a16_3           conda-forge
    numpy                      2.4.2                py312he281c53_1      conda-forge
    openssl                    3.6.1                hd24854e_1           conda-forge
    packaging                  26.0                 pyhcf101f3_0         conda-forge
    pip                        26.0.1               pyh8b19718_0         conda-forge
    pybind11                   3.0.2                pyh7a1b43c_0         conda-forge
    pybind11-global            3.0.2                pyhc7ab6ef_0         conda-forge
    pycparser                  2.22                 pyh29332c3_1         conda-forge
    pyerfa                     2.0.1.5              py310hbb12772_2      conda-forge
    python                     3.12.9               hc22306f_1_cpython   conda-forge
    python_abi                 3.12                 8_cp312              conda-forge
    pyyaml                     6.0.3                py312h04c11ed_1      conda-forge
    readline                   8.3                  h46df422_0           conda-forge
    scipy                      1.17.1               py312h0f234b1_0      conda-forge
    setuptools                 82.0.0               pyh332efcf_0         conda-forge
    tk                         8.6.13               h010d191_3           conda-forge
    tzdata                     2025c                hc9c84f9_1           conda-forge
    wheel                      0.46.3               pyhd8ed1ab_0         conda-forge
    yaml                       0.2.5                h925e9cb_3           conda-forge

    Env Linux:

    # Name                    Version                   Build  Channel
    _openmp_mutex             4.5                      20_gnu    conda-forge
    astropy-base              7.2.0           py312h4f23490_0    conda-forge
    astropy-iers-data         0.2026.2.23.0.48.33    pyhd8ed1ab_0    conda-forge
    bzip2                     1.0.8                hda65f42_9    conda-forge
    ca-certificates           2026.2.25            hbd8a1cb_0    conda-forge
    cffi                      2.0.0           py312h460c074_1    conda-forge
    eigen                     3.4.0                h54a6638_2    conda-forge
    fftw                      3.3.10          nompi_h3b011a4_112    conda-forge
    future                    1.0.0              pyhd8ed1ab_2    conda-forge
    galsim                    2.8.4           py312h7c919be_0    conda-forge
    icu                       78.2                 h33c6efd_0    conda-forge
    ld_impl_linux-64          2.45.1          default_hbd61a6d_101    conda-forge
    libblas                   3.11.0          5_h4a7cf45_openblas    conda-forge
    libcblas                  3.11.0          5_h0358290_openblas    conda-forge
    libexpat                  2.7.4                hecca717_0    conda-forge
    libffi                    3.5.2                h3435931_0    conda-forge
    libgcc                    15.2.0              he0feb66_18    conda-forge
    libgcc-ng                 15.2.0              h69a702a_18    conda-forge
    libgfortran               15.2.0              h69a702a_18    conda-forge
    libgfortran5              15.2.0              h68bc16d_18    conda-forge
    libgomp                   15.2.0              he0feb66_18    conda-forge
    liblapack                 3.11.0          5_h47877c9_openblas    conda-forge
    liblzma                   5.8.2                hb03c661_0    conda-forge
    libnsl                    2.0.1                hb9d3cd8_1    conda-forge
    libopenblas               0.3.30          pthreads_h94d23a6_4    conda-forge
    libsqlite                 3.51.2               hf4e2dac_0    conda-forge
    libstdcxx                 15.2.0              h934c35e_18    conda-forge
    libuuid                   2.41.3               h5347b49_0    conda-forge
    libxcrypt                 4.4.36               hd590300_1    conda-forge
    libzlib                   1.3.1                hb9d3cd8_2    conda-forge
    lsstdesc.coord            1.3.1           py312hd9148b4_0    conda-forge
    ncurses                   6.5                  h2d0b736_3    conda-forge
    numpy                     2.4.2           py312h33ff503_1    conda-forge
    openssl                   3.6.1                h35e630c_1    conda-forge
    packaging                 26.0               pyhcf101f3_0    conda-forge
    pip                       26.0.1             pyh8b19718_0    conda-forge
    pybind11                  3.0.2              pyh7a1b43c_0    conda-forge
    pybind11-global           3.0.2              pyhc7ab6ef_0    conda-forge
    pycparser                 2.22               pyh29332c3_1    conda-forge
    pyerfa                    2.0.1.5         py310h32771cd_2    conda-forge
    python                    3.12.9          h9e4cc4f_1_cpython    conda-forge
    python_abi                3.12                    8_cp312    conda-forge
    pyyaml                    6.0.3           py312h8a5da7c_1    conda-forge
    readline                  8.3                  h853b02a_0    conda-forge
    scipy                     1.17.1          py312h54fa4ab_0    conda-forge
    setuptools                82.0.0             pyh332efcf_0    conda-forge
    tk                        8.6.13          noxft_h366c992_103    conda-forge
    tzdata                    2025c                hc9c84f9_1    conda-forge
    wheel                     0.46.3             pyhd8ed1ab_0    conda-forge
    yaml                      0.2.5                h280c20c_3    conda-forge
    zstd                      1.5.7                hb78ec9c_6    conda-forge
  4. aguinot commented on Mar 4, 2026

    @aguinot
    Author

    As an extra precision, it is really linked to the interpolation kernel. If you replace the psf by galsim.Gaussian you get the same results from both system.

  5. rmjarvis commented on Mar 16, 2026

    @rmjarvis
    Member

    As we discussed last week, I suspect this is just some system-related machine precision differences. If you want to drill down into where the differences arise, I suspect this function:
    https://github.com/GalSim-developers/GalSim/blob/releases/2.8/src/OneDimensionalDeviate.cpp#L422

  6. added
    numericsInvolving details of the numerical algorithms for performing some calculation(s)
    optics/atmRelated to realistic PSFs from optics, atmosphere, etc.
    on May 29, 2026
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

    numericsInvolving details of the numerical algorithms for performing some calculation(s)optics/atmRelated to realistic PSFs from optics, atmosphere, etc.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions