Repository: wright-group/WrightTools

Issue:
Example of Brunold Group rRaman data loading and plotting



Discussion:

Resolving patch:
diff --git a/WrightTools/data.py b/WrightTools/data.py
--- a/WrightTools/data.py
+++ b/WrightTools/data.py
@@ -1912,7 +1912,7 @@ def from_text(filepath, name=None, verbose=True):
         New data object(s).
     """
     if isinstance(filepath, type([])) or isinstance(filepath, type(np.array([]))):
-        return [from_rRaman(f) for f in filepath]
+        return [from_text(f) for f in filepath]
 
     if not os.path.isfile(filepath):
         raise wt_exceptions.FileNotFound(path=filepath)
@@ -1934,22 +1934,56 @@ def from_text(filepath, name=None, verbose=True):
     indicies = np.arange(1)
     for i in indicies:
         axis = Axis(arr[i], 'wn', name='wm')
-        signal = Channel(arr[i + 1], name='signal', label='counts', signed=False)
+        signal = Channel(arr[i + 1], name='signal', label='units', signed=False)
         if name:
-            data = Data([axis], [signal], source='Brunold rRaman', name=name)
+            data = Data([axis], [signal], source='txt file', name=name)
         else:
             name = filepath.split('//')[-1].split('.')[0]
-            data = Data([axis], [signal], source='Brunold rRaman', name=name)
+            data = Data([axis], [signal], source='txt file', name=name)
     # finish
     if verbose:
         print('{0} data objects successfully created from file:'.format(len(indicies)))
-        for i, data in enumerate(datas):
-            print('  {0}: {1}'.format(i, data.name))
     return data
 
 
-def from_rRaman(*args, **kwargs):
-    return from_text(*args, **kwargs)
+def from_BrunoldrRaman(filepath, name=None, verbose=True):
+    """ Create a data object from plaintext tab deliminated file
+
+    Expects one energy (in wavenumbers) and one counts value.
+
+    Parameters
+    ----------
+    filepath : string, list of strings, or array of strings
+        Path to .txt file.
+    name : string (optional)
+        Name to give to the created data object. If None, filename is used.
+        Default is None.
+    verbose : boolean (optional)
+        Toggle talkback. Default is True.
+
+    Returns
+    -------
+    data
+        New data object(s).
+    """
+    if not os.path.isfile(filepath):
+        raise wt_exceptions.FileNotFound(path=filepath)
+    if not filepath.endswith('txt'):
+        wt_exceptions.WrongFileTypeWarning.warn(filepath, 'txt')
+    # import array
+    arr = np.genfromtxt(filepath, delimiter='\t').T
+    # chew through all scans
+    axis = Axis(arr[0], 'wn', name='wm')
+    signal = Channel(arr[1], name='signal', label='counts', signed=False)
+    if name:
+        data = Data([axis], [signal], source='Brunold rRaman', name=name)
+    else:
+        name = filepath.split('//')[-1].split('.')[0]
+        data = Data([axis], [signal], source='Brunold rRaman', name=name)
+    # finish
+    if verbose:
+        print('1 data object successfully created from file')
+    return data
 
 
 def from_COLORS(
diff --git a/WrightTools/datasets/__init__.py b/WrightTools/datasets/__init__.py
--- a/WrightTools/datasets/__init__.py
+++ b/WrightTools/datasets/__init__.py
@@ -48,6 +48,9 @@ def from_directory(self, dirname, prefix=''):
 KENT.from_directory(os.path.join(here, 'KENT', 'PbSe 2D delay A'))
 KENT.from_directory(os.path.join(here, 'KENT', 'PbSe 2D delay B'))
 
+BrunoldrRaman = DatasetContainer()
+BrunoldrRaman.from_files(os.path.join(here, 'BrunoldrRaman'))
+
 PyCMDS = DatasetContainer()
 PyCMDS.from_files('PyCMDS')
 
@@ -55,4 +58,4 @@ def from_directory(self, dirname, prefix=''):
 # --- pretty namespace ----------------------------------------------------------------------------
 
 
-__all__ = ['COLORS', 'JASCO', 'KENT']
+__all__ = ['COLORS', 'JASCO', 'KENT', 'BrunoldrRaman']
diff --git a/examples/rRaman.py b/examples/rRaman.py
new file mode 100644
--- /dev/null
+++ b/examples/rRaman.py
@@ -0,0 +1,20 @@
+# -*- coding: utf-8 -*-
+"""
+Resonance Raman
+==========
+
+A Resonance Raman plot.
+"""
+
+import WrightTools as wt
+from WrightTools import datasets
+
+p = datasets.BrunoldrRaman.LDS821_514nm_80mW
+data = wt.data.from_BrunoldrRaman(p)
+trash_pixels = 56
+data = data.split(0, 843.0)[1]
+
+data.convert('wn', verbose=False)
+
+artist = wt.artists.mpl_1D(data)
+d = artist.plot()


Test patch: