# Afw.table basic operations

**URL:** <https://www.rubin.community/t/afw-table-basic-operations/4346>\
**Category:** Support\
**Tags:** dm-dev\
**Created:** [August 26, 2020, 8:51am UTC](https://www.rubin.community/t/afw-table-basic-operations/4346 "2020-08-26T08:51:05Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![raphaelshirley](https://sea2.discourse-cdn.com/flex002/user_avatar/www.rubin.community/raphaelshirley/32/1230_2.png) [@raphaelshirley](https://www.rubin.community/u/raphaelshirley)\
**Post date:** [August 26, 2020, 8:51am UTC](https://www.rubin.community/t/afw-table-basic-operations/4346/1 "2020-08-26T08:51:05Z")

</div>

Hi,

This is a general question about table manipulation prompted by a specific issue. My broad question is: is the typical LSST stack user expected to stop using astropy/pandas tables altogether or convert between then and afw.table?

I am trying to make a calibration catalogue for VISTA/HSC by taking the PanSTARRS HSC [calibration catalogue](http://www.rubin.community/t/pan-starrs-reference-catalog-in-lsst-format/1572) and merging in 2MASS. The cross matching and stacking etc is trivial with astropy.table but the result will not be loaded by the stack. I am currently hacking it by altering the fits ‘TFORM’ etc using astropy.io.fits. Is this what most people are doing or should I be writing new cross match etc functionality (or does it already exist) using afw.table? The absolute easiest would be some sort of ‘from\_astropy’ functionality.

I followed the very old discussion [here](http://www.rubin.community/t/pythonic-views-for-afw-table/483) but can’t find any example code for basic table manipulation elsewhere.

Many thanks,

Raphael.

---

<div class="post-metadata">

**Author:** ![jrmullaney](https://sea2.discourse-cdn.com/flex002/user_avatar/www.rubin.community/jrmullaney/32/502_2.png) [@jrmullaney](https://www.rubin.community/u/jrmullaney)\
**Post date:** [August 26, 2020, 2:21pm UTC](https://www.rubin.community/t/afw-table-basic-operations/4346/2 "2020-08-26T14:21:51Z")

</div>

Hi Raphael,

I’ve just created a GitHub repository that includes the code that I used to filter the PanSTARRS reference catalogue to include sources brighter than 19th mag. There’s also a README file in there.

The repository’s here: [https://github.com/jrmullaney/filter\_PanSTARRS](https://github.com/jrmullaney/filter_PanSTARRS)

I think you should be able to use that to work out how to generate a new reference catalogue.

J

---

<div class="post-metadata">

**Author:** ![raphaelshirley](https://sea2.discourse-cdn.com/flex002/user_avatar/www.rubin.community/raphaelshirley/32/1230_2.png) [@raphaelshirley](https://www.rubin.community/u/raphaelshirley)\
**Post date:** [August 26, 2020, 2:23pm UTC](https://www.rubin.community/t/afw-table-basic-operations/4346/3 "2020-08-26T14:23:26Z")

</div>

Great thanks very much. I think it is just the afwTable formatting stuff that is breaking processCcd so the table manipulation stuff will be very helpful!

---

<div class="post-metadata">

**Author:** ![jrmullaney](https://sea2.discourse-cdn.com/flex002/user_avatar/www.rubin.community/jrmullaney/32/502_2.png) [@jrmullaney](https://www.rubin.community/u/jrmullaney)\
**Post date:** [August 26, 2020, 2:31pm UTC](https://www.rubin.community/t/afw-table-basic-operations/4346/4 "2020-08-26T14:31:44Z")

</div>

No problems. I’ll defer to the DM team for your broader question of working with tables.

---

<div class="post-metadata">

**Author:** ![jbosch](https://sea2.discourse-cdn.com/flex002/user_avatar/www.rubin.community/jbosch/32/12_2.png) [@jbosch](https://www.rubin.community/u/jbosch)\
**Post date:** [August 26, 2020, 3:56pm UTC](https://www.rubin.community/t/afw-table-basic-operations/4346/5 "2020-08-26T15:56:48Z")

</div>

We definitely don’t encourage (let alone require) everyone to convert external tables to `afw.table`, and we’re actually trying to reduce our own reliance on `afw.table`.

But our processing pipelines currently always start with `afw.table` objects and convert to `pandas.DataFrame` in later steps, so we’ve only had to do that conversion in one direction (and not the direction you need). Our effort to reduce our own `afw.table` usage mostly consists of trying move that conversion point earlier.

If I understand your case correctly, you’re trying to produce a reference catalog our pipelines can use, and that’s well within the steps where it’s still just `afw.table`, so we don’t have any great solutions for you. If you have something working that you understand, it may be best to just live with it, but we can try to answer `afw.table` questions directly if you’d prefer to use those APIs.

---

<div class="post-metadata">

**Author:** ![MelissaGraham](https://sea2.discourse-cdn.com/flex002/user_avatar/www.rubin.community/melissagraham/32/2549_2.png) [@MelissaGraham](https://www.rubin.community/u/MelissaGraham)\
**Post date:** [October 21, 2020, 7:04pm UTC](https://www.rubin.community/t/afw-table-basic-operations/4346/6 "2020-10-21T19:04:12Z")

</div>

@raphaelshirley, I just wanted to check in and see if @jrmullaney’s repository, and/or @jbosch’s explanation, helped you to resolve this issue?
