Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't index into a review table #150

Closed
jeanconn opened this issue Mar 12, 2021 · 1 comment · Fixed by #151
Closed

Can't index into a review table #150

jeanconn opened this issue Mar 12, 2021 · 1 comment · Fixed by #151

Comments

@jeanconn
Copy link
Contributor

In [1]: import pickle                                                                                                         

In [2]: import gzip                                                                                                           

In [3]: acas = pickle.load(gzip.open("/data/mpcrit1/mplogs/2021/MAR1521/oflsa/output/MAR1521A_proseco.pkl.gz"))               

In [6]: aca = acas[24801]                                                                                                     

In [7]: acar = aca.get_review_table()                                                                                         

In [8]: aca[aca['slot'] == 5]                                                                                                 
Out[8]: 
<ACATable length=1>
 slot  idx      id    type  sz   p_acq    mag    maxmag   yang    zang    dim   res  halfw
int64 int32   int64   str3 str3 float64 float64 float64 float64 float64  int32 int32 int64
----- ----- --------- ---- ---- ------- ------- ------- ------- -------- ----- ----- -----
    5     6 723001776  BOT  6x6   0.954    9.24   10.74 1262.03 -2394.13    20     1   160

In [9]: acar[acar['slot'] == 5]                                                                                               
---------------------------------------------------------------------------
KeyError                                  Traceback (most recent call last)
<ipython-input-9-1302b9f0ce48> in <module>
----> 1 acar[acar['slot'] == 5]

/proj/sot/ska3/flight/lib/python3.8/site-packages/astropy/table/table.py in __getitem__(self, item)
   1662             # is produced by np.where, as in t[np.where(t['a'] > 2)]
   1663             # For all, a new table is constructed with slice of all columns
-> 1664             return self._new_from_slice(item)
   1665         else:
   1666             raise ValueError('Illegal type {} for table item access'

/proj/sot/ska3/flight/lib/python3.8/site-packages/astropy/table/table.py in _new_from_slice(self, slice_)
   1172         """Create a new table as a referenced slice from self."""
   1173 
-> 1174         table = self.__class__(masked=self.masked)
   1175         if self.meta:
   1176             table.meta = self.meta.copy()  # Shallow copy for slice

/proj/sot/ska3/flight/lib/python3.8/site-packages/sparkles/core.py in __init__(self, *args, **kwargs)
    438 
    439         # Add row and col columns from yag/zag, if not already there.
--> 440         self.add_row_col()
    441 
    442         self.context = {}  # Jinja2 context for output HTML review

/proj/sot/ska3/flight/lib/python3.8/site-packages/sparkles/core.py in add_row_col(self)
    817             return
    818 
--> 819         row, col = yagzag_to_pixels(self['yang'], self['zang'], allow_bad=True)
    820         index = self.colnames.index('zang') + 1
    821         self.add_column(Column(row, name='row'), index=index)

/proj/sot/ska3/flight/lib/python3.8/site-packages/astropy/table/table.py in __getitem__(self, item)
   1638     def __getitem__(self, item):
   1639         if isinstance(item, str):
-> 1640             return self.columns[item]
   1641         elif isinstance(item, (int, np.integer)):
   1642             return self.Row(self, item)

/proj/sot/ska3/flight/lib/python3.8/site-packages/astropy/table/table.py in __getitem__(self, item)
    237         """
    238         if isinstance(item, str):
--> 239             return OrderedDict.__getitem__(self, item)
    240         elif isinstance(item, (int, np.integer)):
    241             return list(self.values())[item]

KeyError: 'yang'
@jeanconn
Copy link
Contributor Author

I suppose this is more a sparkles issue.

@jeanconn jeanconn transferred this issue from sot/proseco Mar 12, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant