ARPA-SIMC / dballe

Fast on-disk database for meteorological observed and forecast data.
Other
19 stars 6 forks source link

Problem reimporting json #76

Closed dcesari closed 7 years ago

dcesari commented 7 years ago

Importing a json exported by dbamsg dump --json does not work, apparently for two different reasons:

dbamsg dump --json vprof.bufr > vprof.json
dbamsg dump -t json vprof.json
Value 17590 is outside the range [0,16382] for 010004 (PRESSURE)

while 17590 comes from

010004 PRESSURE(PA): 17590

which is an acceptable atmospheric pressure. Replacing 17590 by 17590. and the same for all subsequent pressure values the error becomes:

dbamsg dump -t json vprof_modified.json
#1 message: 1 subsets: 1 generic: no low-level information available

vprof.bufr.gz vprof_modified.json.gz

dcesari commented 7 years ago

Maybe the second problem "no low-level information available" can be ignored because it does not apply to dbadb command, but dbadb import -t json --wipe-first also gives the first error on pressure as dbamsg.

edigiacomo commented 7 years ago

Which version of dballe are you using?

dcesari commented 7 years ago

dballe-7.21-1.x86_64

edigiacomo commented 7 years ago

Ok, I found the problem: when an integer is set on a variable with scale != 0, the value is considered as the value with the scale already applied (for the internal conversion from decimal to integer).

When scale < 0, the method wreport::Var::format() (invoked by the JSON serializer) format the value as an integer. Therefore, the JSON reader cannot rely on the presence of a decimal or integer notation: every value must be treated as a string and set with wreport::Var::setd().

edigiacomo commented 7 years ago
dbamsg dump -t json vprof_modified.json
#1 message: 1 subsets: 1 generic: no low-level information available

This problem is not fixed, I will open another issue.

edigiacomo commented 7 years ago

@dcesari the same thing happens with CSV format.

$ dbamsg dump vprof.bufr --csv --interpreted | dbamsg dump -t csv
#1 message: 1 subsets: 1 generic: no low-level information available

dbamsg need a "binary" (BUFR, AOF, CREX) representation of the input message. Feel free to open an issue if you want to convert JSON or CSV messages in other formats without using dbadb.