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
round-trip land-only unstructured grid #117
Comments
Here is how one could attach the original coords to the unstructured dataset: def renamed_orig_coords(ds, x_dim="lon", y_dim="lat"):
# read dims from dataset
dsc = ds[[y_dim, x_dim]]
# if len(dsc[c].dims -> avoid attaching coords like "height"
name_dict = {c: f"{c}_orig" for c in dsc.coords if len(dsc[c].dims)}
coords = dsc.rename(name_dict).coords
return coords
def restore_orig_coords_as_dataset(ds, x_dim="lon", y_dim="lat"):
# read dims from dataset
dsc = ds[[f"{y_dim}_orig", f"{x_dim}_orig"]]
name_dict = {c: c.replace("_orig", "") for c in dsc.coords}
coords_ds = dsc.rename(name_dict)
return coords_ds Pros
Cons
Example 1print(air_unstructured.assign_coords(renamed_orig_coords(air)))
Example 2print(rasm_unstructured.assign_coords(renamed_orig_coords(rasm, x_dim="x", y_dim="y")))
|
Note: |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I thought about how we can round-trip an unstructured land-only grid. We will in some way need the original grid. I am ignoring this for now but this could be stored as coords on the new dataset (but then all coords and dims need renaming...).
Related to #105
I don't comment the examples - have a look at the "Dimensions":
Example 1: 1D lat and lon coords
Example 2: 2D lat and lon coords
The text was updated successfully, but these errors were encountered: