Reading and Loading Data
Contains high level routines for reading in instrument binary data, and saving and loading xarray datasets. DOLfYN will automatically search through and select a binary reader based on the input data’s file extension.
Read a binary Nortek (e.g., .VEC, .wpr, .ad2cp, etc.) or RDI (.000, .PD0, .ENX, etc.) data file. |
|
Read an ADCP or ADV datafile from the examples directory. |
|
Save xarray dataset as netCDF (.nc). |
|
Load xarray dataset from netCDF (.nc) |
|
Save xarray dataset as a MATLAB (.mat) file |
|
Load xarray dataset from MATLAB (.mat) file, complimentary to save_mat() |
I/O functions can be accessed directly from DOLfYN’s main import:
>> import dolfyn as dlfn
>> dat = dlfn.read(<path/to/my_data_file>)
>> dlfn.save(dat, <path/to/save_file.nc>)
- dolfyn.io.api.read(fname, userdata=True, nens=None)[source]
Read a binary Nortek (e.g., .VEC, .wpr, .ad2cp, etc.) or RDI (.000, .PD0, .ENX, etc.) data file.
- Parameters
filename (string) – Filename of instrument file to read.
userdata (True, False, or string of userdata.json filename (default
True
)) – Whether to read the ‘<base-filename>.userdata.json’ file.nens (None (default: read entire file), int, or 2-element tuple (start, stop)) – Number of pings or ensembles to read from the file
- Returns
ds (xarray.Dataset) – An xarray dataset from instrument datafile.
- dolfyn.io.api.read_example(name, **kwargs)[source]
Read an ADCP or ADV datafile from the examples directory.
- Parameters
name (str) –
A few available files:
AWAC_test01.wpr BenchFile01.ad2cp RDI_test01.000 burst_mode01.VEC vector_data01.VEC vector_data_imu01.VEC winriver01.PD0 winriver02.PD0
- Returns
ds (xarray.Dataset) – An xarray dataset from the binary instrument data.
- dolfyn.io.api.save(dataset, filename)[source]
Save xarray dataset as netCDF (.nc).
- Parameters
dataset (xarray.Dataset) –
filename (str) – Filename and/or path with the ‘.nc’ extension
Notes
Drops ‘config’ lines.
- dolfyn.io.api.load(filename)[source]
Load xarray dataset from netCDF (.nc)
- Parameters
filename (str) – Filename and/or path with the ‘.nc’ extension
- Returns
ds (xarray.Dataset) – An xarray dataset from the binary instrument data.
- dolfyn.io.api.save_mat(dataset, filename, datenum=True)[source]
Save xarray dataset as a MATLAB (.mat) file
- Parameters
dataset (xarray.Dataset) – Data to save
filename (str) – Filename and/or path with the ‘.mat’ extension
datenum (bool) – Converts epoch time into MATLAB datenum
Notes
The xarray data format is saved as a MATLAB structure with the fields ‘vars, coords, config, units’
See also
scipy.io.savemat
- dolfyn.io.api.load_mat(filename, datenum=True)[source]
Load xarray dataset from MATLAB (.mat) file, complimentary to save_mat()
A .mat file must contain the fields: {vars, coords, config, units}, where ‘coords’ contain the dimensions of all variables in ‘vars’.
- Parameters
filename (str) – Filename and/or path with the ‘.mat’ extension
datenum (bool) – Converts MATLAB datenum into epoch time
- Returns
ds (xarray.Dataset) – An xarray dataset from the binary instrument data.
See also
scipy.io.loadmat