-
Notifications
You must be signed in to change notification settings - Fork 15
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
Reduce all json files size #366
Comments
Good point @AugustinMortier. We should do that together with the upcoming AeroVal updates for v0.12.0. |
Would be good to look into this soon, perhaps @dulte, if you have time. Will not go into v0.12.0 though. |
I tumbled over this and looked a bit around: It seems that all json writing is based on the method pyaerocom/pyaerocom/_lowlevel_helpers.py Line 29 in 25aea64
which just calls According to my findings one has to round the floats to a given precision to get these into the json file. like (from above):
|
I would lean into import numpy as np
import simplejson as json
def round_floats(o, *, decimals: int = 5):
if isinstance(o, float):
return np.round(o, decimals)
if isinstance(o, (list, tuple)):
return np.array(o).round(decimals).tolist()
if isinstance(o, dict):
return dict(zip(o, round_floats(o.values(), decimals=decimals))
return o
data = json.dumps(round_floats(data)) And maybe subclass the |
I guess that this would only work for a list of floats... |
The code was just a snippet I found and not meant to be used as it is. My real code will be in the linked PR |
just another comment on this since I am testing the PR. |
Te json files currenthly have 17 decimal numbers. By reducing it down to 4-5?, we could save a lot of space. This can be applied to all of the json files: time series, glob_stats, map, and scat. Only the contour files already have a limited decimal number.
e.g
to be changed to
The text was updated successfully, but these errors were encountered: