Basic types » History » Version 1
Rafael Bailon-Ruiz, 2020-08-28 18:13
1 | 1 | Rafael Bailon-Ruiz | h1. Basic types |
---|---|---|---|
2 | |||
3 | In this page, you'll see how to use the different basic types of the CAMS Python library. |
||
4 | |||
5 | h2. Position |
||
6 | |||
7 | Position structures are composed of 4 element : time, x, y and z (space and time). |
||
8 | They are used to know where a sample or an object can be found. |
||
9 | This object supports addition, soustraction and multiplication of its element. |
||
10 | <pre><code class=python>pos = Position(t, x, y, z) |
||
11 | posNul = Position() # Position with t=0,x=0,y=0,z=0 |
||
12 | newPos = pos + posNul # Addition of elements</code></pre> |
||
13 | |||
14 | h2. SensorSample |
||
15 | |||
16 | The SensorSample object is one of the most current object you will encounter while using CAMS. |
||
17 | It is composed of 5 attributes : |
||
18 | - variableName : the name of the variable |
||
19 | - producer : who produced this sample (aircraft, userbased...) |
||
20 | - timeStamp : at which time the sensor was created (local timestamp) |
||
21 | - position : a Position object that indicates where the sample was fetched in local coordinates. |
||
22 | - data : the values associated to the sample (list format) |
||
23 | <pre><code class=python>sample = SensorSample(variableName='RCT', producer='200', timeStamp=100.34, |
||
24 | position=Position(100.34, 30.94, -200.86, 700.0), |
||
25 | data=[0.012]) # Sensor sample of RCT value registered at time 100.34 |
||
26 | </code></pre> |
||
27 | |||
28 | h2. DimensionHelper |
||
29 | |||
30 | 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. |
||
31 | |||
32 | h2. ScaledArray |
||
33 | |||
34 | 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 : |
||
35 | - data : the data inside the scaledArray, "numpy-like array":https://numpy.org/doc/stable/reference/generated/numpy.array.html |
||
36 | - dimHelper : a DimensionHelper like object (used to change from indexes to units) |
||
37 | - interpolation : how keys passed in getitem methods are interpolated (local to unit) |
||
38 | <pre><code class=python>scArray = ScaledArray(data, dimHelper, interpolation) # Creation of a ScaledArray object |
||
39 | sweetData = scArray.data # Access to data |
||
40 | </code></pre> |
||
41 | 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. |
||
42 | <pre><code class=python> sweetData[0].data # Data inside the first SensorSample element of the array |
||
43 | </code></pre> |
||
44 | 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. |
||
45 | <pre><code class=python>scArray = ScaledArray(data, dimHelper, interpolation) # Creation of a ScaledArray object |
||
46 | tinierScArray = scArray[100.34, 30.94:38.64, -200.86:200.896, 700.0] # New and tinierScArray |
||
47 | </code></pre> |
||
48 | Here, the tinierScArray object have only data assoicated around these coordinates. |