jpierel14 / space_phot

0 stars 1 forks source link

support get_hst3_psf for WFC3/UV images #1

Closed orifox closed 1 year ago

orifox commented 1 year ago

I get the following error when running the notebook hst_uv.ipynb in /astro/armin/data/space_phot_debug/ori. All necessary data files should be accessible from the notebook.


Trailer file written to:  astrodrizzle.log
---------------------------------------------------------------------------
IndexError                                Traceback (most recent call last)
Cell In[11], line 3
      1 hst_flc_obs = st_phot.observation2(input_flcs)
      2 hst_drz_obs = st_phot.observation3('my_ad/f555w_17gax_2023_jhat_drc.fits')
----> 3 psf_drz = st_phot.get_hst3_psf(hst_flc_obs,sn_location)#,num_psfs=4)
      4 plt.imshow(psf_drz.data)
      5 plt.show()

File ~/miniconda3/envs/17gax/lib/python3.9/site-packages/st_phot/util.py:467, in get_hst3_psf(st_obs, sky_location, psf_width)
    463     y,x = astropy.wcs.utils.skycoord_to_pixel(sky_location,imwcs)
    464     mx,my = np.meshgrid(np.arange(-4*psf_width/2,psf_width/2*4+1,1).astype(int)+int(x+.5),
    465                         np.arange(-4*psf_width/2,psf_width/2*4+1,1).astype(int)+int(y+.5))
--> 467     level3_psf = photutils.psf.FittableImageModel(level3[mx,my],normalize=True, 
    468                                                   oversampling=4)
    470     shutil.rmtree(outdir)
    471 except RuntimeError:

IndexError: index -5654 is out of bounds for axis 0 with size 4056
jpierel14 commented 1 year ago

@orifox try this with space_phot==0.0.3 I think it should work now

orifox commented 1 year ago

Got farther. But it crashed. Not sure if it's something on my machine. Error below.

Trailer file written to:  astrodrizzle.log
(16384, 8204)
889.1708190171985 1143.4852111466157 939 1193
Failed to create PSF model
---------------------------------------------------------------------------
OSError                                   Traceback (most recent call last)
File ~/miniconda3/envs/17gax/lib/python3.9/site-packages/space_phot/util.py:477, in get_hst3_psf(st_obs, sky_location, psf_width)
    474     level3_psf = photutils.psf.FittableImageModel(level3[mx,my],normalize=True, 
    475                                                   oversampling=4)
--> 477     shutil.rmtree(outdir)
    478 except:

File ~/miniconda3/envs/17gax/lib/python3.9/shutil.py:740, in rmtree(path, ignore_errors, onerror)
    739     except OSError:
--> 740         onerror(os.rmdir, path, sys.exc_info())
    741 else:

File ~/miniconda3/envs/17gax/lib/python3.9/shutil.py:738, in rmtree(path, ignore_errors, onerror)
    737     fd_closed = True
--> 738     os.rmdir(path)
    739 except OSError:

OSError: [Errno 39] Directory not empty: '/home/ofox/miniconda3/envs/17gax/lib/python3.9/site-packages/space_phot/temp_142'

During handling of the above exception, another exception occurred:

OSError                                   Traceback (most recent call last)
Cell In[12], line 3
      1 hst_flc_obs = space_phot.observation2(input_flcs)
      2 hst_drz_obs = space_phot.observation3('my_ad/f555w_17gax_2023_jhat_drc.fits')
----> 3 psf_drz = space_phot.get_hst3_psf(hst_flc_obs,sn_location)#,num_psfs=4)
      4 plt.imshow(psf_drz.data)
      5 plt.show()

File ~/miniconda3/envs/17gax/lib/python3.9/site-packages/space_phot/util.py:480, in get_hst3_psf(st_obs, sky_location, psf_width)
    478 except:
    479     print('Failed to create PSF model')
--> 480     shutil.rmtree(outdir)
    481 return level3_psf

File ~/miniconda3/envs/17gax/lib/python3.9/shutil.py:734, in rmtree(path, ignore_errors, onerror)
    732 try:
    733     if os.path.samestat(orig_st, os.fstat(fd)):
--> 734         _rmtree_safe_fd(fd, path, onerror)
    735         try:
    736             os.close(fd)

File ~/miniconda3/envs/17gax/lib/python3.9/shutil.py:690, in _rmtree_safe_fd(topfd, path, onerror)
    688     os.unlink(entry.name, dir_fd=topfd)
    689 except OSError:
--> 690     onerror(os.unlink, fullname, sys.exc_info())

File ~/miniconda3/envs/17gax/lib/python3.9/shutil.py:688, in _rmtree_safe_fd(topfd, path, onerror)
    686 else:
    687     try:
--> 688         os.unlink(entry.name, dir_fd=topfd)
    689     except OSError:
    690         onerror(os.unlink, fullname, sys.exc_info())

OSError: [Errno 16] Device or resource busy: '.nfs00000000aa7b758b00000061'
jpierel14 commented 1 year ago

@orifox I can't reproduce this error so I think it is an issue with how you're running this, but I think I know the cause and will try to fix it

orifox commented 1 year ago

Ok, I switched over from my virtual to my local machine and it ran fine. I'm not sure what the issue is, but I can at least run it. I encountered another bug, but I'll open a new ticket for that. I consider this closed. Thank you!