Project

General

Profile

Actions

Basic types

In this page, you'll see how to use the different basic types of the CAMS Python library.

Position

Position structures are composed of 4 element : time, x, y and z (space and time).
They are used to know where a sample or an object can be found.
This object supports addition, soustraction and multiplication of its element.

pos = Position(t, x, y, z)
posNul = Position() # Position with t=0,x=0,y=0,z=0
newPos = pos + posNul # Addition of elements

SensorSample

The SensorSample object is one of the most current object you will encounter while using CAMS.
It is composed of 5 attributes :
- variableName : the name of the variable
- producer : who produced this sample (aircraft, userbased...)
- timeStamp : at which time the sensor was created (local timestamp)
- position : a Position object that indicates where the sample was fetched in local coordinates.
- data : the values associated to the sample (list format)

sample = SensorSample(variableName='RCT', producer='200', timeStamp=100.34,
                  position=Position(100.34, 30.94, -200.86, 700.0),
                  data=[0.012]) # Sensor sample of RCT value registered at time 100.34

DimensionHelper

DimensionHelper is a class that is purely meant to translate keys to unit or to indexes via the to_unit() and the to_index() functions. This class is mandatory for the creation of ScaledArray objects.

ScaledArray

The ScaledArray are arrays that are results of retrieving data from database and also the types used to create maps of cloud for instance. They are composed of 3 attributes :
- data : the data inside the scaledArray, numpy-like array
- dimHelper : a DimensionHelper like object (used to change from indexes to units)
- interpolation : how keys passed in getitem methods are interpolated (local to unit)

scArray = ScaledArray(data, dimHelper, interpolation) # Creation of a ScaledArray object
sweetData = scArray.data # Access to data

It is possible however that the data you retrieve is containing SensorSamples. In this case, don't forget to precise the data attribute of the SensorSample.
 sweetData[0].data # Data inside the first SensorSample element of the array 

When you use the getitem function, you acquire in fact a tinier ScaledArray with only the data you fetched. The advantage of doing this is that you can retrieve a small amount of data with coordinates based indexes and get the associated data without guessing the right indexes in the array.
scArray = ScaledArray(data, dimHelper, interpolation) # Creation of a ScaledArray object
tinierScArray = scArray[100.34, 30.94:38.64, -200.86:200.896, 700.0] # New and tinierScArray

Here, the tinierScArray object have only data assoicated around these coordinates.

Updated by Rafael Bailon-Ruiz over 3 years ago · 1 revisions