Skip to content

Instantly share code, notes, and snippets.

@kwilcox
Last active October 14, 2016 14:22
Show Gist options
  • Save kwilcox/c41834297b1a3b732cae3ee16621f6d0 to your computer and use it in GitHub Desktop.
Save kwilcox/c41834297b1a3b732cae3ee16621f6d0 to your computer and use it in GitHub Desktop.
NetCDF to JSON
Display the source blob
Display the rendered blob
Raw
{
"cells": [
{
"cell_type": "code",
"execution_count": 57,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"import numpy as np\n",
"import xarray as xr\n",
"import simplejson as json"
]
},
{
"cell_type": "code",
"execution_count": 58,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"class BasicNumpyEncoder(json.JSONEncoder):\n",
"\n",
" def default(self, obj):\n",
" \"\"\"\n",
" If input object is an ndarray it will be converted into a list\n",
" If input is a numpy generic it is converted to a python scalar\n",
" \"\"\"\n",
" if isinstance(obj, np.ndarray):\n",
" return obj.tolist()\n",
" elif isinstance(obj, np.generic):\n",
" return np.asscalar(obj)\n",
" # Let the base class default method raise the TypeError\n",
" return json.JSONEncoder(self, obj)"
]
},
{
"cell_type": "code",
"execution_count": 59,
"metadata": {
"collapsed": false
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"{\n",
" \"attrs\": {\n",
" \"geospatial_vertical_min\": 0.0,\n",
" \"contributor\": \"Russell Hopcroft, Jessica Couture\",\n",
" \"history\": \"NetCDF generated by Axiom from CTD files on EVOS Gulfwatch Research Workspace\",\n",
" \"time_coverage_start\": \"2005-07-08T18:48:00-08:00\",\n",
" \"creator_email\": \"jordan@axiomalska.com, rob@axiomalaska.com\",\n",
" \"title\": \"Seward Line Monitoring summer null CTD\",\n",
" \"sea_name\": \"Coastal Waters of S. Alaska\",\n",
" \"creator_name\": \"Jordan Jenckes - Axiom Data Science\",\n",
" \"nodc_template_version\": \"NODC_NetCDF_Profile_Orthogonal_Template_v1.1\",\n",
" \"creator_url\": \"http://www.axiomdatascience.com/\",\n",
" \"instrument\": \"SBE911+\",\n",
" \"license\": \"Data available for public use\",\n",
" \"vessel_name\": \"TN\",\n",
" \"geospatial_lat_units\": \"degrees_north\",\n",
" \"Conventions\": \"CF-1.6\",\n",
" \"date_created\": \"2015-11-13T03:14:44Z\",\n",
" \"metadata_link\": \"https://workspace.aoos.org/group/4601/project/4663/files\",\n",
" \"geospatial_lon_units\": \"degrees_east\",\n",
" \"geospatial_vertical_positive\": \"down\",\n",
" \"standard_name_vocabulary\": \"CF-1.6\",\n",
" \"geospatial_vertical_max\": 96.06,\n",
" \"geospatial_lat_min\": 60.02479934692383,\n",
" \"cdm_data_type\": \"profile\",\n",
" \"geospatial_lon_min\": -149.3582000732422,\n",
" \"geospatial_lat_max\": 60.02479934692383,\n",
" \"featureType\": \"Profile\",\n",
" \"naming_authority\": \"org.gulfwatchalaska\",\n",
" \"time_coverage_end\": \"2005-07-08T18:48:00-08:00\",\n",
" \"Metadata_conventions\": \"Unidata Dataset Discovery v1.0\",\n",
" \"geospatial_lon_max\": -149.3582000732422,\n",
" \"summary\": \"Data was collected on board the R/V Alpha Helix or the Tiglax by a Seabird 19+V2, 25, 911 or 911+ CTD sampling at 24 frames per second with 2 conductivity and 2 temperature sensors. Sensors are factory calibrated once per year. Accuracy of the temperature probes is better than 0.005 degrees C based on manufacturer specifications. Accuracy of the salinity values is better than 0.02 based on expected maximum drift of conductivity cell between annual factory calibrations. Ancillary data are reported as voltages (full range 0-5 volts) and/or as converted to engineering units described at the top of the data file and have not been subjected to any quality control measures.\",\n",
" \"project\": \"Long-Term Observation Program (LTOP) Seward Line CTD data, Gulf of Alaska\",\n",
" \"id\": \"TN179\"\n",
" },\n",
" \"coords\": {\n",
" \"longitude\": {\n",
" \"attrs\": {\n",
" \"valid_max\": \"180.0\",\n",
" \"long_name\": \"Profile Location\",\n",
" \"standard_name\": \"longitude\",\n",
" \"valid_min\": \"-180.0\",\n",
" \"units\": \"degrees_east\",\n",
" \"_CoordinateAxisType\": \"Lon\",\n",
" \"ioos_category\": \"Location\",\n",
" \"axis\": \"Y\"\n",
" },\n",
" \"data\": [\n",
" -149.3582000732422\n",
" ],\n",
" \"dims\": [\n",
" \"profile\"\n",
" ]\n",
" },\n",
" \"profile\": {\n",
" \"attrs\": {\n",
" \"long_name\": \"Profile Name\",\n",
" \"cf_role\": \"profile_id\"\n",
" },\n",
" \"data\": [\n",
" 1\n",
" ],\n",
" \"dims\": [\n",
" \"profile\"\n",
" ]\n",
" },\n",
" \"z\": {\n",
" \"attrs\": {\n",
" \"long_name\": \"Depth\",\n",
" \"standard_name\": \"depth\",\n",
" \"positive\": \"down\",\n",
" \"ioos_category\": \"Location\",\n",
" \"units\": \"m\",\n",
" \"axis\": \"Z\"\n",
" },\n",
" \"data\": [\n",
" 0.0,\n",
" 0.9900000095367432,\n",
" 1.9800000190734863,\n",
" 2.9700000286102295,\n",
" 3.9600000381469727,\n",
" 4.949999809265137,\n",
" 5.940000057220459,\n",
" 6.929999828338623,\n",
" 7.920000076293945,\n",
" 8.90999984741211,\n",
" 9.90999984741211,\n",
" 10.899999618530273,\n",
" 11.890000343322754,\n",
" 12.880000114440918,\n",
" 13.869999885559082,\n",
" 14.859999656677246,\n",
" 15.850000381469727,\n",
" 16.84000015258789,\n",
" 17.829999923706055,\n",
" 18.81999969482422,\n",
" 19.809999465942383,\n",
" 20.799999237060547,\n",
" 21.790000915527344,\n",
" 22.780000686645508,\n",
" 23.770000457763672,\n",
" 24.760000228881836,\n",
" 25.75,\n",
" 26.739999771118164,\n",
" 27.729999542236328,\n",
" 28.719999313354492,\n",
" 29.709999084472656,\n",
" 30.709999084472656,\n",
" 31.700000762939453,\n",
" 32.689998626708984,\n",
" 33.68000030517578,\n",
" 34.66999816894531,\n",
" 35.65999984741211,\n",
" 36.650001525878906,\n",
" 37.63999938964844,\n",
" 38.630001068115234,\n",
" 39.619998931884766,\n",
" 40.61000061035156,\n",
" 41.599998474121094,\n",
" 42.59000015258789,\n",
" 43.58000183105469,\n",
" 44.56999969482422,\n",
" 45.560001373291016,\n",
" 46.54999923706055,\n",
" 47.540000915527344,\n",
" 48.529998779296875,\n",
" 49.52000045776367,\n",
" 50.5099983215332,\n",
" 51.5,\n",
" 52.4900016784668,\n",
" 53.47999954223633,\n",
" 54.470001220703125,\n",
" 55.459999084472656,\n",
" 56.45000076293945,\n",
" 57.439998626708984,\n",
" 58.439998626708984,\n",
" 59.43000030517578,\n",
" 60.41999816894531,\n",
" 61.40999984741211,\n",
" 62.400001525878906,\n",
" 63.38999938964844,\n",
" 64.37999725341797,\n",
" 65.37000274658203,\n",
" 66.36000061035156,\n",
" 67.3499984741211,\n",
" 68.33999633789062,\n",
" 69.33000183105469,\n",
" 70.31999969482422,\n",
" 71.30999755859375,\n",
" 72.30000305175781,\n",
" 73.29000091552734,\n",
" 74.27999877929688,\n",
" 75.2699966430664,\n",
" 76.26000213623047,\n",
" 77.25,\n",
" 78.23999786376953,\n",
" 79.2300033569336,\n",
" 80.22000122070312,\n",
" 81.20999908447266,\n",
" 82.19999694824219,\n",
" 83.19000244140625,\n",
" 84.18000030517578,\n",
" 85.16999816894531,\n",
" 86.16000366210938,\n",
" 87.1500015258789,\n",
" 88.13999938964844,\n",
" 89.12999725341797,\n",
" 90.12000274658203,\n",
" 91.11000061035156,\n",
" 92.0999984741211,\n",
" 93.08999633789062,\n",
" 94.08000183105469,\n",
" 95.06999969482422,\n",
" 96.05999755859375\n",
" ],\n",
" \"dims\": [\n",
" \"z\"\n",
" ]\n",
" },\n",
" \"time\": {\n",
" \"attrs\": {\n",
" \"long_name\": \"Profile Time\",\n",
" \"units\": \"seconds since 1970-01-01T00:00:00Z\",\n",
" \"_CoordinateAxisType\": \"Time\",\n",
" \"ioos_category\": \"Time\",\n",
" \"time_origin\": \"01-JAN-1970 00:00:00\",\n",
" \"axis\": \"T\"\n",
" },\n",
" \"data\": [\n",
" 1120873680\n",
" ],\n",
" \"dims\": [\n",
" \"profile\"\n",
" ]\n",
" },\n",
" \"latitude\": {\n",
" \"attrs\": {\n",
" \"valid_max\": \"90.0\",\n",
" \"long_name\": \"Profile Location\",\n",
" \"standard_name\": \"latitude\",\n",
" \"valid_min\": \"-90.0\",\n",
" \"units\": \"degrees_north\",\n",
" \"_CoordinateAxisType\": \"Lat\",\n",
" \"ioos_category\": \"Location\",\n",
" \"axis\": \"Y\"\n",
" },\n",
" \"data\": [\n",
" 60.02479934692383\n",
" ],\n",
" \"dims\": [\n",
" \"profile\"\n",
" ]\n",
" }\n",
" },\n",
" \"data_vars\": {\n",
" \"temperature\": {\n",
" \"attrs\": {\n",
" \"ioos_category\": \"Temperature\",\n",
" \"long_name\": \"Sea Water Temperature\",\n",
" \"standard_name\": \"sea_water_temperature\",\n",
" \"units\": \"degree_Celsius\"\n",
" },\n",
" \"data\": [\n",
" [\n",
" 7.741000175476074,\n",
" 7.741000175476074,\n",
" 7.741000175476074,\n",
" 7.692999839782715,\n",
" 7.498000144958496,\n",
" 7.446000099182129,\n",
" 7.156000137329102,\n",
" 7.007999897003174,\n",
" 6.735000133514404,\n",
" 6.560999870300293,\n",
" 6.400000095367432,\n",
" 6.341000080108643,\n",
" 6.2820000648498535,\n",
" 6.0269999504089355,\n",
" 5.968999862670898,\n",
" 5.929999828338623,\n",
" 5.715000152587891,\n",
" 5.5980000495910645,\n",
" 5.580999851226807,\n",
" 5.580999851226807,\n",
" 5.4710001945495605,\n",
" 5.3979997634887695,\n",
" 5.250999927520752,\n",
" 5.140999794006348,\n",
" 5.117000102996826,\n",
" 5.111000061035156,\n",
" 5.116000175476074,\n",
" 5.0960001945495605,\n",
" 5.068999767303467,\n",
" 5.0279998779296875,\n",
" 5.013999938964844,\n",
" 5.002999782562256,\n",
" 4.960000038146973,\n",
" 4.953999996185303,\n",
" 4.920000076293945,\n",
" 4.867000102996826,\n",
" 4.769000053405762,\n",
" 4.7789998054504395,\n",
" 4.783999919891357,\n",
" 4.765999794006348,\n",
" 4.75600004196167,\n",
" 4.744999885559082,\n",
" 4.7230000495910645,\n",
" 4.697000026702881,\n",
" 4.71999979019165,\n",
" 4.73799991607666,\n",
" 4.729000091552734,\n",
" 4.736999988555908,\n",
" 4.701000213623047,\n",
" 4.671999931335449,\n",
" 4.64300012588501,\n",
" 4.633999824523926,\n",
" 4.633999824523926,\n",
" 4.627999782562256,\n",
" 4.624000072479248,\n",
" 4.61899995803833,\n",
" 4.609000205993652,\n",
" 4.614999771118164,\n",
" 4.610000133514404,\n",
" 4.613999843597412,\n",
" 4.629000186920166,\n",
" 4.642000198364258,\n",
" 4.676000118255615,\n",
" 4.718999862670898,\n",
" 4.752999782562256,\n",
" 4.784999847412109,\n",
" 4.823999881744385,\n",
" 4.839000225067139,\n",
" 4.877999782562256,\n",
" 4.927000045776367,\n",
" 4.942999839782715,\n",
" 4.949999809265137,\n",
" 4.952000141143799,\n",
" 4.964000225067139,\n",
" 4.980000019073486,\n",
" 4.999000072479248,\n",
" 5.013999938964844,\n",
" 5.0269999504089355,\n",
" 5.034999847412109,\n",
" 5.052999973297119,\n",
" 5.071000099182129,\n",
" 5.0929999351501465,\n",
" 5.118000030517578,\n",
" 5.131999969482422,\n",
" 5.135000228881836,\n",
" 5.14300012588501,\n",
" 5.146999835968018,\n",
" 5.1539998054504395,\n",
" 5.159999847412109,\n",
" 5.168000221252441,\n",
" 5.172999858856201,\n",
" 5.177999973297119,\n",
" 5.179999828338623,\n",
" 5.184000015258789,\n",
" 5.193999767303467,\n",
" 5.203000068664551,\n",
" 5.208000183105469,\n",
" 5.2129998207092285\n",
" ]\n",
" ],\n",
" \"dims\": [\n",
" \"profile\",\n",
" \"z\"\n",
" ]\n",
" },\n",
" \"density\": {\n",
" \"attrs\": {\n",
" \"ioos_category\": \"Other\",\n",
" \"long_name\": \"Sea Water Density\",\n",
" \"standard_name\": \"sea_water_density\",\n",
" \"units\": \"kg.m-3\"\n",
" },\n",
" \"data\": [\n",
" [\n",
" 1022.8189697265625,\n",
" 1022.8189697265625,\n",
" 1022.8189697265625,\n",
" 1022.8839721679688,\n",
" 1023.1649780273438,\n",
" 1023.2260131835938,\n",
" 1023.4569702148438,\n",
" 1023.7269897460938,\n",
" 1023.8209838867188,\n",
" 1023.8330078125,\n",
" 1023.8900146484375,\n",
" 1023.9089965820312,\n",
" 1023.9290161132812,\n",
" 1024.01904296875,\n",
" 1024.0550537109375,\n",
" 1024.0799560546875,\n",
" 1024.175048828125,\n",
" 1024.2239990234375,\n",
" 1024.2330322265625,\n",
" 1024.2349853515625,\n",
" 1024.2760009765625,\n",
" 1024.301025390625,\n",
" 1024.3509521484375,\n",
" 1024.4150390625,\n",
" 1024.427978515625,\n",
" 1024.43994140625,\n",
" 1024.447998046875,\n",
" 1024.4639892578125,\n",
" 1024.47802734375,\n",
" 1024.4969482421875,\n",
" 1024.5069580078125,\n",
" 1024.511962890625,\n",
" 1024.530029296875,\n",
" 1024.5340576171875,\n",
" 1024.5550537109375,\n",
" 1024.574951171875,\n",
" 1024.593017578125,\n",
" 1024.60595703125,\n",
" 1024.614990234375,\n",
" 1024.626953125,\n",
" 1024.633056640625,\n",
" 1024.6400146484375,\n",
" 1024.6529541015625,\n",
" 1024.675048828125,\n",
" 1024.6820068359375,\n",
" 1024.68505859375,\n",
" 1024.696044921875,\n",
" 1024.7039794921875,\n",
" 1024.7110595703125,\n",
" 1024.718017578125,\n",
" 1024.72705078125,\n",
" 1024.7320556640625,\n",
" 1024.739990234375,\n",
" 1024.741943359375,\n",
" 1024.7449951171875,\n",
" 1024.7509765625,\n",
" 1024.7750244140625,\n",
" 1024.7860107421875,\n",
" 1024.7939453125,\n",
" 1024.7979736328125,\n",
" 1024.800048828125,\n",
" 1024.81005859375,\n",
" 1024.8349609375,\n",
" 1024.864990234375,\n",
" 1024.886962890625,\n",
" 1024.9090576171875,\n",
" 1024.9320068359375,\n",
" 1024.9410400390625,\n",
" 1024.9630126953125,\n",
" 1024.991943359375,\n",
" 1025.0,\n",
" 1025.0050048828125,\n",
" 1025.0050048828125,\n",
" 1025.011962890625,\n",
" 1025.02197265625,\n",
" 1025.0340576171875,\n",
" 1025.0419921875,\n",
" 1025.051025390625,\n",
" 1025.0550537109375,\n",
" 1025.0670166015625,\n",
" 1025.0780029296875,\n",
" 1025.092041015625,\n",
" 1025.1070556640625,\n",
" 1025.116943359375,\n",
" 1025.1180419921875,\n",
" 1025.123046875,\n",
" 1025.1259765625,\n",
" 1025.1300048828125,\n",
" 1025.134033203125,\n",
" 1025.136962890625,\n",
" 1025.1409912109375,\n",
" 1025.1429443359375,\n",
" 1025.14501953125,\n",
" 1025.14697265625,\n",
" 1025.154052734375,\n",
" 1025.1590576171875,\n",
" 1025.1619873046875,\n",
" 1025.1639404296875\n",
" ]\n",
" ],\n",
" \"dims\": [\n",
" \"profile\",\n",
" \"z\"\n",
" ]\n",
" },\n",
" \"fluorescence\": {\n",
" \"attrs\": {\n",
" \"ioos_category\": \"\",\n",
" \"long_name\": \"Sea Water Fluorescence\",\n",
" \"standard_name\": \"sea_water_fluorescence\",\n",
" \"units\": \"microg.L-1\"\n",
" },\n",
" \"data\": [\n",
" [\n",
" 2.382999897003174,\n",
" 2.382999897003174,\n",
" 2.382999897003174,\n",
" 2.3970000743865967,\n",
" 2.4189999103546143,\n",
" 2.4189999103546143,\n",
" 2.436000108718872,\n",
" 2.4709999561309814,\n",
" 2.499000072479248,\n",
" 2.5969998836517334,\n",
" 2.630000114440918,\n",
" 2.7130000591278076,\n",
" 2.7190001010894775,\n",
" 2.8359999656677246,\n",
" 2.7750000953674316,\n",
" 2.802999973297119,\n",
" 2.690999984741211,\n",
" 2.924999952316284,\n",
" 2.869999885559082,\n",
" 3.0810000896453857,\n",
" 3.252000093460083,\n",
" 2.984999895095825,\n",
" 3.5390000343322754,\n",
" 3.3570001125335693,\n",
" 3.0160000324249268,\n",
" 2.683000087738037,\n",
" 2.803999900817871,\n",
" 3.23799991607666,\n",
" 3.1989998817443848,\n",
" 2.9019999504089355,\n",
" 2.505000114440918,\n",
" 2.453000068664551,\n",
" 2.4549999237060547,\n",
" 2.424999952316284,\n",
" 2.4210000038146973,\n",
" 2.4509999752044678,\n",
" 2.4719998836517334,\n",
" 2.433000087738037,\n",
" 2.4059998989105225,\n",
" 2.4140000343322754,\n",
" 2.4110000133514404,\n",
" 2.4059998989105225,\n",
" 2.4019999504089355,\n",
" 2.4070000648498535,\n",
" 2.4110000133514404,\n",
" 2.430000066757202,\n",
" 2.4240000247955322,\n",
" 2.4040000438690186,\n",
" 2.4040000438690186,\n",
" 2.447999954223633,\n",
" 2.421999931335449,\n",
" 2.4100000858306885,\n",
" 2.4089999198913574,\n",
" 2.4140000343322754,\n",
" 2.4070000648498535,\n",
" 2.4059998989105225,\n",
" 2.4049999713897705,\n",
" 2.4049999713897705,\n",
" 2.4049999713897705,\n",
" 2.4189999103546143,\n",
" 2.4159998893737793,\n",
" 2.4119999408721924,\n",
" 2.4110000133514404,\n",
" 2.4100000858306885,\n",
" 2.4100000858306885,\n",
" 2.4100000858306885,\n",
" 2.4040000438690186,\n",
" 2.4070000648498535,\n",
" 2.4070000648498535,\n",
" 2.4049999713897705,\n",
" 2.4019999504089355,\n",
" 2.4010000228881836,\n",
" 2.4030001163482666,\n",
" 2.4049999713897705,\n",
" 2.4019999504089355,\n",
" 2.4019999504089355,\n",
" 2.4049999713897705,\n",
" 2.4049999713897705,\n",
" 2.4030001163482666,\n",
" 2.4030001163482666,\n",
" 2.4019999504089355,\n",
" 2.4019999504089355,\n",
" 2.4030001163482666,\n",
" 2.4049999713897705,\n",
" 2.4040000438690186,\n",
" 2.427000045776367,\n",
" 2.4059998989105225,\n",
" 2.4040000438690186,\n",
" 2.4049999713897705,\n",
" 2.4049999713897705,\n",
" 2.4030001163482666,\n",
" 2.4040000438690186,\n",
" 2.4049999713897705,\n",
" 2.4049999713897705,\n",
" 2.4049999713897705,\n",
" 2.4070000648498535,\n",
" 2.4059998989105225,\n",
" 2.4070000648498535\n",
" ]\n",
" ],\n",
" \"dims\": [\n",
" \"profile\",\n",
" \"z\"\n",
" ]\n",
" },\n",
" \"pressure\": {\n",
" \"attrs\": {\n",
" \"ioos_category\": \"Pressure\",\n",
" \"long_name\": \"Sea Water Pressure\",\n",
" \"standard_name\": \"sea_water_pressure\",\n",
" \"units\": \"mbar\"\n",
" },\n",
" \"data\": [\n",
" [\n",
" 0.0,\n",
" 100.0,\n",
" 200.0,\n",
" 300.0,\n",
" 400.0,\n",
" 500.0,\n",
" 600.0,\n",
" 700.0,\n",
" 800.0,\n",
" 900.0,\n",
" 1000.0,\n",
" 1100.0,\n",
" 1200.0,\n",
" 1300.0,\n",
" 1400.0,\n",
" 1500.0,\n",
" 1600.0,\n",
" 1700.0,\n",
" 1800.0,\n",
" 1900.0,\n",
" 2000.0,\n",
" 2100.0,\n",
" 2200.0,\n",
" 2300.0,\n",
" 2400.0,\n",
" 2500.0,\n",
" 2600.0,\n",
" 2700.0,\n",
" 2800.0,\n",
" 2900.0,\n",
" 3000.0,\n",
" 3100.0,\n",
" 3200.0,\n",
" 3300.0,\n",
" 3400.0,\n",
" 3500.0,\n",
" 3600.0,\n",
" 3700.0,\n",
" 3800.0,\n",
" 3900.0,\n",
" 4000.0,\n",
" 4100.0,\n",
" 4200.0,\n",
" 4300.0,\n",
" 4400.0,\n",
" 4500.0,\n",
" 4600.0,\n",
" 4700.0,\n",
" 4800.0,\n",
" 4900.0,\n",
" 5000.0,\n",
" 5100.0,\n",
" 5200.0,\n",
" 5300.0,\n",
" 5400.0,\n",
" 5500.0,\n",
" 5600.0,\n",
" 5700.0,\n",
" 5800.0,\n",
" 5900.0,\n",
" 6000.0,\n",
" 6100.0,\n",
" 6200.0,\n",
" 6300.0,\n",
" 6400.0,\n",
" 6500.0,\n",
" 6600.0,\n",
" 6700.0,\n",
" 6800.0,\n",
" 6900.0,\n",
" 7000.0,\n",
" 7100.0,\n",
" 7200.0,\n",
" 7300.0,\n",
" 7400.0,\n",
" 7500.0,\n",
" 7600.0,\n",
" 7700.0,\n",
" 7800.0,\n",
" 7900.0,\n",
" 8000.0,\n",
" 8100.0,\n",
" 8200.0,\n",
" 8300.0,\n",
" 8400.0,\n",
" 8500.0,\n",
" 8600.0,\n",
" 8700.0,\n",
" 8800.0,\n",
" 8900.0,\n",
" 9000.0,\n",
" 9100.0,\n",
" 9200.0,\n",
" 9300.0,\n",
" 9400.0,\n",
" 9500.0,\n",
" 9600.0,\n",
" 9700.0\n",
" ]\n",
" ],\n",
" \"dims\": [\n",
" \"profile\",\n",
" \"z\"\n",
" ]\n",
" },\n",
" \"salinity\": {\n",
" \"attrs\": {\n",
" \"ioos_category\": \"Salinity\",\n",
" \"long_name\": \"Sea Water Practical Salinity\",\n",
" \"standard_name\": \"sea_water_salinity\",\n",
" \"units\": \"1e-3\"\n",
" },\n",
" \"data\": [\n",
" [\n",
" 29.277999877929688,\n",
" 29.277999877929688,\n",
" 29.277999877929688,\n",
" 29.351999282836914,\n",
" 29.677000045776367,\n",
" 29.746999740600586,\n",
" 29.993000030517578,\n",
" 30.31100082397461,\n",
" 30.386999130249023,\n",
" 30.375,\n",
" 30.422000885009766,\n",
" 30.437999725341797,\n",
" 30.45400047302246,\n",
" 30.530000686645508,\n",
" 30.566999435424805,\n",
" 30.591999053955078,\n",
" 30.68199920654297,\n",
" 30.726999282836914,\n",
" 30.736000061035156,\n",
" 30.738000869750977,\n",
" 30.774999618530273,\n",
" 30.79599952697754,\n",
" 30.839000701904297,\n",
" 30.90399932861328,\n",
" 30.917999267578125,\n",
" 30.93199920654297,\n",
" 30.94300079345703,\n",
" 30.959999084472656,\n",
" 30.975000381469727,\n",
" 30.993000030517578,\n",
" 31.003999710083008,\n",
" 31.009000778198242,\n",
" 31.025999069213867,\n",
" 31.030000686645508,\n",
" 31.052000045776367,\n",
" 31.06999969482422,\n",
" 31.079999923706055,\n",
" 31.097999572753906,\n",
" 31.108999252319336,\n",
" 31.121999740600586,\n",
" 31.128999710083008,\n",
" 31.13599967956543,\n",
" 31.149999618530273,\n",
" 31.173999786376953,\n",
" 31.18600082397461,\n",
" 31.191999435424805,\n",
" 31.204999923706055,\n",
" 31.215999603271484,\n",
" 31.219999313354492,\n",
" 31.225000381469727,\n",
" 31.232999801635742,\n",
" 31.238000869750977,\n",
" 31.24799919128418,\n",
" 31.249000549316406,\n",
" 31.253000259399414,\n",
" 31.259000778198242,\n",
" 31.288999557495117,\n",
" 31.30299949645996,\n",
" 31.312999725341797,\n",
" 31.31800079345703,\n",
" 31.322999954223633,\n",
" 31.336999893188477,\n",
" 31.37299919128418,\n",
" 31.416000366210938,\n",
" 31.448999404907227,\n",
" 31.479999542236328,\n",
" 31.514999389648438,\n",
" 31.527999877929688,\n",
" 31.56100082397461,\n",
" 31.604000091552734,\n",
" 31.617000579833984,\n",
" 31.624000549316406,\n",
" 31.624000549316406,\n",
" 31.635000228881836,\n",
" 31.64900016784668,\n",
" 31.66699981689453,\n",
" 31.679000854492188,\n",
" 31.691999435424805,\n",
" 31.697999954223633,\n",
" 31.715999603271484,\n",
" 31.732999801635742,\n",
" 31.753000259399414,\n",
" 31.775999069213867,\n",
" 31.790000915527344,\n",
" 31.79199981689453,\n",
" 31.798999786376953,\n",
" 31.80299949645996,\n",
" 31.80900001525879,\n",
" 31.815000534057617,\n",
" 31.820999145507812,\n",
" 31.826000213623047,\n",
" 31.829999923706055,\n",
" 31.832000732421875,\n",
" 31.834999084472656,\n",
" 31.844999313354492,\n",
" 31.85300064086914,\n",
" 31.85700035095215,\n",
" 31.861000061035156\n",
" ]\n",
" ],\n",
" \"dims\": [\n",
" \"profile\",\n",
" \"z\"\n",
" ]\n",
" }\n",
" },\n",
" \"dims\": {\n",
" \"profile\": 1,\n",
" \"z\": 98\n",
" }\n",
"}\n"
]
}
],
"source": [
"ds = xr.open_dataset('TN179_2005.nc', decode_times=False)\n",
"d = ds.to_dict()\n",
"print(json.dumps(d, indent=4, cls=BasicNumpyEncoder))"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.5.2"
}
},
"nbformat": 4,
"nbformat_minor": 1
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment