cds-astro / mocpy

Python library to easily create and manipulate MOCs (Multi-Order Coverage maps)
https://cds-astro.github.io/mocpy/
BSD 3-Clause "New" or "Revised" License
56 stars 32 forks source link

from_vizier_table returns empty MOC silently on incorrect table names #143

Closed lmichel closed 16 hours ago

lmichel commented 1 week ago

The following code:

from mocpy import MOC

moc = MOC.from_vizier_table('II/355')
moc.save("II_355.fits", format="fits")

moc = MOC.from_vizier_table('WQAZSXCDE.fits')
moc.save("WQAZSXCDE", format="fits")

moc = MOC.from_vizier_table('II/355/dr3')
moc.save("II_355_dr3.fits", format="fits")

Produces the following output files, all with the same size:

% ls -lrt *.FITS
-rw-rw-r-- 1 laurent.michel laurent.michel  5760 Jun 26 18:29 II_355.fits
-rw-rw-r-- 1 laurent.michel laurent.michel  5760 Jun 26 18:30 WQAZSXCDE.fits
-rw-rw-r-- 1 laurent.michel laurent.michel  5760 Jun 26 18:34 II_355_dr3.fits

None if these MOC files contains data.

ManonMarchand commented 1 week ago

I guess you're trying to get I/355/gaiadr3 ? The valid tables names can be read from VizieR http://vizier.cds.unistra.fr/viz-bin/VizieR?-source=I/355&-to=2

You're right that the method needs a bit of grooming. We can document this better, and we should raise a warning (or even an error?) if the result is empty.

lmichel commented 6 days ago

As you know, CutPast is our worse friend...

I rewrote my script:

from mocpy import MOC
for id in ["I/355", "I/355/gaiadr3", "AZERTYUIOP"]:
    moc = MOC.from_vizier_table(id)
    print(moc)

0/
WARNING: Keyword 'TTYPE1' found more than once in a same HDU! We use the first occurrence.
0/0-11 
8/
0/

In this example, I've a valid Vizier catalogue ID (I/355), a valid Vizier table ID (I/355/gaiadr3) and an invalid ID.

However, none of those return any valid MOC

My expectations:

ManonMarchand commented 6 days ago

These are all valid MOCs.

On empty MOCs

Yes, we plan to raise a warning (or error, not decided yet) for empty MOCs in future versions.

On the expected result

The only correct entry here is I/355/gaiadr3 as it is a VizieR table (not catalog, see the method's name):

from mocpy import MOC
moc = MOC.from_vizier_table("I/355/gaiadr3")
print(moc)
0/0-11 
8/

is the expected result. You did not specify the order. The default is 8 so you get a MOC with a max order of 8 (8/). As the survey covers the whole sky, it has all the cells at order 0 (0/0-11).

If you want a whole catalog, an undocumented trick is to do

from mocpy import MOC
moc = MOC.from_vizier_table("I/355/*")
print(moc)

That only works because the default of the MOCServer is to return the union of all the MOCs, and here "I/355/*" would match any gaia table.

About the warning you got

The warning is upstream. @pferniqu , the FITS file returned by the MOCServer has two TTYPE1 in its header (one is TTYPE1 = 'UNIQ ' and the other is TTYPE1 = 'NPIX ', see this file CDS_I_355_gaiadr3.zip that I got from Laurent's request)

tboch commented 1 day ago

I support Laurent's request. Giving an invalid VizieR table identifier should return an error, not an empty MOC.