X-Git-Url: http://git.tremily.us/?a=blobdiff_plain;ds=sidebyside;f=hooke%2Fdriver%2Fmfp1dexport.py;h=aefb5a5b12ad98e2f6f570b149e9e713346be3ff;hb=565f9d7b69d2e4a9ea447d7a50f8f835c3e08642;hp=5cc18e53f7b25f10d2e3cb84c98bc57e7aa4f3ff;hpb=c0bd161ab41e18f33f4497b8e3206f0a12bf9616;p=hooke.git diff --git a/hooke/driver/mfp1dexport.py b/hooke/driver/mfp1dexport.py index 5cc18e5..aefb5a5 100644 --- a/hooke/driver/mfp1dexport.py +++ b/hooke/driver/mfp1dexport.py @@ -1,21 +1,44 @@ -''' -mfp1dexport.py +# Copyright (C) 2009-2010 Massimo Sandal +# W. Trevor King +# +# This file is part of Hooke. +# +# Hooke is free software: you can redistribute it and/or modify it +# under the terms of the GNU Lesser General Public License as +# published by the Free Software Foundation, either version 3 of the +# License, or (at your option) any later version. +# +# Hooke is distributed in the hope that it will be useful, but WITHOUT +# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY +# or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General +# Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with Hooke. If not, see +# . -Driver for text-exported MFP 1D files +"""Driver for text-exported MFP 1D files +""" -Massimo Sandal (c) 2009 -''' +import os + +from .. import libhooke as lh +from .. import curve as lhc + + +__version__='0.0.0.20090923' -import libhookecurve as lhc -import libhooke as lh class mfp1dexportDriver(lhc.Driver): def __init__(self, filename): - - self.filename=filename - self.filedata=open(filename,'rU') - self.lines=list(self.filedata.readlines()) + ''' + This is a driver to import Asylum Research MFP 1D data. + Status: experimental + ''' + self.filename = filename + self.filedata = open(filename,'rU') + self.lines = list(self.filedata.readlines()) self.filedata.close() self.filetype='mfp1dexport' @@ -26,13 +49,13 @@ class mfp1dexportDriver(lhc.Driver): def is_me(self): try: - self.raw_header=self.lines[0:38] + self.raw_header = self.lines[0:38] except: #Not enough lines for a header; not a good file return False #FIXME: We want a more reasonable header recognition - if self.raw_header[0][0:4]=='Wave': + if self.raw_header[0].startswith('Wave'): return True else: return False @@ -52,7 +75,6 @@ class mfp1dexportDriver(lhc.Driver): #self.k=float(self.raw_header[23][8:]) self.k=float(kline[1]) - xext=[] xret=[] yext=[] @@ -67,20 +89,22 @@ class mfp1dexportDriver(lhc.Driver): return [[xext,yext],[xret,yret]] def deflection(self): - self.data=self._read_columns() - return self.data[0][1],self.data[1][1] - + self.data = self._read_columns() + return self.data[0][1], self.data[1][1] def default_plots(self): - main_plot=lhc.PlotObject() - defl_ext,defl_ret=self.deflection() - yextforce=[i*self.k for i in defl_ext] - yretforce=[i*self.k for i in defl_ret] - main_plot.add_set(self.data[0][0],yextforce) - main_plot.add_set(self.data[1][0],yretforce) + main_plot = lhc.PlotObject() + defl_ext,defl_ret = self.deflection() + yextforce = [i*self.k for i in defl_ext] + yretforce = [i*self.k for i in defl_ret] + main_plot.add_set(self.data[0][0], yextforce) + main_plot.add_set(self.data[1][0], yretforce) main_plot.normalize_vectors() - main_plot.units=['Z','force'] #FIXME: if there's an header saying something about the time count, should be used - main_plot.destination=0 - main_plot.title=self.filename - #main_plot.colors=['red','blue'] + #main_plot.units = ['Z','force'] #FIXME: if there's an header saying something about the time count, should be used + main_plot.units = ['m','N'] + main_plot.destination = 0 + main_plot.filename = self.filename + main_plot.title = os.path.basename(self.filename) + main_plot.colors = ['red','blue'] + main_plot.style = ['plot','plot'] return [main_plot]