scikit-spectra icon indicating copy to clipboard operation
scikit-spectra copied to clipboard

jsonify

Open hughesadam87 opened this issue 11 years ago • 3 comments

If I replace pickle with json, it should make it possible to use stored states after changing program versions. Not sure if htis just works out of hte box or if it's too hard it implement. Inspired by PyGnome serialization.

hughesadam87 avatar Jun 27 '13 23:06 hughesadam87

Will prolly need numpy compat json

import json import numpy as np class NumpyAwareJSONEncoder(json.JSONEncoder): def default(self, obj): if isinstance(obj, np.ndarray): return obj.tolist() return json.JSONEncoder.default(self, obj) with open('figure.json', 'w') as outfile: json.dump(figure, outfile, cls=NumpyAwareJSONEncoder)

hughesadam87 avatar Jun 04 '14 22:06 hughesadam87

After do this, don't forget to update script. Right now, it's outputting csv_cropped outside of the apply_parameters method where it originally was. That's because if I do intervals from csv, I cannot recover the original timestamps. Once jsonifying data, won't need to output this csv file; although could keep it in. I'd rather it be like:

full_data.json baseline_sub_index_cropped_as_interval.json

As to what is output test that the interval version can still fully recover the timestamps

hughesadam87 avatar Jun 14 '14 21:06 hughesadam87

GeoPandasDataframe has to_json(), may help

https://github.com/geopandas/geopandas/blob/master/geopandas/geodataframe.py

hughesadam87 avatar Jul 12 '14 00:07 hughesadam87