VERITAS-Observatory / gammapy-tools

Repository with tools for gammapy analysis
GNU General Public License v3.0
2 stars 0 forks source link

Hipparcos_MAG8_1997.dat Color version #8

Closed steob92 closed 4 months ago

steob92 commented 4 months ago

The version of Hipparcos_MAG8_1997.dat I have has issues on the color column. Can you share the version you're using

INFO:gammapy.data.data_store:Observations selected: 4 out of 4.

---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
Cell In[14], line 1
----> 1 spectral_points, spectral_model, cumulative_time, cumulative_sig = make_spectrum_RE(config)

File ~/mambaforge/envs/vtspy/lib/python3.9/site-packages/gammapy_tools/analysis/data_products.py:122, in make_spectrum_RE(config, plot)
    102         exclusion_regions.append(
    103             CircleSkyRegion(
    104                 center=SkyCoord(ra, dec, unit="deg", frame="icrs"),
    105                 radius=radius * u.deg,
    106             )
    107         )
    109 # exclude nearby HAWC sources
    110 # hawc = SourceCatalog3HWC(environ["GAMMAPY_DATA"] + "/catalogs/3HWC.ecsv")
    111 # hawc_mask = np.sqrt(
   (...)
    120 
    121 # exclude bright stars with 0.3 deg region (same as ED)
--> 122 star_data = np.loadtxt(
    123     environ["GAMMAPY_DATA"] + "/catalogs/Hipparcos_MAG8_1997.dat", usecols=(0, 1, 2, 3, 4)
    124 )
    125 star_cat = Table(
    126     {
    127         "ra": star_data[:, 0],
   (...)
    132     }
    133 )
    134 star_mask = (
    135     np.sqrt(
    136         (star_cat["ra"] - source_pos.ra.deg) ** 2
   (...)
    139     < 2.0
    140 )

File ~/mambaforge/envs/vtspy/lib/python3.9/site-packages/numpy/lib/npyio.py:1356, in loadtxt(fname, dtype, comments, delimiter, converters, skiprows, usecols, unpack, ndmin, encoding, max_rows, quotechar, like)
   1353 if isinstance(delimiter, bytes):
   1354     delimiter = delimiter.decode('latin1')
-> 1356 arr = _read(fname, dtype=dtype, comment=comment, delimiter=delimiter,
   1357             converters=converters, skiplines=skiprows, usecols=usecols,
   1358             unpack=unpack, ndmin=ndmin, encoding=encoding,
   1359             max_rows=max_rows, quote=quotechar)
   1361 return arr

File ~/mambaforge/envs/vtspy/lib/python3.9/site-packages/numpy/lib/npyio.py:999, in _read(fname, delimiter, comment, quote, imaginary_unit, usecols, skiplines, max_rows, converters, ndmin, unpack, dtype, encoding)
    996     data = _preprocess_comments(data, comments, encoding)
    998 if read_dtype_via_object_chunks is None:
--> 999     arr = _load_from_filelike(
   1000         data, delimiter=delimiter, comment=comment, quote=quote,
   1001         imaginary_unit=imaginary_unit,
   1002         usecols=usecols, skiplines=skiplines, max_rows=max_rows,
   1003         converters=converters, dtype=dtype,
   1004         encoding=encoding, filelike=filelike,
   1005         byte_converters=byte_converters)
   1007 else:
   1008     # This branch reads the file into chunks of object arrays and then
   1009     # casts them to the desired actual dtype.  This ensures correct
   1010     # string-length and datetime-unit discovery (like `arr.astype()`).
   1011     # Due to chunking, certain error reports are less clear, currently.
   1012     if filelike:

ValueError: invalid column index 4 at row 1924 with 4 columns
samanthalwong commented 4 months ago

for future reference: to generate this file, I manually removed the lines w/o colour values