Warning, /graphics/kst-plot/docbook/kst/data-chapter.docbook is written in an unsupported language. File is not indexed.
0001 <chapter id="workingwithdata">
0002 <title>Working With Data</title>
0003
0004 <sect1 id="datasources">
0005 <title>Data Sources</title>
0006
0007 <sect2 id="DataSourceConcepts">
0008 <title>Data Source Concepts</title>
0009 <para>
0010 A data source in &kst; is simply a supported data file.
0011 Currently, Kst supports ASCII text files,
0012 <ulink url="http://getdata.sourceforge.net/">dirfiles</ulink>, and
0013 <ulink url="http://www.unidata.ucar.edu/software/netcdf/">NetCDF</ulink>,
0014 for vectors and scalars, and FITS images, BIT image streams,
0015 16 bit TIFF images, and any image format supported by
0016 <ulink url="http://doc.qt.io/qt-5/qimage.html">QImage</ulink>,
0017 (jpg, png, bmp, etc) for images.
0018 </para>
0019 <para>
0020
0021 The following concepts are important in understanding how &kst; works with
0022 different data sources.
0023 Some terminology is also introduced in this section.
0024 </para>
0025
0026 <sect3 id="DefineFields">
0027 <title>Fields</title>
0028 <para>
0029 Data in &kst; are accessed by field names. A field name can refer to a single scalar or string, to a vector of values from a single sensor,
0030 or to a matrix. For example, a column in an ASCII data file can be read in
0031 as a vector. An image in a png file can be read in as a matrix.
0032 Datasource readers provide functions for reading and obtaining fields and
0033 field names.
0034 </para>
0035 </sect3>
0036
0037 <sect3 id="Frames">
0038 <title>Frames</title>
0039 <para>
0040 When reading in a vector from a data source field, data are addressed by their Frame number, not by their sample number. Each field in a data source has its own fixed number of samples per frame.
0041 </para>
0042 <para>
0043 For some data sources (eg, ASCII files) every frame contains exactly one sample (ie, for ASCII files, a frame is a valid row of data, and every row has exactly one sample for each field).
0044 </para>
0045 <para>
0046 However, for other data sources (eg, dirfiles), there may be multiple samples per frame. In the illustration below, the first 3 frames of an imaginary dirfile are shown. In this particular data file, Field1 has a 1 sample per frame, Field2 has 4 samples per frame, and Field3 has 2 samples per frame. Every field must have a constant number of samples per frame throughout the file.
0047 </para>
0048 <para>
0049 <inlinemediaobject>
0050 <imageobject>
0051 <imagedata fileref="Diagram-kst-frames.png" format="PNG"/>
0052 </imageobject>
0053 </inlinemediaobject>
0054 </para>
0055
0056 <para>
0057 In the figure, imagine that time proceeds from top to bottom. &kst; assumes that the first sample in a frame is simultaneous for every field in the data source, and that the rest of the samples are sampled evenly throughout the frame, as shown.
0058 </para>
0059 <para>
0060 When plotting one vector against another, &kst; assumes that the first and last samples of each vector are simultaneous, and interpolates the shorter vector up to the resolution of the longer vector. Since only the first sample in a frame can be assumed to be simultaneous across fields, <emphasis>when &kst; reads data into a vector, it only reads up to the first sample of the last frame requested,</emphasis> so that plotting one vector against another will make sense. The rest of the last frame will not be read.
0061 </para>
0062 <para>
0063 So if the first three frames of Field1 and Field2 are read from the data source in the figure, 3 samples will be read from Field1, and 9 samples will be read from Field2 (ending at first sample of Frame 3) - not 12 as one might expect.
0064 </para>
0065 </sect3>
0066
0067 <sect3 id="supportingadditionalfileformatsdatasourceconceptsindex">
0068 <title>INDEX Field</title>
0069 <para>
0070 As well as the explicit data fields in a data file, &kst; implicitly creates an INDEX field for all data sources. The INDEX field is 1 sample per frame, and simply contains integers from 0 to N-1, where N is the number of frames in the data file. It is common to plot vectors against INDEX. This is convenient since the INDEX of a sample or event is just the frame number, allowing easy identification and retrieval of events from a data file.
0071 </para>
0072 </sect3>
0073
0074 </sect2>
0075
0076 <sect2 id="creatingascii">
0077 <title>ASCII Input Files</title>
0078 <para>
0079 &kst; is capable of reading vectors from a wide range of ASCII formats. As long as the data are in columns, and as long as each non-comment row has the same number of columns, &kst; can probably read it.
0080 </para>
0081 <para>
0082 Consider reading this simple ASCII csv file: each comma separated column represents a field.
0083 </para>
0084
0085 <informalexample>
0086 <screen>
0087 Length,Width
0088 m,m
0089 1.1,6.2
0090 2.4,9.3
0091 4.3,4.7
0092 5.2,8.8
0093 </screen>
0094 </informalexample>
0095
0096
0097 <para>
0098 When you enter an ascii source into a data source selection widget (such as on the first page of the data wizard) the file will be identified as an ASCII file, and the <guibutton>Configure</guibutton> button will be enabled, as shown below.
0099 </para>
0100
0101
0102 <para>
0103 <inlinemediaobject>
0104 <imageobject>
0105 <imagedata fileref="Screenshot-kst-datasource-selector.png" format="PNG"/>
0106 </imageobject>
0107 </inlinemediaobject>
0108 </para>
0109
0110 <para>
0111 Clicking on <guibutton>Configure</guibutton> will bring up the ASCII data source configuration dialog.
0112 </para>
0113
0114 <para>
0115 <inlinemediaobject>
0116 <imageobject>
0117 <imagedata fileref="Screenshot-kst-ascii-config.png" format="PNG"/>
0118 </imageobject>
0119 </inlinemediaobject>
0120 </para>
0121
0122 <para>
0123 Note that the first few lines of the file are shown. The dialog in the screen shot has been filled out to read this file: looking at the first lines of the file, we see that data starts at line 3, line 1 holds the field names, and line 2 holds the units (which will be used by &kst; in plot labels). Additionally, as this is a csv file, a "<literal>,</literal>" has been selected as the <guilabel>Custom delimiter</guilabel>. Selecting <guilabel>OK</guilabel> will assign this configuration to this file. &kst; will continue to use this configuration with this file until the configuration options are changed again in this dialog, or until <guimenuitem>Clear datasource settings</guimenuitem> in the <guimenu>Settings</guimenu> menu is selected.
0124 </para>
0125
0126 <para>
0127 </para>
0128
0129 </sect2>
0130 </sect1>
0131
0132 <sect1 id="datamanager">
0133 <title>The Data Manager</title>
0134 <para>
0135 The Data Manager provides a central location for deleting and modifying all the data objects used in &kst;.
0136 It can be accessed by selecting <guimenuitem>Data Manager</guimenuitem> from the <guimenu>Tools</guimenu> menu or by clicking the
0137
0138 <inlinemediaobject>
0139 <imageobject>
0140 <imagedata fileref="Icon-kst-datamanager.png" format="PNG"/>
0141 </imageobject>
0142 </inlinemediaobject>
0143
0144 icon in the tool bar.
0145 </para>
0146
0147 <screenshot>
0148 <mediaobject>
0149 <imageobject>
0150 <imagedata fileref="Screenshot-kst-datamanager.png" format="PNG"/>
0151 </imageobject>
0152 </mediaobject>
0153 </screenshot>
0154
0155 <para>
0156 The window lists all data objects currently loaded in kst, as well as their type and basic properties. To edit an object, double click on it, or select it and click the <guibutton>Edit</guibutton> button. It will bring up the appropriate edit dialog. Items that have child-vectors can be expanded to list them. Items also have right button context menus with common tasks for the items, such as making curves or power spectra from vectors, or adding curves to plots.
0157 </para>
0158
0159 <para>
0160 Items can also be deleted from this dialog by selecting them and clicking <guibutton>Delete</guibutton>. This will delete the selected item and all items which depend on it. So if you delete a vector, all curves, spectra, histograms, or equations that depend on it will also be deleted. Be careful, because this can not be undone.
0161 </para>
0162 <para>
0163 Clicking <guibutton>Purge</guibutton> will remove all undisplayed data objects. If deleting an object (and everything that depends on it) will not change any plots or labels, then it is deleted. Nothing that is displayed is deleted. This can not be undone.
0164 </para>
0165
0166 </sect1>
0167
0168 <sect1 id="datatypes">
0169 <title>Data Types</title>
0170
0171 <para>
0172 Plots in &kst; are created by building up objects into the displayed curves. In &kst;, there are 5 major classes:
0173 </para>
0174 <itemizedlist>
0175 <listitem>
0176 <para>
0177 Data Sources: data files which are recognized by &kst;.
0178 </para>
0179 </listitem>
0180 <listitem>
0181 <para>
0182 Primitives: These are basic data types, including Strings, Scalars (which are single numbers), Vectors (which are ordered lists of numbers) and Matrices (which are 2D arrays of numbers).
0183 </para>
0184 </listitem>
0185 <listitem>
0186 <para>
0187 Relations: these objects describe how vectors or matrices are displayed in a plot. They include Curves (which display an XY pair of vectors) and Images (which display matrices).
0188 </para>
0189 </listitem>
0190 <listitem>
0191 <para>
0192 Data Objects: these classes take Primitives as inputs, process them, and output Primitives. These include Spectra, Histograms, Equations, Fits, Filters, and other Plugins.
0193 </para>
0194 </listitem>
0195 <listitem>
0196 <para>
0197 View Items: these are objects that can be drawn, and include plots, labels, lines, etc. Plots can display Relations (curves and images). Labels can display Scalars and Strings.
0198 </para>
0199 </listitem>
0200 </itemizedlist>
0201
0202 <para>
0203 As an example of how these various classes work together, consider the example session in the chapter on
0204 <link linkend="tutorial-filters">Filters</link>. In this session, a curve from a data file was plotted, along with a low pass filtered version of the curve. The resulting data structures are as follows:
0205 </para>
0206
0207
0208 <para>
0209 <inlinemediaobject>
0210 <imageobject>
0211 <imagedata fileref="Diagram-datatypes-example.png" format="PNG"/>
0212 </imageobject>
0213 <textobject>
0214 <phrase>&kst; Data Types</phrase>
0215 </textobject>
0216 </inlinemediaobject>
0217 </para>
0218
0219 <para>
0220 The plot displays two curves. One curve takes two data vectors (INDEX and Column 2) as inputs. The other takes INDEX as its X vector, and the output vector of the Low Pass Filter as its Y vector. The low pass filter takes the Column 2 vector, and two Scalars as its inputs. The two data vectors get their data from the Data Source.
0221 </para>
0222
0223 <para>
0224 The data manager for this sessions is shown below. Note that the literal scalars [4 (X30)] and [0.05 (X29)] are not listed. To keep things clean, and because '4' is not editable, literal scalars like this are not presented in the UI.
0225 </para>
0226
0227 <screenshot>
0228 <mediaobject>
0229 <imageobject>
0230 <imagedata fileref="Screenshot-kst-datamanager2.png" format="PNG"/>
0231 </imageobject>
0232 </mediaobject>
0233 </screenshot>
0234
0235 <para>
0236 This structure could have been chained together further. For example, the output of the Filter could have been used as the input to a Histogram, and the Histogram of the output of the filtered data could have been plotted instead.
0237 </para>
0238
0239 <para>
0240 Descriptions of each data type are provided below.
0241 </para>
0242
0243 <sect2 id="vectors">
0244 <title>Vectors</title>
0245 <para>
0246 Vectors are ordered lists of numbers. They are used as the inputs to Data Objects. They are also used to define the X or Y axis for curves. While different types of vectors are created in different ways, they can all be used in Data Objects or curves in the same way.
0247 </para>
0248
0249 <para>
0250
0251 <itemizedlist>
0252 <listitem>
0253 <para>
0254 Data Vectors acquire their data from Data Sources (ie, data files). They can be created from the <guimenuitem>Vector</guimenuitem> option in the <guimenu>Create</guimenu> menu, or by selecting the
0255
0256 <inlinemediaobject>
0257 <imageobject>
0258 <imagedata fileref="Icon-kst-vectornew.png" format="PNG"/>
0259 </imageobject>
0260 </inlinemediaobject>
0261
0262 icon in any vector selector.
0263 </para>
0264 </listitem>
0265 <listitem>
0266 <para>
0267 Generated Vectors are lists of equally spaced numbers whose range and spacing is defined in the GUI. They can be created from the <guimenuitem>Vector</guimenuitem> option in the <guimenu>Create</guimenu> menu, or by selecting the
0268
0269 <inlinemediaobject>
0270 <imageobject>
0271 <imagedata fileref="Icon-kst-vectornew.png" format="PNG"/>
0272 </imageobject>
0273 </inlinemediaobject>
0274
0275 icon in any vector selector.
0276 </para>
0277 </listitem>
0278 <listitem>
0279 <para>
0280 Editable Vectors have their data defined through the Python interface. They can not be created or edited in the GUI.
0281 </para>
0282 </listitem>
0283 <listitem>
0284 <para>
0285 Output Vectors are the output of data objects, such as histograms or filters.
0286 </para>
0287 </listitem>
0288 </itemizedlist>
0289
0290 </para>
0291
0292 </sect2>
0293
0294 <sect2 id="scalars">
0295 <title>Scalars</title>
0296 <para>
0297 Scalars are single numbers that can be used in labels and equations.
0298 </para>
0299
0300 <itemizedlist>
0301 <listitem>
0302 <para>
0303 Generated Scalars are a single number whose value is defined by the user. To create a Generated Scalar, select <guilabel>Generate</guilabel> in the <guilabel>New Scalar</guilabel> dialog, opened by selecting <guimenuitem>Scalar</guimenuitem> from the <guimenu>Create</guimenu> menu.
0304 </para>
0305 </listitem>
0306 <listitem>
0307 <para>
0308 Data Vector Field based Scalars are generated through Data Sources from the a single specified from a vector field on disk. To create a Data Vector Field based Scalar, select <guilabel>Read from data vector</guilabel> from the <guilabel>New Scalar</guilabel> dialog under <guimenuitem>Scalar</guimenuitem> in the <guimenu>Create</guimenu> menu. You will specify the data file to read from, the Field name for the vector, and the index of the field you want to read from. In real time applications, one might want to only read the most recent value. In this case, select <guilabel>last frame</guilabel> rather than entering a frame number.
0309 </para>
0310 </listitem>
0311 <listitem>
0312 <para>
0313 Data Scalars are scalars output directly by data sources. Most datasources provide <literal>FRAMES</literal> which gives the number of frames in the data file. Some data sources (eg, dirfiles) also support user defined scalar values. These are read by selecting <guilabel>Read from data source</guilabel> from the <guilabel>New Scalar</guilabel> dialog under <guimenuitem>Scalar</guimenuitem> in the <guimenu>Create</guimenu> menu.
0314 </para>
0315 </listitem>
0316 <listitem>
0317 <para>
0318 Slave scalars are created automatically by each vector which has been created in &kst;. Many of these are particularly useful in text labels. The automatically created slave scalars are:
0319 </para>
0320 <para>
0321 <informaltable>
0322 <tgroup cols="2">
0323 <thead>
0324 <row>
0325 <entry>Scalar Name</entry>
0326 <entry>Description</entry>
0327 </row>
0328 </thead>
0329
0330 <tbody>
0331
0332
0333 <row>
0334 <entry>NS</entry>
0335 <entry>The number of data points in the vector.</entry>
0336 </row>
0337
0338 <row>
0339 <entry>First</entry>
0340 <entry>The first data point in the vector.</entry>
0341 </row>
0342
0343 <row>
0344 <entry>Last</entry>
0345 <entry>The last data point in the vector.</entry>
0346 </row>
0347
0348 <row>
0349 <entry>Min</entry>
0350 <entry>The minimum value in the vector.</entry>
0351 </row>
0352
0353 <row>
0354 <entry>iMin</entry>
0355 <entry>the index in the vector of the minimum value in the vector. The first sample in the vector is index 0.</entry>
0356 </row>
0357
0358 <row>
0359 <entry>Max</entry>
0360 <entry>The maximum value in the vector.</entry>
0361 </row>
0362
0363 <row>
0364 <entry>iMax</entry>
0365 <entry>the index in the vector of the maximum value in the vector. The first sample in the vector is index 0.</entry>
0366 </row>
0367
0368 <row>
0369 <entry>Mean</entry>
0370 <entry>The mean of the data points in the vector.</entry>
0371 </row>
0372
0373 <row>
0374 <entry>Sigma</entry>
0375 <entry>The standard deviation of the data points in the vector.</entry>
0376 </row>
0377
0378 <row>
0379 <entry>Sum</entry>
0380 <entry>The sum of the data points in the vector.</entry>
0381 </row>
0382
0383 <row>
0384 <entry>SumSquared</entry>
0385 <entry>The sum of the squares of the data points in the vector.</entry>
0386 </row>
0387
0388 <row>
0389 <entry>Rms</entry>
0390 <entry>The square root of the mean of the squares of the data points in the vector.</entry>
0391 </row>
0392
0393 <row>
0394 <entry>MinPos</entry>
0395 <entry>The smallest positive number in the vector.</entry>
0396 </row>
0397
0398 </tbody>
0399 </tgroup>
0400 </informaltable>
0401 </para>
0402 <para>
0403 The names for Slave Scalars are <Vector Name>:<Scalar Name> (X<N>). For example, the name of the scalar giving the last sample of the Vector <literal>Az (V2)</literal> would be <literal>Az:Last (X18)</literal>.
0404 </para>
0405 </listitem>
0406 </itemizedlist>
0407 </sect2>
0408
0409 <sect2 id="curves">
0410 <title>Curves</title>
0411 <para>
0412 Curves are used to create plottable objects from vectors. Curves are created from two vectors - an <quote>X axis vector</quote> and a <quote>Y axis vector</quote>. These two vectors are interpreted as a set of (X,Y) pairs to be plotted. When the X and Y vectors have the same length, the interpretation is obvious.
0413 </para>
0414 <para>
0415 If, however, the X vector is of a different length than the Y vector, then the first and last points of each are assumed to represent the first and last (X,Y) pair, and the shorter vector is resampled using linear interpolation to have the same number of samples as the longer vector.
0416 </para>
0417 <para>
0418 Curves are created by the data wizard, from the creation dialog from Data Objects (such as histograms) or by using the <guimenuitem>Curve</guimenuitem> option in the <guimenu>Create</guimenu> menu. The latter produces the following:
0419 </para>
0420
0421 <screenshot>
0422 <screeninfo>New Curve</screeninfo>
0423 <mediaobject>
0424 <imageobject>
0425 <imagedata fileref="Screenshot-kst-newcurve.png" format="PNG" />
0426 </imageobject>
0427 <textobject>
0428 <phrase>New Curve</phrase>
0429 </textobject>
0430 </mediaobject>
0431 </screenshot>
0432
0433 <para>
0434 Here, in the <guilabel>Curve Contents</guilabel> box, the curve has been set up to use INDEX (V1) as the X axis vector and Column 2 (V3) as the Y axis vector. Note that vectors holding X and Y axis error bars can also be selected. The
0435
0436 <inlinemediaobject>
0437 <imageobject>
0438 <imagedata fileref="Icon-kst-vectornew.png" format="PNG"/>
0439 </imageobject>
0440 </inlinemediaobject>
0441
0442 icon in any of the vector selectors will bring up a new vector dialog. The
0443
0444 <inlinemediaobject>
0445 <imageobject>
0446 <imagedata fileref="Icon-kst-vectoredit.png" format="PNG"/>
0447 </imageobject>
0448 </inlinemediaobject>
0449 icon will edit the selected vector.
0450 </para>
0451
0452 <para>
0453 The appearance of curves is adjusted in the <guilabel>Appearance</guilabel> box. Some of the flexibility of curves in kst is shown in the next figure.
0454 Note that the options are not exclusive - for example, <guilabel>Lines</guilabel> and <guilabel>Points</guilabel> can both be selected. The <guilabel>Size</guilabel> field specifies the dimensions of display elements such as points and error flags in points (the same way as font sizes are defined.)
0455 The <guilabel>Weight</guilabel> field specifies the width of lines,
0456 bar graph borders, and the strokes for points. The color selector to the right of the example line sets the color of lines, points, and bargraph borders. The color selector to the right of the <guilabel>Bargraph</guilabel> checkbox sets the fill color for bargraphs. The last (most recent) point of a
0457 curve can be indicated by selecting <guilabel>Head</guilabel> and specifying
0458 a point type and color. The color selector to the right of the <guilabel>Head</guilabel> sets the color for this point.
0459 </para>
0460
0461 <screenshot>
0462 <screeninfo>Curve Demo</screeninfo>
0463 <mediaobject>
0464 <imageobject>
0465 <imagedata fileref="Screenshot-kst-curvedemo.png" format="PNG" />
0466 </imageobject>
0467 <textobject>
0468 <phrase>Curve Demo</phrase>
0469 </textobject>
0470 </mediaobject>
0471 </screenshot>
0472
0473
0474 <para>
0475 The <guilabel>Placement</guilabel> box specifies what plot the curve will be displayed in. Both the <guilabel>Placement</guilabel> and <guilabel>Appearance</guilabel> boxes appear in data object creation dialogs as well, and work the same way.
0476 </para>
0477
0478 </sect2>
0479
0480 <sect2 id="equations">
0481 <title>Equations</title>
0482 <para>
0483 Equations are data objects whose outputs are:
0484 </para>
0485 <itemizedlist>
0486 <listitem>
0487 <para>
0488 A vector (<literal>...:y</literal>) which is the function of one or more data vectors.
0489 </para>
0490 </listitem>
0491 <listitem>
0492 <para>
0493 A vector (<literal>...:x</literal>) which passes through the X input vector.
0494 </para>
0495 </listitem>
0496 </itemizedlist>
0497
0498 <para>
0499 The inputs are:
0500 </para>
0501 <itemizedlist>
0502 <listitem>
0503 <para>
0504 A vector which is used as the <literal>x</literal> variable in equations.
0505 </para>
0506 </listitem>
0507 <listitem>
0508 <para>
0509 Any vectors or scalars specified by name in the equation text.
0510 </para>
0511 </listitem>
0512 </itemizedlist>
0513
0514 <para>
0515 Equations are used to produce vectors which are the point-by-point function of one or more input vectors and scalars. They are created by selecting <guimenuitem>Equation</guimenuitem> from the <guimenu>Create</guimenu> menu. An example of creating an equation, and the resulting plot is shown below. In this example, a Generated Vector consisting of 1000 points from -10 to 10 was selected for the x vector. Recall that a Generated vector can be created by selecting the new vector icon,
0516
0517 <inlinemediaobject>
0518 <imageobject>
0519 <imagedata fileref="Icon-kst-vectornew.png" format="PNG"/>
0520 </imageobject>
0521 </inlinemediaobject>
0522
0523 which appears to the right of the <guilabel>X Vector</guilabel> field. The equation, <literal>sin(x)/x</literal>, was entered into the <guilabel>Equation</guilabel> field.
0524 </para>
0525
0526 <screenshot>
0527 <screeninfo>New Equation</screeninfo>
0528 <mediaobject>
0529 <imageobject>
0530 <imagedata fileref="Screenshot-kst-newequation.png" format="PNG" />
0531 </imageobject>
0532 <textobject>
0533 <phrase>New Equation</phrase>
0534 </textobject>
0535 </mediaobject>
0536 </screenshot>
0537
0538 <screenshot>
0539 <screeninfo>sin(x)/x</screeninfo>
0540 <mediaobject>
0541 <imageobject>
0542 <imagedata fileref="Screenshot-kst-sinx_x.png" format="PNG" />
0543 </imageobject>
0544 <textobject>
0545 <phrase>sin(x)/x</phrase>
0546 </textobject>
0547 </mediaobject>
0548 </screenshot>
0549
0550 <para>
0551 Equations support the following operators:
0552 </para>
0553
0554 <itemizedlist>
0555 <listitem>
0556 <para>
0557 Arithmetic operators: <literal>+</literal>, <literal>-</literal>, <literal>*</literal>, <literal>/</literal>, <literal>%</literal> (modulus operator) and <literal>^</literal> (power operator).
0558 </para>
0559 </listitem>
0560 <listitem>
0561 <para>
0562 Bitwise operators: <literal>&</literal>, <literal>|</literal>. These operators assume the vector is comprised of integers.
0563 </para>
0564 </listitem>
0565 <listitem>
0566 <para>
0567 Logical operators: <literal>!</literal>, <literal>&&</literal>, <literal>||</literal>, <literal><</literal>, <literal><=</literal>, <literal>==</literal>, <literal>>=</literal>, <literal>></literal>, and <literal>!=</literal>. These functions output 1 for True and 0 for False.
0568 </para>
0569 </listitem>
0570 </itemizedlist>
0571
0572 <para>
0573 Functions supported by kst are:
0574 </para>
0575
0576 <itemizedlist>
0577 <listitem>
0578 <para>
0579 Trig functions working in Radians: <literal>SIN()</literal>, <literal>COS()</literal>, <literal>TAN()</literal>, <literal>ASIN()</literal>, <literal>ACOS()</literal>, <literal>ATAN()</literal>, <literal>ATAN2()</literal>, <literal>SEC()</literal>, <literal>CSC()</literal> and <literal>COT()</literal>.
0580 </para>
0581 </listitem>
0582 <listitem>
0583 <para>
0584 Trig functions working in Degrees: <literal>SIND()</literal>, <literal>COSD()</literal>, <literal>TAND()</literal>, <literal>ASIND()</literal>, <literal>ACOSD()</literal>, <literal>ATAND()</literal>, <literal>SECD()</literal>, <literal>CSCD()</literal> and <literal>COTD()</literal>.
0585 </para>
0586 </listitem>
0587 <listitem>
0588 <para>
0589 Other functions: <literal>ABS()</literal> (absolute value), <literal>SQRT()</literal> (square root), <literal>CBRT()</literal> (cube root), <literal>SINH()</literal>, <literal>COSH()</literal>, <literal>TANH()</literal>, <literal>EXP()</literal>, <literal>LN()</literal> (natural logarithm), <literal>LOG()</literal> (base 10 logarithm) and <literal>STEP()</literal> (returns 1 if the argument is greater than 0, and 0 otherwise).
0590 </para>
0591 </listitem>
0592 </itemizedlist>
0593
0594 <para>
0595 Equations also support the constants <literal>PI</literal> and <literal>e</literal>.
0596 </para>
0597
0598 <para>
0599 Equations can use any vector or scalar as their input vectors, not just the X vector. In the next example, the bottom right plot shows the signal in Column 2 with the signal in Column 1 regressed out of it. This has been done by subtracting Column 1, scaled by the slope of a fit to Column 2 vs Column 1, from Column 2. The fit had been created previously using the <guimenuitem>Fit</guimenuitem> option in the right mouse button menu of the top right plot.
0600 </para>
0601
0602 <screenshot>
0603 <screeninfo>Regression</screeninfo>
0604 <mediaobject>
0605 <imageobject>
0606 <imagedata fileref="Screenshot-kst-eq2Plots.png" format="PNG" />
0607 </imageobject>
0608 <textobject>
0609 <phrase>Regression</phrase>
0610 </textobject>
0611 </mediaobject>
0612 </screenshot>
0613
0614 <para>
0615 The <guilabel>New Equation</guilabel> dialog which created this plot is shown below. Note that vectors are identified by enclosing their names in <literal>[ ]</literal>. So Column 2 is indicated by <literal>[Column 2 (V2)]</literal>. The <guilabel>Equation</guilabel> line widget has a fairly powerful autocomplete mechanism with a scrollable list of all possible scalars (in its first column) or vectors (in its second column) as you enter the name of the object. Similarly, the auto complete lists all valid functions and operators as relevant while you type. The <literal>Esc</literal> key hides the autocomplete widget.
0616 </para>
0617
0618 <para>
0619 If the vectors were set to <guilabel>Read to end</guilabel> mode, all elements would be updated real time as new data came in.
0620 </para>
0621
0622 <screenshot>
0623 <screeninfo>Complex Equation</screeninfo>
0624 <mediaobject>
0625 <imageobject>
0626 <imagedata fileref="Screenshot-kst-eq2.png" format="PNG" />
0627 </imageobject>
0628 <textobject>
0629 <phrase>Complex Equation</phrase>
0630 </textobject>
0631 </mediaobject>
0632 </screenshot>
0633
0634 </sect2>
0635
0636 <sect2 id="Histograms">
0637 <title>Histograms</title>
0638
0639 <para>
0640 Histograms are data objects whose outputs are:
0641 </para>
0642 <itemizedlist>
0643 <listitem>
0644 <para>
0645 A vector (<literal>...:num</literal>) which contains the (optionally normalized) count of samples from the input vector which lie within each interval.
0646 </para>
0647 </listitem>
0648 <listitem>
0649 <para>
0650 A vector (<literal>...:bin</literal>) which contains the center of each interval for which the counts have been calculated.
0651 </para>
0652 </listitem>
0653 </itemizedlist>
0654
0655 <para>
0656 The input is:
0657 </para>
0658 <itemizedlist>
0659 <listitem>
0660 <para>
0661 A vector for which the histogram is calculated.
0662 </para>
0663 </listitem>
0664 </itemizedlist>
0665
0666 <para>
0667 In the <guilabel>New Histogram</guilabel> dialog, the bins can be set manually, can be preset once by selecting <guilabel>Auto Bin</guilabel> or can be set to be automatically reset with each data update by selecting <guilabel>Real-time auto bin</guilabel>.
0668 </para>
0669
0670 <para>
0671 By selecting <guilabel>Bargraph</guilabel> in the dialog, the histogram can be shown in the standard bar-graph form, below.
0672 </para>
0673
0674 <screenshot>
0675 <screeninfo>New Histogram</screeninfo>
0676 <mediaobject>
0677 <imageobject>
0678 <imagedata fileref="Screenshot-kst-new-histogram.png" format="PNG" />
0679 </imageobject>
0680 <textobject>
0681 <phrase>New Histogram</phrase>
0682 </textobject>
0683 </mediaobject>
0684 </screenshot>
0685
0686 <screenshot>
0687 <screeninfo>Histogram</screeninfo>
0688 <mediaobject>
0689 <imageobject>
0690 <imagedata fileref="Screenshot-kst-histogram.png" format="PNG" />
0691 </imageobject>
0692 <textobject>
0693 <phrase>Histogram</phrase>
0694 </textobject>
0695 </mediaobject>
0696 </screenshot>
0697
0698 </sect2>
0699
0700 <sect2 id="power-spectra">
0701 <title>Power Spectra</title>
0702
0703 <para>
0704 Power Spectra are data objects whose outputs are:
0705 </para>
0706 <itemizedlist>
0707 <listitem>
0708 <para>
0709 A vector (<literal>...:psd</literal>) which contains the fft-based spectrum of the input
0710 vector.
0711 </para>
0712 </listitem>
0713 <listitem>
0714 <para>
0715 A vector (<literal>...:f</literal>) which contains the centers of the corresponding
0716 frequency bins.
0717 </para>
0718 </listitem>
0719 </itemizedlist>
0720
0721 <para>
0722 The input is:
0723 </para>
0724 <itemizedlist>
0725 <listitem>
0726 <para>
0727 A vector for which the power spectrum is calculated. Uniform sampling is assumed.
0728 </para>
0729 </listitem>
0730 </itemizedlist>
0731
0732
0733 <para>
0734 The following plot shows an example spectrum. The plot has been converted to log-log mode (hit 'l' and 'g' in the plot window to toggle Y and X log axes respectively).
0735 </para>
0736
0737 <screenshot>
0738 <screeninfo>Spectrum</screeninfo>
0739 <mediaobject>
0740 <imageobject>
0741 <imagedata fileref="Screenshot-kst-spectrum_log.png" format="PNG" />
0742 </imageobject>
0743 <textobject>
0744 <phrase>Spectrum</phrase>
0745 </textobject>
0746 </mediaobject>
0747 </screenshot>
0748
0749
0750 <para>
0751 The spectrum dialog (select <guimenuitem>Power Spectrum</guimenuitem> from the <guimenu>Create</guimenu> menu) used to create this plot is shown below:
0752 </para>
0753
0754 <screenshot>
0755 <screeninfo>New Spectrum Dialog</screeninfo>
0756 <mediaobject>
0757 <imageobject>
0758 <imagedata fileref="Screenshot-kst-new-spectrum.png" format="PNG" />
0759 </imageobject>
0760 <textobject>
0761 <phrase>The New Spectrum Dialog</phrase>
0762 </textobject>
0763 </mediaobject>
0764 </screenshot>
0765
0766 <para>
0767 The dialog entries are as follows:
0768 </para>
0769
0770 <variablelist>
0771 <varlistentry>
0772 <term>
0773 <guilabel>Data vector</guilabel>
0774 </term>
0775 <listitem>
0776 <para>
0777 The data vector to create a power spectrum from.
0778 </para>
0779 </listitem>
0780 </varlistentry>
0781
0782 <varlistentry>
0783 <term>
0784 <guilabel>Remove Mean</guilabel>
0785 </term>
0786 <listitem>
0787 <para>
0788 Remove a constant from the input vector to make it mean zero before calculating the spectrum.
0789 </para>
0790 </listitem>
0791 </varlistentry>
0792
0793 <varlistentry>
0794 <term>
0795 <guilabel>Apodize</guilabel>
0796 </term>
0797 <listitem>
0798 <para>
0799 Apodize the data with the selected function before calculating the power spectrum to reduce
0800 bin to bin leakage. The default is a Hanning Window.
0801 </para>
0802 </listitem>
0803 </varlistentry>
0804
0805 <varlistentry>
0806 <term>
0807 <guilabel>Interleaved average</guilabel> and <guilabel>FFT Length</guilabel>
0808 </term>
0809 <listitem>
0810 <para>
0811 When <guilabel>Interleaved average</guilabel> is not set, the spectrum is based on an FFT
0812 whose length is power of two larger or equal to the length of the input vector. The remaining points are zero padded. For cases like this, apodization and mean removal is quite important.
0813 </para>
0814 <para>
0815 When <guilabel>Interleaved average</guilabel> is set, the spectrum is based on the average of FFTs of length <literal>2^x</literal> where <literal>x</literal> is specified by the <guilabel>FFT Length</guilabel> entry, interleaved such that no zero padding is required. Choosing this option reduces the noise of the spectrum, at the cost of reduced resolution.
0816 </para>
0817 </listitem>
0818 </varlistentry>
0819
0820 <varlistentry>
0821 <term>
0822 <guibutton>Sample rate</guibutton>
0823 </term>
0824 <listitem>
0825 <para>
0826 The frequency bin output vector (<literal>...:f</literal>) will be calculated assuming the input vector was uniformly sampled at this sample rate.</para>
0827 </listitem>
0828 </varlistentry>
0829
0830 <varlistentry>
0831 <term>
0832 <guilabel>Data units</guilabel> and <guilabel>Rate units</guilabel>
0833 </term>
0834 <listitem>
0835 <para>
0836 Auto-generating axes labels for plots will be based on these units.
0837 </para>
0838 </listitem>
0839 </varlistentry>
0840 </variablelist>
0841
0842 </sect2>
0843
0844 <sect2 id="fits">
0845 <title>Fits</title>
0846 <para>
0847 Fits are data objects whose outputs are:
0848 </para>
0849 <itemizedlist>
0850 <listitem>
0851 <para>
0852 A vector (<literal>...:Fit</literal>) which is the fit to the data, evaluated at the X value corresponding to each input Y point.
0853 </para>
0854 </listitem>
0855 <listitem>
0856 <para>
0857 A vector (<literal>...:Residuals</literal>) which is the difference between the input Y vector and the fit.
0858 </para>
0859 </listitem>
0860 <listitem>
0861 <para>
0862 One or more named scalars which correspond to the fit parameters. For example, for linear fits, the scalars are <literal>...:Intercept</literal> and <literal>...:Gradient</literal>.
0863 </para>
0864 </listitem>
0865 <listitem>
0866 <para>
0867 A scalar (<literal>...:chi^2/nu</literal> which holds the reduced chi squared of the fit.
0868 </para>
0869 </listitem>
0870 <listitem>
0871 <para>
0872 A vector (<literal>...:Covariance</literal>) which holds the Covariance matrix of the fit in an arbitrary order. Because the parameters are listed in an arbitrary order, this vector is not currently particularly useful.
0873 </para>
0874 </listitem>
0875 <listitem>
0876 <para>
0877 A vector (<literal>...:Parameters</literal>) which is a list of the fit parameters in some arbitrary order. This vector is rarely useful and may be removed in the future. The named parameter scalars are a much more useful interface to the fit parameters.
0878 </para>
0879 </listitem>
0880 </itemizedlist>
0881
0882 <para>
0883 The inputs are:
0884 </para>
0885 <itemizedlist>
0886 <listitem>
0887 <para>
0888 A vector which is to be fit to. (The Y axis vector)
0889 </para>
0890 </listitem>
0891 <listitem>
0892 <para>
0893 A vector which is used to generate the X values corresponding to the Y vector. Note that if the X vector is not the same length as the Y vector, then the X vector will be resampled to have the same number of points as the Y vector in order to generate a series of (X, Y) pairs.
0894 </para>
0895 </listitem>
0896 <listitem>
0897 <para>
0898 If a weighted fit is chosen: A vector which describes the error bars for the Y vector.
0899 </para>
0900 </listitem>
0901 </itemizedlist>
0902
0903 <para>
0904 A number of fits are available in kst, including weighted (in which the error bar for each Y value is specified) and unweighted fits to lines, polynomials, Gaussians, Lorentians, and exponentials.
0905 </para>
0906
0907 <para>
0908 The easiest way to create a fit is by selecting <guimenuitem>Create fit</guimenuitem> from the
0909 plot context menu (right click in the plot, and then selecting the curve you would like to fit. The following dialog will appear.
0910 </para>
0911
0912 <screenshot>
0913 <screeninfo>New Spectrum Dialog</screeninfo>
0914 <mediaobject>
0915 <imageobject>
0916 <imagedata fileref="Screenshot-kst-fitdialog.png" format="PNG" />
0917 </imageobject>
0918 <textobject>
0919 <phrase>The Create Fit Dialog</phrase>
0920 </textobject>
0921 </mediaobject>
0922 </screenshot>
0923
0924 <para>
0925 A linear fit has been selected in the <guilabel>Plugin Selection</guilabel> combo box. The X and Y vectors have been automatically selected from the curve which was selected and can not be changed. The curve properties and placement of the automatically generated curve can be selected as usual.
0926 </para>
0927
0928 <para>
0929 When <guibutton>Ok</guibutton> has been selected, the curve is placed in the selected plot, and a label with the fit parameters is automatically created. Click the mouse wherever you want the label to go.
0930 </para>
0931
0932 <para>
0933 You can also create a fit plugin by selecting the appropriate fit from the <guimenu>Fit plugin</guimenu> submenu in the <guimenu>Create</guimenu> menu. With this dialog you can select the input vectors, but it does not automatically create a curve. You will have to create a curve by hand by selecting <guimenu>Curve</guimenu> in the <guimenu>Create</guimenu> menu.
0934 </para>
0935
0936 </sect2>
0937
0938 <sect2 id="filters">
0939 <title>Filters</title>
0940 <para>
0941 Filters are data objects whose output is:
0942 </para>
0943 <itemizedlist>
0944 <listitem>
0945 <para>
0946 A vector (<literal>...:Filtered</literal>) which is the same size as the input vector.
0947 </para>
0948 </listitem>
0949 </itemizedlist>
0950
0951 <para>
0952 The inputs are:
0953 </para>
0954 <itemizedlist>
0955 <listitem>
0956 <para>
0957 A vector which is to be filtered.
0958 </para>
0959 </listitem>
0960 <listitem>
0961 <para>
0962 A number of numbers or scalars which are parameters for the filter.
0963 </para>
0964 </listitem>
0965 </itemizedlist>
0966
0967 <para>
0968 A number of filters are available in kst. The band pass, band stop, high pass and low pass filters are conventional zero phase shift Fourier domain filters whose band edges follow the shape of a Butterworth filter. A higher order filter is a steeper cutoff.
0969 </para>
0970
0971 <para>
0972 Numerical Integrals can be created with the Cumulative Sum filter, and Numerical Derivatives with the Fixed Step Differentiation filter. In both of these dX takes the size of the step between samples.
0973 </para>
0974
0975 <para>
0976 For fields such as angles which have (for example) a discontinuity at 360 degrees, the Unwind Filter can be used to make the signal continuous. So if the unfiltered signal goes from 359.5 degrees to 0.5 degrees in consecutive samples, the filtered signal will go from 359.5 degrees to 360.5 degrees.
0977 </para>
0978
0979 <para>
0980 The Flag filter can be used to mask a vector with NaNs whenever certain bit patters in the flag field are true.
0981 </para>
0982
0983 <para>
0984 The easiest way to create a filter is by selecting <guimenuitem>Create filter</guimenuitem> from the
0985 plot context menu (right click in the plot, and then selecting the curve you would like to fit.
0986 </para>
0987
0988 <para>
0989 You can also create a filter plugin by selecting the appropriate filter from the <guimenu>Filter plugin</guimenu> submenu in the <guimenu>Create</guimenu> menu. With this dialog you can select the input vectors, but it does not automatically create a curve. You will have to create a curve by hand by selecting <guimenu>Curve</guimenu> in the <guimenu>Create</guimenu> menu.
0990 </para>
0991
0992 </sect2>
0993
0994 <sect2 id="plugins">
0995 <title>Standard Plugins</title>
0996 <para>
0997 Plugins that do not fit the requirements of being either fits are filters can be created from the <guimenu>Standard Plugin</guimenu> submenu in the <guimenu>Create</guimenu> menu. They are not well documented.
0998 </para>
0999 </sect2>
1000
1001
1002 <sect2 id="arrays">
1003 <title>Matrices</title>
1004 <para>
1005 Matrices are two dimensional tables of numbers. They can be used as the inputs to Data Objects. They are also used to define the values for Images. While different types of Matrices are created in different ways, they can all be used in Data Objects or Images in the same way.
1006 </para>
1007
1008 <para>
1009
1010 <itemizedlist>
1011 <listitem>
1012 <para>
1013 Data Matrices acquire their data from Data Sources (ie, data files). They can be created from the <guimenuitem>Matrix</guimenuitem> option in the <guimenu>Create</guimenu> menu, or by selecting the
1014
1015 <inlinemediaobject>
1016 <imageobject>
1017 <imagedata fileref="Icon-kst-matrixnew.png" format="PNG"/>
1018 </imageobject>
1019 </inlinemediaobject>
1020
1021 icon in any matrix selector (for example, in the Image dialog).
1022 </para>
1023 </listitem>
1024 <listitem>
1025 <para>
1026 Editable Matrices have their data defined through the Python interface. They can not be created or edited in the GUI.
1027 </para>
1028 </listitem>
1029 <listitem>
1030 <para>
1031 Output Matrices are the output of data objects, such as Spectrograms.
1032 </para>
1033 </listitem>
1034 </itemizedlist>
1035 </para>
1036
1037 <screenshot>
1038 <screeninfo>New Matrix Dialog</screeninfo>
1039 <mediaobject>
1040 <imageobject>
1041 <imagedata fileref="Screenshot-kst-newmatrix.png" format="PNG" />
1042 </imageobject>
1043 <textobject>
1044 <phrase>The New Matrix Dialog</phrase>
1045 </textobject>
1046 </mediaobject>
1047 </screenshot>
1048
1049 <para>
1050 Matrices can be read from:
1051 </para>
1052
1053 <para>
1054 <itemizedlist>
1055
1056 <listitem>
1057 <para>
1058 Any data file compatible with QImage - (jpg, png, tiff, bmp, gif, etc). For color images, four
1059 matrices can be read: RED, GREEN, BLUE, and GRAY.
1060 </para>
1061 </listitem>
1062 <listitem>
1063 <para>
1064 conventional 2D FITS images (if built with cfitsio).
1065 </para>
1066 </listitem>
1067 <listitem>
1068 <para>
1069 BIT Image Streams (BIS) files.
1070 </para>
1071 </listitem>
1072 </itemizedlist>
1073 </para>
1074
1075 <para>
1076 The BIS data source can provide matrices from an image stream. In these cases, the frame number can be selected when the Matrix is created.
1077 </para>
1078
1079 </sect2>
1080
1081 <sect2 id="images">
1082 <title>Images</title>
1083
1084 <para>
1085 Images are used to create plottable objects from Matrices. The pixels are directly mapped from the matrix. ie, rows in the matrix are rows in the image. Columns in the matrix are columns in the image. The value of the Matrix sets the color of the pixel.
1086 </para>
1087
1088 <para>
1089 Images are typically created from selecting <guimenuitem>Image</guimenuitem> from the <guimenu>Create</guimenu> menu. The Image dialog is shown below:
1090 </para>
1091
1092 <screenshot>
1093 <screeninfo>New Image Dialog</screeninfo>
1094 <mediaobject>
1095 <imageobject>
1096 <imagedata fileref="Screenshot-kst-new-image.png" format="PNG" />
1097 </imageobject>
1098 <textobject>
1099 <phrase>The New Image Dialog</phrase>
1100 </textobject>
1101 </mediaobject>
1102 </screenshot>
1103
1104 <para>
1105 A matrix has been read from a png file, and selected in the Matrix selector (<literal>GRAY (M1)</literal>). A color map rather than a contour map has been selected, and a grey scale color pallet has been selected. With <guilabel>Real-time auto threshold</guilabel> selected, the maximum value in the matrix will be set to the maximum value of the color pallet, and the minimum value in the matrix will be set to the minimum value of the color pallet. All other values will be linearly interpolated. Alternatively, the maximum and minimum values can be set once, either using <guilabel>Smart</guilabel>/<guilabel>Percentile</guilabel> tool, or by manually setting the thresholds.
1106 </para>
1107
1108 <para>
1109 The resulting image is shown below. Note that, by default, the image will automatically fill the plot window, and will not preserve aspect ratio.
1110 </para>
1111
1112 <screenshot>
1113 <screeninfo>New Image Dialog</screeninfo>
1114 <mediaobject>
1115 <imageobject>
1116 <imagedata fileref="Screenshot-kst-image1.png" format="PNG" />
1117 </imageobject>
1118 <textobject>
1119 <phrase>The New Image Dialog</phrase>
1120 </textobject>
1121 </mediaobject>
1122 </screenshot>
1123
1124 <para>
1125 The aspect ratio can be normalized by selecting <guimenuitem>Normalize X-Axis to Y-Axis</guimenuitem> in the <guimenu>X Zoom</guimenu> submenu of the <guimenu>Zoom</guimenu> plot context menu, or by pressing the "n" key in a plot window. The image will now have square pixels.
1126 </para>
1127
1128 <screenshot>
1129 <screeninfo>New Image Dialog</screeninfo>
1130 <mediaobject>
1131 <imageobject>
1132 <imagedata fileref="Screenshot-kst-image2.png" format="PNG" />
1133 </imageobject>
1134 <textobject>
1135 <phrase>The New Image Dialog</phrase>
1136 </textobject>
1137 </mediaobject>
1138 </screenshot>
1139
1140 <para>
1141 The range of the color pallet can be adjusted from the curve edit dialog, or by pressing 'i' in an image. This will cycle the color limits, allowing an increasing fraction of the pixels to be saturated at either end of the color scale before returning to full range.
1142 </para>
1143
1144 </sect2>
1145
1146 </sect1>
1147 </chapter>
1148
1149 <!-- Keep this comment at the end of the file
1150 Local variables:
1151 mode: xml
1152 sgml-omittag:nil
1153 sgml-shorttag:nil
1154 sgml-namecase-general:nil
1155 sgml-general-insert-case:lower
1156 sgml-minimize-attributes:nil
1157 sgml-always-quote-attributes:t
1158 sgml-indent-step:0
1159 sgml-indent-data:true
1160 sgml-parent-document:("index.docbook" "book" "chapter")
1161 sgml-exposed-tags:nil
1162 sgml-local-catalogs:nil
1163 sgml-local-ecat-files:nil
1164 End:
1165 -->