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

Delete size 1 domain axis #100

Closed
davidhassell opened this issue Jul 20, 2020 · 0 comments · Fixed by #102
Closed

Delete size 1 domain axis #100

davidhassell opened this issue Jul 20, 2020 · 0 comments · Fixed by #102
Assignees
Labels
enhancement New feature or request

Comments

@davidhassell
Copy link
Collaborator

To delete a size 1 domain axis that is spanned by other constructs is hard work. E.g.

n=cf.read(input)
n=n[0]
xkey=n.axis('ncdim%x',key=True)
n.squeeze(xkey,inplace=True)
n.coordinate('latitude').squeeze(n.get_data_axes('latitude').index(xkey),inplace=True)
n.set_data_axes(n.axis('ncdim%y',key=True),n.coordinate('latitude',key=True))
n.del_construct('longitude')
n.del_construct(xkey)

This method is correct, but should be wrapped in a method, e.g. something like

>> n.del_construct('ncdim%x')
ValueError: Can't remove size 1 domain axis that is spanned by other constructs. Consider using Field.del_domain_axis instead.
>>> n = n.del_doman_axis('ncdim%x', remove_size_1=True)
>>>
@davidhassell davidhassell added the enhancement New feature or request label Jul 20, 2020
@davidhassell davidhassell self-assigned this Jul 20, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant