{ "cells": [ { "cell_type": "markdown", "id": "736320d0", "metadata": {}, "source": [ "# An example of creating coefficients using pyEXP\n", "\n", "This example uses a prerun simulation whose output stored in the `Tutorials/Data` directory. This can be recreated using `EXP` and the example configuration and input files from the `EXP-examples/Nbody` simulation. But this notebook could be adapted for any simulation you like.\n", "\n", "We begin by importing `pyEXP` and friends and setting the working directory." ] }, { "cell_type": "code", "execution_count": 1, "id": "1ed1fc36", "metadata": {}, "outputs": [], "source": [ "import os\n", "import yaml\n", "import pyEXP\n", "\n", "# As described in the README, we assume that you have started Jupyter in the `Tutorials` directory and have provided all of the\n", "# necessary data in the `Data` subdirectory. We move to that directory as a first step:\n", "#\n", "os.chdir('../Data')" ] }, { "cell_type": "markdown", "id": "f92d6788", "metadata": {}, "source": [ "## Create the basis\n", "We'll only do the halo coefficients in this simple example. The cylindrical coefficients would procede similarly. See the `viewing a basis` notebook for an example of creating the cylindrical basis." ] }, { "cell_type": "code", "execution_count": 2, "id": "03899777", "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "------------------------------------------------------------\n", "Read from file\n", "------------------------------------------------------------\n", "id: sphereSL\n", "parameters:\n", " Lmax: 4\n", " cachename: sphereSL.model\n", " modelname: SLGridSph.model\n", " nmax: 10\n", " numr: 2000\n", " rmapping: 0.0667\n", " rmax: 1.95\n", " rmin: 0.0001\n", "\n", "------------------------------------------------------------\n", "Constructed from string\n", "------------------------------------------------------------\n", "\n", "---\n", "id: sphereSL\n", "parameters :\n", " numr: 2000\n", " rmin: 0.0001\n", " rmax: 1.95\n", " Lmax: 4\n", " nmax: 10\n", " rmapping: 0.0667\n", " modelname: SLGridSph.model\n", " cachename: sphereSL.cache\n", "...\n", "\n", "------------------------------------------------------------\n", "---- SLGridSph::ReadH5Cache: successfully read basis cache \n", "---- Spherical::orthoTest: worst=0.00016446\n" ] } ], "source": [ "# Get the basis config. This loads a YAML stanza specifies all of the input parameters \n", "# necessary to build the basis. \n", "#\n", "yaml_config = \"\"\n", "with open('basis.yaml') as f:\n", " config = yaml.load(f, Loader=yaml.FullLoader)\n", " yaml_config = yaml.dump(config)\n", "\n", "# Alternatively, you could construct this on the fly in Python, e.g.\n", "bconfig = \"\"\"\n", "---\n", "id: sphereSL\n", "parameters :\n", " numr: 2000\n", " rmin: 0.0001\n", " rmax: 1.95\n", " Lmax: 4\n", " nmax: 10\n", " rmapping: 0.0667\n", " modelname: SLGridSph.model\n", " cachename: sphereSL.cache\n", "...\n", "\"\"\"\n", "print('-'*60)\n", "print('Read from file')\n", "print('-'*60)\n", "print(yaml_config)\n", "print('-'*60)\n", "print('Constructed from string')\n", "print('-'*60)\n", "print(bconfig)\n", "print('-'*60)\n", "\n", "# Construct the basis instance\n", "#\n", "basis = pyEXP.basis.Basis.factory(yaml_config)" ] }, { "cell_type": "markdown", "id": "346c72d3", "metadata": {}, "source": [ "When an adaptive basis such as `sphereSL` or `Cylindrical` is constrructed, the orthogonality of the biorthogonal\n", "basis is automatically computed as a sanity check on the model file and input parameters. The condition reported\n", "by `orthoTest` is the absolute value of the inner product minus one or the inner product itself, for diagonal and\n", "off-diagonal matrix elements, respectively. In this case, you can see that the worst inner product is ~0.0001 or\n", "on part in $10^4$." ] }, { "cell_type": "markdown", "id": "ab2066fc", "metadata": {}, "source": [ "## Creating a particle reader\n", "Now that we have a basis, we can use it to create coefficients from the particle snapshots. `pyEXP` uses a `ParticleReader` object for that.\n", "\n", "The first step is to hand off the files that comprise a snapshot for every time slice. The `ParticleReader` provides a helper function for that. There are two helper functions: `parseFileList` and `parseStringList`. The first reads a list from a file and the second takes a list. Otherwise they are the same. The file names in the list are assumed to end with a snapshot index and an optional part index. For example, if you have single files per snapshot, the list might look like: `myrun.00000`, `myrun.00001`, etc. If you have multiple files per snapshot, they will look something like `myrun.00000_0001`, `myrun.00000_0002`, `myrun.00001_0000`, `myrun.00001_0001`, etc.\n", "\n", "Here is the call for a file:" ] }, { "cell_type": "code", "execution_count": 3, "id": "1549afbf", "metadata": {}, "outputs": [], "source": [ "# Construct batches of files the particle reader. One could use the\n", "# parseStringList to create batches from a vector/list of files. NB:\n", "# a std::vector in C++ becomes a Python.list and vice versa\n", "#\n", "batches = pyEXP.read.ParticleReader.parseFileList('file.list', '')" ] }, { "cell_type": "markdown", "id": "a77e06c1", "metadata": {}, "source": [ "We now iterate the `batches` created by the file parser to create the coefficients. For each batch we create a new reader and pass the reader to the basis instance. The `basis.createFromReader` member creates and returns the coefficients. The coefficients are added to a coefficient container called `coefs`. Note: on the first call `coefs=None` so a new container is created on the first time through." ] }, { "cell_type": "code", "execution_count": 4, "id": "917e2c02", "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "file group is ['OUT.run0.00000']\n", "The component names are: ['dark halo', 'star disk']\n", "Selected dark halo\n", "Call createFromReader at Time 0.0 for 100000 particles\n", "Created coef\n", "Added coef\n", "------------------------------------------------------------\n", "file group is ['OUT.run0.00001']\n", "The component names are: ['dark halo', 'star disk']\n", "Selected dark halo\n", "Call createFromReader at Time 0.009999999999999764 for 100000 particles\n", "Created coef\n", "Added coef\n", "------------------------------------------------------------\n", "file group is ['OUT.run0.00002']\n", "The component names are: ['dark halo', 'star disk']\n", "Selected dark halo\n", "Call createFromReader at Time 0.019999999999998665 for 100000 particles\n", "Created coef\n", "Added coef\n", "------------------------------------------------------------\n", "file group is ['OUT.run0.00003']\n", "The component names are: ['dark halo', 'star disk']\n", "Selected dark halo\n", "Call createFromReader at Time 0.029999999999997563 for 100000 particles\n", "Created coef\n", "Added coef\n", "------------------------------------------------------------\n", "file group is ['OUT.run0.00004']\n", "The component names are: ['dark halo', 'star disk']\n", "Selected dark halo\n", "Call createFromReader at Time 0.04000000000000035 for 100000 particles\n", "Created coef\n", "Added coef\n", "------------------------------------------------------------\n", "file group is ['OUT.run0.00005']\n", "The component names are: ['dark halo', 'star disk']\n", "Selected dark halo\n", "Call createFromReader at Time 0.05000000000000369 for 100000 particles\n", "Created coef\n", "Added coef\n", "------------------------------------------------------------\n", "file group is ['OUT.run0.00006']\n", "The component names are: ['dark halo', 'star disk']\n", "Selected dark halo\n", "Call createFromReader at Time 0.06000000000000703 for 100000 particles\n", "Created coef\n", "Added coef\n", "------------------------------------------------------------\n", "file group is ['OUT.run0.00007']\n", "The component names are: ['dark halo', 'star disk']\n", "Selected dark halo\n", "Call createFromReader at Time 0.0700000000000037 for 100000 particles\n", "Created coef\n", "Added coef\n", "------------------------------------------------------------\n", "file group is ['OUT.run0.00008']\n", "The component names are: ['dark halo', 'star disk']\n", "Selected dark halo\n", "Call createFromReader at Time 0.07999999999999816 for 100000 particles\n", "Created coef\n", "Added coef\n", "------------------------------------------------------------\n", "file group is ['OUT.run0.00009']\n", "The component names are: ['dark halo', 'star disk']\n", "Selected dark halo\n", "Call createFromReader at Time 0.08999999999999261 for 100000 particles\n", "Created coef\n", "Added coef\n", "------------------------------------------------------------\n", "file group is ['OUT.run0.00010']\n", "The component names are: ['dark halo', 'star disk']\n", "Selected dark halo\n", " for 100000 particles at Time 0.09999999999998707\n", "Created coef\n", "Added coef\n", "------------------------------------------------------------\n", "file group is ['OUT.run0.00011']\n", "The component names are: ['dark halo', 'star disk']\n", "Selected dark halo\n", "Call createFromReader at Time 0.10999999999998153 for 100000 particles\n", "Created coef\n", "Added coef\n", "------------------------------------------------------------\n", "file group is ['OUT.run0.00012']\n", "The component names are: ['dark halo', 'star disk']\n", "Selected dark halo\n", "Call createFromReader at Time 0.11999999999997599 for 100000 particles\n", "Created coef\n", "Added coef\n", "------------------------------------------------------------\n", "file group is ['OUT.run0.00013']\n", "The component names are: ['dark halo', 'star disk']\n", "Selected dark halo\n", "Call createFromReader at Time 0.12999999999997933 for 100000 particles\n", "Created coef\n", "Added coef\n", "------------------------------------------------------------\n", "file group is ['OUT.run0.00014']\n", "The component names are: ['dark halo', 'star disk']\n", "Selected dark halo\n", "Call createFromReader at Time 0.13999999999999155 for 100000 particles\n", "Created coef\n", "Added coef\n", "------------------------------------------------------------\n", "file group is ['OUT.run0.00015']\n", "The component names are: ['dark halo', 'star disk']\n", "Selected dark halo\n", "Call createFromReader at Time 0.15000000000000377 for 100000 particles\n", "Created coef\n", "Added coef\n", "------------------------------------------------------------\n", "file group is ['OUT.run0.00016']\n", "The component names are: ['dark halo', 'star disk']\n", "Selected dark halo\n", "Call createFromReader at Time 0.160000000000016 for 100000 particles\n", "Created coef\n", "Added coef\n", "------------------------------------------------------------\n", "file group is ['OUT.run0.00017']\n", "The component names are: ['dark halo', 'star disk']\n", "Selected dark halo\n", "Call createFromReader at Time 0.1700000000000282 for 100000 particles\n", "Created coef\n", "Added coef\n", "------------------------------------------------------------\n", "file group is ['OUT.run0.00018']\n", "The component names are: ['dark halo', 'star disk']\n", "Selected dark halo\n", "Call createFromReader at Time 0.18000000000004043 for 100000 particles\n", "Created coef\n", "Added coef\n", "------------------------------------------------------------\n", "file group is ['OUT.run0.00019']\n", "The component names are: ['dark halo', 'star disk']\n", "Selected dark halo\n", "Call createFromReader at Time 0.19000000000005265 for 100000 particles\n", "Created coef\n", "Added coef\n", "------------------------------------------------------------\n", "file group is ['OUT.run0.00020']\n", "The component names are: ['dark halo', 'star disk']\n", "Selected dark halo\n", "Call createFromReader at Time 0.20000000000006488 for 100000 particles\n", "Created coef\n", "Added coef\n", "------------------------------------------------------------\n", "\n", "Completed the file group list\n", "\n", "The coefficient time list is [0.01, 0.02, 0.03, 0.04, 0.05, 0.06, 0.07, 0.08, 0.09, 0.1, 0.11, 0.12, 0.13, 0.14, 0.15, 0.16, 0.17, 0.18, 0.19, 0.2]\n" ] } ], "source": [ "# This will contain the coefficient container, need to start with a\n", "# null instance to trigger construction\n", "#\n", "coefs = None\n", "\n", "for group in batches:\n", "\n", " print(\"file group is\", group)\n", "\n", " # Make the reader for the desired type. One could probably try to\n", " # do this by inspection but that's another project.\n", " #\n", " reader = pyEXP.read.ParticleReader.createReader('PSPout', group, 0, False);\n", "\n", " # Print the type list\n", " #\n", " print('The component names are:', reader.GetTypes())\n", "\n", " compname = 'dark halo'\n", " reader.SelectType(compname)\n", " print('Selected', compname)\n", "\n", " print('Call createFromReader at Time', reader.CurrentTime(), 'for', reader.CurrentNumber(), 'particles')\n", "\n", " coef = basis.createFromReader(reader)\n", " print(\"Created coef\")\n", "\n", " # We need this idiom here because None is not mapping to a\n", " # null pointer in pybind11. There is probably a way to do this. \n", " # Suggestions anyone?\n", " #\n", " # This is optional---+\n", " # |\n", " if coefs is None: # v\n", " coefs = pyEXP.coefs.Coefs.makecoefs(coef, compname)\n", " else:\n", " coefs.add(coef)\n", "\n", " print('Added coef')\n", " print('-'*60)\n", "\n", "print('\\nCompleted the file group list\\n')\n", "\n", "print('The coefficient time list is', coefs.Times())" ] }, { "cell_type": "markdown", "id": "615e1cd8-a71a-445f-b4b7-d06130739ec6", "metadata": {}, "source": [ "The reader gives a verbose status update for each snapshot as it is read. You can see the component names, simulation time,\n", "and particles numbers per snapshot as the files are read. For large simulations, coefficient construction can take awhile.\n", "Check out the following two scripts in the `Utitilies` directory:\n", "1. make coefficients MPI.py\n", "2. make coefficients native MPI.py\n", " \n", "The first one is an example for Gadget snapshots and the second is an example for EXP snapshots.\n" ] }, { "cell_type": "markdown", "id": "455fc72d", "metadata": {}, "source": [ "## Using a FieldGenerator\n", "Now that we have our new coefficients, we can use the `FieldGenerator` to view the BFE representation of the underlying fields. Here is an example:" ] }, { "cell_type": "code", "execution_count": 5, "id": "9009be62", "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "We now have the following [time field] pairs\n", "----------------------------------------\n", " 0.0100 azi force\n", " 0.0100 dens\n", " 0.0100 dens m=0\n", " 0.0100 dens m>0\n", " 0.0100 mer force\n", " 0.0100 potl\n", " 0.0100 potl m=0\n", " 0.0100 potl m>0\n", " 0.0100 rad force\n", "----------------------------------------\n", " 0.0200 azi force\n", " 0.0200 dens\n", " 0.0200 dens m=0\n", " 0.0200 dens m>0\n", " 0.0200 mer force\n", " 0.0200 potl\n", " 0.0200 potl m=0\n", " 0.0200 potl m>0\n", " 0.0200 rad force\n", "----------------------------------------\n", " 0.0300 azi force\n", " 0.0300 dens\n", " 0.0300 dens m=0\n", " 0.0300 dens m>0\n", " 0.0300 mer force\n", " 0.0300 potl\n", " 0.0300 potl m=0\n", " 0.0300 potl m>0\n", " 0.0300 rad force\n", "\n", "Here is the first one:\n", "----------------------------------------\n", "---- azi force\n", "----------------------------------------\n", "[[-0.00087384 -0.00098027 -0.00113208 ... 0.00053854 0.00058888\n", " 0.00065692]\n", " [-0.00104563 -0.00117976 -0.00136719 ... 0.00044353 0.00050006\n", " 0.00057894]\n", " [-0.00120132 -0.0013625 -0.00158698 ... 0.00027801 0.00034734\n", " 0.00044279]\n", " ...\n", " [-0.00086897 -0.00120733 -0.00153372 ... 0.00364213 0.00354581\n", " 0.00338669]\n", " [-0.00081985 -0.00113707 -0.00144417 ... 0.00372749 0.00363169\n", " 0.00347801]\n", " [-0.00079396 -0.00109152 -0.00138081 ... 0.00380656 0.00370932\n", " 0.00355781]]\n", "----------------------------------------\n", "---- dens\n", "----------------------------------------\n", "[[0.01483475 0.01596043 0.01714892 ... 0.01672023 0.01557306 0.01447723]\n", " [0.01600303 0.01726678 0.01860979 ... 0.01800252 0.01671672 0.01549673]\n", " [0.01722907 0.01864478 0.02016317 ... 0.01938812 0.01793789 0.01657638]\n", " ...\n", " [0.01678794 0.01815355 0.01959459 ... 0.02029726 0.01882576 0.01744723]\n", " [0.01564873 0.01686448 0.01813334 ... 0.0186915 0.01740002 0.01617756]\n", " [0.01458028 0.01566568 0.0167905 ... 0.01718854 0.01605308 0.01497049]]\n", "----------------------------------------\n", "---- dens m=0\n", "----------------------------------------\n", "[[0.01438968 0.0155077 0.01669507 ... 0.01669507 0.0155077 0.01438968]\n", " [0.0155077 0.01676509 0.01810998 ... 0.01810998 0.01676509 0.0155077 ]\n", " [0.01669507 0.01810998 0.01963967 ... 0.01963967 0.01810998 0.01669507]\n", " ...\n", " [0.01669507 0.01810998 0.01963967 ... 0.01963967 0.01810998 0.01669507]\n", " [0.0155077 0.01676509 0.01810998 ... 0.01810998 0.01676509 0.0155077 ]\n", " [0.01438968 0.0155077 0.01669507 ... 0.01669507 0.0155077 0.01438968]]\n", "----------------------------------------\n", "---- dens m>0\n", "----------------------------------------\n", "[[ 4.45073500e-04 4.52731590e-04 4.53846878e-04 ... 2.51552956e-05\n", " 6.53618481e-05 8.75497790e-05]\n", " [ 4.95328044e-04 5.01695555e-04 4.99815797e-04 ... -1.07452950e-04\n", " -4.83680560e-05 -1.09646717e-05]\n", " [ 5.34000923e-04 5.34801453e-04 5.23498224e-04 ... -2.51551945e-04\n", " -1.72089174e-04 -1.18696655e-04]\n", " ...\n", " [ 9.28678128e-05 4.35745387e-05 -4.50829830e-05 ... 6.57595694e-04\n", " 7.15783623e-04 7.52157473e-04]\n", " [ 1.41032098e-04 9.93959984e-05 2.33634619e-05 ... 5.81527303e-04\n", " 6.34925615e-04 6.69857895e-04]\n", " [ 1.90603168e-04 1.57983566e-04 9.54256029e-05 ... 4.93466156e-04\n", " 5.45385177e-04 5.80809254e-04]]\n", "----------------------------------------\n", "---- mer force\n", "----------------------------------------\n", "[[ 0.00116107 0.0012984 0.00143422 ... 0.00141841 0.00133688\n", " 0.00125844]\n", " [ 0.0010585 0.00120293 0.00134758 ... 0.00156861 0.00148209\n", " 0.00139784]\n", " [ 0.00094972 0.00110494 0.00126318 ... 0.00172921 0.00163881\n", " 0.00154933]\n", " ...\n", " [-0.00298936 -0.003173 -0.00336324 ... 0.00119402 0.00105672\n", " 0.00093735]\n", " [-0.00276366 -0.00292988 -0.0031003 ... 0.00081658 0.00071328\n", " 0.00062615]\n", " [-0.00254213 -0.00269264 -0.00284517 ... 0.0004661 0.0003963\n", " 0.00034138]]\n", "----------------------------------------\n", "---- potl\n", "----------------------------------------\n", "[[-0.9169819 -0.9383662 -0.95999885 ... -0.960537 -0.9389293\n", " -0.917559 ]\n", " [-0.9383129 -0.9611787 -0.9843996 ... -0.984946 -0.96175075\n", " -0.93889844]\n", " [-0.95987254 -0.98432374 -1.0092399 ... -1.009817 -0.98492396\n", " -0.960483 ]\n", " ...\n", " [-0.9592484 -0.98363 -1.0084537 ... -1.0091766 -0.984431\n", " -0.9601257 ]\n", " [-0.93764687 -0.9604352 -0.98355633 ... -0.98422873 -0.9611766\n", " -0.9384567 ]\n", " [-0.91629386 -0.9375966 -0.9591268 ... -0.9597348 -0.9382673\n", " -0.9170273 ]]\n", "----------------------------------------\n", "---- potl m=0\n", "----------------------------------------\n", "[[-0.9166649 -0.9380169 -0.9596112 ... -0.9596112 -0.9380169 -0.9166649]\n", " [-0.9380169 -0.9608532 -0.9840379 ... -0.9840379 -0.9608532 -0.9380169]\n", " [-0.9596112 -0.9840379 -1.0089229 ... -1.0089229 -0.9840379 -0.9596112]\n", " ...\n", " [-0.9596112 -0.9840379 -1.0089229 ... -1.0089229 -0.9840379 -0.9596112]\n", " [-0.9380169 -0.9608532 -0.9840379 ... -0.9840379 -0.9608532 -0.9380169]\n", " [-0.9166649 -0.9380169 -0.9596112 ... -0.9596112 -0.9380169 -0.9166649]]\n", "----------------------------------------\n", "---- potl m>0\n", "----------------------------------------\n", "[[-0.00031698 -0.00034926 -0.00038765 ... -0.00092586 -0.00091239\n", " -0.00089413]\n", " [-0.00029595 -0.00032549 -0.00036175 ... -0.00090816 -0.00089753\n", " -0.00088152]\n", " [-0.00026139 -0.00028588 -0.00031703 ... -0.00089411 -0.00088608\n", " -0.00087182]\n", " ...\n", " [ 0.00036277 0.00040785 0.00046916 ... -0.00025367 -0.00039316\n", " -0.00051454]\n", " [ 0.00037004 0.00041801 0.00048153 ... -0.00019086 -0.00032336\n", " -0.00043978]\n", " [ 0.00037099 0.00042032 0.00048442 ... -0.00012365 -0.00025039\n", " -0.0003624 ]]\n", "----------------------------------------\n", "---- rad force\n", "----------------------------------------\n", "[[-0.58504117 -0.60900503 -0.63369316 ... -0.63327456 -0.6087623\n", " -0.5849374 ]\n", " [-0.6087843 -0.6348392 -0.66203845 ... -0.66186184 -0.6348188\n", " -0.60887575]\n", " [-0.6331737 -0.661728 -0.691743 ... -0.6919265 -0.66203153\n", " -0.6335524 ]\n", " ...\n", " [-0.6329953 -0.6614362 -0.6912934 ... -0.69079643 -0.66104454\n", " -0.632722 ]\n", " [-0.60824454 -0.6341394 -0.66113216 ... -0.66103613 -0.6340929\n", " -0.6082666 ]\n", " [-0.58422893 -0.6079955 -0.6324451 ... -0.632654 -0.6082124\n", " -0.5844728 ]]\n" ] } ], "source": [ "# Now try some slices for rendering\n", "#\n", "\n", "times = coefs.Times()[0:3]\n", "pmin = [-1.0, -1.0, 0.0]\n", "pmax = [ 1.0, 1.0, 0.0]\n", "grid = [ 40, 40, 0]\n", "\n", "fields = pyEXP.field.FieldGenerator(times, pmin, pmax, grid)\n", "\n", "surfaces = fields.slices(basis, coefs)\n", "\n", "print(\"We now have the following [time field] pairs\")\n", "for v in surfaces:\n", " print('-'*40)\n", " for u in surfaces[v]:\n", " print(\"{:8.4f} {}\".format(v, u))\n", "\n", "print(\"\\nHere is the first one:\")\n", "for v in surfaces:\n", " for u in surfaces[v]:\n", " print('-'*40)\n", " print('----', u)\n", " print('-'*40)\n", " print(surfaces[v][u])\n", " break" ] }, { "cell_type": "markdown", "id": "b5987403", "metadata": {}, "source": [ "These could be make into images and so forth. We'll do this in another example notebook.\n", "\n", "## Saving the coefficients\n", "\n", "At this point, it makes sense to save the coefficients that you have just created. This is sone with the following call:" ] }, { "cell_type": "code", "execution_count": 6, "id": "730e21e8", "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Nothing to delete\n", "Coefficient file saved\n" ] } ], "source": [ "# Remove any old file with the same name\n", "try:\n", " os.remove('test_coefs')\n", "except:\n", " print('Nothing to delete')\n", "coefs.WriteH5Coefs('test_coefs')\n", "print('Coefficient file saved')" ] }, { "cell_type": "markdown", "id": "768e73d4", "metadata": {}, "source": [ "We now have a EXP HDF5 coefficient file called `test_coefs`. You can view the contents of `test_coefs` directly using the\n", "`h5dump` command supplied in your HDF5 installion:\n", "```\n", "h5dump test_coefs | less\n", "```\n", "\n", "As an example of manipulating the newly made coefficients in pyEXP, let's try reading the newly created file into another coefficient container, `coefs2`. The container has a member function called `CompareStanzas` which will check on the contents. Let's do it." ] }, { "cell_type": "code", "execution_count": 7, "id": "4cc3d3d7", "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Type is sphere\n", "Times are the same, now checking parameters at each time\n", "Parameters are the same, now checking coefficients\n" ] }, { "data": { "text/plain": [ "True" ] }, "execution_count": 7, "metadata": {}, "output_type": "execute_result" } ], "source": [ "# Now try reading it in\n", "#\n", "coefs2 = pyEXP.coefs.Coefs.factory('test_coefs')\n", "print(\"Type is\", coefs2.getGeometry())\n", "\n", "# Now compare with the original\n", "#\n", "coefs2.CompareStanzas(coefs)" ] }, { "cell_type": "markdown", "id": "fc6cabce", "metadata": {}, "source": [ "This member function will print differences. No differenced should be printed, of course." ] }, { "cell_type": "markdown", "id": "424e6b92", "metadata": {}, "source": [ "***\n", "\n", "## Where do you want to go next?\n", "\n", "- [Return to Table of Contents](../README.ipynb)\n", "- [Go to next notebook](./Part2-Analysis.ipynb)\n" ] } ], "metadata": { "kernelspec": { "display_name": "Python 3 (ipykernel)", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.12.3" } }, "nbformat": 4, "nbformat_minor": 5 }