Skip to content
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

Discussion: Metadata JSON format #6

Open
kwilcox opened this issue Apr 11, 2022 · 3 comments
Open

Discussion: Metadata JSON format #6

kwilcox opened this issue Apr 11, 2022 · 3 comments

Comments

@kwilcox
Copy link
Collaborator

kwilcox commented Apr 11, 2022

I suggest using the NCO-JSON[1][2][3] format for passing any JSON-based metadata around in the MQTT topics. It is very close to what the Payload: Data with metadata already defines and will allow us to standardize on the tools used to interpret and apply the metadata elsewhere.

[1] https://www.essoar.org/doi/abs/10.1002/essoar.10500689.1
[2] http://nco.sourceforge.net/nco.html#json
[3] cf-json/cf-json.github.io#10

For example:

"metadata": {
    "make": "MockCo",
    "model": "Sensor_1",
    "variables": {
        "time": {
            "long_name": "Time",
            "dimension": [
                "time"
            ]
        },
        "latitude": {
            "long_name": "Latitude",
            "data_type": "double",
            "units": "degrees_north",
            "dimension": [
                "time"
            ]
        }
    }
}

in NCO-JSON would be

"metadata": {
  "attributes": {
    "make": "MockCo",
    "model": "Sensor_1"
  },
  "variables": {
    "time": {
      "shape": ["time"],
      "attributes": {
        "long_name": "Time"
      }
    },
    "latitude": {
      "type": "double",
      "shape": ["time"]
      "attributes": {
        "long_name": "Latitude",
        "units": "degrees_north"
      }
    }
  }
}

NCO-JSON can also serialize the "type" of the attributes so they can be represented in JSON and then decoded back to the correct type. This is useful for "type aware" attributes like _FillValue, missing_value, scale_factor add_offset, etc.

"metadata": {
  "variables": {
    "time": {
      "shape": ["time"],
      "attributes": {
         "missing_value": { "type": "float", "data": 75.0 },
         "short_attribute": { "type": "short", "data": 75 },
      }
    }
  }
}
@derekcoffman
Copy link
Collaborator

Perfect...I will look into that and make the changes. I knew there was a more standard way to do it, I just didn't know what that standard was which leads to me just making things up as I go along. Heh.

@derekcoffman
Copy link
Collaborator

I made the changes to the metadata. For now, I've left out the extra type information for the attributes. If you see a need for it, let me know and I can add

@kwilcox
Copy link
Collaborator Author

kwilcox commented Jul 21, 2022

I started using this metadata format in the register-thing app and updated mock_sensor to output a data field (the data) and metadata field in NCO-JSON.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants