<div dir="ltr"><div>Dear Raitis,</div><div><br></div><div>You may take a look at Cube-Toolz (<a href="https://github.com/funkymunkycool/Cube-Toolz">https://github.com/funkymunkycool/Cube-Toolz</a>).<br></div><div><br></div><div>However, as cube files are human readable and quite easy to parse, you can always do the operations you need yourself. For example, the following Python3 script implements a class that can parse a density cube file:</div><div><br></div><div>import scipy as sp<br>class Cube:<br>    def __init__(self, filename):<br>        self.filename = filename<br>        <br>        with open(self.filename, 'r') as f:<br>            raw_data = f.readlines()<br>        <br>        self.natoms = int(raw_data[2].split()[0])<br>        self.nx, self.ny, <a href="http://self.nz">self.nz</a> = [int(line.split()[0]) for line in raw_data[3:6]]<br>        <br>        self.parse_density(raw_data)<br>        print('Cube file {:s} parsed'.format(filename))<br>    <br>    def parse_density(self, raw_data):<br>        """ builds an nx times ny times nz array representing the spin density """<br>        <br>        data = []<br>        for line in raw_data[self.natoms + 6:]:<br>            data.extend(float(x) for x in line.split())<br>        <br>        self.density = sp.zeros((self.nx, self.ny, <a href="http://self.nz">self.nz</a>))<br>        for i in range(self.nx):<br>            for j in range(self.ny):<br>                for k in range(<a href="http://self.nz">self.nz</a>):<br>                    self.density[i, j, k] = data[i * self.ny * <a href="http://self.nz">self.nz</a> + j * <a href="http://self.nz">self.nz</a> + k]<br></div><div><br></div><div>You can then calculate the average density by simply summing up the density array of each cube file.</div><div><br></div><div>Yours sincerely,</div><div>Patrick Gono<br></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Mon, Nov 25, 2019 at 9:58 AM Raitis <<a href="mailto:raitis...@gmail.com">raitis...@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div>Dear all,</div><div><br></div><div>I am trying to compute Raman spectra for my system by following this tutorial: <a href="https://brehm-research.de/files/spec_tutorial_2018.pdf" target="_blank">https://brehm-research.de/files/spec_tutorial_2018.pdf</a></div><div><br></div><div>At the electron density data calculation step I messed up and got cube files for each frame separately (I believe it is because I forgot to put "=" in front of results.cube).</div><div>Is there a way to merge all the cube files of md simulation in one?</div><div><br></div><div>Raitis<br></div></div>

<p></p>

-- <br>
You received this message because you are subscribed to the Google Groups "cp2k" group.<br>
To unsubscribe from this group and stop receiving emails from it, send an email to <a href="mailto:cp...@googlegroups.com" target="_blank">cp...@googlegroups.com</a>.<br>
To view this discussion on the web visit <a href="https://groups.google.com/d/msgid/cp2k/86012e05-b236-4bd4-8106-ce1adf3aad07%40googlegroups.com?utm_medium=email&utm_source=footer" target="_blank">https://groups.google.com/d/msgid/cp2k/86012e05-b236-4bd4-8106-ce1adf3aad07%40googlegroups.com</a>.<br>
</blockquote></div>