unstructured grids
See original GitHub issueI tried regionmask
on unstructured grids and it works with a tweak: https://gist.github.com/aaronspring/1b45cf22f80360ddc4ef13af1cadec63
Unstructured grids like ICON just have one spatial dimension like ncells
and 2 spatial coordinates clon
and clat
.
To avoid:
/work/mh0727/m300524/conda-envs/pymistral/lib/python3.8/site-packages/regionmask/core/mask.py in _get_LON_LAT_out_shape(lon, lat, fill)
467
468 if ndim == 1:
--> 469 LON, LAT = np.meshgrid(lon, lat)
470 elif ndim == 2:
471 LON, LAT = lon, lat
and use L470 instead, I add a fake dimension dummy
:
ds = ds.assign_coords(clon=ds.coords['clon'].expand_dims('dummy'))
ds = ds.assign_coords(clat=ds.coords['clat'].expand_dims('dummy'))
To identify unstructured grids, we could maybe use the metadata CDI_grid_type
from the xr.DataArrays
variables:
ds[v].attrs
{'standard_name': 'sea_water_potential_temperature',
'long_name': 'sea water potential temperature',
'units': 'deg C',
'code': 2,
'CDI_grid_type': 'unstructured',
'number_of_grid_in_reference': 1}
or we just check for the number of dimensions used in lon
and lat
and add such a fake dimension.
Do you think regionmask
could handle such unstructured grids without such tweaks?
A solution should also work for other unstructured output from MPAS @mgrover1, FESOM @koldunovn, etc
Issue Analytics
- State:
- Created 2 years ago
- Reactions:2
- Comments:9 (4 by maintainers)
Top Results From Across the Web
Unstructured Grid - an overview | ScienceDirect Topics
The use of unstructured grid offers several advantages over structured grids. These lie in the ability to deal with arbitrary complex geometries and...
Read more >UNSTRUCTURED GRID TECHNIQUES
An overview of the current state of the art in unstructured mesh techniques for computational fluid dynamics is given. The topics of mesh...
Read more >Grid Systems | CFD-101 | What Are the Advantages and ...
A popular type of unstructured grid consists of tetrahedral elements. These grids tend to be easier to generate than those composed of hexahedral...
Read more >Chapter 11: Unstructured Grids Introduction
Structured curvilinear grids are based on mapping of the flow domain onto a computational domain. It is very difficult to find viable mappings...
Read more >Smoothing of Unstructured Grids
Abstract. Two mesh smoothing techniques applied to unstructured grids are compared. These are based on the solution of elliptic equations,.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Here are a couple use cases. Both of these can be accessed using the geocat-datafiles repository Here is an MPAS file:
And a CAM-SE (unstructured atmospheric climate model output) case
You can access these files for testing using the following:
@aaronspring let me know if you have any questions
I don’t look at the data only the coordinates. @aaronspring can you share a repr of the dataset? I could only call
meshgrid
if the dimension name is not equal to the coords name. I.e. callmeshgrid
:don’t call
meshgrid
:That might work.
Yes that is probably necessary (although I prefer to not add yet another argument). Unless we have enough trust in the above solution.
b.t.w. - the
__version__
was wrong when installing with conda (see the gist) - that should be fixed.