Voici une tentative de sérialisation d'un fichier
Characterization en
JSON :
{
"characterisation": {
"characterisationAxis": [
{
"accuracy": {
"statError": {
"ErrorRefVal": {
"stc:Error2": {
"stc:C1": ".000055",
"stc:C2": ".000055"
}
},
"flavor": "statistical"
}
},
"axisName": "spatial",
"calibrationStatus": "CALIBRATED",
"coordsystem": {
"id": "TT-ICRS-WAVELENGTH-TOPO",
"xlink:href": "ivo:\/\/STClib\/CoordSys#TT-ICRS-TOPO",
"xlink:type": "simple"
},
"coverage": {
"bounds": {
"limits": {
"Coord2VecInterval": {
"stc:HiLimit2Vec": {
"stc:C1": "190.37601",
"stc:C2": "11.369167"
},
"stc:LoLimit2Vec": {
"stc:C1": "190.37157",
"stc:C2": "11.364722"
}
},
"coord_system_id": "TT-ICRS-WAVELENGTH-TOPO"
}
},
"location": {
"coord": {
"coord_system_id": "TT-ICRS-WAVELENGTH-TOPO",
"stc:Position2D": {
"stc:Name1": "RA",
"stc:Name2": "Dec",
"stc:Value2": {
"stc:C1": "190.37379",
"stc:C2": "11.366944"
}
}
}
}
},
"independentAxis": "true",
"numBins2": {
"I1": "16",
"I2": "16"
},
"regularsamplingStatus": "true",
"resolution": {
"resolutionRefVal": {
"stc:Resolution2": {
"stc:C1": "1.4",
"stc:C2": "1.4"
}
},
"unit": "arcsec"
},
"samplingPrecision": {
"samplingPrecisionRefVal": {
"samplingPeriod": {
"stc:C1": "1.0",
"stc:C2": "1.0"
}
},
"unit": "arcsec"
},
"ucd": "pos",
"undersamplingStatus": "false",
"unit": "deg"
},
{
"axisName": "time",
"calibrationStatus": "UNCALIBRATED",
"coordsystem": {
"idref": "TT-ICRS-WAVELENGTH-TOPO"
},
"coverage": {
"location": {
"coord": {
"coord_system_id": "TT-ICRS-WAVELENGTH-TOPO",
"stc:Time": {
"stc:TimeInstant": {
"stc:ISOTime": "2004-05-24T22:23:58"
}
}
}
}
},
"independentAxis": "true",
"numBins1": "1",
"ucd": "time",
"unit": "none"
},
{
"accuracy": {
"statError": {
"ErrorRefVal": {
"stc:Error": "0.0001"
},
"flavor": "statistical"
}
},
"axisName": "spectral",
"calibrationStatus": "CALIBRATED",
"coordsystem": {
"idref": "TT-ICRS-WAVELENGTH-TOPO"
},
"coverage": {
"bounds": {
"limits": {
"CoordScalarInterval": {
"stc:HiLimit": "0.56548382",
"stc:LoLimit": "0.4140"
},
"coord_system_id": "TT-ICRS-WAVELENGTH-TOPO"
}
},
"location": {
"coord": {
"coord_system_id": "TT-ICRS-WAVELENGTH-TOPO",
"stc:Spectral": {
"stc:Value": "0.4858137"
}
}
}
},
"independentAxis": "true",
"numBins1": "2048",
"regularsamplingStatus": "false",
"resolution": {
"resolutionBounds": {
"resolutionLimits1": {
"stc:HiLimit": "101.142",
"stc:LoLimit": "48.3233"
}
},
"resolutionRefVal": {
"stc:Resolution": "78.6162"
},
"unit": "km\/s"
},
"samplingPrecision": {
"samplingPrecisionRefVal": {
"samplingPeriod": "40.0000"
},
"unit": "km\/s"
},
"ucd": "em",
"undersamplingStatus": "false",
"unit": "um"
},
{
"accuracy": {
"statError": {
"ErrorBounds": {
"ErrorLimits1": {
"stc:HiLimit": "1.12e-16",
"stc:LoLimit": "5.80e-19"
}
},
"ErrorRefVal": {
"stc:Error": "5.63e-17"
},
"flavor": "statistical"
}
},
"axisName": "flux",
"calibrationStatus": "UNCALIBRATED",
"coordsystem": {
"id": "UNKNOWN"
},
"coverage": {
"bounds": {
"limits": {
"CoordScalarInterval": {
"stc:HiLimit": "1.1838107e-14",
"stc:LoLimit": "-2.8933970e-15"
},
"coord_system_id": "UNKNOWN"
}
},
"location": {
"coord": {
"coord_system_id": "UNKNOWN",
"stc:ScalarCoordinate": {
"stc:Value": "2.3519587e-17"
}
}
}
},
"independentAxis": "false",
"numBins1": "0",
"regularsamplingStatus": "true",
"ucd": "phot",
"undersamplingStatus": "false",
"unit": "counts"
}
]
}
}
La lecture d'un tel fichier en Python par exemple est très aisée :
boch@cds-dev-tb:~/charac/json$ python
Python 2.5.1 (r251:54863, Jul 31 2008, 23:17:40)
[GCC 4.1.3 20070929 (prerelease) (Ubuntu 4.1.2-16ubuntu2)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import json
>>> f = open('MPFS.json')
>>> obj = json.read(f.read())
>>> # affichage du nom du premier axe
...
>>> obj['characterisation']['characterisationAxis'][0]['axisName']
'spatial'
>>> # affichage d'un element STC
...
>>> obj['characterisation']['characterisationAxis'][0]['coverage']['location']['coord']['stc:Position2D']['stc:Value2']
{'stc:C1': '190.37379', 'stc:C2': '11.366944'}
--
ThomasBoch - 14 Oct 2008