Skip to content

astropy.io.ascii.Cds format exception (ValueError for invalid NULL) #11239

Closed

Description

@gilleslandais

EDIT: Solution provided at #11239 (comment)

Description

The CDS format (astropy.io.ascii.Cds) throws exceptions for some VizieR tables.

The exception appears for ascii tables having '-' as null values.

Expected behavior

Take into account the '-' as null values in the read method.

Actual behavior

Throw an Exception

Steps to Reproduce

# Put your Python code snippet here.
from astropy.io import ascii
readme = "ftp://cdsarc.u-strasbg.fr/pub/cats/J/A+A/642/A176/ReadMe"
r = ascii.get_reader(ascii.Cds, readme=readme)
table = r.read("ftp://cdsarc.u-strasbg.fr/pub/cats/J/A+A/642/A176/table5.dat")

System Details

Activity

  1. pllim commented on Jan 12, 2021

    @pllim
    Member

    The exception is InconsistentTableError: Can't find table contents from astropy 4.3.dev . (I did use download_file to cache both files first, so maybe I am hitting a different error...)

    .../astropy/io/ascii/cds.py in read(self, table)
        325                     return table
        326         else:
    --> 327             return super().read(table)
    
    .../astropy/io/ascii/core.py in read(self, table)
       1271 
       1272         # Get the table column definitions
    -> 1273         self.header.get_cols(self.lines)
       1274 
       1275         # Make sure columns are valid
    
    .../astropy/io/ascii/cds.py in get_cols(self, lines)
         86 
         87             else:
    ---> 88                 raise core.InconsistentTableError("Can't find table {} in {}".format(
         89                     self.data.table_name, self.readme))
         90 
    
    InconsistentTableError: Can't find table contents in ...
    

    From the readme:

    Byte-by-byte Description of file: table5.dat
    --------------------------------------------------------------------------------
       Bytes Format Units   Label     Explanations
    --------------------------------------------------------------------------------
       1-  7  F7.2  0.1nm   lambda    Wavelength
       9- 12  A4    ---     El        Element
      14- 17  F4.2  eV      chiex     Excitation potential
      19- 23  F5.2  [-]     log(gf)   Oscillator strength
      25- 27  I3    0.1nm   EW1       ? S05-5 equivalent width
      29- 32  F4.1  0.1nm e_EW1       ? rms uncertainty on EW1
          33  A1    ---   n_EW1       [*] Note on EW1 (1)
      36- 38  I3    0.1nm   EW2       ? S08-229 equivalent width
      40- 43  F4.1  0.1nm e_EW2       ? rms uncertainty on EW2
          44  A1    ---   n_EW2       [*]  Note on EW2 (1)
    --------------------------------------------------------------------------------
    Note (1): The asterisk indicates lines with equivalent widths >180{AA} which
      were not considered in the analysis.
    --------------------------------------------------------------------------------
    
    Table data
    4736.77 FeI  3.21 -0.75   -         -
    4871.32 FeI  2.87 -0.36   -         -
    4872.14 FeI  2.88 -0.57   -         -
    4891.49 FeI  2.85 -0.11   -         -
    4903.31 FeI  2.88 -0.93   -         -
    4918.99 FeI  2.87 -0.34   -         -
    4920.50 FeI  2.83  0.07   -         -
    4938.81 FeI  2.87 -1.08   -         -      
    4939.69 FeI  0.86 -3.34   -         -      
    4966.10 FeI  3.33 -0.89 114  4.0    94  5.5
    4994.13 FeI  0.92 -3.08   -         -      
    5001.86 FeI  3.88  0.01   -         -      
    5006.12 FeI  2.83 -0.63 125  3.8   127  5.4
    5041.07 FeI  0.96 -3.09   -         -      
    5041.76 FeI  1.49 -2.20   -         -      
    5049.82 FeI  2.28 -1.36   -         -      
    5051.64 FeI  0.92 -2.80   -         -      
    5068.77 FeI  2.94 -1.04   -         -      
    5074.75 FeI  4.22 -0.20   -         -      
    5079.75 FeI  0.99 -3.24 159  6.2   151  8.5
    5083.34 FeI  0.96 -2.96   -         -      
    5110.41 FeI  0.00 -3.76   -         -      
    5127.36 FeI  0.92 -3.31   -         -      
    5150.84 FeI  0.99 -3.04   -         -      
    5150.85 FeI  0.99 -3.03 152  4.7   135  9.3
    5151.91 FeI  1.01 -3.32   -         -      
    5151.92 FeI  1.01 -3.33 155  9.7   126  9.3
    5159.05 FeI  4.28 -0.81  27  2.2    35  5.5
    5162.29 FeI  4.18  0.02  80  3.3    80  6.2
    5165.41 FeI  4.22 -0.04  34  2.6    44  4.5
    5166.28 FeI  0.00 -4.20 177  3.9   146  6.3
    5171.61 FeI  1.48 -1.75 179  3.9   149  5.4
    5191.46 FeI  3.04 -0.55   -         -      
    5192.34 FeI  3.00 -0.52 134  4.5   131  7.9
    5194.94 FeI  1.56 -2.09   -         -      
    5196.08 FeI  4.26 -0.45   -         42  4.6
    5215.19 FeI  3.27 -0.93  90  1.9    95  3.9
    5216.28 FeI  1.61 -2.10 153  4.3   128  6.0
    5217.30 FeI  3.21 -1.27   -         -      
    5225.53 FeI  0.11 -4.79   -         -      
    5232.95 FeI  2.94 -0.07 162  5.0   157  5.8
    5250.21 FeI  0.12 -4.70 144  2.8   116  5.8
    5253.02 FeI  2.28 -3.81   -         -      
    5254.96 FeI  0.11 -4.76   -         -      
    5266.56 FeI  3.00 -0.39   -         -      
    5281.79 FeI  3.04 -0.83   -         -      
    5283.62 FeI  3.24 -0.52   -         -      
    5302.30 FeI  3.28 -0.88   -         -      
    5307.37 FeI  1.61 -2.81 119  3.1   100  3.8
    5324.19 FeI  3.21 -0.10 137  2.2   143  4.5
    5328.04 FeI  0.92 -1.47   -         -      
    5328.53 FeI  1.56 -1.85   -         -      
    5339.93 FeI  3.27 -0.68 112  3.4   119  5.9
    5364.86 FeI  4.45  0.22  68  2.1    81  5.9
    5367.48 FeI  4.42  0.55  76  3.0    77  4.0
    5369.96 FeI  4.37  0.54 101  2.9    96  4.8
    5383.37 FeI  4.31  0.50  88  2.8    94  8.9
    5389.48 FeI  4.42 -0.40  31  2.5    52  4.0
    5393.17 FeI  3.24 -0.92 108  3.4   116  4.7
    5397.14 FeI  0.91 -1.99         *          *
    5400.51 FeI  4.37 -0.15  55  2.0    61  3.2
    5405.79 FeI  0.99 -1.85         *          *
    5415.19 FeI  4.39  0.51  93  2.4   103  3.9
    5424.07 FeI  4.32  0.52 104  2.5   110  4.4
    5455.61 FeI  1.01 -2.09   -         -      
    5497.52 FeI  1.01 -2.85   -         -      
    5501.48 FeI  0.96 -3.05 167  3.9   153  3.2
    5506.79 FeI  0.99 -2.79 178  3.8   152  4.9
    5569.62 FeI  3.42 -0.54   -         -      
    5572.84 FeI  3.40 -0.31   -         -      
    5576.09 FeI  3.43 -1.00   -         -      
    5586.76 FeI  3.37 -0.14   -         -      
    5615.66 FeI  3.33  0.05 145  2.3   138  9.1
    5956.70 FeI  0.86 -4.57  91  2.8    67  5.7
    6003.03 FeI  3.88 -1.11  46  3.2    50  3.2
    6024.05 FeI  4.55 -0.11  51  3.0    90  4.3
    6027.06 FeI  4.07 -1.18  20  2.2    46  4.2
    6056.01 FeI  4.73 -0.45  20  2.1    -      
    6078.50 FeI  4.79 -0.37   -         41  5.4
    6082.72 FeI  2.22 -3.59  36  3.0    61  5.8
    6136.62 FeI  2.45 -1.50 142  4.1   139 10.7
    6137.70 FeI  2.59 -1.37 102 22.9   128  6.5
    6151.62 FeI  2.18 -3.37  54  2.3    51  3.7
    6157.75 FeI  4.07 -1.26  27  1.7    31  5.6
    6173.34 FeI  2.22 -2.85  73  2.1    83  3.6
    6191.57 FeI  2.43 -1.42 140  3.6   148  7.8
    6213.43 FeI  2.22 -2.66  92  2.3    93  3.0
    6219.29 FeI  2.20 -2.44 101  2.7   112  3.1
    6229.23 FeI  2.84 -2.90   -         -      
    6230.74 FeI  2.56 -1.28 136  4.1   131  3.2
    6240.66 FeI  2.22 -3.23  44  3.1    32  3.2
    6252.57 FeI  2.40 -1.76 131  2.7   142  4.9
    6290.97 FeI  4.73 -0.76  31  1.5    40  2.4
    6297.80 FeI  2.22 -2.74  38  5.1    99  2.8
    6301.50 FeI  3.65 -0.72  84  2.3    91  4.4
    6302.49 FeI  3.69 -1.15  46  1.7    54  3.3
    6355.04 FeI  2.84 -2.29  49  1.5    45  5.0
    6380.75 FeI  4.19 -1.50   -         20  2.9
    6392.54 FeI  2.28 -3.95  24  3.2    -      
    6393.61 FeI  2.43 -1.63 137  6.2   133  4.2
    6419.96 FeI  4.73 -0.24  27  1.6    38  3.2
    6421.36 FeI  2.28 -2.01 110  3.1   120  3.9
    6430.86 FeI  2.18 -1.95 129  3.4   132  2.8
    6498.94 FeI  0.96 -4.69  68  2.2    75  2.6
    6518.37 FeI  2.83 -2.46  45  2.6    59  4.8
    6574.23 FeI  0.99 -5.02  54  1.9    40  2.5
    6581.22 FeI  1.48 -4.68  38  3.7    43  3.1
    6593.88 FeI  2.43 -2.39  98  2.7    88  3.9
    6609.12 FeI  2.56 -2.66  58  2.6    74  4.0
    4923.92 FeII 2.89 -1.32  97 57.1    -      
    5018.43 FeII 2.89 -1.22 176  5.5           *
    5196.08 FeII 4.26 -0.45   -         42  4.6
    5197.57 FeII 3.23 -2.10  73  3.1    80  5.9
    5234.63 FeII 3.22 -2.12  79  2.3    92  4.7
    5264.81 FeII 3.23 -3.21  31  2.2    32  3.5
    5276.00 FeII 3.20 -1.95 100  5.4   108  5.7
    5284.10 FeII 2.89 -3.19  50  2.9    58  5.0
    5425.25 FeII 3.20 -3.36   -         28  3.9
    5534.85 FeII 3.24 -2.92  49  2.1    54  5.1
    6149.25 FeII 3.89 -2.72  20  2.2    29  2.9
    6238.38 FeII 3.89 -2.67   -         32  2.9
    6247.56 FeII 3.89 -2.36  25  1.9    43  3.3
    6369.46 FeII 2.89 -4.02   -         23  2.5
    6416.93 FeII 3.89 -2.79   -         31  2.5
    6432.68 FeII 2.89 -3.71  32  1.9    44  3.1
    6456.39 FeII 3.90 -2.08  43  1.9    73  3.9
    6516.08 FeII 2.89 -3.45  42  3.0    61  3.0
    6300.31 OI   0.00 -9.75  46  2.9    -      
    5889.97 NaI  0.00  0.12 164 10.1           *
    5895.92 NaI  0.00 -0.19   -         -      
    4571.10 MgI  0.00 -5.39   -         -      
    4703.00 MgI  4.33 -0.52   -         -      
    5528.41 MgI  4.35 -0.36 148  3.3   121  5.0
    5711.09 MgI  4.35 -1.73  45  3.4    26  2.4
    5265.56 CaI  2.52 -0.26   -         -      
    5349.47 CaI  2.71 -0.31   -         -      
    5581.97 CaI  2.52 -0.71   -         -      
    5588.75 CaI  2.52  0.21   -         -      
    5590.11 CaI  2.52 -0.71   -         -      
    5601.28 CaI  2.52 -0.69   -         -      
    5857.45 CaI  2.93  0.23   -         -      
    6102.73 CaI  1.88 -0.79 110  3.1    99  5.7
    6122.23 CaI  1.89 -0.32 128  2.9    -      
    6161.30 CaI  2.52 -1.27  25  1.9    -      
    6162.17 CaI  1.90 -0.09   -         -      
    6166.44 CaI  2.52 -1.14  21  1.5    31  2.5
    6169.04 CaI  2.52 -0.80  41  1.9    46  2.4
    6169.56 CaI  2.52 -0.48  60  2.2    68  3.3
    6439.08 CaI  2.52  0.39 129  2.4   136  5.7
    6455.60 CaI  2.52 -1.29  23  2.1    -      
    6499.65 CaI  2.52 -0.82  41  2.0    49  3.7
    6717.68 CaI  2.71 -0.61  31  8.7    -      
    5031.02 ScII 1.36 -0.40  93  5.0    49  8.0
    5526.79 ScII 1.77  0.03  83  4.5    60  9.5
    5657.90 ScII 1.51 -0.60  81  4.1    -      
    4533.24 TiI  0.85  0.48   -         -      
    4534.78 TiI  0.84  0.28   -         -      
    4535.57 TiI  0.83  0.13   -         -      
    4548.76 TiI  0.83 -0.29   -         -      
    4555.49 TiI  0.85 -0.43   -         -      
    4645.19 TiI  1.74 -0.50   -         -      
    4656.47 TiI  0.00 -1.28   -         -      
    4840.87 TiI  0.90 -0.45  61  3.4    -      
    4913.62 TiI  1.87  0.22   -         -      
    4981.73 TiI  0.84  0.50   -         -      
    4991.07 TiI  0.84  0.38   -         -      
    4997.10 TiI  0.00 -2.06  48  3.6    -      
    4999.50 TiI  0.83  0.25   -         -      
    5016.16 TiI  0.85 -0.51  71  3.2    72  5.6
    5039.96 TiI  0.02 -1.13   -         -      
    5064.65 TiI  0.05 -0.93 124  3.9    -      
    5145.47 TiI  1.46 -0.52   -         -      
    5173.74 TiI  0.00 -1.12   -         -      
    5192.97 TiI  0.02 -1.01   -         -      
    6258.10 TiI  1.44 -0.35   -         40  7.2
    5129.16 TiII 1.89 -1.39  86  2.9    -      
    5154.07 TiII 1.57 -1.52  86  3.7    89  5.7
    5185.91 TiII 1.89 -1.35   -         -      
    5226.55 TiII 1.57 -1.00 124  3.2    -      
    5381.01 TiII 1.57 -1.78  79  3.4    89  4.9
    5418.77 TiII 1.58 -2.11  64  2.5    75  5.2
    5206.04 CRI  0.94  0.02 177  6.4   167  7.1
    5345.80 CRI  1.00 -0.98   -         -      
    5409.80 CRI  1.03 -0.72 133  2.5   134  4.4
    4754.04 MnI  2.28 -0.09   -         -      
    4823.52 MnI  2.32  0.14   -         -      
    5420.36 MnI  2.14 -1.46   -         -      
    5432.55 MnI  0.00 -3.79  56  2.8    -      
    6013.51 MnI  3.07 -0.25   -         -      
    6021.82 MnI  3.08  0.04  27  2.2    -      
    5483.34 CoI  1.71 -1.49  43  3.4    46  6.0
    5476.92 NiI  1.83 -0.89 152  6.9   141 10.8
    5105.50 CuI  1.39 -1.50  44  3.5    -      
    4810.54 ZnI  4.08 -0.17  54  3.3    47  5.5
    4883.69 YII  1.08  0.07  60  2.0    72  4.3
    4900.11 YII  1.03 -0.09   -         -      
    5087.43 YII  1.08 -0.17  46  2.8    -      
    5200.42 YII  0.99 -0.57   -         -      
    5853.69 BaII 0.60 -1.01  81  3.1    -      
    6141.73 BaII 0.70 -0.08 124  8.5   156  6.5
    6496.91 BaII 0.60 -0.38 129  2.6   159  6.0
    5301.97 LaII 0.40 -1.14   -         -      
    5249.59 NdII 0.98  0.20  29  2.9    32  4.5
    5319.82 NdII 0.55 -0.14  34  2.1    40  4.7
    6645.13 EuII 1.37  0.12   -         21  3.0
    
    
  2. taldcroft commented on Jan 12, 2021

    @taldcroft
    Member

    The problem is that the table5.dat file is not compliant with the CDS data standard. It uses '-' to indicate NULL values, whereas the standard requires a blank field. This should be reported to the data provider. That table also has bad values for the units, but these don't cause anything more than warnings.

    Fortunately there is a workaround:

    readme = "ftp://cdsarc.u-strasbg.fr/pub/cats/J/A+A/642/A176/ReadMe"
    table = ascii.read("ftp://cdsarc.u-strasbg.fr/pub/cats/J/A+A/642/A176/table5.dat", readme=readme, fill_values=[('-', '0')])
    Downloading ftp://cdsarc.u-strasbg.fr/pub/cats/J/A+A/642/A176/table5.dat
    |===============================================================================================================================| 8.9k/8.9k (100.00%)         0s
    Downloading ftp://cdsarc.u-strasbg.fr/pub/cats/J/A+A/642/A176/ReadMe
    |===============================================================================================================================|  21k/ 21k (100.00%)         0s
    WARNING: UnitsWarning: '[-]' did not parse as cds unit: Invalid character at col 1 If this is meant to be a custom unit, define it with 'u.def_unit'. To have it recognized inside a file reader or other code, enable it with 'u.add_enabled_units'. For details, see https://docs.astropy.org/en/latest/units/combining_and_defining.html [astropy.units.core]
    
    In [17]: table
    Out[17]: 
    <Table length=205>
     lambda  El   chiex  log(gf)  EW1    e_EW1  n_EW1  EW2    e_EW2  n_EW2
     0.1 nm         eV     [-]   0.1 nm  0.1 nm       0.1 nm  0.1 nm      
    float64 str4 float64 float64 int64  float64  str1 int64  float64  str1
    ------- ---- ------- ------- ------ ------- ----- ------ ------- -----
    4736.77  FeI    3.21   -0.75     --      --           --      --      
    4871.32  FeI    2.87   -0.36     --      --           --      --      
    4872.14  FeI    2.88   -0.57     --      --           --      --      
    4891.49  FeI    2.85   -0.11     --      --           --      --      
    4903.31  FeI    2.88   -0.93     --      --           --      --      
    4918.99  FeI    2.87   -0.34     --      --           --      --      
     4920.5  FeI    2.83    0.07     --      --           --      --      
    4938.81  FeI    2.87   -1.08     --      --           --      --      
    4939.69  FeI    0.86   -3.34     --      --           --      --      
     4966.1  FeI    3.33   -0.89    114     4.0           94     5.5      
    4994.13  FeI    0.92   -3.08     --      --           --      --      
    5001.86  FeI    3.88    0.01     --      --           --      --      
    5006.12  FeI    2.83   -0.63    125     3.8          127     5.4      
    5041.07  FeI    0.96   -3.09     --      --           --      --      
    5041.76  FeI    1.49    -2.2     --      --           --      --      
    5049.82  FeI    2.28   -1.36     --      --           --      --      
        ...  ...     ...     ...    ...     ...   ...    ...     ...   ...
    6013.51  MnI    3.07   -0.25     --      --           --      --      
    6021.82  MnI    3.08    0.04     27     2.2           --      --      
    5483.34  CoI    1.71   -1.49     43     3.4           46     6.0      
    5476.92  NiI    1.83   -0.89    152     6.9          141    10.8      
     5105.5  CuI    1.39    -1.5     44     3.5           --      --      
    4810.54  ZnI    4.08   -0.17     54     3.3           47     5.5      
    4883.69  YII    1.08    0.07     60     2.0           72     4.3      
    4900.11  YII    1.03   -0.09     --      --           --      --      
    5087.43  YII    1.08   -0.17     46     2.8           --      --      
    5200.42  YII    0.99   -0.57     --      --           --      --      
    5853.69 BaII     0.6   -1.01     81     3.1           --      --      
    6141.73 BaII     0.7   -0.08    124     8.5          156     6.5      
    6496.91 BaII     0.6   -0.38    129     2.6          159     6.0      
    5301.97 LaII     0.4   -1.14     --      --           --      --      
    5249.59 NdII    0.98     0.2     29     2.9           32     4.5      
    5319.82 NdII    0.55   -0.14     34     2.1           40     4.7      
    6645.13 EuII    1.37    0.12     --      --           21     3.0      
    
  3. pllim commented on Jan 12, 2021

    @pllim
    Member

    I was just gonna post an updated traceback for the record. I did get a different traceback if I curl the files first to working directory. I am glad @taldcroft found a solution already!

    WARNING: UnitsWarning: '[-]' did not parse as cds unit: Invalid character at col 1
    If this is meant to be a custom unit, define it with 'u.def_unit'.
    To have it recognized inside a file reader or other code, enable it with 'u.add_enabled_units'.
    For details, see https://docs.astropy.org/en/latest/units/combining_and_defining.html [astropy.units.core]
    ---------------------------------------------------------------------------
    IndexError                                Traceback (most recent call last)
    .../astropy/io/ascii/core.py in _convert_vals(self, cols)
       1014                 try:
    -> 1015                     converter_func, converter_type = col.converters[0]
       1016                     if not issubclass(converter_type, col.type):
    
    IndexError: list index out of range
    
    During handling of the above exception, another exception occurred:
    
    ValueError                                Traceback (most recent call last)
    <ipython-input-5-092f6cbe7b14> in <module>
    ----> 1 t = r.read(filename)
    
    .../astropy/io/ascii/cds.py in read(self, table)
        325                     return table
        326         else:
    --> 327             return super().read(table)
    
    .../astropy/io/ascii/core.py in read(self, table)
       1309                                      self.include_names, self.exclude_names)
       1310 
    -> 1311         table = self.outputter(self.header.cols, self.meta)
       1312         self.cols = self.header.cols
       1313 
    
    .../astropy/io/ascii/core.py in __call__(self, cols, meta)
       1068         # Sets col.data to numpy array and col.type to io.ascii Type class (e.g.
       1069         # FloatType) for each col.
    -> 1070         self._convert_vals(cols)
       1071 
       1072         t_cols = [numpy.ma.MaskedArray(x.data, mask=x.mask)
    
    .../astropy/io/ascii/core.py in _convert_vals(self, cols)
       1031                     last_err = err
       1032                 except IndexError:
    -> 1033                     raise ValueError(f'Column {col.name} failed to convert: {last_err}')
       1034 
       1035 
    
    ValueError: Column EW1 failed to convert: invalid literal for int() with base 10: '-'
    
  4. changed the title [-]astropy.io.ascii.Cds format exception[/-] [+]astropy.io.ascii.Cds format exception (ValueError for invalid NULL)[/+] on Jan 12, 2021
  5. taldcroft commented on Jan 12, 2021

    @taldcroft
    Member

    @gilleslandais - are you OK closing this issue? I think astropy is behaving correctly by reporting that it expects integer values in that column based on the header and got a - instead.

  6. mhvk commented on Jan 14, 2021

    @mhvk
    Contributor

    @gilleslandais - the solution by @taldcroft is a good one, and it sounds like it would be nice if it were documented somewhere... Obviously, the trouble is how to both make it discoverable yet not distract too much from the flow of the more common usage. Is there a specific place in the documentation where you looked that would be a good place to put something like this?

  7. gilleslandais commented on Jan 14, 2021

    @gilleslandais
    ContributorAuthor

    There is an incoherence between our documentation and the current usage – we have to discuss about it in CDS .. and then I will get back to you..
    about the unit : []  in the ReadMe byte-by-byte means log. In the table considered, the unit is [-] which means a log value on undefined unit – the rule is briefly presented in the CDS documentation.

  8. taldcroft commented on Jan 14, 2021

    @taldcroft
    Member
  9. taldcroft commented on Jan 14, 2021

    @taldcroft
    Member

    About logarithmic units, the code should handle this a little better. AFAIK astropy units cannot deal with arbitrary log units, so the general [unit] syntax isn't going to work. But we could detect that and issue a more useful warning. We could also special-case [-] as a do-nothing unit.

  10. gilleslandais commented on Jan 14, 2021

    @gilleslandais
    ContributorAuthor

    yes - as information only !

  11. mhvk commented on Jan 14, 2021

    @mhvk
    Contributor

    We can deal with log10 units - u.dex(physical_unit) - in fact, the following works:

    In [2]: u.Unit('[cm/s2]', format='cds')
    Out[2]: Unit("dex(cm / s2)")
    

    So, it may be a question of just special-casing [-]. Should be quite easy!

  12. mhvk commented on Jan 14, 2021

    @mhvk
    Contributor

    @gilleslandais - just to be sure, a single - is not expected to occur, right? I.e., dimensionless itself would always be ---.

  13. 4 remaining items

  14. pllim commented on Jan 16, 2021

    @pllim
    Member

    Can we close this now that #11250 is merged? Thanks, everyone!

  15. mhvk commented on Jan 16, 2021

    @mhvk
    Contributor

    The main issue was about different ways in which absent data is represented. @taldcroft provided a nice work-around, but should there perhaps be a bit more flexibility in the reader about what constitutes absent data? Or at least additional documentation?

  16. taldcroft commented on Jan 16, 2021

    @taldcroft
    Member

    but should there perhaps be a bit more flexibility in the reader about what constitutes absent data

    It is entirely understandable that people might not find the existing docs, or appreciate that the generalized infrastructure applies to the CDS reader, but here you go:

    https://docs.astropy.org/en/latest/io/ascii/read.html#bad-or-missing-values

    The existing code is actually quite flexible in what constitutes absent data, to the point of leading to an API that is probably more complicated than I would write these days.

    If using - is a commonly used but undocumented quasi-standard for missing data in CDS, then it could be worth putting the workaround I suggested into the CDS reader doc string (https://docs.astropy.org/en/latest/api/astropy.io.ascii.Cds.html#astropy.io.ascii.Cds).

    BTW if the byte-by-byte indicates the column with ?=-, then it should mark those as missing (otherwise would be a bug).

  17. mhvk commented on Jan 16, 2021

    @mhvk
    Contributor

    Indeed. I just tried in ipython, Table.read.help('cds') and indeed do get information that should help.

    Possibly, one could add another "caveat" at https://docs.astropy.org/en/latest/api/astropy.io.ascii.Cds.html#astropy.io.ascii.Cds to send people in the right direction? Something along the lines of "While most tables will read fine, sometimes it may be necessary to use some of the general reader settings, such as to setcustom fill_values".

    But I'm just guessing now... @gilleslandais - was there a particular place where you tried to look for information? We always have the difficulty of trying to provide helpful information yet not making the documentation so long that the information can no longer be found! Obviously, what is to be done also depends on whether this table was effectively "buggy" by CDS standards.

    p.s. I realize I bigger thing that we should (eventually) implement is writing in CDS format - that should make things quite a bit easier for people to upload data/catalogues.

  18. gilleslandais commented on Jan 18, 2021

    @gilleslandais
    ContributorAuthor

    The CDS documention had to be rewrite, but I confirm that the URL given in astropy https://docs.astropy.org/en/latest/api/astropy.io.ascii.Cds.html#astropy.io.ascii.Cds is the current official documentation in CDS (http://vizier.u-strasbg.fr/doc/catstd.htx)

    About the option to write in CDS format - I guess you mean a serialisation from an astropy table to generate byte-by-byte+ascii aligned table ?
    We provide a Python library which do it  - see https://github.com/cds-astro/cds.pyreadme/ -
    The library was updated recently and is now provided through github . The package is based on astropy. The process to extract the format and the process to write could certainly be improved with astropy expertise :-) in particular for large tables (I am really interested if you have suggestion)

    The cdspyreadme package is dedicated for authors to submit data in VizieR (linked also in AAS documentation) – it is one of the possibility for authors (currently not the most popular) – there are others.

    Having an astropy library to build byte-by-byte is an interesting idea !

  19. taldcroft commented on Jan 18, 2021

    @taldcroft
    Member

    That's great about the CDS writer! I didn't know about that. At the very least we should include information about the writer in the astropy CDS docs. I would be very happy to discuss adapting the code to work directly within astropy, either as an optional dependency or else effectively moving the package into astropy as a subpackage of astropy.io.ascii. This could allow people to use the existing cdspyreadme interface directly or just use tbl.write(... format='ascii.cds'). This is up to you @gilleslandais. There are always pros and cons of moving a lightweight little package into a big one with a longer release cycle etc.

  20. mhvk commented on Jan 18, 2021

    @mhvk
    Contributor

    That's very good news indeed! It should help a lot to have code to either incorporate or have sanity checks against. Since it is a bit orthogonal to the issue here of having problems reading CDS tables, I opened a separate issue: #11257.

  21. gilleslandais commented on Jan 19, 2021

    @gilleslandais
    ContributorAuthor

    BTW if the byte-by-byte indicates the column with ?=-, then it should mark those as missing (otherwise would be a bug).

    It's sounds good -

    In CDS side we will clarify NULL decimal values-
    when NULL decimal values are not specified with '?=..' , only blank are accepted. Else decimal NULL values will be declared (example: ?=999 for 999 NULL values or ?=- to use the pattern --* as NULL)

  22. taldcroft commented on Jan 21, 2021

    @taldcroft
    Member

    ?=- to use the pattern --* as NULL

    Just to note that the astropy reader won't work out of the box with a regex for specifying missing values. From a standards perspective I'm happier with things being explicit and simple: ?=- means exactly - is NULL and ?=--- means --- is NULL. But if there is a legacy of files that assume that ?=- should mean --* then the CDS reader needs to find a way.

  23. taldcroft commented on Jan 21, 2021

    @taldcroft
    Member

    I had forgotten that the code does handle basically handle this case of ?=- by allowing for any of -, --, ---, or ---- as null values. See #1335.

  24. pllim commented on Aug 30, 2021

    @pllim
    Member

    Hi humans 👋 - this issue was labeled as Close? approximately 7 months ago. If you think this issue should not be closed, a maintainer should remove the Close? label - otherwise, I will close this issue in 7 days.

    If you believe I commented on this issue incorrectly, please report this here

  25. pllim commented on Aug 30, 2021

    @pllim
    Member

    Ops... Bot comment is accurate but I used the wrong API key. 😅

  26. github-actions commented on Sep 7, 2021

    @github-actions
    Contributor

    I'm going to close this issue as per my previous message, but if you feel that this issue should stay open, then feel free to re-open and remove the Close? label.

    If this is the first time I am commenting on this issue, or if you believe I closed this issue incorrectly, please report this here

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions