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

xarray Datasets are not correctly serialized to netcdf #111

Closed
bocklund opened this issue Jul 27, 2017 · 1 comment
Closed

xarray Datasets are not correctly serialized to netcdf #111

bocklund opened this issue Jul 27, 2017 · 1 comment

Comments

@bocklund
Copy link
Collaborator

bocklund commented Jul 27, 2017

import numpy as np
import xarray as xr
import datetime
data = xr.DataArray(np.random.randn(2, 3), coords={'x': ['a', 'b']}, dims=('x', 'y'))
ds = xr.Dataset({'z': data})
ds.to_netcdf('netcdf_test.nc')  # works
ds.attrs['created'] = datetime.datetime.now()
ds.to_netcdf('netcdf_test_time.nc')  # fails

I thought about opening this issue upstream, but their solution for handling datetimes as DataArrays is precisely to use the attrs as metadata for that array. I don't think they would support generic serialization of datetimes that are in attrs.

It seems like we should either not use datetimes or just serialize/deserialize ourselves.

@richardotis
Copy link
Collaborator

richardotis commented Jul 28, 2017

I would be comfortable converting datetimes to strings on creation. We don't use them in any library code, from a readability standpoint it's the same for the user, and it's trivial for downstream code to convert the string to a datetime object if programmatic access is needed. Also, it would be a one line change.

bocklund added a commit to bocklund/pycalphad that referenced this issue Aug 17, 2021
* Weighting individual datasets in single phase fitting is now implemented via scikit-learn.
* Updated to use pycalphad's `LightDataset` objects in the equilibrium hot path.
* Updated context building to use pycalphad exact Hessian solver.
* Support writing SER reference state information to the `ELEMENT` keyword in TDBs based on the SGTE unary 5 database.
* ESPEI schema input schema validation is moved to a new module and deferred for import time performance.
* Fix for small residuals in parameter selection so the AICc penalty factor can work even when n data = n parameters (giving an RSS of 0).
* MCMC now calculates the likelihood of the initial parameter set so the starting point can be reasonably compared.
* Fixed a bug where mis-aligned configurations and site occupancies in single phase datasets passed the dataset checker
* Phase names entered in the "phase_models.json" file are now all coerced to upper case.
* ESPEI debug logging now reports symengine and emcee versions to improve log-debugging.
* Requirements are updated to account for working versions of dask/distributed, emcee, and pycalphad
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

No branches or pull requests

2 participants