CorentinLouis / SPACE_labelling_tool

SPectrogram Analysis and Cataloguing Environment (SPACE) labelling tool
MIT License
2 stars 4 forks source link

fields and schema objects are missing in the json TFCat output #38

Open CorentinLouis opened 1 year ago

CorentinLouis commented 1 year ago

Are missing in the TFCat file the following:

   {
     "fields": {
        "quality": {
           "info": "Quality parameter: -1 (not set), 1 (good), 2 (medium) and 3 (bad quality).",
           "datatype": "str",
           "ucd": "meta.code.qual"
        }

      "$schema": "https://voparis-ns.obspm.fr/maser/tfcat/v1.0/schema#"
   }

Each "property" name MUST be defined in the Fields Object. 3.3.1. Field Object The Field Object contains the metadata defining one of the "property" included in the Properties Object members of each Feature Object (see Section 3.2.1.). The Field Object is a JSON object.

The Field Object has a member with name "info". The value of this member contain a description of the "field". The Field Object has a member with name "datatype". The value of this member is one of 'int', 'float' 'bool', or 'str' (TBC) The Field Object has a member with name "ucd". The value of this member is a valid UCD (IVOA Unified Content Description). The Field Object may have a member with name "unit". The value of this member is a valid unit, as defined in the VOUnit specification. If "unit" is not applicable, the member should not be present.

CorentinLouis commented 1 year ago

see the function written by @AdamBoudouma to automatically fill the fields object

CorentinLouis commented 1 year ago

It should be added in the write_features_to_json function (line 421), file https://github.com/CorentinLouis/SPACE_labelling_tool/blob/master/spacelabel/models/dataset/__init__.py

from tfcat.validate import JSONSCHEMA_URI

with open(path_tfcat, 'w') as file_json:
        json.dump(
            {
                "type": "FeatureCollection",
                "features": [
                    feature.to_tfcat_dict() for feature in self._features
                ],
                "schema": JSONSCHEMA_URI,
                "fields": {
                              "feature_name": {
                                      "info": "Feature Type", 
                                      "datatype": "str",
                                      "ucd": "meta.id",
                                      "values": {
                                              "shortname1?": "Definition of shortname1",
                                              "shortname2?": "Definition of shortname2",
                                              }
                                      }
                               },
                "crs": {
                    "type": "local",
                    "properties": {
                        "name": "Time-Frequency",
                        "time_coords_id": "unix",
                        "spectral_coords": {
                            "type": "frequency",
                            "unit": self._units['Frequency']
                        },
                        "ref_position_id": self._observer
                    }
                }
            },
            file_json
        )