BDNYC / sedkit

Spectral energy distribution construction and analysis tools
https://sedkit.readthedocs.io/
BSD 3-Clause "New" or "Revised" License
18 stars 13 forks source link

Occasional `ValueError` in `find_photometry` method #53

Closed hover2pi closed 3 years ago

hover2pi commented 4 years ago

Once in a while I run the find_photometry method and I get thisValueError:

---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
~/miniconda3/envs/awesimsoss/lib/python3.6/site-packages/astropy/table/table.py in insert_row(self, index, vals, mask)
   2765 
-> 2766                 newcol = col.insert(index, val, axis=0)
   2767 

~/miniconda3/envs/awesimsoss/lib/python3.6/site-packages/astropy/units/quantity.py in insert(self, obj, values, axis)
   1691         """
-> 1692         out_array = np.insert(self.value, obj, self._to_own_unit(values), axis)
   1693         return self._new_view(out_array)

~/miniconda3/envs/awesimsoss/lib/python3.6/site-packages/astropy/units/quantity.py in _to_own_unit(self, value, check_precision)
   1366                                             np.isnan(_value))):
-> 1367                     raise TypeError("cannot convert value type to array type "
   1368                                     "without precision loss")

TypeError: cannot convert value type to array type without precision loss

During handling of the above exception, another exception occurred:

ValueError                                Traceback (most recent call last)
<ipython-input-2-a6263c9e3703> in <module>
      2 target = 'G199-28' # or 'LTT 3908'
      3 s = SED(target)
----> 4 s.find_2MASS()
      5 s.find_WISE()
      6 s.plot()

~/Documents/Modules/sedkit/sedkit/sed.py in find_2MASS(self, **kwargs)
    956                              ['Jmag', 'Hmag', 'Kmag'],
    957                              ['2MASS.J', '2MASS.H', '2MASS.Ks'],
--> 958                              **kwargs)
    959 
    960     def find_Gaia(self, search_radius=None, catalog='I/345/gaia2', idx=0):

~/Documents/Modules/sedkit/sedkit/sed.py in find_photometry(self, name, catalog, band_names, target_names, search_radius, idx, **kwargs)
   1079                     mag, unc = list(rec[[viz, 'e_' + viz]])
   1080                     mag, unc = round(float(mag), 3), round(float(unc), 3)
-> 1081                     self.add_photometry(band, mag, unc, ref=ref)
   1082                 except IOError:
   1083                     pass

~/Documents/Modules/sedkit/sedkit/sed.py in add_photometry(self, band, mag, mag_unc, **kwargs)
    303 
    304         # Add it to the table
--> 305         self._photometry.add_row(new_photometry)
    306 
    307         # Set SED as uncalculated

~/miniconda3/envs/awesimsoss/lib/python3.6/site-packages/astropy/table/table.py in add_row(self, vals, mask)
   2656              3   6   9
   2657         """
-> 2658         self.insert_row(len(self), vals, mask)
   2659 
   2660     def insert_row(self, index, vals=None, mask=None):

~/miniconda3/envs/awesimsoss/lib/python3.6/site-packages/astropy/table/table.py in insert_row(self, index, vals, mask)
   2788         except Exception as err:
   2789             raise ValueError("Unable to insert row because of exception in column '{}':\n{}"
-> 2790                              .format(name, err))
   2791         else:
   2792             self._replace_cols(columns)

ValueError: Unable to insert row because of exception in column 'eff':
cannot convert value type to array type without precision loss
hover2pi commented 3 years ago

Having trouble reproducing this error with v1.0.8! I'm going to close this issue for now as resolved and see if the problem crops up again.