mcclearyj / cweb_psf

1 stars 0 forks source link

Os path join errors #3

Open EdwardBerman opened 1 year ago

EdwardBerman commented 1 year ago

The python debugger showcases the following error when running get_jwst_psf.py:

/home/eddieberman/research/mcclearygroup/cweb_psf/get_jwst_psf.py(122)run_sextractor() -> cmd = ' '.join([ (Pdb) catname *** NameError: name 'catname' is not defined (Pdb) cat_name '~/research/mcclearygroup/mock_data/mosaics/COSMOS2020_sims/~/research/mcclearygroup/mock_data/mosaics/COSMOS2020_sims/mosaic_nircam_f115w_COSMOS-Web_cat.fits' (Pdb) outdir '~/research/mcclearygroup/mock_data/mosaics/COSMOS2020_sims'

mcclearyj commented 1 year ago

Hi Eddie, thank you for pointing out this bug. I believe you are referring to this line and the ones below. If both outdir and image_file contain absolute paths, then that os.path.join() call will yield a nonsense path and the code could fail.

https://github.com/mcclearyj/cweb_psf/blob/255670136092cb63e134dcae233cba4323438e9d/get_jwst_psf.py#L96

What I still don't understand is why I never got this error message, despite using identical code. Perhaps MacOS (my operating system) is doing something I don't know about?

In any case, it's a simple fix: using os.path.basename() as the image name instead of the whole path. I will implement that now.

mcclearyj commented 1 year ago

OK, bug fix has been pushed and code seems to run OK on my laptop. Please update with whether or not that solves your problem.