ec-jrc / Thalassa

Large scale visualizations of unstructured mesh data
https://thalassa.readthedocs.io/en/latest/?badge=latest
European Union Public License 1.2
20 stars 15 forks source link

Polygon-Based Data Cropping #87

Open AtiehAlipour-NOAA opened 5 months ago

AtiehAlipour-NOAA commented 5 months ago

Hi, I have a question: do we need to adjust this part of the code to use a polygon like the one below for cropping the data? Thanks!

polygon = array ([[271.09419606, 30.29241252], [270.80483714, 30.47217758], [270.31435613, 30.35380055], [269.89991289, 30.0740687 ], [269.9734827 , 29.72115943], [270.38302128, 29.34776829], [270.5129946 , 28.86997287], [270.96177041, 28.87641531], [271.38357063, 29.16376929], [271.45468811, 29.68281716], [271.68765915, 29.83609834], [271.65087425, 29.96790232], [271.09419606, 30.29241252]])

pmav99 commented 5 months ago

You will need to update the implementation too. As it is it will only work with rectangular regions. For a polygon you will need to use some shapely method like https://shapely.readthedocs.io/en/stable/reference/shapely.contains.html or geopandas sjoin: https://geopandas.org/en/stable/docs/reference/api/geopandas.sjoin.html.

And you will need to check performance for large meshes. The pure numpy implementation we have here is probably faster than the alternatives. Nevertheless, try to get something working and if performance proves to be problematic you can investigate making it faster afterwards (e.g. leverage numba or something).

josephzhang8 commented 5 months ago

I cannot find Searvey anymroe; anyone? Thx.

AtiehAlipour-NOAA commented 5 months ago

You will need to update the implementation too. As it is it will only work with rectangular regions. For a polygon you will need to use some shapely method like https://shapely.readthedocs.io/en/stable/reference/shapely.contains.html or geopandas sjoin: https://geopandas.org/en/stable/docs/reference/api/geopandas.sjoin.html.

And you will need to check performance for large meshes. The pure numpy implementation we have here is probably faster than the alternatives. Nevertheless, try to get something working and if performance proves to be problematic you can investigate making it faster afterwards (e.g. leverage numba or something).

Thanks for the quick response and the detailed explanation. For now, I am using a rectangle region but I wanted to confirm if there's a possibility to switch to a polygon later on. Thanks once again.

AtiehAlipour-NOAA commented 5 months ago

I cannot find Searvey anymroe; anyone? Thx.

Hi, please check here: https://github.com/oceanmodeling/searvey

josephzhang8 commented 5 months ago

Thx, Atieh!

pmav99 commented 3 months ago

https://github.com/asascience-open/xarray-subset-grid