-
Notifications
You must be signed in to change notification settings - Fork 263
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
Add complex number support #1295
Conversation
a5f2e27
to
df42ae1
Compare
thanks @ZedThree! I see you are adding a submodule that points to your repo - which is fine, but I think it should still be possible to build netcdf4-python without that submodule. How hard would it be to add the ability to bypass the complex number support? and BTW, do you plan to try to get this integrated into netcdf-c? |
Definitely possible, but a little complicated. We'd need to do something like I added for the optional parallel support, switching out a The intention with the current implementation is that the complex number support is completely opt-in anyway. The underlying Happy to do this, but honestly I'm not sure it's worth making it optional at build-time.
From this discussion: Unidata/netcdf-c#2652 it seems unlikely to be accepted unfortunately. |
I guess I was thinking there were two reasons to make it easily disable-able.
|
That was exactly my thinking for including it as a submodule, so that it would always be available :) |
Looks good - guess all it needs is a Changelog entry |
Yep, will do! There's one more thing I want to add to the base library first, will get on that this week |
Ok, I think this is complete from my side |
Closes #1280
This adds support for reading/writing complex numbers in a variety of conventions, using my nc-complex library to do the heavy lifting. It's taken awhile because I had to go back and polish up the base library. It now supports writing complex numbers to netCDF3/classic model by automatically creating the complex dimension.
Complex number support is enabled by passing
auto_complex=True
toDataset
:Internally,
auto_complex
is then used to switch between calling thenc_*
andpfnc_*
versions of the various functions.pfnc_def_var
is always used to create variables, as this just falls through tonc_def_var
if it's not a complex datatype.I still need to add an example and update the docs, but all the code is working and I've added some tests, so I thought I'd open the PR so you can see what it looks like and maybe try it out.
There's probably still some sharp edges around vlen or compound types with nested complex numbers. I've not tested them.