I am trying to write a function to clean catalog files that are output from sextractor. The sextractor catalog creation command and the initial ascii read command seem fine:
cat_sci = ascii.read('sci_match.cat',format='sextractor')
cat_sci
....bunch of stuff that looks like the catalog I expect....
This catalog has the following format:
# 1 VIGNET Pixel data around detection [count]
# 3482 X_IMAGE Object position along x [pixel]
# 3483 Y_IMAGE Object position along y [pixel]
# 3484 X_WORLD Barycenter position along world x axis [deg]
# 3485 Y_WORLD Barycenter position along world y axis [deg]
# 3486 FLUX_APER Flux vector within fixed circular aperture(s) [count]
# 3487 FLUX_AUTO Flux within a Kron-like elliptical aperture [count]
# 3488 FLUXERR_APER RMS error vector for aperture flux(es) [count]
# 3489 FLUX_RADIUS Fraction-of-light radii [pixel]
# 3490 ELONGATION A_IMAGE/B_IMAGE
# 3491 FLAGS Extraction flags
# 3492 SNR_WIN Gaussian-weighted SNR
# 3493 MAG_AUTO Kron-like elliptical aperture magnitude [mag]
# 3494 MAG_APER Fixed aperture magnitude vector [mag]
# 3495 CLASS_STAR S/G classifier output
[Data columns follow]
So I clean this, using the FLAG keyword, which removes some of the rows (correctly, I think). However, when I try to rewrite it:
cat_data.write(catalog,overwrite=True)
the error culminations in this:
IORegistryError: No writer defined for format 'sextractor' and class 'Table'.
The available formats are:
<long list of formats that does not include sextractor>
So it appears that the ascii writer can READ sextractor catalogs, but not write them. This is in contrast with the docs: " All of the input Reader formats supported by [astropy.io.ascii] for reading are also supported for writing." (ASCII Tables (astropy.io.ascii) — Astropy v0.2.dev2728)
Q1: Have I interpreted the problem correctly? (“ascii reads but does not write in sextractor format”) (now answered YES, THAT’S THE PROBLEM see my edit below…)
Q2: How to fix it? If I can read the header first, store it, and start the new catalog file with it, that should be enough - can someone help with that?
[Context: The sextractor header includes units (you can see this above), and my code requires those units to do the thing it wants to do…but just writing ascii format doesn’t preserve the headers, and so kills the units.]
Thanks for any help people can provide!
EDIT: Slight correction - more up to date docs (ASCII Tables (astropy.io.ascii) — Astropy v6.1.1) seem to confirm that sextractor format is NOT writable, answering Q1. Any help on Q2?