sot / proseco

Probabilistic star evaluation and catalog optimization
https://sot.github.io/proseco
BSD 3-Clause "New" or "Revised" License
1 stars 0 forks source link

Plotting of guide catalog is broken for pure guide catalog (get_guide_catalog()) #260

Closed jeanconn closed 5 years ago

jeanconn commented 5 years ago
In [18]: cat = proseco.guide.get_guide_catalog(obsid=20944)

In [19]: cat.plot()
---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
<ipython-input-19-fb7abec1d2e6> in <module>()
----> 1 cat.plot()

/proj/sot/ska/jeanproj/git/proseco/proseco/core.py in plot(self, ax, **kwargs)
    675         :param kwargs: other keyword args for plot_stars
    676         """
--> 677         kwargs.setdefault('catalog', self.get_catalog_for_plot())
    678         kwargs.setdefault('stars', self.stars)
    679         kwargs.setdefault('bad_stars', self.bad_stars_mask)

/proj/sot/ska/jeanproj/git/proseco/proseco/core.py in get_catalog_for_plot(self)
    665         catalog = self.as_array()
    666         if self.catalog_type:
--> 667             catalog['type'] = self.catalog_type
    668         return catalog
    669 

ValueError: no field of name type
taldcroft commented 5 years ago

This only applies to a catalog generated with get_guide_catalog(). The fix should be to move the catalog=self.as_array() line below the if self.catalog_type block. After self.as_array() the catalog is no longer a Table and if it doesn't already have a type column then that line fails.

taldcroft commented 5 years ago

Though I guess that approach has a side effect of adding a type column to the guide catalog. Not a huge deal I guess.

jeanconn commented 5 years ago

From a vocab perspective, I don't see a difference between a "guide catalog" and a "pure guide catalog (get_guide_catalog)". Are you contrasting a "pure guide catalog" with a "subset of guide stars in a get_aca_catalog catatlog"?

jeanconn commented 5 years ago

Also, I'm a little confused by the suggested fix? If I bump that line down below the block I just get

UnboundLocalError: local variable 'catalog' referenced before assignment

when it is trying to assign the type

    665         if self.catalog_type:
--> 666             catalog['type'] = self.catalog_type
    667         catalog = self.as_array()
    668         return catalog
jeanconn commented 5 years ago

Eh. I guess self['type'] = self.catalog_type would be doable.