CARTAvis / carta

To CARTA users, this repo holds the CARTA release packages. Please use this repo to log bugs and feature requests. These will be triaged by the development team and prioritised as necessary in the development cycles.
19 stars 0 forks source link

Question: Scripted interface - load regions, set colorscale? #166

Open keflavich opened 1 year ago

keflavich commented 1 year ago

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?

veggiesaurus commented 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?

keflavich commented 1 year ago
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)
keflavich commented 1 year ago

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

keflavich commented 1 year ago

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

keflavich commented 1 year ago

The "load regions" part comes from https://github.com/CARTAvis/carta-frontend/issues/1556#issuecomment-1012428721

veggiesaurus commented 1 year ago

@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?

keflavich commented 1 year ago

Yes, go ahead and close now that this discussion: https://github.com/CARTAvis/carta/discussions/168 exists