Skip to content

Commit

Permalink
No commit message
Browse files Browse the repository at this point in the history
  • Loading branch information
ratal committed Sep 28, 2015
1 parent 1f4bff8 commit 016edf0
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 7 deletions.
6 changes: 4 additions & 2 deletions mdfreader/mdf.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,11 +126,13 @@ def add_channel(self, channel_name, data, master_channel, master_type=1, unit=''
self[channel_name]['masterType'] = 1
else: # mdf4
self[channel_name]['masterType'] = master_type
if conversion is not None and 'conversion' in conversion:
if conversion is not None:
self[channel_name]['conversion'] = {}
self[channel_name]['conversion']['type'] = conversion['cc_type']
self[channel_name]['conversion']['parameters'] = conversion['conversion']
self[channel_name]['conversion']['parameters'] = {}
if self.MDFVersionNumber < 400: # mdf3
if 'conversion' in conversion:
self[channel_name]['conversion']['parameters'] = conversion['conversion']
if conversion['cc_type'] == 0 and \
(self[channel_name]['conversion']['parameters']['P2'] == 1.0 and \
self[channel_name]['conversion']['parameters']['P1'] in (0.0, -0.0)):
Expand Down
17 changes: 13 additions & 4 deletions mdfreader/mdfreader.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
from mdf4reader import mdf4
from numpy import arange, linspace, interp, all, diff, mean, vstack, hstack, float64, zeros, empty, delete
from numpy import nan, datetime64, array
from datetime import datetime

from argparse import ArgumentParser
from sys import version_info
Expand Down Expand Up @@ -473,7 +474,8 @@ def resample(self, samplingTime=None, masterChannel=None):
Parameters
----------------
samplingTime : float, optional
resampling interval
resampling interval, None by default. If None, will merge all datagroups
into a unique datagroup having the highest sampling rate from all datagroups
**or**
masterChannel : str, optional
master channel name to be used for all channels
Expand Down Expand Up @@ -560,7 +562,7 @@ def resample(self, samplingTime=None, masterChannel=None):
elif samplingTime is None:
print('Already resampled')

def exportToCSV(self, filename=None, sampling=0.1):
def exportToCSV(self, filename=None, sampling=None):
"""Exports mdf data into CSV file
Parameters
Expand All @@ -569,7 +571,7 @@ def exportToCSV(self, filename=None, sampling=0.1):
file name. If no name defined, it will use original mdf name and path
sampling : float, optional
sampling interval. By default, sampling is 0.1sec but can be changed
sampling interval. None by default
Notes
--------
Expand Down Expand Up @@ -1056,9 +1058,16 @@ def convertToPandas(self, sampling=None):
raise ImportError('Module pandas missing')
if sampling is not None:
self.resample(sampling)
datetimeInfo = datetime64(self.file_metadata['date'].replace(':', '-') + 'T' + self.file_metadata['time'])
if self.file_metadata['date'] != '' and self.file_metadata['time']!='':
date = self.file_metadata['date'].replace(':', '-')
time = self.file_metadata['time']
datetimeInfo = datetime64(date + 'T' + time)
else:
datetimeInfo = datetime64(datetime.now())
originalKeys = list(self.keys())
for group in list(self.masterChannelList.keys()):
if self[group]['masterType']!=1:
print('Warning: master channel is not time, not appropriate conversion for pandas')
temp = {}
# convert time channel into timedelta
time = datetimeInfo + array(self.getChannelData(group) * 10E6, dtype='timedelta64[us]')
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@
# project is installed. For an analysis of "install_requires" vs pip's
# requirements files see:
# https://packaging.python.org/en/latest/technical.html#install-requires-vs-requirements-files
install_requires=['numpy>=1.6', 'sympy', 'cython>=0.21']
install_requires=['numpy>=1.7', 'sympy', 'cython>=0.21']

# List additional groups of dependencies here (e.g. development dependencies).
# You can install these using the following syntax, for example:
Expand Down

0 comments on commit 016edf0

Please sign in to comment.