skyportal / gwemopt

Gravitational-wave Electromagnetic Optimization
GNU General Public License v3.0
19 stars 34 forks source link

Catalog is 2MRS got error #145

Closed parkma99 closed 1 year ago

parkma99 commented 1 year ago

When I run command python -m gwemopt --event S230609u --catalog 2MRS, I got error , message is below:

Found voevent S230609u-5-Update.xml
Latest skymap URL: https://gracedb.ligo.org/api/superevents/S230609u/files/Bilby.multiorder.fits,0
File /home/ma/Data/gwemopt/skymaps/S230609u_5_Bilby.multiorder.fits,0 already exists. Using this.
natural_nside = 256
nside = 256
Output directory: /home/ma/Data/gwemopt/S230609u_5_Bilby.multiorder/ATLAS
Loading skymap...
Generating catalog...
Traceback (most recent call last):
  File "<frozen runpy>", line 198, in _run_module_as_main
  File "<frozen runpy>", line 88, in _run_code
  File "/home/ma/code/gwemopt/gwemopt/__main__.py", line 55, in <module>
    run(sys.argv[1:])
  File "/home/ma/code/gwemopt/gwemopt/run.py", line 59, in run
    map_struct, catalog_struct = get_catalog(params, map_struct)
                                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/ma/code/gwemopt/gwemopt/catalogs/get.py", line 46, in get_catalog
    cat_df = cat.get_catalog()
             ^^^^^^^^^^^^^^^^^
  File "/home/ma/code/gwemopt/gwemopt/catalogs/base_catalog.py", line 35, in get_catalog
    self.download_catalog()
  File "/home/ma/code/gwemopt/gwemopt/catalogs/twomrs.py", line 18, in download_catalog
    cat["z"] = (u.Quantity(cat["cz"]) / c.c).to(u.dimensionless_unscaled)
                           ~~~^^^^^^
  File "/home/ma/miniconda3/envs/gwemopt/lib/python3.11/site-packages/astroquery/utils/commons.py", line 253, in __getitem__
    raise TypeError("TableLists can only be indexed with the "
TypeError: TableLists can only be indexed with the named keys and integers.
parkma99 commented 1 year ago

I try fix by changing L16 to cat = Vizier.get_catalogs("J/ApJS/199/26/table3")[0].

Then got error message:

Found voevent S230609u-5-Update.xml
Latest skymap URL: https://gracedb.ligo.org/api/superevents/S230609u/files/Bilby.multiorder.fits,0
File /home/ma/Data/gwemopt/skymaps/S230609u_5_Bilby.multiorder.fits,0 already exists. Using this.
natural_nside = 256
nside = 256
Output directory: /home/ma/Data/gwemopt/S230609u_5_Bilby.multiorder/ATLAS
Loading skymap...
Generating catalog...
Traceback (most recent call last):
  File "/home/ma/miniconda3/envs/gwemopt/lib/python3.11/site-packages/pandas/core/indexes/base.py", line 3652, in get_loc
    return self._engine.get_loc(casted_key)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "pandas/_libs/index.pyx", line 147, in pandas._libs.index.IndexEngine.get_loc
  File "pandas/_libs/index.pyx", line 176, in pandas._libs.index.IndexEngine.get_loc
  File "pandas/_libs/hashtable_class_helper.pxi", line 7080, in pandas._libs.hashtable.PyObjectHashTable.get_item
  File "pandas/_libs/hashtable_class_helper.pxi", line 7088, in pandas._libs.hashtable.PyObjectHashTable.get_item
KeyError: 'magb'

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "<frozen runpy>", line 198, in _run_module_as_main
  File "<frozen runpy>", line 88, in _run_code
  File "/home/ma/code/gwemopt/gwemopt/__main__.py", line 55, in <module>
    run(sys.argv[1:])
  File "/home/ma/code/gwemopt/gwemopt/run.py", line 59, in run
    map_struct, catalog_struct = get_catalog(params, map_struct)
                                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/ma/code/gwemopt/gwemopt/catalogs/get.py", line 46, in get_catalog
    cat_df = cat.get_catalog()
             ^^^^^^^^^^^^^^^^^
  File "/home/ma/code/gwemopt/gwemopt/catalogs/base_catalog.py", line 38, in get_catalog
    return self.load_catalog()
           ^^^^^^^^^^^^^^^^^^^
  File "/home/ma/code/gwemopt/gwemopt/catalogs/twomrs.py", line 46, in load_catalog
    df["mag"] = df["magb"] * 1.0
                ~~^^^^^^^^
  File "/home/ma/miniconda3/envs/gwemopt/lib/python3.11/site-packages/pandas/core/frame.py", line 3761, in __getitem__
    indexer = self.columns.get_loc(key)
              ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/ma/miniconda3/envs/gwemopt/lib/python3.11/site-packages/pandas/core/indexes/base.py", line 3654, in get_loc
    raise KeyError(key) from err
KeyError: 'magb'

I think it's because L29.

mcoughlin commented 1 year ago

@parkma99 Please try again. Feel free to reopen if you run into the same issue.