riogroup / SORA

MIT License
15 stars 12 forks source link

Getting Started example fails to create Body object #88

Closed ellequelle closed 1 year ago

ellequelle commented 1 year ago

Running the "Getting Started" example produces the following output:

In [2]: chariklo = Body(name="Chariklo", ephem=['guidelines/input/bsp/Chariklo.
    ...: bsp', 'guidelines/input/bsp/de438_small.bsp'])
Obtaining data for Chariklo from SBDB
---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
Cell In[12], line 1
----> 1 chariklo = Body(name="Chariklo", ephem=['guidelines/input/bsp/Chariklo.bsp', 'guidelines/input/bsp/de438_small.bsp'])

File ~/miniconda3/envs/occultation/lib/python3.12/site-packages/sora/body/core.py:126, in Body.__init__(self, name, database, **kwargs)
    124 if database in ['auto', 'sbdb']:
    125     try:
--> 126         self.__from_sbdb(name=name)
    127     except ValueError:
    128         pass

File ~/miniconda3/envs/occultation/lib/python3.12/site-packages/sora/body/core.py:177, in Body.__from_sbdb(self, name)
    175 self.H = PhysicalData('Absolute Magnitude', pp.get('H'), pp.get('H_sig'), pp.get('H_ref'), pp.get('H_note'), unit=u.mag)
    176 self.G = PhysicalData('Phase Slope', pp.get('G'), pp.get('G_sig'), pp.get('G_ref'), pp.get('G_note'))
--> 177 self.diameter = PhysicalData('Diameter', pp.get('diameter'), pp.get('diameter_sig'), pp.get('diameter_ref'),
    178                              pp.get('diameter_note'), unit=u.km)
    179 self.density = PhysicalData('Density', pp.get('density'), pp.get('density_sig'), pp.get('density_ref'),
    180                             pp.get('density_note'), unit=u.g/u.cm**3)
    181 self.GM = PhysicalData('Standard Gravitational Parameter', pp.get('GM'), pp.get('GM_sig'), pp.get('GM_ref'),
    182                        pp.get('GM_note'), unit=u.km**3/u.s**2)

File ~/miniconda3/envs/occultation/lib/python3.12/site-packages/sora/body/meta.py:208, in BaseBody.diameter(self, value)
    206 self._diameter = diameter
    207 if not getattr(self, '_shape', None) and not np.isnan(self._diameter):
--> 208     self.shape = self._diameter.value/2
    209 self._shared_with['ephem']['radius'] = self.radius

File ~/miniconda3/envs/occultation/lib/python3.12/site-packages/sora/body/meta.py:400, in BaseBody.shape(self, value)
    398     self._shape = Shape3D(value)
    399 else:
--> 400     value = np.array(value, ndmin=1, dtype=np.float)
    401     if len(value) <= 3:
    402         self._shape = Ellipsoid(*value)

File ~/miniconda3/envs/occultation/lib/python3.12/site-packages/numpy/__init__.py:324, in __getattr__(attr)
    319     warnings.warn(
    320         f"In the future `np.{attr}` will be defined as the "
    321         "corresponding NumPy scalar.", FutureWarning, stacklevel=2)
    323 if attr in __former_attrs__:
--> 324     raise AttributeError(__former_attrs__[attr])
    326 if attr == 'testing':
    327     import numpy.testing as testing

AttributeError: module 'numpy' has no attribute 'float'.
`np.float` was a deprecated alias for the builtin `float`. To avoid this error in existing code, use `float` by itself. Doing this will not modify any behavior and is safe. If you specifically wanted the numpy scalar type, use `np.float64` here.
The aliases was originally deprecated in NumPy 1.20; for more details and guidance see the original release note at:
    https://numpy.org/devdocs/release/1.20.0-notes.html#deprecations

Versions:

astropy                       5.3.4
astroquery                    0.4.6
matplotlib                    3.8.0
numpy                         1.26.0
pyerfa                        2.0.1.1
requests                      2.31.0
scipy                         1.11.3
shapely                       2.0.2
spiceypy                      6.0.0
tqdm                          4.66.1
altairgomes commented 1 year ago

Dear Elle

Thank you for your report. Our develop branch already has a fix for this issue. Feel free to test it.

Version 0.3.1 with this and other fixes should be published soon.

Thanks