Skip to content

Commit 6ee1bb1

Browse files
committed
Improve the documentation for the formula functions
1 parent 36717c7 commit 6ee1bb1

File tree

6 files changed

+56
-23
lines changed

6 files changed

+56
-23
lines changed

core/formula/doc/index.rst

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,7 @@ This includes the average, min, max, and element count
150150

151151
**arrayMin(VNumberArray array)** - Returns a VDouble with the smallest value of the given array
152152

153+
**arraySampleWithStride(VNumberArray array, VNumber stride, VNumber offset)** - Returns a VNumberArray where each element is defined as array\[x \* stride + offset\].
153154

154155
String
155156
------
@@ -206,4 +207,12 @@ i.e. [Int8, UInt8, Int16, UInt16, Int32, UInt32, Float32, Float64].
206207

207208
**imageYOffset(VImage image)** - Fetch vertical offset of image.
208209

209-
**imageYReversed(VImage image)** - Fetch vertical reversal of image.
210+
**imageYReversed(VImage image)** - Fetch vertical reversal of image.
211+
212+
**imageDataHorizontalProfile(VNumberArray image, VNumber imageWidth, VNumber yPosition)** - Fetch the horizontal profile data for the given Image data at a specific y position.
213+
214+
**imageDataVerticalProfile(VNumberArray image, VNumber imageWidth, VNumber xPosition)** - Fetch the vertical profile data for the given Image data at a specific x position.
215+
216+
**imageHorizontalProfile(VImage image, VNumber yPosition)** - Fetch the horizontal profile of the given Image at a specific y position.
217+
218+
**imageVerticalProfile(VImage image, VNumber xPosition)** - Fetch the vertical profile of the given Image at a specific x position.

core/formula/src/main/java/org/csstudio/apputil/formula/areadetector/ADDataTypeMappingFunction.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
package org.csstudio.apputil.formula.areadetector;
22

3-
43
import java.util.Arrays;
54
import java.util.List;
65

core/formula/src/main/java/org/csstudio/apputil/formula/areadetector/ImageDataHorizontalProfileFunction.java

Lines changed: 30 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -10,38 +10,43 @@
1010
import java.util.Arrays;
1111
import java.util.List;
1212

13-
/** A formula function for fetching the horizontal profile from image data.
14-
* @author Kunal Shroff
13+
/**
14+
* A formula function for fetching the horizontal profile from image data.
15+
* This function extracts the horizontal profile along a given y position.
16+
*
17+
* @author Kunal Shroff
1518
*/
16-
public class ImageDataHorizontalProfileFunction implements FormulaFunction
17-
{
19+
public class ImageDataHorizontalProfileFunction implements FormulaFunction {
1820

1921
@Override
20-
public String getCategory()
21-
{
22+
public String getCategory() {
2223
return "areaDetector";
2324
}
2425

2526
@Override
26-
public String getName()
27-
{
27+
public String getName() {
2828
return "imageDataHorizontalProfile";
2929
}
3030

3131
@Override
32-
public String getDescription()
33-
{
32+
public String getDescription() {
3433
return "Fetch the horizontal profile data for the given Image data at a specific y position.";
3534
}
3635

3736
@Override
38-
public List<String> getArguments()
39-
{
37+
public List<String> getArguments() {
4038
return List.of("image", "image width", "y position");
4139
}
4240

43-
protected VType getHorizontalProfile(final VNumberArray imageData, final int imageWidth, final int yPosition)
44-
{
41+
/**
42+
* Computes the horizontal profile of the given image data at the specified y position.
43+
*
44+
* @param imageData The image data.
45+
* @param imageWidth The width of the image.
46+
* @param yPosition The y position in the image data from which to extract the horizontal profile.
47+
* @return A VNumberArray representing the extracted horizontal profile.
48+
*/
49+
protected VType getHorizontalProfile(final VNumberArray imageData, final int imageWidth, final int yPosition) {
4550
int start = yPosition * imageWidth;
4651
int end = start + imageWidth;
4752
return VNumberArray.of(imageData.getData().subList(start, end),
@@ -50,9 +55,18 @@ protected VType getHorizontalProfile(final VNumberArray imageData, final int ima
5055
Display.none());
5156
}
5257

58+
/**
59+
* Computes the horizontal profile based on the provided arguments.
60+
*
61+
* @param args The arguments, where:
62+
* - args[0] must be a numeric array
63+
* - args[1] must be the image width
64+
* - args[2] must be the y position
65+
* @return The computed horizontal profile as a VType.
66+
* @throws Exception If invalid arguments are provided.
67+
*/
5368
@Override
54-
public VType compute(final VType... args) throws Exception
55-
{
69+
public VType compute(final VType... args) throws Exception {
5670
if (args.length != 3) {
5771
throw new Exception("Function " + getName() +
5872
" requires 3 arguments but received " + Arrays.toString(args));

core/formula/src/main/java/org/csstudio/apputil/formula/areadetector/ImageDataVerticalProfileFunction.java

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,9 @@ public List<String> getArguments()
5050
/**
5151
* Computes the vertical profile of the given VImage at the specified x position.
5252
*
53-
* @param imageData The imageData.
54-
* @param xPosition The x position in the imageData from which to extract the vertical profile.
53+
* @param imageData The image data.
54+
* @param width The width of the image.
55+
* @param xPosition The x position in the image data from which to extract the vertical profile.
5556
* @return A VNumberArray representing the extracted vertical profile.
5657
*/
5758
protected VType getVerticalProfile(final VNumberArray imageData, final int width, final int xPosition) {
@@ -83,8 +84,9 @@ public int size() {
8384
* Computes the vertical profile based on the provided arguments.
8485
*
8586
* @param args The arguments, where:
86-
* - args[0] must be a VImage
87-
* - args[1] must be the x position
87+
* - args[0] must be a numeric array representing the image data
88+
* - args[1] must be the image width
89+
* - args[2] must be the x position
8890
* @return The computed vertical profile as a VType.
8991
* @throws Exception If invalid arguments are provided.
9092
*/

core/formula/src/main/java/org/csstudio/apputil/formula/areadetector/ImageHorizontalProfileFunction.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,15 @@ protected VType getHorizontalProfile(final VImage image, final int yPosition)
4848
return VNumberArray.of(image.getData().subList(start, end), Alarm.none(), image.getTime(), Display.none());
4949
}
5050

51+
/**
52+
* Computes the horizontal profile based on the provided arguments.
53+
*
54+
* @param args The arguments, where:
55+
* - args[0] must be a VImage
56+
* - args[1] must be the y position
57+
* @return The computed horizontal profile as a VType.
58+
* @throws Exception If invalid arguments are provided.
59+
*/
5160
@Override
5261
public VType compute(final VType... args) throws Exception
5362
{

core/formula/src/main/java/org/csstudio/apputil/formula/array/ArraySampleWithStrideFunction.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ public String getDescription() {
4949

5050
@Override
5151
public List<String> getArguments() {
52-
return List.of("array", "stride", "offset(optional)");
52+
return List.of("array", "stride", "offset");
5353
}
5454

5555

0 commit comments

Comments
 (0)