@loveluthien/carta-frontend 6.0.0-dev
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.github/ISSUE_TEMPLATE/bug_report.md +34 -0
- package/.github/pull_request_template.md +23 -0
- package/.github/workflows/continuous_integration.yml +139 -0
- package/.github/workflows/deploy.yml +30 -0
- package/.husky/pre-commit +16 -0
- package/.husky/pre-push +42 -0
- package/.prettierignore +1 -0
- package/.prettierrc.json +18 -0
- package/CHANGELOG.md +363 -0
- package/COPYING.md +636 -0
- package/README.md +112 -0
- package/babel.config.json +10 -0
- package/build/ast_wrapper.wasm +0 -0
- package/build/carta_computation.wasm +0 -0
- package/build/carta_icon_128px.png +0 -0
- package/build/carta_logo.png +0 -0
- package/build/gsl_wrapper.wasm +0 -0
- package/build/index.html +147 -0
- package/build/manifest.json +15 -0
- package/build/robots.txt +3 -0
- package/build/static/css/546.aa44a897.css +1 -0
- package/build/static/css/async/359.4d8f6ff7.css +1 -0
- package/build/static/css/async/403.ea9edfac.css +1 -0
- package/build/static/css/async/462.8bde08e0.css +1 -0
- package/build/static/css/index.c1f77b92.css +1 -0
- package/build/static/font/blueprint-icons-16.5fb1af27.woff2 +0 -0
- package/build/static/font/blueprint-icons-16.79f603d1.woff +0 -0
- package/build/static/font/blueprint-icons-16.83d51978.eot +0 -0
- package/build/static/font/blueprint-icons-16.af0c342f.ttf +0 -0
- package/build/static/font/blueprint-icons-20.83fddc09.ttf +0 -0
- package/build/static/font/blueprint-icons-20.9a51bc58.woff +0 -0
- package/build/static/font/blueprint-icons-20.d61315fe.eot +0 -0
- package/build/static/font/blueprint-icons-20.ebf16e9a.woff2 +0 -0
- package/build/static/image/allmaps.03f2ba92.png +0 -0
- package/build/static/image/gamma.6fca425b.png +0 -0
- package/build/static/image/linear.c7941b64.png +0 -0
- package/build/static/image/log.7fce6aee.png +0 -0
- package/build/static/image/power.5dac9727.png +0 -0
- package/build/static/image/sqrt.0ec2b3f1.png +0 -0
- package/build/static/image/squared.798b23aa.png +0 -0
- package/build/static/js/546.b5841ade.js +489 -0
- package/build/static/js/546.b5841ade.js.LICENSE.txt +925 -0
- package/build/static/js/async/359.97257512.js +1 -0
- package/build/static/js/async/403.b00f768c.js +1 -0
- package/build/static/js/async/462.92c07a07.js +1 -0
- package/build/static/js/async/905.70044ee8.js +1 -0
- package/build/static/js/async/907.dc17f1d2.js +1 -0
- package/build/static/js/async/blueprint-icons-16px-paths.e17db832.js +1 -0
- package/build/static/js/async/blueprint-icons-20px-paths.6ad43f5f.js +1 -0
- package/build/static/js/async/blueprint-icons-all-paths-loader.61cc0f7b.js +1 -0
- package/build/static/js/async/blueprint-icons-all-paths.0c699441.js +1 -0
- package/build/static/js/async/blueprint-icons-split-paths-by-size-loader.5cff79f5.js +1 -0
- package/build/static/js/index.8fc34b4d.js +1344 -0
- package/build/static/js/index.9a30d560.worker.js +1 -0
- package/build/static/js/zfp_wrapper.wasm +0 -0
- package/build/static/svg/blueprint-icons-16.130888ef.svg +2097 -0
- package/build/static/svg/blueprint-icons-20.c8456d56.svg +2097 -0
- package/build/zfp_wrapper.wasm +0 -0
- package/declarations.d.ts +18 -0
- package/docs_website/.prettierignore +1 -0
- package/docs_website/api/api.md +13 -0
- package/docs_website/babel.config.js +3 -0
- package/docs_website/docs/assets/enable-code-snippets.png +0 -0
- package/docs_website/docs/code-snippet-tutorial/_category_.json +8 -0
- package/docs_website/docs/code-snippet-tutorial/basics.md +97 -0
- package/docs_website/docs/code-snippet-tutorial/image-blending.mdx +57 -0
- package/docs_website/docs/code-snippet-tutorial/image-fitting.mdx +44 -0
- package/docs_website/docs/code-snippet-tutorial/image-properties.mdx +84 -0
- package/docs_website/docs/code-snippet-tutorial/moment-images.mdx +31 -0
- package/docs_website/docs/code-snippet-tutorial/pv-images.mdx +28 -0
- package/docs_website/docs/code-snippet-tutorial/quick-start.mdx +82 -0
- package/docs_website/docs/code-snippet-tutorial/regions.mdx +49 -0
- package/docs_website/docs/contributing/_category_.json +7 -0
- package/docs_website/docs/contributing/developer-tips.md +61 -0
- package/docs_website/docs/contributing/documentation-guidelines.md +87 -0
- package/docs_website/docs/contributing/github-workflow.md +146 -0
- package/docs_website/docs/contributing/release-guidelines.md +73 -0
- package/docs_website/docs/contributing/unit-test-guidelines.md +79 -0
- package/docs_website/docs/documents.mdx +15 -0
- package/docs_website/docusaurus.config.js +167 -0
- package/docs_website/package-lock.json +16769 -0
- package/docs_website/package.json +121 -0
- package/docs_website/patches/@docusaurus+core+3.9.2.patch +20 -0
- package/docs_website/sidebars.js +33 -0
- package/docs_website/static/.nojekyll +0 -0
- package/docs_website/static/img/carta_icon_128px.png +0 -0
- package/docs_website/versioned_docs/version-4.1.0/api-packages.json +1 -0
- package/docs_website/versioned_docs/version-4.1.0/api-typedoc.json +214112 -0
- package/docs_website/versioned_docs/version-4.1.0/assets/enable-code-snippets.png +0 -0
- package/docs_website/versioned_docs/version-4.1.0/code-snippet-tutorial/_category_.json +8 -0
- package/docs_website/versioned_docs/version-4.1.0/code-snippet-tutorial/basics.md +97 -0
- package/docs_website/versioned_docs/version-4.1.0/code-snippet-tutorial/image-fitting.mdx +42 -0
- package/docs_website/versioned_docs/version-4.1.0/code-snippet-tutorial/image-properties.mdx +86 -0
- package/docs_website/versioned_docs/version-4.1.0/code-snippet-tutorial/moment-images.mdx +31 -0
- package/docs_website/versioned_docs/version-4.1.0/code-snippet-tutorial/pv-images.mdx +28 -0
- package/docs_website/versioned_docs/version-4.1.0/code-snippet-tutorial/quick-start.mdx +82 -0
- package/docs_website/versioned_docs/version-4.1.0/code-snippet-tutorial/regions.mdx +49 -0
- package/docs_website/versioned_docs/version-4.1.0/contributing/_category_.json +7 -0
- package/docs_website/versioned_docs/version-4.1.0/contributing/developer-tips.md +36 -0
- package/docs_website/versioned_docs/version-4.1.0/contributing/documentation-guidelines.md +87 -0
- package/docs_website/versioned_docs/version-4.1.0/contributing/github-workflow.md +141 -0
- package/docs_website/versioned_docs/version-4.1.0/contributing/release-guidelines.md +73 -0
- package/docs_website/versioned_docs/version-4.1.0/contributing/unit-test-guidelines.md +79 -0
- package/docs_website/versioned_docs/version-4.1.0/documents.mdx +15 -0
- package/docs_website/versioned_docs/version-5.0.0/api-packages.json +1 -0
- package/docs_website/versioned_docs/version-5.0.0/api-typedoc.json +315266 -0
- package/docs_website/versioned_docs/version-5.0.0/assets/enable-code-snippets.png +0 -0
- package/docs_website/versioned_docs/version-5.0.0/code-snippet-tutorial/_category_.json +8 -0
- package/docs_website/versioned_docs/version-5.0.0/code-snippet-tutorial/basics.md +97 -0
- package/docs_website/versioned_docs/version-5.0.0/code-snippet-tutorial/image-blending.mdx +57 -0
- package/docs_website/versioned_docs/version-5.0.0/code-snippet-tutorial/image-fitting.mdx +44 -0
- package/docs_website/versioned_docs/version-5.0.0/code-snippet-tutorial/image-properties.mdx +86 -0
- package/docs_website/versioned_docs/version-5.0.0/code-snippet-tutorial/moment-images.mdx +31 -0
- package/docs_website/versioned_docs/version-5.0.0/code-snippet-tutorial/pv-images.mdx +28 -0
- package/docs_website/versioned_docs/version-5.0.0/code-snippet-tutorial/quick-start.mdx +82 -0
- package/docs_website/versioned_docs/version-5.0.0/code-snippet-tutorial/regions.mdx +49 -0
- package/docs_website/versioned_docs/version-5.0.0/contributing/_category_.json +7 -0
- package/docs_website/versioned_docs/version-5.0.0/contributing/developer-tips.md +36 -0
- package/docs_website/versioned_docs/version-5.0.0/contributing/documentation-guidelines.md +87 -0
- package/docs_website/versioned_docs/version-5.0.0/contributing/github-workflow.md +141 -0
- package/docs_website/versioned_docs/version-5.0.0/contributing/release-guidelines.md +73 -0
- package/docs_website/versioned_docs/version-5.0.0/contributing/unit-test-guidelines.md +79 -0
- package/docs_website/versioned_docs/version-5.0.0/documents.mdx +15 -0
- package/docs_website/versioned_sidebars/version-4.1.0-sidebars.json +8 -0
- package/docs_website/versioned_sidebars/version-5.0.0-sidebars.json +8 -0
- package/docs_website/versions.json +4 -0
- package/eslint.config.mjs +86 -0
- package/jest.config.js +101 -0
- package/package.json +186 -0
- package/patches/golden-layout+1.5.9.patch +24 -0
- package/patches/react-split-pane+0.1.92.patch +20 -0
- package/rsbuild.config.ts +75 -0
- package/schemas/.github/workflows/AddToCartaVisProject.yml +23 -0
- package/schemas/.prettierrc.json +18 -0
- package/schemas/CMakeLists.txt +15 -0
- package/schemas/README.md +1 -0
- package/schemas/_config.yml +7 -0
- package/schemas/controller_config_schema_1.json +343 -0
- package/schemas/controller_config_schema_2.json +685 -0
- package/schemas/layout_schema_2.json +440 -0
- package/schemas/preference_backend_schema_1.json +81 -0
- package/schemas/preference_backend_schema_2.json +118 -0
- package/schemas/preference_schema_1.json +410 -0
- package/schemas/preferences_schema_2.json +421 -0
- package/schemas/schemacompiler.c +200 -0
- package/schemas/snippet_schema_1.json +45 -0
- package/schemas/workspace_schema_1.json +573 -0
- package/scripts/make_colormaps.py +161 -0
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
---
|
|
2
|
+
sidebar_position: 2
|
|
3
|
+
---
|
|
4
|
+
|
|
5
|
+
# Basics
|
|
6
|
+
|
|
7
|
+
Code snippets are regular ES6-based JavaScript (JS) code blocks.
|
|
8
|
+
|
|
9
|
+
Lines starting with "//" are treated as comments. You can also comment in multiple lines using C-style comments.
|
|
10
|
+
|
|
11
|
+
```javascript
|
|
12
|
+
// Lines starting with "//" are treated as comments.
|
|
13
|
+
/* you can also comment in
|
|
14
|
+
* multiple lines using C-style comments
|
|
15
|
+
*/
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
To log to the development console, use `console.log`.
|
|
19
|
+
|
|
20
|
+
```javascript
|
|
21
|
+
console.log("hello world");
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
Variables can be defined using `let` (mutable) or `const` (immutable).
|
|
25
|
+
|
|
26
|
+
```javascript
|
|
27
|
+
let x = 1;
|
|
28
|
+
const y = "hello world";
|
|
29
|
+
x += 15;
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
## Functions
|
|
33
|
+
|
|
34
|
+
Functions can be defined in a number of ways.
|
|
35
|
+
|
|
36
|
+
```javascript
|
|
37
|
+
function squared(x) {
|
|
38
|
+
return x * x;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
// This is an arrow function
|
|
42
|
+
const cubed = x => x * x * x;
|
|
43
|
+
|
|
44
|
+
// This is an arrow function with a block of codes
|
|
45
|
+
const sqrt = x => {
|
|
46
|
+
// You can use builtin JS library functions
|
|
47
|
+
return Math.sqrt(x);
|
|
48
|
+
};
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
Functions can also be asynchronous. Any functions that wait for user input or interact with the backend will be asynchronous.
|
|
52
|
+
|
|
53
|
+
```javascript
|
|
54
|
+
function delay(time) {
|
|
55
|
+
return new Promise((resolve, reject) => {
|
|
56
|
+
if (time < 0) {
|
|
57
|
+
reject("Invalid delay duration");
|
|
58
|
+
} else {
|
|
59
|
+
setTimeout(resolve, time);
|
|
60
|
+
}
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
You can `await` asynchronous functions within another async function, or at the top level.
|
|
66
|
+
|
|
67
|
+
```javascript
|
|
68
|
+
async function pauseForOneSecond() {
|
|
69
|
+
await delay(1000);
|
|
70
|
+
return true;
|
|
71
|
+
}
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
Awaiting is necessary to ensure that return values can be used correctly. Compare the following outputs:
|
|
75
|
+
|
|
76
|
+
```javascript
|
|
77
|
+
console.log("Awaiting properly:");
|
|
78
|
+
const resultWithAwait = await pauseForOneSecond();
|
|
79
|
+
console.log(resultWithAwait);
|
|
80
|
+
console.log();
|
|
81
|
+
|
|
82
|
+
console.log("No await:");
|
|
83
|
+
const resultWithoutAwait = pauseForOneSecond();
|
|
84
|
+
console.log(resultWithoutAwait);
|
|
85
|
+
console.log();
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
Asynchronous functions can also be used with promise syntax.
|
|
89
|
+
|
|
90
|
+
```javascript
|
|
91
|
+
delay(100).then(() => console.log("Looks promising"));
|
|
92
|
+
delay(-100).catch(err => console.log(err));
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
Note that the response to the first "delay" call is printed after the second one, because execution is non-blocking.
|
|
96
|
+
|
|
97
|
+
For more usages of ES6-based JavaScript, please refer to the features of the language.
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
---
|
|
2
|
+
sidebar_position: 7
|
|
3
|
+
---
|
|
4
|
+
|
|
5
|
+
# Image fitting
|
|
6
|
+
|
|
7
|
+
The process of fitting images with multiple Gaussians can be done using code snippets.
|
|
8
|
+
|
|
9
|
+
The configuration for the fitting is accessible via <ApiLink path="/.-stores/class/ImageFittingStore">`ImageFittingStore`</ApiLink>. Example code:
|
|
10
|
+
|
|
11
|
+
```javascript
|
|
12
|
+
// Open an image
|
|
13
|
+
const file = await app.openFile("[filename]");
|
|
14
|
+
|
|
15
|
+
// Display the fitting widget
|
|
16
|
+
app.dialogStore.showFittingDialog();
|
|
17
|
+
|
|
18
|
+
// Clear previous inputs of initial values
|
|
19
|
+
app.imageFittingStore.clearComponents();
|
|
20
|
+
|
|
21
|
+
// Set initial values
|
|
22
|
+
app.imageFittingStore.setComponents(2);
|
|
23
|
+
|
|
24
|
+
const component1 = app.imageFittingStore.components[0];
|
|
25
|
+
component1.setCenterX(128);
|
|
26
|
+
component1.setCenterY(129);
|
|
27
|
+
component1.setAmplitude(0.01);
|
|
28
|
+
component1.setFwhmX(10);
|
|
29
|
+
component1.setFwhmY(6);
|
|
30
|
+
component1.setPa(36);
|
|
31
|
+
|
|
32
|
+
const component2 = app.imageFittingStore.components[1];
|
|
33
|
+
component2.setCenterX(135);
|
|
34
|
+
component2.setCenterY(135);
|
|
35
|
+
component2.setAmplitude(0.01);
|
|
36
|
+
component2.setFwhmX(4);
|
|
37
|
+
component2.setFwhmY(9);
|
|
38
|
+
component2.setPa(40);
|
|
39
|
+
|
|
40
|
+
// Fit the image
|
|
41
|
+
app.imageFittingStore.fitImage();
|
|
42
|
+
```
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
---
|
|
2
|
+
sidebar_position: 3
|
|
3
|
+
---
|
|
4
|
+
|
|
5
|
+
# Image properties
|
|
6
|
+
|
|
7
|
+
Actions for modifying various properties of the image. In the following examples, we assume that an image is loaded as
|
|
8
|
+
|
|
9
|
+
```javascript
|
|
10
|
+
const file = await app.openFile("my_image.fits");
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
## Changing field of view
|
|
14
|
+
|
|
15
|
+
The field of view can be adjusted using various functions within <ApiLink path="/.-stores/class/FrameStore">`FrameStore`</ApiLink>.
|
|
16
|
+
|
|
17
|
+
<ApiLink path="/.-stores/class/FrameStore/#setCenter">`setCenter`</ApiLink> and <ApiLink path="/.-stores/class/FrameStore/#setCenterWcs">`setCenterWcs`</ApiLink> set the center of the image.
|
|
18
|
+
|
|
19
|
+
```javascript
|
|
20
|
+
// image coordinate
|
|
21
|
+
file.setCenter([x position], [y position]);
|
|
22
|
+
|
|
23
|
+
// world coordinate
|
|
24
|
+
file.setCenterWcs("[x position, ex: 0:00:00.0615838925]", "[y position, ex: 29:59:59.1999990820]");
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
<ApiLink path="/.-stores/class/FrameStore/#fitZoom">`fitZoom`</ApiLink> zooms the image to fit the widget size.
|
|
28
|
+
|
|
29
|
+
```javascript
|
|
30
|
+
file.fitZoom();
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
<ApiLink path="/.-stores/class/FrameStore/#zoomToSizeX">`zoomToSize...`</ApiLink> functions zoom the image to a specific scale.
|
|
34
|
+
|
|
35
|
+
```javascript
|
|
36
|
+
// image coordinate
|
|
37
|
+
file.zoomToSizeX([size in x direction]);
|
|
38
|
+
file.zoomToSizeY([size in y direction]);
|
|
39
|
+
|
|
40
|
+
// world coordinate
|
|
41
|
+
file.zoomToSizeXWcs('[size in x direction, ex: 2.56"]');
|
|
42
|
+
file.zoomToSizeYWcs('[size in y direction, ex: 2.56"]');
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
## Changing the channel and Stokes
|
|
46
|
+
|
|
47
|
+
<ApiLink path="/.-stores/class/FrameStore/#setChannel">`setChannel`</ApiLink> changes the channel of the image.
|
|
48
|
+
|
|
49
|
+
```javascript
|
|
50
|
+
file.setChannel([channel]);
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
<ApiLink path="/.-stores/class/FrameStore/#setStokes">`setStokes`</ApiLink> and <ApiLink path="/.-stores/class/FrameStore/#setStokesByIndex">`setStokesByIndex`</ApiLink> change the stokes of the image using <ApiLink path="/.-models/enum/POLARIZATIONS">
|
|
54
|
+
`POLARIZATIONS`
|
|
55
|
+
</ApiLink> enum or the index.
|
|
56
|
+
|
|
57
|
+
```javascript
|
|
58
|
+
file.setStokes(2); // Stokes Q
|
|
59
|
+
file.setStokesByIndex(2); // The third polarization shown in the animator widget
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
## Changing render configuration
|
|
63
|
+
|
|
64
|
+
Render configuration can be modified using <ApiLink path="/.-stores/class/RenderConfigStore">`renderConfig`</ApiLink> within <ApiLink path="/.-stores/class/FrameStore">`FrameStore`</ApiLink>.
|
|
65
|
+
|
|
66
|
+
<ApiLink path="/.-stores/class/RenderConfigStore/#setCustomScale">`setCustomScale`</ApiLink> and <ApiLink path="/.-stores/class/RenderConfigStore/#setPercentileRank">`setPercentileRank`</ApiLink> change the rendering range.
|
|
67
|
+
|
|
68
|
+
```javascript
|
|
69
|
+
file.renderConfig.setCustomScale([clip min], [clip max]);
|
|
70
|
+
file.renderConfig.setPercentileRank(90); // Change to 90%
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
<ApiLink path="/.-stores/class/RenderConfigStore/#setScaling">`setScaling`</ApiLink> changes the scaling functions using <ApiLink path="/.-stores/enum/FrameScaling">`FrameScaling`</ApiLink> enum.
|
|
74
|
+
|
|
75
|
+
```javascript
|
|
76
|
+
file.renderConfig.setScaling(1); // Log
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
<ApiLink path="/.-stores/class/RenderConfigStore/#setColorMap">`setColorMap`</ApiLink> changes the color map using options in <ApiLink path="/.-stores/class/RenderConfigStore/#COLOR_MAPS_ALL">`COLOR_MAPS_ALL`</ApiLink> list, and <ApiLink path="/.-stores/class/RenderConfigStore/#setInverted">
|
|
80
|
+
`setInverted`
|
|
81
|
+
</ApiLink> inverts the color map.
|
|
82
|
+
|
|
83
|
+
```javascript
|
|
84
|
+
file.renderConfig.setColorMap("gray");
|
|
85
|
+
file.renderConfig.setInverted(true);
|
|
86
|
+
```
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
---
|
|
2
|
+
sidebar_position: 5
|
|
3
|
+
---
|
|
4
|
+
|
|
5
|
+
# Moment images
|
|
6
|
+
|
|
7
|
+
The process of generating moment images can be done using code snippets.
|
|
8
|
+
|
|
9
|
+
The configuration for the generator is accessible via <ApiLink path="/.-stores/class/SpectralProfileWidgetStore">`SpectralProfileWidgetStore`</ApiLink>. Available moment types (as enum) can be found [here](https://carta-protobuf.readthedocs.io/en/latest/enums.html#moment). Example code:
|
|
10
|
+
|
|
11
|
+
```javascript
|
|
12
|
+
// Open an image
|
|
13
|
+
const file = await app.openFile("[filename]");
|
|
14
|
+
|
|
15
|
+
// Create a spectral profile settings widget
|
|
16
|
+
app.widgetsStore.createFloatingSpectralProfilerWidget();
|
|
17
|
+
app.widgetsStore.createFloatingSettingsWidget("", "spectral-profiler-0", "spectral-profiler");
|
|
18
|
+
|
|
19
|
+
// Get the SpectralProfileWidgetStore object
|
|
20
|
+
const spectralProfileWidget = app.widgetsStore.spectralProfileWidgets.get("spectral-profiler-0");
|
|
21
|
+
|
|
22
|
+
// Navigate to the moments tab
|
|
23
|
+
spectralProfileWidget.setSettingsTabId(3);
|
|
24
|
+
|
|
25
|
+
// Modify the configuration using SpectralProfileWidgetStore
|
|
26
|
+
spectralProfileWidget.clearSelectedMoments(); // remove default: integrated value of the spectrum
|
|
27
|
+
spectralProfileWidget.selectMoment(0); // mean value of the spectrum
|
|
28
|
+
|
|
29
|
+
// Generate a moment image
|
|
30
|
+
spectralProfileWidget.requestMoment();
|
|
31
|
+
```
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
---
|
|
2
|
+
sidebar_position: 6
|
|
3
|
+
---
|
|
4
|
+
|
|
5
|
+
# PV images
|
|
6
|
+
|
|
7
|
+
The process of generating PV images can be done using code snippets.
|
|
8
|
+
|
|
9
|
+
The configuration for the generator is accessible via <ApiLink path="/.-stores/class/PvGeneratorWidgetStore">`PvGeneratorWidgetStore`</ApiLink>. Example code:
|
|
10
|
+
|
|
11
|
+
```javascript
|
|
12
|
+
// Open an image
|
|
13
|
+
const file = await app.openFile("[filename]");
|
|
14
|
+
|
|
15
|
+
// Create a line region
|
|
16
|
+
const region = await file.regionSet.addRegionAsync(1, [{x: [start x], y: [start y]}, {x: [end x], y: [end y]}]);
|
|
17
|
+
|
|
18
|
+
// Create a pv generator widget
|
|
19
|
+
app.widgetsStore.createFloatingPvGeneratorWidget();
|
|
20
|
+
|
|
21
|
+
// Get the PvGeneratorWidgetStore object
|
|
22
|
+
const pvGeneratorWidget = app.widgetsStore.pvGeneratorWidgets.get("pv-generator-0");
|
|
23
|
+
|
|
24
|
+
// Generate a pv image
|
|
25
|
+
pvGeneratorWidget.setFileId(file.frameInfo.fileId);
|
|
26
|
+
pvGeneratorWidget.setRegionId(file.frameInfo.fileId, region.regionId);
|
|
27
|
+
pvGeneratorWidget.requestPV();
|
|
28
|
+
```
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
---
|
|
2
|
+
sidebar_position: 1
|
|
3
|
+
---
|
|
4
|
+
|
|
5
|
+
# Quick start
|
|
6
|
+
|
|
7
|
+
## Enabling code snippets
|
|
8
|
+
|
|
9
|
+
The code snippet feature can be enabled via the preferences dialog:
|
|
10
|
+
|
|
11
|
+
<img src={require("../assets/enable-code-snippets.png").default} alt="Enable code snippets" width="500" />
|
|
12
|
+
|
|
13
|
+
Once the code snippet feature is enabled, the "Snippets" option appears in the menu. This allows you to create and run code snippets, providing additional functionality to CARTA.
|
|
14
|
+
|
|
15
|
+
## Loading images
|
|
16
|
+
|
|
17
|
+
CARTA functions and objects can be accessed via the top-level <ApiLink path="/.-stores/class/AppStore">`app`</ApiLink> object (or the <ApiLink path="/.-stores/class/AppStore">`carta`</ApiLink> alias). In the following example, we display the welcome splash screen for 1000 ms and then close it.
|
|
18
|
+
|
|
19
|
+
```javascript
|
|
20
|
+
carta.showSplashScreen();
|
|
21
|
+
await carta.delay(1000);
|
|
22
|
+
app.hideSplashScreen();
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
Images loaded in the frontend are referred as and registered in the <ApiLink path="/.-stores/class/AppStore/#frames">`frames`</ApiLink> array which contains each frame (i.e., image) as a <ApiLink path="/.-stores/class/FrameStore">`FrameStore`</ApiLink> object. The currently active frame is accessible with <ApiLink path="/.-stores/class/AppStore/#activeFrame">`activeFrame`</ApiLink>. In the following example, we firstly list the frames array, then list the 0th frame, and finally list the current active frame in the console.
|
|
26
|
+
|
|
27
|
+
```javascript
|
|
28
|
+
console.log(app.frames);
|
|
29
|
+
console.log(app.frames[0]);
|
|
30
|
+
console.log(app.activeFrame);
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
<ApiLink path="/.-stores/class/AppStore/#openFile">`openFile`</ApiLink> takes up to three arguments: directory, filename and HDU. If no HDU is provided, the first HDU ("0") is adopted. The directory and filename can also be combined into a single
|
|
34
|
+
argument. <ApiLink path="/.-stores/class/AppStore/#openFile">`openFile`</ApiLink> must be called with `await`, as it is an asynchronous function that requires communicating with the backend. In the following example, in the end we will see that
|
|
35
|
+
only the last image is loaded as each <ApiLink path="/.-stores/class/AppStore/#openFile">`openFile`</ApiLink> will close all loaded image first before loading the target image.
|
|
36
|
+
|
|
37
|
+
```javascript
|
|
38
|
+
await app.openFile("test_directory", "testfile.fits", "0");
|
|
39
|
+
await app.openFile("test_directory", "testfile.fits");
|
|
40
|
+
await app.openFile("test_directory/testfile.fits");
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
Additional images can be appended using <ApiLink path="/.-stores/class/AppStore/#appendFile">`appendFile`</ApiLink>. The arguments are the same as <ApiLink path="/.-stores/class/AppStore/#openFile">`openFile`</ApiLink>. In the following example, in the end there will be three images loaded.
|
|
44
|
+
|
|
45
|
+
```javascript
|
|
46
|
+
const file1 = await app.openFile("testfile1.fits");
|
|
47
|
+
const file2 = await app.appendFile("testfile2.fits");
|
|
48
|
+
const file3 = await app.appendFile("testfile3.fits");
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
The active image can be changed with <ApiLink path="/.-stores/class/AppStore/#setActiveFrame">`setActiveFrame`</ApiLink>, as well as the wrapper functions <ApiLink path="/.-stores/class/AppStore/#setActiveFrameById">`setActiveFrameById`</ApiLink> and <ApiLink path="/.-stores/class/AppStore/#setActiveFrameByIndex">`setActiveFrameByIndex`</ApiLink>.
|
|
52
|
+
|
|
53
|
+
```javascript
|
|
54
|
+
app.setActiveFrameByIndex(0);
|
|
55
|
+
app.setActiveFrameById(file2.frameInfo.fileId);
|
|
56
|
+
app.setActiveFrame(file3);
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
## Closing images
|
|
60
|
+
|
|
61
|
+
<ApiLink path="/.-stores/class/AppStore/#closeCurrentFile">`closeCurrentFile`</ApiLink> closes the active image. There will be no user confirmation if the active image serves as the spatial reference image and there are other images matched
|
|
62
|
+
to it.
|
|
63
|
+
|
|
64
|
+
```javascript
|
|
65
|
+
app.closeCurrentFile();
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
<ApiLink path="/.-stores/class/AppStore/#closeFile">`closeFile`</ApiLink> takes an optional boolean argument to control whether user confirmation is required if other images are matched to the given file. This defaults to true. `await` is required
|
|
69
|
+
to delay execution until the user confirms.
|
|
70
|
+
|
|
71
|
+
```javascript
|
|
72
|
+
await app.closeFile(file1);
|
|
73
|
+
app.closeFile(file1, false); // No user confirmation
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
<ApiLink path="/.-stores/class/AppStore/#closeOtherFiles">`closeOtherFiles`</ApiLink> closes all images other than the given file.
|
|
77
|
+
|
|
78
|
+
```javascript
|
|
79
|
+
app.closeOtherFiles(file2);
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
For all functions and objects available in the <ApiLink path="/.-stores/class/AppStore">`app`</ApiLink> object, please refer to the <ApiLink path="/.-stores/class/AppStore">API documentation</ApiLink>.
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
---
|
|
2
|
+
sidebar_position: 4
|
|
3
|
+
---
|
|
4
|
+
|
|
5
|
+
import Link from "@docusaurus/Link";
|
|
6
|
+
|
|
7
|
+
# Regions
|
|
8
|
+
|
|
9
|
+
Actions related to regions. In the following examples, we assume that an image is loaded as
|
|
10
|
+
|
|
11
|
+
```javascript
|
|
12
|
+
const file = await app.openFile("my_image.fits");
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
## Creating regions
|
|
16
|
+
|
|
17
|
+
Regions on a specific image are accessible via <ApiLink path="/.-stores/class/RegionSetStore">`RegionSetStore`</ApiLink> under each image. Each region is represented by a <ApiLink path="/.-stores/class/RegionStore">`RegionStore`</ApiLink> object.
|
|
18
|
+
|
|
19
|
+
```javascript
|
|
20
|
+
console.log(file.regionSet.regions); // View all regions
|
|
21
|
+
console.log(file.regionSet.selectedRegion); // View the selected region
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
<ApiLink path="/.-stores/class/RegionSetStore/#addRegionAsync">`addRegionAsync`</ApiLink> creates regions on the loaded image with available [region types](https://carta-protobuf.readthedocs.io/en/latest/enums.html#regiontype).
|
|
25
|
+
|
|
26
|
+
```javascript
|
|
27
|
+
const regionSet = file.regionSet;
|
|
28
|
+
const region = await regionSet.addRegionAsync(3, [{x: [center x], y: [center y]}, {x: [width], y: [height]}]); // Add a rectangle region
|
|
29
|
+
const region2 = await regionSet.addRegionAsync(1, [{x: [start x], y: [start y]}, {x: [end x], y: [end y]}]); // Add a line region
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
## Changing region properties
|
|
33
|
+
|
|
34
|
+
Properties of a region can be modified using the <ApiLink path="/.-stores/class/RegionStore">`RegionStore`</ApiLink> object.
|
|
35
|
+
|
|
36
|
+
```javascript
|
|
37
|
+
// ex: a rectangle region
|
|
38
|
+
region.setCenter({x: 0, y: 0}); // Move the region to position (0, 0)
|
|
39
|
+
region.setSize({x: 100, y: 100}); // Resize to 100 x 100 pixels
|
|
40
|
+
region.setColor("#ffffff"); // Change the color to white
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
## Importing regions
|
|
44
|
+
|
|
45
|
+
<ApiLink path="/.-stores/class/AppStore/#importRegion">`importRegion`</ApiLink> imports regions to the active image with the provided path, filename, and [file type](https://carta-protobuf.readthedocs.io/en/latest/enums.html#filetype) enum.
|
|
46
|
+
|
|
47
|
+
```javascript
|
|
48
|
+
await app.importRegion("[path]", "[filename]", 1); // File type: CRTF
|
|
49
|
+
```
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
---
|
|
2
|
+
sidebar_position: 1
|
|
3
|
+
---
|
|
4
|
+
|
|
5
|
+
# Developer tips
|
|
6
|
+
|
|
7
|
+
Useful commands for development.
|
|
8
|
+
|
|
9
|
+
## Checking and fixing code format
|
|
10
|
+
|
|
11
|
+
To check the code format:
|
|
12
|
+
|
|
13
|
+
```
|
|
14
|
+
npm run checkformat
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
To automatically fix the code format:
|
|
18
|
+
|
|
19
|
+
```
|
|
20
|
+
npm run reformat
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
## Code linting
|
|
24
|
+
|
|
25
|
+
ESLint is applied to identify program errors and to check for the format of imported packages and TSDoc documentation.
|
|
26
|
+
To run the lint checks:
|
|
27
|
+
|
|
28
|
+
```
|
|
29
|
+
npm run check-eslint
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
To automatically fix the identified errors, particularly those related to import package formats:
|
|
33
|
+
|
|
34
|
+
```
|
|
35
|
+
npm run fix-eslint
|
|
36
|
+
```
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
---
|
|
2
|
+
sidebar_position: 4
|
|
3
|
+
---
|
|
4
|
+
|
|
5
|
+
# Documentation guidelines
|
|
6
|
+
|
|
7
|
+
Guidelines for building and writing this website.
|
|
8
|
+
|
|
9
|
+
## Building documentation
|
|
10
|
+
|
|
11
|
+
The website is hosted on GitHub Pages, and whenever the `dev` branch is updated, the website is automatically updated using GitHub Actions.
|
|
12
|
+
|
|
13
|
+
To build and test the website locally, navigate to the `docs_website/` directory and install package dependencies:
|
|
14
|
+
|
|
15
|
+
```
|
|
16
|
+
cd docs_website
|
|
17
|
+
npm install
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
and run the development server:
|
|
21
|
+
|
|
22
|
+
```
|
|
23
|
+
npm start
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
If you make changes to the files in the `docs/` and `api/` folders, the site will automatically reload and display the changes.
|
|
27
|
+
|
|
28
|
+
To create a local production build:
|
|
29
|
+
|
|
30
|
+
```
|
|
31
|
+
npm run build
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
To test the local production build:
|
|
35
|
+
|
|
36
|
+
```
|
|
37
|
+
npm run serve
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
Please note that the search feature is only available in production builds.
|
|
41
|
+
|
|
42
|
+
## Writing documentation pages
|
|
43
|
+
|
|
44
|
+
The "Docs" pages and the "API/Overview" page are generated from markdown files in the `docs/` and `api/` directories. Simply edit these directories to modify the content or add new pages.
|
|
45
|
+
|
|
46
|
+
For links to the "Docs" index pages and "API" subpages, it is required to use the `DocsIndexLink` and `ApiLink` MDX components to ensure the corresponding version is linked. If the file contains MDX components, it is recommended to use the `.mdx` extension.
|
|
47
|
+
|
|
48
|
+
### Formatting
|
|
49
|
+
|
|
50
|
+
To check the format of the changes, run (from the `docs_website/` folder):
|
|
51
|
+
|
|
52
|
+
```
|
|
53
|
+
npm run checkformat
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
To automatically fix the format:
|
|
57
|
+
|
|
58
|
+
```
|
|
59
|
+
npm run reformat
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
This maintains consistent markdown styling, including indentation, maximum line length, and list numbering. Please refer to the [Prettier documentation](https://prettier.io/blog/2017/11/07/1.8.0.html#markdown-support) for more information.
|
|
63
|
+
|
|
64
|
+
## Writing API documentation
|
|
65
|
+
|
|
66
|
+
The "API" subpages are generated from TSDoc documentation in the codebase. Catalogs are created based on the `index.ts` files, and elements need to be exported in the respective `index.ts` file to appear on the catalog subpages. Private and projected elements are not displayed.
|
|
67
|
+
|
|
68
|
+
Please note that the development server does not automatically re-parse TSDoc. Therefore, if you modify TSDoc in the codebase, you will need to rebuild it to display the changes.
|
|
69
|
+
|
|
70
|
+
### Formatting
|
|
71
|
+
|
|
72
|
+
For TSDoc format, please refer to the [TSDoc documentation](https://tsdoc.org). ESLint is applied to check for the required format. To run the lint checks (from the repository root):
|
|
73
|
+
|
|
74
|
+
```
|
|
75
|
+
npm run check-eslint
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
## Versioning
|
|
79
|
+
|
|
80
|
+
To tag a new version, run (from the `docs_website/` folder):
|
|
81
|
+
|
|
82
|
+
```
|
|
83
|
+
npm run docusaurus docs:version 1.2.3
|
|
84
|
+
npm run docusaurus api:version 1.2.3
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
This will append the new version to `versions.json` and create files in the `versioned_docs/` and `versioned_sidebars/` folders. To modify the content or add new pages for a specific version, edit the files in these folders.
|