After going through the technical explanation converting tag data into a NetCDF file, we hope we have convinced you about the benefits of this file format. Thus, if you have mat files from Dtag (versions 1, 2 and 3) deployments and you want to convert them into the
.nc format, it is really easy if you follow these next steps. This tutorial is specific for Dtag deployments from Dtag version 3 (for Dtag version 1 and 2 the first step when loading the data is the different one).
Load the Test Data Set
For this practical we will use data from a suction cup tag attached to the back of a blue whale animal [Note]This dataset has already been converted from a source file that was offloaded from the tag into a NetCDF file. In doing so, some metadata was gleaned from the file and added to the data. Other metadata was added by hand.. This dataset is built into the
tagtools package, so you can access it using
system.file. The tag data name follows the standard DTAG protocol of: 2-letter Latin or common species initials, 2-digit
year, underscore, 3-digit Julian day of year, 1-letter animal of the day, e.g.:
Create sensor structures
Then convert the data matrices into sensor structures:
Indicate in the metadata that the accelerometer and magnetometer data are in the animal frame:
Load CAL file add information about cropped data and create metadata info structure
Load the cal file which contains information about the deployment that we will save in the metadata info structure:
The following step is not crucial but if the data was cropped and you know the start and end time of the cropping period, add it. Hint: it may be that this information is saved in the cal file. This deployment was not cropped, however, if you have one that has been, you can do the following, where x1 and x2 are the cropping times in seconds.
Add the history information in the creation of Aa and Ma.
Make the metadata (replace xx with the initials of the data owner, making sure that they are listed in researchers.csv). For this particular deployment there are many metadata missing, thus we have only added the available information, but for your own deployments, please add as much information as possible as this is very valuable and will help to future researchers. See the metadata tutorial for a greater explanation of researchers.csv (in progress):
Edit the fields below so that they reflect the deployment method and location etc: Take the information from the DEPLOY or DEPLOYMENT sensor structure (mat file) or at the end of the cal .xml file that contains information regarding location, author, email from data owner, tag on position, tag on time, tag on placement, tag recovery position, tag recovery time, UTC to Local time, photo information…
If you know the following information add it to the info saying where the data came from:
It is very important to save the OTAB (Orientation Table) matrix in
Ma sensor structures.
Save the data and metadata to a
if temperature is present in the
prh mat file (not available for this particular example), then save Temperature data in the ncfile as follows:
nc files are only formed by sensor structures, thus pitch, roll and heading orientation angles cannot be saved here. However, they are very easy to compute afterwards as you can see in the code below. See the animal orientation tutorial for greater detail.