hughesadam87 / scikit-spectra

Python pandas-based toolkit for explorative spectroscopy, in particular UVVis spectroscopic data.
Other
94 stars 41 forks source link

area/series _transfer limitation #105

Closed hughesadam87 closed 10 years ago

hughesadam87 commented 10 years ago

Wavelength slices and boxcar both use transfer. I think pvutils should be modified to return obj.__class() instead of DataFrame and problem will be solved.

For wavelength slices, a new object must be generated using _transfer. Messing with this, I've determined _transfer is necessary because it converts all the important attributes etc...

However, transfer is returning a TimeSpectra. TimeSpectra is supposed to have strict index, strict columns, but these are ignored. Thus, since the index is "u[430.1:680]", index.full_specunit fails. This failure is because _transfer construction doesn't use _strict_index. I tried putting _strict_index in _cnsvd_attr and got an error. In any case, it's not even important for this use case to be strict, but repr_html will not print this out correctly. There's nothing wrong with area, just that it it doesn't have the correct column type to have full_specunit.

A couple solutions come to mind:

  1. Alter repr_html to accept attribute error and return "unkown or something"
  2. Create a new class to store this type of data? It would return full_specunit() as 'unkown' or index[0](ie [430.1:680]).
  3. Do something with units?
  4. Create a series spectra??
  5. Return the pure series/numpy array without _transfer. Areaplot() works, so plotting is not an issue. Then can't do area.plot() but that's not very useful. At least it works if you do this: area = ts.area().values plt.plot(area.transpose())

    area

Area is technically not a timespectra, so shouldn't hack this to make it quack like a timespectra. But the area should carry through... hmm maybe just resorting to our custom plots is the best approach afterall, at least until a suitable new object can be created.

hughesadam87 commented 10 years ago

Printout issue actually is for any series. Same with slicing:

see related #101

hughesadam87 commented 10 years ago

If I do end up making a Series class, would area.plot() now work correctly, or still need transpose()?

hughesadam87 commented 10 years ago

Created Spectrum and MetaSeries