[Kst] branches/work/kst/portto4/kst/pyKst
Barth Netterfield
netterfield at astro.utoronto.ca
Tue Dec 11 05:08:09 UTC 2012
SVN commit 1328064 by netterfield:
Add some filters to scripting.
M +3 -0 demo/dataobjects.py
M +194 -0 pykst.py
--- branches/work/kst/portto4/kst/pyKst/demo/dataobjects.py #1328063:1328064
@@ -16,6 +16,9 @@
dataVectorGY1=kst.DataVector(client,"/data/blast2003",field="GYRO1",changeDetection=False,timeInterval=True,dontUpdate=False,start=0,drange=1000)
GYCurve=kst.NewCurve(client,dataVectorIndex, dataVectorGY1, curvecolor="blue", curveweight=1, placeinexistingplot=P1)
+Filter = kst.NewBandStopFilter(client, dataVectorGY1, 4, 0.05, 0.01)
+FiltCurve = kst.NewCurve(client,dataVectorIndex, Filter.Y(), curvecolor="red", curveweight=1, placeinexistingplot=P1)
+
GYEquation=kst.NewEquation(client, "x^2", dataVectorIndex)
GYEqCurve = kst.NewCurve(client,GYEquation.X(), GYEquation.Y(), curvecolor="black", curveweight=1, placeinexistingplot=P2)
--- branches/work/kst/portto4/kst/pyKst/pykst.py #1328063:1328064
@@ -1123,6 +1123,200 @@
ExponentialFit.__init__(self,client)
self.handle=handle
+# FILTER ###################################################################
+class Filter(NamedObject) :
+ """ This is a class which provides some methods common to all filters """
+ def __init__(self,client) :
+ NamedObject.__init__(self,client)
+
+ def Y(self) :
+ """ a vector containing the filtered output """
+ YHandle = QtCore.QString(self.client.send("DataObject::outputVectorHandle("+self.handle+", Y Vector)"))
+ return ExistingVector(self.client, YHandle)
+
+
+# LOW PASS FILTER #################################################################
+class LowPassFilter(Filter) :
+ """ This is a class which some convenience classes within pykst use. You should not use it directly.
+
+ TODO: edit functions..."""
+ def __init__(self,client) :
+ NamedObject.__init__(self,client)
+
+class NewLowPassFilter(LowPassFilter) :
+ """ This class represents a filter you would create via "Create>Filter Plugin->Low Pass Filter" from the menubar inside kst or by using
+ "rmb->filter->[curvename], and then selecting "Low Pas Filter" in the plugin combo. The parameters of this function mirror the parameters within
+ the latter dialog."""
+
+ def __init__(self,client,yvector,order_in, cutoff_in,name="") :
+ LowPassFilter.__init__(self,client)
+
+ if isinstance(order_in, Scalar):
+ order = order_in
+ else :
+ order = GeneratedScalar(client, order_in);
+
+ if isinstance(cutoff_in, Scalar):
+ cutoff = cutoff_in
+ else :
+ cutoff = GeneratedScalar(client, cutoff_in);
+
+ QtCore.QString(self.client.send("newPlugin(Low Pass Filter)"))
+ QtCore.QString(self.client.send("setInputVector(Y Vector,"+yvector.handle+")"))
+ QtCore.QString(self.client.send("setInputScalar(Order Scalar,"+order.handle+")"))
+ QtCore.QString(self.client.send("setInputScalar(Cutoff / Spacing Scalar,"+cutoff.handle+")"))
+
+ self.handle=QtCore.QString(self.client.send("endEdit()"))
+ self.handle.remove(0,self.handle.indexOf("ing ")+4)
+
+class ExistingLowPassFilter(LowPassFilter) :
+ """ This class allows access to an Linear Fit created inside kst or through a script given a descriptive or short name.
+
+ handle is a descriptive or short name of a Linear Fit created inside kst or through a script. """
+ def __init__(self,client,handle) :
+ LowPassFilter.__init__(self,client)
+ self.handle=handle
+
+# HIGH PASS FILTER #################################################################
+class HighPassFilter(Filter) :
+ """ This is a class which some convenience classes within pykst use. You should not use it directly.
+
+ TODO: edit functions..."""
+ def __init__(self,client) :
+ NamedObject.__init__(self,client)
+
+class NewHighPassFilter(HighPassFilter) :
+ """ This class represents a filter you would create via "Create>Filter Plugin->High Pass Filter" from the menubar inside kst or by using
+ "rmb->filter->[curvename], and then selecting "High Pas Filter" in the plugin combo. The parameters of this function mirror the parameters within
+ the latter dialog."""
+
+ def __init__(self,client,yvector,order_in, cutoff_in,name="") :
+ HighPassFilter.__init__(self,client)
+
+ if isinstance(order_in, Scalar):
+ order = order_in
+ else :
+ order = GeneratedScalar(client, order_in);
+
+ if isinstance(cutoff_in, Scalar):
+ cutoff = cutoff_in
+ else :
+ cutoff = GeneratedScalar(client, cutoff_in);
+
+ QtCore.QString(self.client.send("newPlugin(High Pass Filter)"))
+ QtCore.QString(self.client.send("setInputVector(Y Vector,"+yvector.handle+")"))
+ QtCore.QString(self.client.send("setInputScalar(Order Scalar,"+order.handle+")"))
+ QtCore.QString(self.client.send("setInputScalar(Cutoff / Spacing Scalar,"+cutoff.handle+")"))
+
+ self.handle=QtCore.QString(self.client.send("endEdit()"))
+ self.handle.remove(0,self.handle.indexOf("ing ")+4)
+
+class ExistingHighPassFilter(HighPassFilter) :
+ """ This class allows access to an Linear Fit created inside kst or through a script given a descriptive or short name.
+
+ handle is a descriptive or short name of a Linear Fit created inside kst or through a script. """
+ def __init__(self,client,handle) :
+ HighPassFilter.__init__(self,client)
+ self.handle=handle
+
+# BAND PASS FILTER #################################################################
+class BandPassFilter(Filter) :
+ """ This is a class which some convenience classes within pykst use. You should not use it directly.
+
+ TODO: edit functions..."""
+ def __init__(self,client) :
+ NamedObject.__init__(self,client)
+
+class NewBandPassFilter(BandPassFilter) :
+ """ This class represents a filter you would create via "Create>Filter Plugin->Band Pass Filter" from the menubar inside kst or by using
+ "rmb->filter->[curvename], and then selecting "Band Pas Filter" in the plugin combo. The parameters of this function mirror the parameters within
+ the latter dialog."""
+
+ def __init__(self,client,yvector,order_in, central_in, bandwidth_in,name="") :
+ BandPassFilter.__init__(self,client)
+
+ if isinstance(order_in, Scalar):
+ order = order_in
+ else :
+ order = GeneratedScalar(client, order_in);
+
+ if isinstance(central_in, Scalar):
+ central = central_in
+ else :
+ central = GeneratedScalar(client, central_in);
+
+ if isinstance(bandwidth_in, Scalar):
+ bandwidth = bandwidth_in
+ else :
+ bandwidth = GeneratedScalar(client, bandwidth_in);
+
+ QtCore.QString(self.client.send("newPlugin(Band Pass Filter)"))
+ QtCore.QString(self.client.send("setInputVector(Y Vector,"+yvector.handle+")"))
+ QtCore.QString(self.client.send("setInputScalar(Order Scalar,"+order.handle+")"))
+ QtCore.QString(self.client.send("setInputScalar(Central Frequency / Sample Rate Scalar,"+central.handle+")"))
+ QtCore.QString(self.client.send("setInputScalar(Band width Scalar,"+bandwidth.handle+")"))
+
+ self.handle=QtCore.QString(self.client.send("endEdit()"))
+ self.handle.remove(0,self.handle.indexOf("ing ")+4)
+
+class ExistingBandPassFilter(BandPassFilter) :
+ """ This class allows access to an Linear Fit created inside kst or through a script given a descriptive or short name.
+
+ handle is a descriptive or short name of a Linear Fit created inside kst or through a script. """
+ def __init__(self,client,handle) :
+ BandPassFilter.__init__(self,client)
+ self.handle=handle
+
+# BAND STOP FILTER #################################################################
+class BandStopFilter(Filter) :
+ """ This is a class which some convenience classes within pykst use. You should not use it directly.
+
+ TODO: edit functions..."""
+ def __init__(self,client) :
+ NamedObject.__init__(self,client)
+
+class NewBandStopFilter(BandStopFilter) :
+ """ This class represents a filter you would create via "Create>Filter Plugin->Band Stop Filter" from the menubar inside kst or by using
+ "rmb->filter->[curvename], and then selecting "Band Pas Filter" in the plugin combo. The parameters of this function mirror the parameters within
+ the latter dialog."""
+
+ def __init__(self,client,yvector,order_in, central_in, bandwidth_in,name="") :
+ BandStopFilter.__init__(self,client)
+
+ if isinstance(order_in, Scalar):
+ order = order_in
+ else :
+ order = GeneratedScalar(client, order_in);
+
+ if isinstance(central_in, Scalar):
+ central = central_in
+ else :
+ central = GeneratedScalar(client, central_in);
+
+ if isinstance(bandwidth_in, Scalar):
+ bandwidth = bandwidth_in
+ else :
+ bandwidth = GeneratedScalar(client, bandwidth_in);
+
+ QtCore.QString(self.client.send("newPlugin(Band Stop Filter)"))
+ QtCore.QString(self.client.send("setInputVector(Y Vector,"+yvector.handle+")"))
+ QtCore.QString(self.client.send("setInputScalar(Order Scalar,"+order.handle+")"))
+ QtCore.QString(self.client.send("setInputScalar(Central Frequency / Sample Rate Scalar,"+central.handle+")"))
+ QtCore.QString(self.client.send("setInputScalar(Band width Scalar,"+bandwidth.handle+")"))
+
+ self.handle=QtCore.QString(self.client.send("endEdit()"))
+ self.handle.remove(0,self.handle.indexOf("ing ")+4)
+
+class ExistingBandStopFilter(BandStopFilter) :
+ """ This class allows access to an Linear Fit created inside kst or through a script given a descriptive or short name.
+
+ handle is a descriptive or short name of a Linear Fit created inside kst or through a script. """
+ def __init__(self,client,handle) :
+ BandStopFilter.__init__(self,client)
+ self.handle=handle
+
+# IMAGE #################################################################
+
class Image(NamedObject) :
""" This is a class which some convenience classes within pykst use. You should not use it directly.
More information about the Kst
mailing list