fkiwy / Finder_charts

A Python module to create finder charts from image data of various sky surveys
MIT License
2 stars 0 forks source link

UnboundLocalError: local variable 'ra' referenced before assignment & wcs error #5

Closed jennifrench closed 2 months ago

jennifrench commented 3 months ago

When trying to run your minimum example of create_finder_charts(16.9701886, 0.6992208), I get two errors:

TypeError Traceback (most recent call last) File ~/Finder_Charts/Finder_charts.py:289, in create_finder_charts..finder_charts..plot_image(image_bucket, img_idx) 287 overlay_phot = image_bucket.overlay_phot --> 289 ax = fig.add_subplot(rows, cols, img_idx, projection=wcs) 291 if targets:

File ~/anaconda3/lib/python3.10/site-packages/matplotlib/figure.py:743, in FigureBase.add_subplot(self, *args, kwargs) 741 projection_class, pkw = self._process_projection_requirements( 742 *args, *kwargs) --> 743 ax = projection_class(self, args, pkw) 744 key = (projection_class, pkw)

TypeError: WCSAxes.init() got multiple values for argument 'wcs'

During handling of the above exception, another exception occurred:

UnboundLocalError Traceback (most recent call last) Cell In[4], line 1 ----> 1 create_finder_charts(16.9701886, 0.6992208)

File ~/Finder_Charts/Finder_charts.py:1563, in create_finder_charts(ra, dec, img_size, overlays, overlay_color, dss, twomass, spitzer, wise, ukidss, uhs, vhs, vvv, viking, ps1, decam, neowise, neowise_contrast, gaia_images, gaia_entries, gaia_pm_vectors, gaia_pm_years, gaia_color, targets, pmra, pmdec, ref_epoch, crosshair_type, propagate_gaia_positions, chrono_order, object_info, directory, cache, show_progress, timeout, open_file, file_format, save_result_tables, result_tables_format, result_tables_extension) 1560 warnings.simplefilter('ignore', category=Warning) 1562 if np.isscalar(ra) and np.isscalar(dec): -> 1563 finder_charts(ra, dec, targets) 1564 else: 1565 if not isinstance(ra, (collections.Sequence, np.ndarray)):

File ~/Finder_Charts/Finder_charts.py:1505, in create_finder_charts..finder_charts(ra, dec, targets) 1503 img_idx += 1 1504 if image_bucket is not None: -> 1505 plot_image(image_bucket, img_idx) 1506 if image_bucket.band == TWO_MASS_K: 1507 info_idx = img_idx

File ~/Finder_Charts/Finder_charts.py:370, in create_finder_charts..finder_charts..plot_image(image_bucket, img_idx) 368 ax.axis('off') 369 except Exception: --> 370 print('A problem occurred while plotting an image for object ra={ra}, dec={dec}, band={band}'.format(ra=ra, dec=dec, band=band)) 371 print(traceback.format_exc())

UnboundLocalError: local variable 'ra' referenced before assignment

This is from a fresh install using jupyter notebook, and I get the same issues if trying it in the terminal. Any help would be greatly appreciated, thanks!

fkiwy commented 3 months ago

This is a known compatibility issue between Astropy 5.1 and Matplotlib 3.7 (see https://github.com/astropy/astropy/issues/14817 and https://github.com/sunpy/sunpy/issues/6946).

I recommend creating a new conda environment and installing Finder_charts using the requirements.txt file by adding the version numbers provided in the README file: https://github.com/fkiwy/Finder_charts?tab=readme-ov-file#module-dependencies You can copy/paste the dependencies and version numbers from the README file directly into the requirements.txt file in the cloned Finder_charts repository on your computer and then run the following command: pip install -r requirements.txt.