askap-vast / vast-tools

A collection of tools that are useful for the VAST project and for exploration of results from the VAST Pipeline.
https://vast-survey.org/vast-tools/
MIT License
8 stars 0 forks source link

vasttools.Source: make_png breaks when source name is an int #533

Closed ddobie closed 4 months ago

ddobie commented 5 months ago

It's standard(ish) to want to create a Query from a list of pipeline sources, with the pipeline ID corresponding to the source name. However, this breaks make_png:

File /home/jovyan/vast-tools/vasttools/source.py:1848, in Source.make_png(self, index, selavy, percentile, zscale, contrast, outfile, no_islands, label, no_colorbar, title, crossmatch_overlay, hide_beam, save, size, force, disable_autoscaling, cutout_data, norms, plot_dpi, offset_axes)
   1845     raise ValueError(f"Cannot access {index}th measurement.")
   1847 if outfile is None:
-> 1848     outfile = self._get_save_name(index, ".png")
   1850 if self.outdir != ".":
   1851     outfile = os.path.join(
   1852         self.outdir,
   1853         outfile
   1854     )

File /home/jovyan/vast-tools/vasttools/source.py:1020, in Source._get_save_name(self, index, ext)
   1017 if not ext.startswith("."):
   1018     ext = f".{ext}"
-> 1020 source_name = self.name.replace(" ", "_").replace("/", "_")
   1022 if self.pipeline:
   1023     outfile = f"{source_name}_{index}{ext}"

AttributeError: 'int' object has no attribute 'replace'

Solution is to convert names to a string in init.