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

Bug in creating Rainbow object from arrays (changes original arrays!)? #180

Open catrionamurray opened 2 years ago

catrionamurray commented 2 years ago

For some reason when I create a Rainbow object with numpy arrays the original arrays are changed and have a strange double-transit feature? Some issue with sorting perhaps? Screen Shot 2022-08-01 at 10 42 22 AM Screen Shot 2022-08-01 at 10 42 47 AM

catrionamurray commented 2 years ago

I get this issue for this file also when slicing the rainbow!

catrionamurray commented 2 years ago

Strongly suspect this is an issue with sorting: Screen Shot 2022-08-01 at 5 04 58 PM

catrionamurray commented 2 years ago

The wavelengths were in reverse order and this issue disappears if I correctly order them in the reader before importing into Rainbow

zkbt commented 2 years ago

Very weird! I think this must be something with the arrays loaded out of the h5 still referencing the same underlying arrays, which can then be modified inside the Rainbow. I'll take a look at the basic initialization from arrays method to check. In other contexts, I've had luck just multiplying every array by 1, so that the thing that gets stored internally is the result of a calculation, rather than a link to some mutable object somewhere else. I confess I still don't totally understand this perfectly, but hopefully it's a kludge that will work well enough.

zkbt commented 2 years ago

OK, I updated _initialize_from_arrays and _initialize_from_dictionaries to (hopefully?) decouple the input arrays from the internal ones. I just pushed this to develop, so pulling down the most recent might (hopefully?) fix the problem?

zkbt commented 2 years ago

@catrionamurray , when you get a chance, can you please confirm that the updates I made to this in early August actually fix the problem with Adina's hdf5 file?

catrionamurray commented 2 years ago

Hi Zach, I'm afraid I still have the same issue with v0.3.14!

zkbt commented 2 years ago

Blerg. OK. Let's try to figure this out tomorrow!