t-onoz / igorwriter Goto Github PK
View Code? Open in Web Editor NEWWrite IGOR binary (.ibw) or text (.itx) files from numpy array
License: MIT License
Write IGOR binary (.ibw) or text (.itx) files from numpy array
License: MIT License
check invalid chars, conflicts with built-in functions, etc.
It may be good to add Unicode support for wave names, data units, text wave elements, etc.
It seems newer (Igor7 or later) waves contain info on encoding which we can modify with SetWaveTextEncoding
, but I need to find out where in the .ibw files it is stored (that is not documented in Igor TN#003).
I have found your package very useful as I work mostly in Python but my boss wants everything plotted in Igor Pro. I have much of my data in pandas dataframes and so I have written a function that saves the dataframe as either .itx or .ibw files.
When save_pd()
is passed a Pandas DataFrame df
( if as_ibw = False
) it saves the DataFrame as .itx
file with the name name
that is passed as a string and each column being a different Igor wave. or it save each column as individual .ibw
file ( if as_ibw = True
).
def save_pd(df, name=None, as_ibw = False):
#If no name specified then take the name of the DataFrame
if not name:
name =[x for x in globals() if globals()[x] is df][0]
with open("./{0}.itx".format(name),'w') as fp:
for column in df.columns:
#Igor does not accept waves named 'time
igor_wave_name = 'times' if 'time' in column else column
#The conversion to np.array then IgorWave5 and then saving is all done here as either .ibw or .itx
if as_ibw:
exec("IgorWave5(np.asarray(df.{0}),'{1}_{2}').save('./{1}_{2}.ibw')".format(column,name,igor_wave_name))
else:
exec("IgorWave5(np.asarray(df.{0}),'{1}_{2}').save_itx(fp)".format(column,name,igor_wave_name))
The dependancy is of course pandas
(for df.columns
).
It would be great to see a function like this added to the IgorWave5
class.
Please email me if there is anything that you want to discuss: [email protected]
Hi,
I'm trying to write a script for internal use that takes numpy arrays and creates some .ibw files that can be loaded in Igor Pro and used for analysis. However, the pre-existing Igor pipeline requires a parameter table from which values are grabbed using DimensionLabels. It would be great to be able to set these labels to the IgorWave in Python similar to how .set_dimscale
already works.
Q's are: Is this already possible? And if not, would this be possible to implement? If you have some pointer's I'm happy to give it a go myself.
Sometimes you might need to create a numpy array containing strings (here using dtype=object
, but other dtypes such as dtype('<U16')
could also work), but this fails on line 287-288 in __init__.py
with the following line:
if a.dtype.type not in TYPES:
raise TypeError('Unsupported dtype: %r' % a.dtype.type)
A simple work is to include np.object_: '/T',
in TYPES
and ITX_TYPES
Igor Textファイル内にTrue, Falseが書き込まれるため、Igor Proで開いたときに読み込みエラーになる。
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.