Git Product home page Git Product logo

pycomtrade's People

Contributors

bluesdog164 avatar fortes23 avatar ldemattos avatar miguelmoreto avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

pycomtrade's Issues

Problems with *.cfg with frequency and sample rate as floats

The .cfg file that I'm attempting to read has the frequency and sample rate data as:

60.000000000
1
15360.000000000,42240

Then, when I try to read it, I get:

pyComtrade instance created!
Traceback (most recent call last):
File "example1_l.py", line 44, in
comtradeObj = pyComtrade.ComtradeRecord(dataFile)
File "/home/leonardo/projects/pycomtrade/src/pyComtrade.py", line 105, in init
self.ReadCFG()
File "/home/leonardo/projects/pycomtrade/src/pyComtrade.py", line 210, in ReadCFG
self.lf = int(self.filehandler.readline())
ValueError: invalid literal for int() with base 10: '60.000000000\r\n'

I already have a proposition that I will submit as pull request.

Different *.cfg breaks the library

The oscillographic record that I'm trying to read doesn't have some data fields that are currently taken for granted by pycomtrade, hence I get IndexError exception. Those fields are:

on method ReadCFG()
self.rev_year = int(templist[2])

self.primary.append(float(templist[10]))
self.secondary.append(float(templist[11]))
self.PS.append(templist[12])
self.Dccbm.append(templist[3])
self.y.append(int(templist[4]))

and

self.timemul = float(self.filehandler.readline())

I'm proposing a solution through PR. It's based on a simple check of the templist vector length.

WRONG READ RESULT with multiple sample rate!

Where a wrong result come to my cases while multiple sample rate applied. Here the codes can run after some debugs.

Briefly, a logical mistake results

wrong outputs under multiple sample rate. So some changes in functions below.

def dct_samples(self, data)
--BEFORE
# For each sample rate
for i in range(self.cfg_data['nrates']):
output['samp'].append(data[0]) # Sample rates
output['endsamp'].append(data[1]) # Number of samples
--AFTER
output['samp'].append(data[0]) # Sample rates
output['endsamp'].append(data[1]) # Number of samples

def read_bin_digital(self) && def read_bin_analog(self)
--BEFORE
nS = self.cfg_data['endsamp']
--AFTER
nS = sum(self.cfg_data['endsamp'])

And the core is to get the addition where "# Reading One or Multiple Sample Rates ".

def read(self, cfg_path, dat_path):
......

    # Try to open the config file
    with open(cfg_path, 'r') as cfg_file:

        ......

            # Extracting and testing arguments
            if arg in ['A', 'D']:

                ......
            
            # Reading One or Multiple Sample Rates 
            elif arg in ['samples']:
                
                # Number of Sample Rates
                nsamrate = self.cfg_data['nrates']
                
                # Reading each sample rate
                for i in range(nsamrate):
                    # Read line
                    line = cfg_file.readline()
                    if line.rstrip() == '':
                        break

                    # Process line
                    out_dct = self.proc_line(line, arg)
                    if i in range(1):
                        self.cfg_data.update(out_dct)
                        
                    else:
                        for k in list(out_dct.keys()):
                            self.cfg_data[k].append(out_dct[k][0])
                    
            else:

                ......

    ......

ComtradeRecord

Traceback (most recent call last):
File "example1.py", line 36, in
comtradeObj = pyComtrade.ComtradeRecord()
AttributeError: module 'pyComtrade' has no attribute 'ComtradeRecord'

I get this error please advice

Lacks write example or documentation

Hello, sorry I searched for a documentation here and on the website https://pypi.org/project/pyComtrade/ but I found no documentation for it. I looked at the code and saw the example, but it's an example of how to read comtrade files; the description says it's intended to read and write comtrade files, but by looking at the code I couldn't figure out how to write them.

If the pathfile does not starts with ./ the program breaks

Dear Miguel Moreto,

Thank you very much for this library to open comtrade files! You just made my life so much easier! You deserve an oscar!

Follows the issue description:

If the filepath for *.cfg file don't starts with . the program breaks.
Within the file example1.py
change the line
comtradeObj = pyComtrade.ComtradeRecord('./test_data3/test3.cfg')
to
comtradeObj = pyComtrade.ComtradeRecord('test_data3/test3.cfg')
and you get
No data file content. Use the method ReadDataFile first
No data file content. Use the method ReadDataFile first
Traceback (most recent call last):
File "example1_l.py", line 66, in
axarr[0].plot(time, AnalogChannelData)
File "/usr/lib/python2.7/dist-packages/matplotlib/init.py", line 1814, in inner
return func(ax, *args, **kwargs)
File "/usr/lib/python2.7/dist-packages/matplotlib/axes/_axes.py", line 1424, in plot
for line in self._get_lines(*args, **kwargs):
File "/usr/lib/python2.7/dist-packages/matplotlib/axes/_base.py", line 386, in _grab_next_args
for seg in self._plot_args(remaining, kwargs):
File "/usr/lib/python2.7/dist-packages/matplotlib/axes/_base.py", line 364, in _plot_args
x, y = self._xy_from_xy(x, y)
File "/usr/lib/python2.7/dist-packages/matplotlib/axes/_base.py", line 223, in _xy_from_xy
raise ValueError("x and y must have same first dimension")
ValueError: x and y must have same first dimension

I do have a proposal to correct the method ReadDataFile(), however I'm still struggling with git and github! ASAP, I'll do a pullrequest. I'm used to mercurial and bitbucket.

Pylab not found

pycomtrade-master\pycomtrade-master\examples\example1.py", line 33, in
import pylab
ModuleNotFoundError: No module named 'pylab'

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.