tango-controls / pytango

This project was moved to gitlab.com
http://pytango.rtfd.io
55 stars 44 forks source link

Change x-axis for spectrum attribute #382

Closed EmCeBeh closed 2 years ago

EmCeBeh commented 4 years ago

Hi,

I created a device server with the attribute:

pressure = attribute(label="Pressure values", dtype=[float,],
                                max_dim_x = 60)

And in the read_pressure function I return an array / a spectrum

    def read_pressure(self):
        return np.random(60)

I can access the device server via e.g. Jive, which gives me a nice graph of all 60 values of that attribute. Is there a way to return x-axis values along with the pressure values?

This would be useful if the pressure values are not equidistant on the x-axis.

Second / side question: Inside Jive I can customise the axes and markers, linestyle, etc. Can I do this from the pytango server directly?

Thanks Martin :)

My Setup uses:

PyTango 9.2.5 (9, 2, 5)
PyTango compiled with:
    Python : 3.7.1
    Numpy  : 1.15.4
    Tango  : 9.2.5
    Boost  : 1.67.0
PyTango runtime is:
    Python : 3.7.3
    Numpy  : 1.16.2
    Tango  : 9.2.5
    Boost  : 0.0.0
ajoubertza commented 4 years ago

Hi @EmCeBeh

Tango spectrum attributes, like you have in your example, are strictly one dimensional arrays. If you want to store both the X and Y coordinates, you will need a 2-D array. This can be done with Tango image attributes. As the name suggests, this typically used for plotting images, so you probably won't get a 2-D scatter plot in Jive.

Here's an untested example - in this case I've used the decorator directly on the read method.

    @attribute(
        dtype=((float,),),
        max_dim_x=60,
        max_dim_y=2,
        label="Pressure values",
        doc="Pressure values 2-D data: time and pressure",
    )
    def pressure_xy(self):
        return [np.random(60), np.random(60)]

I don't know how the Jive chart customisation works. Does it persist? If it based on properties in the Tango DB, then it would be possible to set it that way. Mayb3 @JeanLucPons or another Jive expert can help us?