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

Customizable RTC with Sentinel-1 #285

Open
Ahleroy opened this issue Nov 9, 2023 · 2 comments
Open

Customizable RTC with Sentinel-1 #285

Ahleroy opened this issue Nov 9, 2023 · 2 comments

Comments

@Ahleroy
Copy link

Ahleroy commented Nov 9, 2023

Following the Customisable RTC tutorial with Sentinel-1, I am facing this issue when it comes to using sarsen v0.9.3:

TypeError                                 Traceback (most recent call last)
Cell 18 line 1
----> gtc = apps.terrain_correction(
   product_urlpath=grd_local_path,
    measurement_group=measurement_group,
dem_urlpath=dem_path,
output_urlpath=os.path.join(
       tmp_dir, os.path.basename(product_folder) + ".10m.GTC.tif"
    ),
 )

TypeError: terrain_correction() got an unexpected keyword argument 'product_urlpath'

This happens when running In 13 of the tutorial which corresponds to the following piece of code:

gtc = apps.terrain_correction(
    product_urlpath=grd_local_path,
    measurement_group=measurement_group,
    dem_urlpath=dem_path,
    output_urlpath=os.path.join(
        tmp_dir, os.path.basename(product_folder) + ".10m.GTC.tif"
    ),
)

Looking at the sarsen API, it seems it has changed since the tutorial was made. However, I do not see any equivalent to how to use the new API.

@Ahleroy
Copy link
Author

Ahleroy commented Nov 9, 2023

Digging into sensar's repository, I was able to found a workaround :

import json

def gtc(
    product_urlpath: str,
    measurement_group: str,
    dem_urlpath: str,
    output_urlpath: str = "GTC.tif",
    enable_dask_distributed: bool = False,
    client_kwargs_json: str = '{"processes": false}',
    chunks: int = 1024,
) -> None:
    """Generate a geometrically terrain corrected (GTC) image from Sentinel-1 product."""
    client_kwargs = json.loads(client_kwargs_json)
    real_chunks = chunks if chunks > 0 else None
    product = sarsen.sentinel1.Sentinel1SarProduct(
        product_urlpath,
        measurement_group,
    )
    return apps.terrain_correction(
        product,
        dem_urlpath,
        output_urlpath=output_urlpath,
        enable_dask_distributed=enable_dask_distributed,
        client_kwargs=client_kwargs,
        chunks=real_chunks,
    )
gtc = gtc(
    grd_local_path,
    measurement_group=measurement_group,
    dem_urlpath=dem_path,
    output_urlpath=os.path.join(
        tmp_dir, os.path.basename(product_folder) + ".10m.GTC.tif"
    ),
)

@TomAugspurger
Copy link

Thanks for the report. cc @alexamici, is that the recommended way to handle the product_urlpath change?

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

No branches or pull requests

2 participants