Example #1
0
 def test_frequency_plot(self):
     sp = Spectrum(name='Example 1')
     sp.from_surface(surface=np.ones([10, 10]))
     pl = sp.frequency_plot()
     os.makedirs('data/test_data')
     pl.savefig('data/test_data/frequency_plot.png')
     self.assertEqual(os.path.exists('data/test_data/frequency_plot.png'),
                      True)
     shutil.rmtree('data/test_data/')
Example #2
0
def plot_spectra(inputfolder, outputfolder, **kwargs):
    """
    Plot bar plots for individual frequency spectra in a given directory. 

    Parameters
    ----------
    inputfolder : str
        Input directory with spectra to plot.
    outputfolder : str
        Output directory to save the bar plots.
    kwargs : key, value pairings
            Arbitrary keyword arguments to pass to the Spectrum.frequency_plot function.
    """
    files = filelib.list_subfolders(inputfolder, extensions=['csv'])

    for fn in files:
        s = Spectrum(filename=inputfolder + fn)
        pl = s.frequency_plot(title=fn[:-4], **kwargs)
        filelib.make_folders([os.path.dirname(outputfolder + fn[:-4])])
        pl.savefig(outputfolder + fn[:-4] + '.png')
        pl.clf()