Create Observable Object ======================== Problem ------- You want to create an :class:`~geodesic.entanglement.object.object.Observable` object and add it to the entanglement graph. Solution -------- An :class:`~geodesic.entanglement.object.object.Observable` object is a physical property or attribute that can be observed by an :class:`~geodesic.entanglement.object.Object.Entity` or :class:`~geodesic.entanglement.object.Object.Dataset`. :class:`~geodesic.entanglement.object.object.Observable` typically denotes something measurable by a sensor or methodology. In this example, we are going to create a :class:`~geodesic.entanglement.object.object.Observable` object for **maximum fire radiative power** band from the `MODIS Terra Thermal Anomalies & Fire Daily Global `_. For details on adding the *MODIS Terra Thermal Anomalies & Fire Daily Global* dataset, refer to :ref:`adding Google Earth Engine data set`. All :class:`~geodesic.entanglement.object.Object` can have additional qualifers, though ``name`` is the only qualifier that is required. In this example, we will also be adding ``domain``, ``category``, and ``type`` qualifiers, along with ``description`` and ``alias`` attributes. Setup ~~~~~ Start by setting up the :ref:`basic geodesic` workflow in python. .. code-block:: python >>> import geodesic >>> geodesic.set_active_project('cookbook-examples') Creating The Object ~~~~~~~~~~~~~~~~~~~ .. code-block:: python >>> observable_object = geodesic.entanglement.Object(object_class='observable', name='fire-radiative-power, domain = 'earth-observation', category = 'thermal-anomalies', type='radiative-power', description = 'Fire radiative power (FRP) within the pixel is estimated using the empirical relationship established in Kaufman et al. 1998 paper "Potential global fire monitoring from EOS-MODIS."', alias = 'Fire radiative power' ) >>> observable_object.save() The ``domain``, ``category``, and ``type`` qualifers are used to help organize and classify the object. The ``description`` and ``alias`` attributes are optional and can be used to store additional information about the object. Accessing the Object ~~~~~~~~~~~~~~~~~~~~ To check that your object has been created and added to the entanglement graph, you can use the :meth:`~geodesic.entanglement.object.Object.get_objects` method to search either by object type or by name. .. code-block:: python :caption: Search by object class >>> geodesic.get_objects(object_class='observable') [observable:earth-observation:thermal-anomalies:radiative-power:fire-radiative-power] .. code-block:: python :caption: Search by object name >>> geodesic.get_objects(search='fire') [observable:earth-observation:thermal-anomalies:radiative-power:fire-radiative-power] We can save the search results as a list of :class:`~geodesic.entanglement.object.Objects` and then access the object by index which will allow us to access the object's attributes. .. code-block:: python :caption: Accessing the object's attributes >>> obj_lst = geodesic.get_objects(search='fire') >>> fire_radiative_power_obj = obj_lst[0] >>> dict(fire_radiative_power_obj) .. figure:: ../../_static/img/cookbooks/entanglement/observable_object_dic.png :width: 600