[go: up one dir, main page]

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

Feat/use titiler cmr #1131

Merged
merged 14 commits into from
Sep 12, 2024
Merged

Feat/use titiler cmr #1131

merged 14 commits into from
Sep 12, 2024

Conversation

abarciauskas-bgse
Copy link
Contributor
@abarciauskas-bgse abarciauskas-bgse commented Aug 28, 2024

Related Ticket: #1056

Description of Changes

This change was actually relatively straightforward. Titiler-cmr handles the business of searching CMR for which assets to tile, which means that logic no longer needs to exist in veda-ui. We can just pass the concept id and other parameters directly to titiler-cmr. The asset discovery logic was happening in the useCmr hook which searched CMR STAC endpoints (endpoints plural because there are different catalogues for different DAACs) for data. This was especially messy given the S3 urls are not in the CMR STAC item representations, so we had to replace an https protocol and host with the S3 protocol and bucket name.

Itemized changes:

  • Remove useCmr hook
  • Change parameterization to RasterPaintLayer to make the url optional: titiler-xarray requires a url parameter, whereas titiler-cmr does not.
  • Removed TRMM layer as this dataset is not yet in VEDA STAC (necessary to be included in the dashboard)

Notes

  • dev-titiler-xarray.delta-backend.com uses datetime which is consistent with titiler-cmr, however this change has not yet been deployed to prod-titiler-xarray.delta-backend.com.

Validation / Testing

Loaded and toggled both layers in the deploy preview

Copy link
netlify bot commented Aug 28, 2024

Deploy Preview for veda-ui ready!

Name Link
🔨 Latest commit 7d884b6
🔍 Latest deploy log https://app.netlify.com/sites/veda-ui/deploys/66d2470a7d33be0008fab32b
😎 Deploy Preview https://deploy-preview-1131--veda-ui.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@hanbyul-here
Copy link
Collaborator

Yay~ thanks for the great work. I have some questions about titiler parameters for these datasets!

While resolving the conflict, I noticed that rescale values for both zarr and cmr are configured as string, not as an array. (ex. GPM IMERG rescale: 0,46) . When I check renders attribute from the stac endpoint: https://staging.openveda.cloud/api/stac/collections/GPM_3IMERGDF it returns the scale value as an array of array. So, I tried to change the configuration to use an array for rescale values, but I can't seem to get the tiles loaded with an error that "detail": "could not convert string to float: '[[0'". (https://dev-titiler-cmr.delta-backend.com/tiles/WebMercatorQuad/1/0/0@1x?datetime=2024-08-30T04%3A00%3A00.000Z&resampling=bilinear&variable=precipitation&colormap_name=gnbu&rescale=%5B%5B0,46%5D%5D&concept_id=C2723754864-GES_DISC&backend=xarray)

We recently started using renders attributes from renders extensions and assumed that all the datasets would have rescale values as an array of arrays. Is the expectation different for Zarr and CMR datasets? We can work around it, but I would like to confirm the different expectations for different datasets!

const tileParams = qs.stringify({
url: assetUrl,
time_slice: date,
...(assetUrl && { url: assetUrl }), // Only include `url` if `assetUrl` is truthy (not null or undefined)
Copy link
Collaborator

Choose a reason for hiding this comment

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

🤔 I wonder if it is best if the raster-paint-layer doesn't need to care about the specifics of the layer- How about we move this logic to Zarr-time-series?
I picture something like the below in zarr-timeseries layer

  const zarrSourceParams = { ...sourceParams, assetUrl};
 return <RasterPaintLayer {...props} sourceParams={zarrSourceParams} />;

Copy link
Contributor Author
@abarciauskas-bgse abarciauskas-bgse Aug 30, 2024

Choose a reason for hiding this comment

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

yes I had something similar to that at one point actually, so happy to make this change. I had all tileParams in the data-type specific layer, so I'll push that change. I think I prefer tileParams to sourceParams since sourceParams can be kept as the static params (the same for all time steps) where as tileParams can include assetUrl and date, which can change whenever the selected date time changes.

@@ -29,7 +29,7 @@ export function RasterPaintLayer(props: RasterPaintLayerProps) {

const { updateStyle } = useMapStyle();
const [minZoom] = zoomExtent ?? [0, 20];
const generatorId = `zarr-timeseries-${id}`;
const generatorId = `raster-timeseries-${id}`;
Copy link
Collaborator

Choose a reason for hiding this comment

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

a nitpick, but it might make sense to let each parent layer pass the generatorPrefix to keep the original way of signaling which layer is which through generator Id

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yes that makes sense and I made that change here: aa6e9b8. I don't fully understand how the generatorId is used however so I can't really test it (other than it doesn't seem to break anything). Could you advise me on if there is a way to manually test that the generatorId is being set? And how is it being used out of curiosity?

Copy link
Collaborator

Choose a reason for hiding this comment

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

As far as I understand, generator Id is used to uniquely identify the layers for mapboxgl. (but the entire generator id is also suffixed by layer-id - which should be unique - so it will be only useful if there are layers with the same ID but with different data types) And it might come handy if I face a messy situation ex. I have to check layer IDs on the dashboard? It is there for more of a practice rather than actual use at this point.

@abarciauskas-bgse
Copy link
Contributor Author

@hanbyul-here thanks for reviewing!

In response to #1131 (comment), you are right that in the dataset MDX files I am passing the rescale value for the rescale parameter as a string, not as an array. That is because the tile API, for titiler-xarray (zarr), titiler-cmr (cmr), and VEDA titiler accept the rescale parameter as a comma-delimited string, not an array of arrays. Looking at the titiler changelog and the [documentation] it looks like the API expects multiple rescale parameters for multiple bands, e.g. rescale=0,1000&rescale=0,1000&rescale=0,1000

So I would expect, in the case that we are using data from the STAC renders extension to set tiling parameters, that we need to breakdown the array of arrays into separate rescale parameters. Can you point me to where the parameters are being set by the renders extension?

A valid question though is should my code also be using the renders extension (at least, when it exists and is not set in the MDX file which would override the defaults set in STAC metadata) to set these tiling parameters 🤔 . I think it should so I could open a new issue for that!

@hanbyul-here
Copy link
Collaborator

Ah, I misunderstood in a way that renders extensions format === titiler inputs. You are right that it was about formatting query aprameters - I opened a pr for it : #1140 Thanks for spotting !! 🙇

re: using render extension - All the datasets are being reconciled with STAC data before reaching layers already! (The reconciled data includes render params - but we are giving priority to the input from configuration file. We fall back to render params only when the configuration for sourceParams is missing - we will gradually deprecate manual configuration ! )

@abarciauskas-bgse
Copy link
Contributor Author

@hanbyul-here I'm taking a look at #1140 I was confused at first because I didn't notice it was a PR to this branch and includes a bit of history we don't have here. I'm not sure why yet but I'll look into it.

This 1. resolves the conflict with main branch, 2. clarifies how to
format values in an array (we might need to revisit this if we want to
support multiple values for rescale, but this is at least the coherent
behavior with other layers) 3. edits the rescale value for zarr and cmr
dataset for consistency
@abarciauskas-bgse
Copy link
Contributor Author

@hanbyul-here ok I believe the reason I was seeing so many commits was because you had merged main into feat/use-titiler-cmr and some conflicts needed to be resolved against my changes. I had to add the arrayFormat: "comma" argument to qs.stringify and now things are working nicely. Let me know what you think.

@abarciauskas-bgse
Copy link
Contributor Author

@hanbyul-here do you have any other feedback or is this good to merge?

Copy link
Collaborator
@hanbyul-here hanbyul-here left a comment

Choose a reason for hiding this comment

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

Apologies that it took some time to review this PR. Thanks for working on it 🙇

@abarciauskas-bgse abarciauskas-bgse merged commit fe91ed7 into main Sep 12, 2024
8 checks passed
@abarciauskas-bgse abarciauskas-bgse deleted the feat/use-titiler-cmr branch September 12, 2024 20:31
sandrahoang686 added a commit that referenced this pull request Sep 25, 2024
## 🎉 Features
- [E&A] Implement colormap configurability
#1117
- [E&A] Feature flag colormap configurability
#1147
- Add font md size as 20px for new Design System
#1125
## 🚀 Improvements
- [E&A] Return default value of colormap along with other settings
#1128
- Create new raster paint layer module and factor out
BaseTimeseriesProps #1105
- Consolidate a place where to check linkProps
#1121
#1160
- Expose Data Catalog and update child components to pass in routing/nav
for library build #1096
#1159
- Set up eslint rule for no trailing spaces
#1146
- Replace cmr-stac with titiler-cmr
#1131
## 🐛 Fixes
- Update external link in top navigation target
#1145
- Update PageHeader/Nav to not throw
#1149
- [E&A] Fix to convert the time to usertzdate
#1151
- Use sourceparams as it is when it is there
#1148
- Fix compare label on block map
#1153
- Discard the previous sourceExclusive value to fix the case when the
datasets with different sourceExclusive can be selected together
#1161
- Show the name of the selected filter on story hub
#1161
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.

2 participants