Skip to content

Commit

Permalink
feat: review advanced light-flat matching (and logs)
Browse files Browse the repository at this point in the history
  • Loading branch information
TomyCesaille committed Jan 10, 2025
1 parent 3dabf2d commit e252a6a
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 12 deletions.
1 change: 1 addition & 0 deletions .github/pull_request_template.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ Closes # (issue)
- [ ] Chore
- [ ] Bug fix
- [ ] New feature
- [ ] Feature change
- [ ] Breaking change
- [ ] Documentation update

Expand Down
63 changes: 51 additions & 12 deletions src/commands/prepare.ts
Original file line number Diff line number Diff line change
Expand Up @@ -253,8 +253,13 @@ const getFlatsMatchingLightsNaive = (
for (const skip of [...new Set(notMatchedFlats)]) {
logger.warning(skip);
}

const sequencesLightsCount = [
...new Set(matchingFlats.map(file => file.sequenceId)),
].length;

logger.info(
`Found ${matchingFlats.length} matching flats (${sequences.length} sequences).`,
`Pre-selected ${matchingFlats.length} flats (${sequences.length} sequences) that matches with ${lights.length} lights (${sequencesLightsCount} sequences).`,
);

return matchingFlats;
Expand All @@ -276,11 +281,22 @@ const matchLightsToFlats = async (

const LightFlatMatches: LightsFlatsMatch[] = [];

let introManualMatchingDisplayed = false;

// TODO. Review the archi overall. We should walk light by light instead of flat by flat. This will be easier to discover and setup the project.
for (const flatSet of flatSets) {
const flatSetSpecs = getImageSpecFromSetName(flatSet);

// Search for sequences that are similar.
const flatSetNameSequenceIds = [
...new Set(
matchingFlats
.filter(flat => flat.setName === flatSet)
.filter(
flat =>
// https://pixinsight.com/forum/index.php?threads/can-flats-be-different-iso-than-lights.23686/
flat.bin === flatSetSpecs.bin &&
flat.filter === flatSetSpecs.filter,
)
.map(flat => `${flat.setName}__${flat.sequenceId}`),
),
];
Expand All @@ -292,7 +308,7 @@ const matchLightsToFlats = async (
// Auto match the flat to the light. Nothing to ask from the user.
const flatSetNameSequenceId = flatSetNameSequenceIds[0];
const matchingLights = lights.filter(light =>
matchSetFile(light, getImageSpecFromSetName(flatSet)),
matchSetFile(light, flatSetSpecs),
);
const matchingLightSetNameSequenceIds = [
...new Set(
Expand All @@ -314,16 +330,30 @@ const matchLightsToFlats = async (
continue;
}

logger.info(`🤚 Several sequences found for flat set ${flatSet}:`);
logger.info(
`${flatSetNameSequenceIds.map(x => `- ${x.split("__")[1]}`).join("\n")}`,
);
logger.debug(
"We assume that multiple sequences of the same flat set indicate multiple night sessions where the flats had to be re-shot in between (e.g., a significant date gap between shooting sessions and the lights were not collected with the same collimation and/or same dust in the optical train).",
);
if (introManualMatchingDisplayed) {
logger.space();
}

logger.info(
"We will ask you to tag each concerned light sequence to the right flat sequence.",
`🤚 Several sequences of flats are compatible with ${
flatSetSpecs.filter
? `${flatSetSpecs.bin} Filter ${flatSetSpecs.filter}`
: flatSetSpecs.bin
}:`,
);
if (!introManualMatchingDisplayed) {
logger.info(`${flatSetNameSequenceIds.map(x => `- ${x}`).join("\n")}`);

logger.debug(
"We assume that multiple sequences of the same flat kind indicate multiple night sessions where the flats had to be re-shot in between (e.g., a significant date gap between shooting sessions and the lights were not collected with the same collimation and/or same dust in the optical train).",
);
logger.debug(
"We will ask you to tag each concerned light sequence to the right flat sequence (this disclaimer won't be displayed again 🤓).",
);
introManualMatchingDisplayed = true;
}

logger.space();

const lightsConcerned = [
...new Set(
Expand All @@ -343,6 +373,15 @@ const matchLightsToFlats = async (
];

for (const lightConcerned of lightsConcerned) {
if (
LightFlatMatches.map(
x => `${x.lightSetName}__${x.lightSequenceId}`,
).includes(lightConcerned)
) {
// Skip if the light sequence has already been matched to a flat sequence.
continue;
}

const lightConcernedSetName = lightConcerned.split("__")[0];
const lightConcernedSequenceId = lightConcerned.split("__")[1];

Expand All @@ -354,7 +393,7 @@ const matchLightsToFlats = async (
),
choices: flatSetNameSequenceIds.map(x => ({
name: x,
message: formatMessage(x.replace("__", " ")),
message: formatMessage(x.replace("__", " ")), // TODO. Print sequence length.
})),
})) as { selectedFlatSequence: string };

Expand Down

0 comments on commit e252a6a

Please sign in to comment.