rmjarvis / Piff

PSFs In the Full FOV. A software package for modeling the point-spread function (PSF) across the full field of view (FOV). Documentation:

Home Page:http://rmjarvis.github.io/Piff/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

very large PSF (after re-installation) | Bad fit

MickaelRigault opened this issue · comments

Hi all,

I feel quite bad about it but I'm back to the PSF analysis after a break during which I had to re-install my anaconda and stuff. Anyway, I run the same code as before but it seems that the PSF fit do not work anymore.

I am displaying (with imshow) the star.image.array using origin="lower"
Capture d’écran 2021-02-02 à 15 35 16

I don't know if it's related but now, the star.run_hsm() provide very small numbers for sigma (looks like in degree while it used to be in acsec or pixel)

stars[0].run_hsm() (same as the one in the plot, so from data)

-> (21680.30859375,
-1.6098867571617825e-05,
8.088880247614227e-06,
0.00023743436571854406, # =0.85 i.e close to expectation if *3600
-0.02727522535297076,
-0.0020419692128555034,
0)

---- Versions
treecorr : 4.1.3
galsim : 2.2.4
piff : 1.0.0

Thanks

Data (sciimg and catalog available here)
https://www.dropbox.com/s/x5jfvhwk51ynnem/ztf_20190917468333_000698_zi_c03_o_q2.zip?dl=0

config:
'image_hdu': 0, 'noise': 1.0, 'ra': 'TELRA', 'dec': 'TELDEC', 'cat_hdu': 1, 'x_col': 'xpos', 'y_col': 'ypos', 'sky_col': 'sky', 'gain': 'GAIN', 'satur': 'SATURATE', 'nstars': 300, 'stamp_size': 15

I don't know what you want me to do here. I'm not particularly interested in debugging your script. If you think there is a bug in Piff, please provide a SSCCE, and I can take a look.

Of course, here is the Code.

Change the directory where you downloaded the images from the dropbox:

# DataLocation
dl_dir = "/Users/mrigault/Downloads/ztf_20190917468333_000698_zi_c03_o_q2/"
sciimg = dl_dir+"ztf_20190917468333_000698_zi_c03_o_q2_sciimg.fits"
catalog = dl_dir+"ztf_20190917468333_000698_zi_c03_o_q2_gaia.fits"



# Config
config = {'io': {'image_hdu': 0,
                  'noise': 1.0,
                  'ra': 'TELRA',
                  'dec': 'TELDEC',
                  'cat_hdu': 1,
                  'x_col': 'xpos',
                  'y_col': 'ypos',
                  'sky_col': 'sky',
                  'gain': 'GAIN',
                  'satur': 'SATURATE',
                  'nstars': 300,
                  'stamp_size': 15,
                  'image_file_name': sciimg,
                  'cat_file_name': catalog},
            'psf': {'model': {'type': 'PixelGrid',
                               'interp': 'Lanczos(5)',
                               'scale': 1.012,
                               'size': 15,
                               'start_sigma': 2.0,
                               'centered': 0},
                    'interp': {'type': 'BasisPolynomial', 
                               'order': 3},
                    'outliers': {'include_reserve': 0,
                                   'max_remove': 5,
                                   'nsigma': 3,
                               'type': 'Chisq'}
                    }
         }


# Loading the stars to fit and fit them

import piff
# - Input files
inputfile = piff.InputFiles(config["io"], logger=None)
inputfile.setPointing('RA','DEC')
# - need for the fit
wcs = inputfile.getWCS()
pointing = inputfile.getPointing()
stars = inputfile.makeStars(logger=None)

# - PSF
psf = piff.SimplePSF.process(config['psf'])
psf.fit(stars, wcs, pointing, logger=None)

# - Plot the results
star_plotted  = psf.stars[0]
model_plotted = psf.drawStar(star_plotted)

#
import matplotlib.pyplot as mpl

fig = mpl.figure(figsize=[9,3])
axd  = fig.add_subplot(121)
axm  = fig.add_subplot(122)

prop = dict(origin="lower", cmap="cividis")


# Data
scd = axd.imshow(star_plotted.image.array, **prop)
fig.colorbar(scd, ax=axd)

scm = axm.imshow(model_plotted.image.array, **prop)
fig.colorbar(scm, ax=axm)

Capture d’écran 2021-02-02 à 17 19 37

Problem: The PSF model (right) does not match at all the data (left)

I used the galsim version installable from conda (fails otherwise ; I'm on mac).
Does this galsim 2.2.4 include the update you made following the ZTF wcs issues ?

@rmjarvis

I was able to move to galsim version 2.3 from git (main) and it solved the problem.

I however add issue with the installation because of "-stdlib=libc++" that was failing at the very end (when calling g++ instead of gcc). -stdlib=libc++ was unknown.
I removed it from the setup.py and it installed everything smoothly.

In details

  • I installed the eigen, fftw and pyblind11 using conda install.
  • I git clone the main branch from galsim
  • I removed the -stdlib=libc++ from the setup.py
  • and run python setup.py install

and it worked.

I'm using anaconda, python version 3.8 on macOS 10.15.7

OK. Good. Yeah, we haven't released a GalSim version yet with the WCS fix you needed. We should get on that...

Anyway, I'm surprised that you should have needed to manually remove the libc++ bit in setup.py. We already have a place where if things fail using that flag, it tries removing it to see if it helps. So I'm not sure why that didn't work for you. In any case, that would be a GalSim issue, not a Piff one, so if you want to iterate on that, probably best to open an issue there.