To change the recording rate call the <tt>set_cycle()</tt> method of the recording group.
```python
drg.set_cycle(0.01)
```
### Buffering Techniques
Data recording groups have three buffering options:
- DR_Buffer - the group will save recorded data to a buffer and use a separate thread to write recorded
data to disk. This will have little impact to the performance of the simulation. The downside
is that if the simulation crashes, the most recent recorded points may not be written to disk in time.
DR_Buffer is the default buffering technique. (For backwards compatibility, DR_Buffer can also be called DR_Thread_Buffer).
- DR_No_Buffer - the group will write recorded data straight to disk. All data is guaranteed to be written
to disk at simulation termination time. The downside of this method is that it is performed in
the main thread of the simulation and could impact real-time performance.
- DR_Ring_Buffer - the group will save a set number of records in memory and write this data to disk during
a graceful simulation termination. The advantage of this method is that there is only a set, usually
small, number of records written. The downside of this method is that if the simulation terminates
ungracefully, all recorded data may be lost.
To set the buffering technique call the <tt>set_buffer_type(trick.<buffering_option>)</tt> method of the recording group.
For example:
```python
drg.set_buffer_type(trick.DR_Buffer)
```
All buffering options (except for DR_No_Buffer) have a maximum amount of memory allocated to
holding data. See Trick::DataRecordGroup::set_max_buffer_size for buffer size information.
### Recording Frequency: Always or Only When Data Changes
Data recording groups have three recording frequency options:
- DR_Always - the group will record the variable value(s) at every recording cycle. (This is the default).
- DR_Changes - the group will record the variable value(s) only when a particular watched parameter (or parameters) value changes.
- DR_Changes_Step - like DR_Changes, except that a before and after value will be recorded for each variable,
creating a stair step effect (instead of point-to-point) when plotted.
To set the recording frequency call the <tt>set_freq(trick.<frequency_option>)</tt> method of the recording group. For example:
```python
drg.set_freq(trick.DR_Changes)
```
For DR_Changes or DR_Changes_Step, to specify parameter(s) to watch that will control when the variables added with <tt>add_variable</tt> are recorded,
call the <tt>add_change_variable(string)</tt> method of the recording group. For example:
So if we assume the <tt>add_variable</tt> statements from the example in @ref S_7_8_3 "7.8.3" combined with the above <tt>add_change_variable</tt> statement,
then <tt>ball.obj.state.output.position[0]</tt> and <tt>ball.obj.state.output.position[1]</tt> will be recorded only when
<tt>ball.obj.state.output.velocity[0]</tt> changes. Multiple parameters may be watched by adding more change variables, in which case
data will be recorded when any of the watched variable values change.
### Turn Off/On and Record Individual Recording Groups
At any time during the simulation, model code or the input processor can turn on/off individual
recording groups as well as record a single point of data.
|Trick-\<vv>-\<e>| \<vv> is trick version (2 chars, "07" or "10"). \<e> is endianness (1 char) 'L' -> little endian, and 'B' -> big endian.|char|10|
|*numparms*|Number of recorded variables |char|4|
|| List of Variable Descriptors | [Variable-Descriptor-List](#variable-descriptor-list)||
|| List Data Records |[Data-Record-List](#data-record-list)||
|EOF| End of File |||
<aid=variable-descriptor-list></a>
#### Variable-Descriptor-List
A Variable-Descriptor-List is a sequence of [Variable-Descriptors](#variable-descriptor).
The number of descriptors in the list is specified by *numparms*. The list describes each of the recorded variables, starting with the simulation time variable.
|Value|Description|Type|#Bytes|
|---|---|---|---|
|[*Time-Variable-Descriptor*](#time-variable-descriptor)| Descriptor for Variable # 1. This first descriptor always represents the simulation time variable.| [Variable-Descriptor](#variable-descriptor) |34|
|...|...|...|...|
|| Descriptor for Variable # *numparms* |[Variable-Descriptor](#variable-descriptor)|variable|
<aid=variable-descriptor></a>
#### Variable-Descriptor
A Variable-Descriptor describes a recorded variable.
|Value|Description|Type|Bytes|
|---|---|---|---|
| *namelen*| Length of Variable Name |int|4|
| *name* | Variable Name ||*namelen*|
| *unitlen*| Length of Variable Units |int|4|
| *unit* | Variable Units ||*unitlen*|
| *type* | Variable Type (see Notes 2. & 3.)|int|4|
| *sizeof(type)* | Variable Type Size |int|4|
**Notes:**
1. the size of a Variable-Descriptor in bytes = *namelen* + *unitlen* + 16.
2. If *vv* = "07", use [Trick 07 Data Types](#trick-07-data-types).
3. If *vv* = "10", use [Trick 10 Data Types](#trick-10-data-types).
<aid=time-variable-descriptor></a>
#### *Time-Variable-Descriptor*
|Value|Description|Type|Bytes|
|---|---|---|---|
|17| Length of Variable Name |int|4|
|```sys.exec.out.time```| Variable Name |char|17|
|1| Length of Variable Units |int|4|
|```s```| Variable Units (see Note 1.) |char|1|
|11| Variable Type |int|4|
|8| Variable Type Size |int|4|
**Notes:**
1. Here, we are assuming "vv" = "10", and so, referring to [Trick 10 Data Types](#trick-10-data-types), Variable Type = 11, which corresponds to **double**.
<aid=data-record-list></a>
#### Data-Record-List
A Data-Record-List contains a collection of [Data-Records](#data-record), at regular times.
|Value|Description|Type|Bytes|
|---|---|---|---|
||Data-Record #1|[Data-Record](#data-record)||
|...|...|...|...|
||Data-Record #Last|[Data-Record](#data-record)||
<aid=data-record></a>
#### Data-Record
A Data-Record contains a collection of values for each of the variables we are recording, at a specific time.
Data recording groups are able to be checkpointed, reloaded, and restarted without any interaction by the user. When a checkpoint is loaded that includes data recording,
the data recording groups will be initiated and begin recording at the time in the checkpoint. For example, if a checkpoint was dumped when t=5, when the checkpoint is
loaded into another run, it will data record starting at t=5, no matter what time in the run it was loaded or whether the run was already data recording. Loading a checkpoint
will overwrite any data recording files that were being recorded before the load.
Loading a checkpoint with different data recording groups than the current run will overwrite the current data recording groups.
Refer to test/SIM_checkpoint_data_recording to see expected behavior in action. Overall, the loading a checkpoint should completely overwrite any other data recording the sim is currently doing, and the new recording will start at the time in the checkpoint. If you come across different behavior, please open an issue.