Open keflavich opened 1 year ago
I'm not entirely sure what you mean by that. Could you provide some pseudocode or an example where the snippet would fit into a workflow?
const handle = await app.openFile("file1.fits");
# now I want to load a region file
const handle2 = await app.appendFile("file2.fits")
# now I want to match the colorbar & stretch (the "raster" settings) to file 1
# and I still want the regions available (but that should be the default)
From tab completion in the console, I see:
app.setRasterScalingMatchingEnabled()
which I see also here: https://github.com/CARTAvis/carta-frontend/issues/2004
so what I want can be done partly with:
for (const frame of app.frames) {
app.setRasterScalingMatchingEnabled(frame, true);
}
and maybe I can do...
for (const frame of app.frames) {
frame.renderConfig.setScaling("Log");
}
I'm trying to back out how to do this by reading the source code... so I might have it wrong, but I think sharing my notes here may be useful
Solution:
for (const frame of app.frames) {
app.setRasterScalingMatchingEnabled(frame, true);
frame.renderConfig.setScaling(1);
frame.renderConfig.setCustomScale(-5, 100);
}
await app.importRegion('jwst/brick/regions', 'manual_destar_right_405.reg', 2);
The scaling constants have to be numbers from https://github.com/CARTAvis/carta-frontend/blob/0be037f58fa23b0643495fb71480188c6b522765/src/stores/Frame/RenderConfigStore.ts#L7-L16
The "load regions" part comes from https://github.com/CARTAvis/carta-frontend/issues/1556#issuecomment-1012428721
@keflavich can we close this? I've made a new discussion category for code snippets: https://github.com/CARTAvis/carta/discussions/categories/code-snippets
Perhaps you can add this there?
Yes, go ahead and close now that this discussion: https://github.com/CARTAvis/carta/discussions/168 exists
I need to repeatedly re-open files that I want to have color-matched, and I want to load regions superposed on them. Can I do that with the snippet interface?