radio-astro-tools / casa-formats-io

Code to handle I/O from/to data in CASA format
Other
10 stars 7 forks source link

Measurement Set read gives error. #34

Closed miguelcarcamov closed 2 years ago

miguelcarcamov commented 2 years ago

Hello everyone, I am testing casa-formats-io because I am interested on reading and writing data bypassing python-casacore.

I am currently testing with this DSHARP dataset:

https://almascience.nrao.edu/almadata/lp/DSHARP/MSfiles/HD163296_continuum.ms.tgz

When I do

import casa_formats_io
from astropy.table import Table
table = Table.read('/home/miguel/Documents/datasets/ALMA/HD163296/HD163296_continuum.ms')

I get this error:

---------------------------------------------------------------------------
IORegistryError                           Traceback (most recent call last)
/tmp/ipykernel_404283/3282424571.py in <module>
----> 1 table = Table.read('/home/miguel/Documents/datasets/ALMA/HD163296/HD163296_continuum.ms')

~/Documents/pyralysis/venv/lib/python3.9/site-packages/astropy/table/connect.py in __call__(self, *args, **kwargs)
     59         descriptions = kwargs.pop('descriptions', None)
     60 
---> 61         out = registry.read(cls, *args, **kwargs)
     62 
     63         # For some readers (e.g., ascii.ecsv), the returned `out` class is not

~/Documents/pyralysis/venv/lib/python3.9/site-packages/astropy/io/registry.py in read(cls, format, cache, *args, **kwargs)
    514                     fileobj = args[0]
    515 
--> 516             format = _get_valid_format(
    517                 'read', cls, path, fileobj, args, kwargs)
    518 

~/Documents/pyralysis/venv/lib/python3.9/site-packages/astropy/io/registry.py in _get_valid_format(mode, cls, path, fileobj, args, kwargs)
    594     if len(valid_formats) == 0:
    595         format_table_str = _get_format_table_str(cls, mode.capitalize())
--> 596         raise IORegistryError("Format could not be identified based on the"
    597                               " file name or contents, please provide a"
    598                               " 'format' argument.\n"

IORegistryError: Format could not be identified based on the file name or contents, please provide a 'format' argument.
The available formats are:
           Format           Read Write Auto-identify Deprecated
--------------------------- ---- ----- ------------- ----------
                      ascii  Yes   Yes            No           
               ascii.aastex  Yes   Yes            No           
                ascii.basic  Yes   Yes            No           
                  ascii.cds  Yes    No            No           
     ascii.commented_header  Yes   Yes            No           
                  ascii.csv  Yes   Yes           Yes           
              ascii.daophot  Yes    No            No           
                 ascii.ecsv  Yes   Yes           Yes           
           ascii.fast_basic  Yes   Yes            No           
ascii.fast_commented_header  Yes   Yes            No           
             ascii.fast_csv  Yes   Yes            No           
       ascii.fast_no_header  Yes   Yes            No           
             ascii.fast_rdb  Yes   Yes            No           
             ascii.fast_tab  Yes   Yes            No           
          ascii.fixed_width  Yes   Yes            No           
ascii.fixed_width_no_header  Yes   Yes            No           
 ascii.fixed_width_two_line  Yes   Yes            No           
                 ascii.html  Yes   Yes           Yes           
                 ascii.ipac  Yes   Yes            No           
                ascii.latex  Yes   Yes           Yes           
            ascii.no_header  Yes   Yes            No           
                  ascii.rdb  Yes   Yes           Yes           
                  ascii.rst  Yes   Yes            No           
           ascii.sextractor  Yes    No            No           
                  ascii.tab  Yes   Yes            No           
                       asdf  Yes   Yes           Yes           
                       fits  Yes   Yes           Yes           
                       hdf5  Yes   Yes           Yes           
                 pandas.csv  Yes   Yes            No           
                 pandas.fwf  Yes    No            No           
                pandas.html  Yes   Yes            No           
                pandas.json  Yes   Yes            No           
                    votable  Yes   Yes           Yes           
                     aastex  Yes   Yes            No        Yes
                        cds  Yes    No            No        Yes
                        csv  Yes   Yes            No        Yes
                    daophot  Yes    No            No        Yes
                       html  Yes   Yes            No        Yes
                       ipac  Yes   Yes            No        Yes
                      latex  Yes   Yes            No        Yes
                        rdb  Yes   Yes            No        Yes

What can I do to fix this? Cheers,

keflavich commented 2 years ago

@miguelcarcamov can you check that you have the latest astropy & casa-formats-io? I tried the same code and instead got this:


In [5]: table = Table.read('HD163296_continuum.ms')
read (None, None, 'HD163296_continuum.ms') {}
/blue/adamginsburg/adamginsburg/repos/casa-formats-io/casa_formats_io/casa_low_level_io/data_managers/tiled.py:163: RuntimeWarning: divide by zero encountered in long_scalars
  factors = [f for f in range(stacks[dim] + 1) if stacks[dim] % f == 0]
Traceback (most recent call last):
  File "<ipython-input-5-b128b0d2433e>", line 1, in <module>
    table = Table.read('HD163296_continuum.ms')
  File "/home/adamginsburg/.local/lib/python3.9/site-packages/astropy/table/connect.py", line 61, in __call__
    out = registry.read(cls, *args, **kwargs)
  File "/home/adamginsburg/.local/lib/python3.9/site-packages/astropy/io/registry.py", line 527, in read
    data = reader(*args, **kwargs)
  File "/blue/adamginsburg/adamginsburg/repos/casa-formats-io/casa_formats_io/table_reader.py", line 19, in read_casa_table
    return table.as_astropy_table(data_desc_id=data_desc_id)
  File "/blue/adamginsburg/adamginsburg/repos/casa-formats-io/casa_formats_io/casa_low_level_io/table.py", line 380, in as_astropy_table
    raise ValueError("There are multiple DATA_DESC_ID values present "
ValueError: There are multiple DATA_DESC_ID values present in the table, select the one you need with data_desc_id=<value>. Valid options are 0/1/2/3/4/5/6/7/8/9/10/11/12/13/14/15/16/17/18/19/20/21/22/23
keflavich commented 2 years ago

and here's the successful version, plus my astropy/casaformatsio versions:


In [6]: table = Table.read('HD163296_continuum.ms', data_desc_id=0)
read (None, None, 'HD163296_continuum.ms') {'data_desc_id': 0}
/blue/adamginsburg/adamginsburg/repos/casa-formats-io/casa_formats_io/casa_low_level_io/data_managers/tiled.py:163: RuntimeWarning: divide by zero encountered in long_scalars
  factors = [f for f in range(stacks[dim] + 1) if stacks[dim] % f == 0]

In [7]: import astropy, casa_formats_io

In [8]: print(astropy.__version__, casa_formats_io.__version__)
4.3.1 0.2.dev79+gf3fcc08
miguelcarcamov commented 2 years ago

Yes, it was the version! I needed to install the last version from the main branch. Thanks!