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

Remove manual adjustment of start_index #990

Closed
7 tasks done
veenstrajelmer opened this issue Sep 6, 2024 · 0 comments · Fixed by #991
Closed
7 tasks done

Remove manual adjustment of start_index #990

veenstrajelmer opened this issue Sep 6, 2024 · 0 comments · Fixed by #991

Comments

@veenstrajelmer
Copy link
Collaborator

veenstrajelmer commented Sep 6, 2024

Is implemented here:

#convert 0-based to 1-based indices for connectivity variables like face_node_connectivity
xu_grid_ds = xu_grid.to_dataset()
xu_grid_ds = xr.decode_cf(xu_grid_ds) #decode_cf is essential since it replaces fillvalues with nans
ds_idx = xu_grid_ds.filter_by_attrs(start_index=0)
for varn_conn in ds_idx.data_vars:
xu_grid_ds[varn_conn] += 1 #from startindex 0 to 1 (fillvalues are now nans)
xu_grid_ds[varn_conn].attrs["start_index"] += 1
xu_grid_ds[varn_conn].encoding["_FillValue"] = -1 #can be any value <=0, but not 0 is currently the most convenient for proper xugrid plots.

Todo:

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 a pull request may close this issue.

1 participant