Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add LST Backward Average script #333

Merged

Conversation

AmberMulder
Copy link
Contributor

Add documentation and evalscripts on computation of Land Surface Temperature Backward Average.

@AmberMulder AmberMulder marked this pull request as draft November 4, 2024 13:30
@AmberMulder AmberMulder changed the title Draft: Add LST Backward Average script Add LST Backward Average script Nov 4, 2024
@AmberMulder AmberMulder marked this pull request as ready for review November 4, 2024 13:54
@AmberMulder
Copy link
Contributor Author

@jonasViehweger Can you please review?

Copy link
Contributor

@jonasViehweger jonasViehweger left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One question about the calculationDate, mainly why this is done in the script and not through setting the process API request to a different end date.

Other than that looks good!

const date = "2022-12-31"; // The date for which the backward average is calculated
const nDays = 20; // The number of days to load data for
const scaleFactor = 100; // The scale factor for the SWC values
const defaultVis = true; // If true, the default visualization will be applied. If false, the color_min and color_max values will be used.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here it's the same as for SWC, we can now set the min/max directly in the ColorRamp, so no need to do it ourselves.

Suggested change
const defaultVis = true; // If true, the default visualization will be applied. If false, the color_min and color_max values will be used.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Initially I did not add this to be able to have a defaultVis just like the other LST custom script examples. But I agree it would be better to immediately include the update in the ColorRampVisualizer initialization. Therefore, I have updated it.

Comment on lines 82 to 94
function updateCMap(min, max) {
const numIntervals = cmap.length;
const intervalLength = (max - min) / (numIntervals - 1);
for (let i = 0; i < numIntervals; i++) {
cmap[i][0] = min + intervalLength * i;
}
}

// Update the min max of color bar if defaultVis set to false
if (!defaultVis) updateCMap(color_min, color_max);

// Initialize the ColorRamp
const visualizer = new ColorRampVisualizer(cmap);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
function updateCMap(min, max) {
const numIntervals = cmap.length;
const intervalLength = (max - min) / (numIntervals - 1);
for (let i = 0; i < numIntervals; i++) {
cmap[i][0] = min + intervalLength * i;
}
}
// Update the min max of color bar if defaultVis set to false
if (!defaultVis) updateCMap(color_min, color_max);
// Initialize the ColorRamp
const visualizer = new ColorRampVisualizer(cmap);
// Initialize the ColorRamp
const visualizer = new ColorRampVisualizer(cmap, color_min, color_max);

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See comment above. Updated.

@AmberMulder
Copy link
Contributor Author

@jonasViehweger Thanks for the review, I have added the changes!

@jonasViehweger jonasViehweger merged commit 59d4b9d into sentinel-hub:main Nov 5, 2024
charliemoriarty pushed a commit to charliemoriarty/custom-scripts that referenced this pull request Nov 7, 2024
* Initial setup LST Backwar Average scripts and docs

* Create and update color ramp in one command

---------

Co-authored-by: Amber Mulder <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants