Closed brechmos-stsci closed 6 years ago
We will also have a notebook to demonstrate some of this ( @kassin and jesse )
SpectralCube
package supports basic arithmetic.
Was there an idea of an interface for this? I can think of a couple of ways of doing the gui:
an input box where one could type things like "3 * FLUX" or " FLUX + FLUX_manga". This would take some parsing of the text. But it would make it reasonably extensible.
Alternatively "we" could make it more rigid and have things like:
add/multiply by a constant:
or
operate on images of same shape:
I am not sure what people are used to or if you guys have thought this through previously?
@kassin @hcferguson @nmearl @astrofrog
I would be inclined to keep this pretty simple and then have a tutorial for how to pop up the ipython window and use python to do anything more complex. But I could be over-ruled :)
I do think that inventing a grammar for this kind of thing is a slippery slope...
I agree- let's keep things simple. A pop-uo box to so simple add, multiple, divide, exponent, and subtract would be great.
So.... not to over-rule @hcferguson but there is a package I found that might actually might make the text input idea actually reasonably simple. The package is https://newville.github.io/asteval/basics.html.
In [1]: from asteval import Interpreter
In [2]: aeval = Interpreter()
In [3]: import numpy as np
In [4]: aeval('x=sqrt(3)')
In [7]: aeval('print(x)')
1.73205080757
In [8]: aeval.symtable['x']
Out[8]: 1.7320508075688772
In [9]: aeval.symtable['y'] = 12
In [10]: aeval('print(y)')
12
In [11]: a = 3*np.ones((3,3))
In [12]: aeval.symtable['a'] = a
In [13]: aeval('print(a)')
[[ 3. 3. 3.]
[ 3. 3. 3.]
[ 3. 3. 3.]]
In [14]: b = 5*np.ones((3,3))
In [15]: aeval.symtable['b'] = b
In [16]: aeval('c = a + b')
In [17]: c = aeval.symtable['c']
In [18]: c
Out[18]:
array([[ 8., 8., 8.],
[ 8., 8., 8.],
[ 8., 8., 8.]])
So, it basically means we could have a text box and could do just about any type of calculations that numpy allows. It would just be a matter of passing the necessary data into the package and then taking it out.
I think at this point, this would be even easier than doing a whole bunch of drop-downs etc. So, unless there is a compelling reason to not do it this way, I think I will aim for this.
Oh this is neat. I'm in favor of using this. I need to remember to provide examples in the documentation.
@brechmos-stsci SpecViz uses py-expression-eval for its spectrum arithmetic, which is a simple textual input popup box that matches variables to spectrum object names.
SK +, -, *, / operations on 3D data using 1D, 2D, 3D inputs
HF We'll need to define this better. Probably makes sense to layer a 3D-spectrum class on top of NDData, defining sensible defaults for handling masks, uncertainties, WCS, and metadata propagation for the JWST IFU use cases.
We punted on a gui interface for arithmetic during the 1-d spectral viewing sprint.
Robitaille specutils data object
PL pysynphot can already do arithmetic on 1D spectra
SK mean, median, mode (over a given wavelength range or entire wavelength range) (over a given spatial region or entire spatial region)
Imported from Trello https://trello.com/c/Klv10jH4