pencil.io.snapshot ================== .. py:module:: pencil.io.snapshot .. autoapi-nested-parse:: Contains the functions to generate a snapshot (VAR files). Functions --------- .. autoapisummary:: pencil.io.snapshot.write_snapshot pencil.io.snapshot.write_h5_snapshot pencil.io.snapshot.write_h5_grid pencil.io.snapshot.write_h5_averages pencil.io.snapshot.write_h5_slices Module Contents --------------- .. py:function:: write_snapshot(snapshot, file_name='VAR0', datadir='data', nprocx=1, nprocy=1, nprocz=1, precision='d', nghost=3, persist=None, param=None, t=None, x=None, y=None, z=None, lshear=False, dx=None, dy=None, dz=None) Write a snapshot given as numpy array. call signature: write_snapshot(snapshot, file_name='VAR0', datadir='data', nprocx=1, nprocy=1, nprocz=1, precision='d', nghost=3, persist=None, param=None, t=None, x=None, y=None, z=None, lshear=False, dx=None, dy=None, dz=None) Keyword arguments: *snapshot*: Numpy array containing the snapshot. Must be of shape [nvar, nz, ny, nx] (without boundaries). *file_name*: Name of the snapshot file to be written, e.g. VAR0 or var.dat. *datadir*: Directory where the data is stored. *nproc[xyz]*: Number of processors in xyz. *precision*: Single 'f' or double 'd' precision. *nghost*: Number of ghost zones. *persist*: Structure of persistent values *param*: Optional Param object. *t*: Time of the snapshot. *xyz*: xyz arrays of the domain without ghost zones. *lshear*: Flag for the shear. *dx, dy, dz* : float Grid spacing (for calculation in the case of nonequidistant grids, see subroutine grid.f90/construct_grid) .. py:function:: write_h5_snapshot(snapshot, file_name='VAR0', datadir='data/allprocs', precision='d', nghost=3, persist=None, settings=None, param=None, grid=None, lghosts=False, indx=None, proc=None, ipx=None, ipy=None, ipz=None, procdim=None, unit=None, t=None, x=None, y=None, z=None, state='a', quiet=True, lshear=False, driver=None, comm=None, overwrite=False, rank=0, size=1, sim_datadir='data') Write a snapshot given as numpy array. We assume by default that a run simulation directory has already been constructed and start completed successfully in h5 format so that files dim, grid and param files are already present. If not the contents of these will need to be supplied as dictionaries along with persist if included. call signature: write_h5_snapshot(snapshot, file_name='VAR0', datadir='data/allprocs', precision='d', nghost=3, persist=None, settings=None, param=None, grid=None, lghosts=False, indx=None, unit=None, t=None, x=None, y=None, z=None, procdim=None, quiet=True, lshear=False, driver=None, comm=None) Keyword arguments: *snapshot*: Numpy array containing the snapshot. Must be of shape [nvar, nz, ny, nx] without boundaries or. Must be of shape [nvar, mz, my, mx] with boundaries for lghosts=True. *file_name*: Name of the snapshot file to be written, e.g. VAR0 or var. *datadir*: Directory which the snapshot will be written into. *precision*: Single 'f' or double 'd' precision. *persist*: optional dictionary of persistent variable. *settings*: optional dictionary of persistent variable. *param*: optional Param object. *grid*: optional Pencil Grid object of grid parameters. *nghost*: Number of ghost zones. *lghosts*: If True the snapshot contains the ghost zones. *indx* Index object of index for each variable in f-array *unit*: Optional dictionary of simulation units. *quiet*: Option to print output. *t*: Time of the snapshot. *xyz*: xyz arrays of the domain with ghost zones. This will normally be obtained from Grid object, but facility to redefine an alternative grid value. *lshear*: Flag for the shear. *driver* File driver for hdf5 io for use in serial or MPI parallel. *comm* MPI objects supplied if driver is 'mpio'. *overwrite* flag to replace existing h5 snapshot file. *rank* rank of process with root=0. *sim_datadir* Datadir of the destination simulation. Used to get param, dim, and index info when they are not provided. .. py:function:: write_h5_grid(file_name='grid', datadir='data', precision='d', nghost=3, settings=None, param=None, grid=None, unit=None, quiet=True, driver=None, comm=None, overwrite=False, rank=0) Write the grid information as hdf5. We assume by default that a run simulation directory has already been constructed, but start has not been executed in h5 format so that binary sim files dim, grid and param files are already present in the sim directory, or provided from an old binary sim source directory as inputs. call signature: write_h5_grid(file_name='grid', datadir='data', precision='d', nghost=3, settings=None, param=None, grid=None, unit=None, quiet=True, driver=None, comm=None) Keyword arguments: *file_name*: Prefix of the file name to be written, 'grid'. *datadir*: Directory where 'grid.h5' is stored. *precision*: Single 'f' or double 'd' precision. *nghost*: Number of ghost zones. *settings*: Optional dictionary of persistent variable. *param*: Optional Param object. *grid*: Optional Pencil Grid object of grid parameters. *unit*: Optional dictionary of simulation units. *quiet*: Option to print output. .. py:function:: write_h5_averages(aver, file_name='xy', datadir='data/averages', nt=None, precision='d', indx=None, trange=None, quiet=True, append=False, procdim=None, dim=None, aver_by_proc=False, proc=-1, driver=None, comm=None, rank=0, size=1, overwrite=False, nproc=1) Write an hdf5 format averages dataset given as an Averages object. We assume by default that a run simulation directory has already been constructed and start completed successfully in h5 format so that files dim, grid and param files are already present. If not the contents of these will need to be supplied as dictionaries along with persist if included. call signature: write_h5_averages(aver, file_name='xy', datadir='data/averages', precision='d', indx=None, trange=None, quiet=True) Keyword arguments: *aver*: Averages object. Must be of shape [n_vars, n1] for averages across 'xy', 'xz' or 'yz'. Must be of shape [n_vars, n1, n2] for averages across 'y', 'z'. *file_name*: Name of the snapshot file to be written, e.g. 'xy', 'xz', 'yz', 'y', 'z'. *datadir*: Directory where the data is stored. *precision*: Single 'f' or double 'd' precision. *indx* Restrict iterative range to be written. *trange*: Restrict time range to be written. *append* For large binary files the data may need to be appended iteratively. *dim* Dim object required if the large binary files are supplied in chunks. .. py:function:: write_h5_slices(vslice, coordinates, positions, datadir='data/slices', precision='d', indx=None, trange=None, quiet=True, append=False, dim=None) Write an hdf5 format slices dataset given as an Slices object. We assume by default that a run simulation directory has already been constructed and start completed successfully in h5 format so that files dim, grid and param files are already present. If not the contents of these will need to be supplied as dictionaries along with persist if included. call signature: write_h5_slices(vslice, coordinates, positions, datadir='data/slices', precision='d', indx=None, trange=None, quiet=True) Keyword arguments: *vslice*: Slices object. Object with attributes 't', extensions e.g, 'xy', 'xy2', 'xz', 'yz' and data fields of shape [nt, n1, n2] e.g 'uu1', 'uu2', 'uu3', ... *coordinates* Dictionary of lmn indices of all slices in the object n for 'xy', etc. Obtained from 'data/positions.dat' in source binary simulation *positions* Dictionary of xyz values of all slices in the object z for 'xy', etc. Obtained from source binary simulation grid at coordinates. *datadir*: Directory where the data is stored. *precision*: Single 'f' or double 'd' precision. *indx* Restrict iterative range to be written. *trange*: Restrict time range to be written. *append* For large binary files the data may need to be appended iteratively. *dim* Dim object required if the large binary files are supplied in chunks.