zkbt / chromatic

Tools for visualizing spectrosopic light curves, with flux as a function of wavelength and time.
MIT License
14 stars 4 forks source link

Although numpy is in latest version (1.25), its concatenate() is having a dtype issue #230

Closed agarciasoto18 closed 12 months ago

agarciasoto18 commented 1 year ago

Command:

rainbow.imshow()

Output Error:


TypeError                                 Traceback (most recent call last)
Cell In[15], line 1
----> 1 rainbow.imshow()

File ~/Astronomy_Python/Python_Codes_Notebook/MDM_TESS_M-dwarf_Project/Amplitude_Analysis/Scripts/Garcia+2024/CUBoulder/chromatic/chromatic/rainbows/visualizations/imshow.py:66, in imshow(self, ax, quantity, xaxis, w_unit, t_unit, colorbar, aspect, mask_ok, color_ok, alpha_ok, vmin, vmax, filename, **kw)
     64 # make sure some wavelength and time edges are defined
     65 self._make_sure_wavelength_edges_are_defined()
---> 66 self._make_sure_time_edges_are_defined()
     68 # set up the wavelength extent
     69 try:

File ~/Astronomy_Python/Python_Codes_Notebook/MDM_TESS_M-dwarf_Project/Amplitude_Analysis/Scripts/Garcia+2024/CUBoulder/chromatic/chromatic/rainbows/rainbow.py:876, in Rainbow._make_sure_time_edges_are_defined(self, redo)
    874     self.timelike["time_upper"] = np.exp(upper) * self.time.unit
    875 else:
--> 876     lower, upper = calculate_bin_leftright(self.time)
    877     self.timelike["time_lower"] = lower
    878     self.timelike["time_upper"] = upper

File ~/Astronomy_Python/Python_Codes_Notebook/MDM_TESS_M-dwarf_Project/Amplitude_Analysis/Scripts/Garcia+2024/CUBoulder/chromatic/chromatic/resampling.py:50, in calculate_bin_leftright(x)
     47 first_edge = x[0] - (inner_edges[0] - x[0])
     48 last_edge = x[-1] + (x[-1] - inner_edges[-1])
---> 50 left = np.hstack([first_edge, inner_edges])
     51 right = np.hstack([inner_edges, last_edge])
     53 return left, right

File /opt/anaconda3/envs/python310/lib/python3.10/site-packages/astropy/units/quantity.py:1683, in Quantity.__array_function__(self, function, types, args, kwargs)
   1670 # A function should be in one of the following sets or dicts:
   1671 # 1. SUBCLASS_SAFE_FUNCTIONS (set), if the numpy implementation
   1672 #    supports Quantity; we pass on to ndarray.__array_function__.
   (...)
   1680 # function is in none of the above, we simply call the numpy
   1681 # implementation.
   1682 if function in SUBCLASS_SAFE_FUNCTIONS:
-> 1683     return super().__array_function__(function, types, args, kwargs)
   1685 elif function in FUNCTION_HELPERS:
   1686     function_helper = FUNCTION_HELPERS[function]

File /opt/anaconda3/envs/python310/lib/python3.10/site-packages/numpy/core/shape_base.py:357, in hstack(tup, dtype, casting)
    355 # As a special case, dimension 0 of 1-dimensional arrays is "horizontal"
    356 if arrs and arrs[0].ndim == 1:
--> 357     return _nx.concatenate(arrs, 0, dtype=dtype, casting=casting)
    358 else:
    359     return _nx.concatenate(arrs, 1, dtype=dtype, casting=casting)

File /opt/anaconda3/envs/python310/lib/python3.10/site-packages/astropy/units/quantity.py:1688, in Quantity.__array_function__(self, function, types, args, kwargs)
   1686 function_helper = FUNCTION_HELPERS[function]
   1687 try:
-> 1688     args, kwargs, unit, out = function_helper(*args, **kwargs)
   1689 except NotImplementedError:
   1690     return self._not_implemented_or_raise(function, types)

TypeError: concatenate() got an unexpected keyword argument 'dtype'

Command:

debug

### Output: 

> /Users/aylingarcias/Astronomy_Python/Python_Codes_Notebook/MDM_TESS_M-dwarf_Project/Amplitude_Analysis/Scripts/Garcia+2024/CUBoulder/chromatic/chromatic/resampling.py(50)calculate_bin_leftright()
     48     last_edge = x[-1] + (x[-1] - inner_edges[-1])
     49 
---> 50     left = np.hstack([first_edge, inner_edges])
     51     right = np.hstack([inner_edges, last_edge])
     52 

ipdb>  print (first_edge)
3971.770792596283 Angstrom
ipdb>  print (inner_edges)
[3972.41497965 3973.05919717 3973.70347992 ... 6875.72247102 6876.44553828
 6877.16858585] Angstrom

Command for Versions:

pip list

Output:

Package                       Version
----------------------------- -----------
aiofiles                      22.1.0
aiosqlite                     0.18.0
altair                        5.0.1
anyio                         3.7.0
appdirs                       1.4.4
appnope                       0.1.3
argon2-cffi                   21.3.0
argon2-cffi-bindings          21.2.0
astropy                       5.1
asttokens                     2.2.1
async-lru                     2.0.2
attrs                         23.1.0
Babel                         2.12.1
backcall                      0.2.0
backports.functools-lru-cache 1.6.5
beautifulsoup4                4.12.2
bleach                        6.0.0
Bottleneck                    1.3.5
certifi                       2023.5.7
cffi                          1.15.1
charset-normalizer            3.1.0
comm                          0.1.3
contourpy                     1.0.5
cycler                        0.11.0
debugpy                       1.6.7
decorator                     5.1.1
defusedxml                    0.7.1
entrypoints                   0.4
exceptiongroup                1.1.1
executing                     1.2.0
fastjsonschema                2.17.1
flit_core                     3.9.0
fonttools                     4.25.0
h5py                          3.7.0
idna                          3.4
importlib-metadata            6.7.0
importlib-resources           5.12.0
ipykernel                     6.23.3
ipython                       8.14.0
ipython-genutils              0.2.0
ipywidgets                    8.0.4
jedi                          0.18.2
Jinja2                        3.1.2
json5                         0.9.5
jsonschema                    4.17.3
jupyter_client                8.3.0
jupyter_core                  5.3.1
jupyter-events                0.6.3
jupyter-lsp                   2.2.0
jupyter_server                2.5.0
jupyter_server_fileid         0.9.0
jupyter_server_terminals      0.4.4
jupyter_server_ydoc           0.8.0
jupyter-ydoc                  0.2.4
jupyterlab                    3.6.3
jupyterlab-pygments           0.2.2
jupyterlab_server             2.23.0
jupyterlab-widgets            3.0.5
kiwisolver                    1.4.4
lxml                          4.9.2
MarkupSafe                    2.1.3
matplotlib                    3.7.1
matplotlib-inline             0.1.6
mistune                       0.8.4
mkl-fft                       1.3.6
mkl-random                    1.2.2
mkl-service                   2.4.0
munkres                       1.1.4
nbclassic                     0.5.5
nbclient                      0.8.0
nbconvert                     6.5.4
nbformat                      5.9.0
nest-asyncio                  1.5.6
notebook                      6.5.4
notebook_shim                 0.2.3
numexpr                       2.8.4
numpy                         1.25.0
overrides                     7.3.1
packaging                     23.0
pandas                        1.5.3
pandocfilters                 1.5.0
parso                         0.8.3
pexpect                       4.8.0
pickleshare                   0.7.5
Pillow                        9.4.0
pip                           23.1.2
pkgutil_resolve_name          1.3.10
platformdirs                  3.8.0
pooch                         1.4.0
prometheus-client             0.17.0
prompt-toolkit                3.0.38
psutil                        5.9.5
ptyprocess                    0.7.0
pure-eval                     0.2.2
pycparser                     2.21
pyerfa                        2.0.0
Pygments                      2.15.1
pyobjc-core                   9.2
pyobjc-framework-Cocoa        9.2
pyparsing                     3.0.9
pyrsistent                    0.19.3
PySocks                       1.7.1
python-dateutil               2.8.2
python-json-logger            2.0.7
pytz                          2022.7
PyYAML                        6.0
pyzmq                         25.1.0
requests                      2.31.0
rfc3339-validator             0.1.4
rfc3986-validator             0.1.1
scipy                         1.10.1
Send2Trash                    1.8.2
setuptools                    67.8.0
six                           1.16.0
sniffio                       1.3.0
soupsieve                     2.3.2.post1
stack-data                    0.6.2
terminado                     0.17.1
tinycss2                      1.2.1
tomli                         2.0.1
toolz                         0.12.0
tornado                       6.3.2
tqdm                          4.65.0
traitlets                     5.9.0
typing_extensions             4.7.0
typing-utils                  0.1.0
urllib3                       2.0.3
wcwidth                       0.2.6
webencodings                  0.5.1
websocket-client              1.6.1
wheel                         0.38.4
widgetsnbextension            4.0.5
xarray                        2022.11.0
y-py                          0.5.9
ypy-websocket                 0.8.2
zipp                          3.15.0
zkbt commented 12 months ago

Sorry for the absurdly long delay on this one @agarciasoto18 and @gmduvvuri, but I think this should hopefully now be fixed in the latest version 0.4.10. I couldn't fully reproduce the error on my own, but I got something similar and seemed to find that it depended on which matplotlib backend was being used. I'd love if one of you could please pull down the latest in the develop branch and see if it fixed things? Thanks!