Subject: Script for setting contour levels
From: Tom Goddard
Date: May 12, 2010

Previous: 707 Next: 709


The script described in this message posted earlier was not archived on
the Sparky Yahoo group. Here is the sparky_init.py script.


def initialize_session(session):

def set_contour_levels():

p = session.project

from sparky import Contour_Levels

plev = Contour_Levels()
plev.lowest = 1000
plev.factor = 1.2
plev.levels = 5
plev.color = red

nlev = Contour_Levels()
nlev.lowest = -1000
nlev.factor = 1.2
nlev.levels = 5
nlev.color = green

for v in p.view_list():
v.positive_levels = plev
v.negative_levels = nlev

session.add_command(kl, Set all contour levels, set_contour_levels)




Hi Marco,

You can add a shortcut and menu entry for setting all contour
levels using the attached Python code that you put in the Sparky
start-up file:

~/Sparky/Python/sparky_init.py

This will add a shortcut kl that sets the contour levels of all open
spectrum windows. The actual contour level is hard-coded in the
sparky_init.py file. If you wanted to be able to type the number into a
dialog that would take some more work to code the dialog in Python. It
is not too hard if you want me to show you.

Tom


Hi Tom,


I have a little question about sparky. Is there a way to make
an extension that lets you adjust the contour levels for multiple
spectra at the same time ? I need to open a bunch of 2D planes and I
would like to set the contour levels the same for all of them, but
doing it one at the time by hand takes a lot of time. I tried looking
at other extensions and the classes available, but I dont see anything.

Thanks a lot,

Marco