Skip to content

printtipsy

wadsley edited this page Nov 3, 2021 · 4 revisions

printtipsy is a command line reader program for tipsy format files (binary & standard) including auxiliary files (e.g. out.00128.iord). It is intended to quickly check file contents under unix/linux so as to avoid having to move the files or load them into python (e.g. with pynbody).

Usage: printtipsy [-af] [-av] [-a CSV] [-p nprint (def 10)] [-i istart] [-e iend] [-n nth] [-gds] [-sphere x y z r] [-nc] [-prop] filename

By default printtipsy prints the header and the properties of the first 10 particles of each type in plain text. The only required argument is a filename. You can use optional parameters to print every nth particle (with -n), where to start (-i) and end (-e) and how many to print (-p). It can also print the properties with -prop (e.g. total mass, centre of mass position & motion). You can modify which ones are included in the properties using the -sphere option. You can limit is to only gas, dark or star with -dgs (or any subset, -g is gas only). -nc Attempts to force printtipsy to read the file contents even if it cannot determine what the format is.

Getting and compiling

The source is: printtipsy.c
It can be compiled with:
gcc printtipsy.c -lm -o printtipsy

The main dependency is the xdr library for std format files and associated headers xdr.h and rpc.h
printtipsy was written by James Wadsley

File formats

printtipsy automatically detects the legacy formats of tipsy files: binary (normal binary: intel/little endian), standard (xdr, Sun/apple big endian)
It can cope with 28 byte or 32 byte headers so it will read most files without help, e.g.
printtipsy tipsyfile.std
printtipsy cosmosim.01024
It can also detect binary or standard auxiliary files and print the content, e.g.
printtipsy cosmosim.1024.HI

Example:

$ printtipsy -prop cosmo32standard.00160
  Time 0.251354 Particles in STD TIPSY file: 32768 gas, 32768 dark, 0 stars
       GAS     mass         x          y          z             vx         vy         vz         dens         temp      eps          Z        phi  
         0 1.46484e-06   -0.484375  -0.484375  -0.484375  6.97573e-18 5.23105e-18 1.4331e-18   0.0478297    13045.6  0.0104063          0          0
         1 1.46484e-06   -0.453125  -0.484375  -0.484375  -1.81774e-18 9.80294e-18 -3.51299e-19   0.0478297    13045.6  0.0104063          0          0
         2 1.46484e-06   -0.421875  -0.484375  -0.484375  -2.88847e-20 5.2512e-18 1.63241e-18   0.0478297    13045.6  0.0104063          0          0
         3 1.46484e-06   -0.390625  -0.484375  -0.484375  -2.04643e-19 8.46894e-18 1.2522e-18   0.0478297    13045.6  0.0104063          0          0
         4 1.46484e-06   -0.359375  -0.484375  -0.484375  -1.45326e-18 3.09829e-18 -5.47565e-19   0.0478297    13045.6  0.0104063          0          0
         5 1.46484e-06   -0.328125  -0.484375  -0.484375  2.29802e-19 6.18175e-18 1.29731e-18   0.0478297    13045.6  0.0104063          0          0
         6 1.46484e-06   -0.296875  -0.484375  -0.484375  -2.08524e-19 3.45811e-18 -5.06143e-20   0.0478297    13045.6  0.0104063          0          0
         7 1.46484e-06   -0.265625  -0.484375  -0.484375  -4.82878e-19 6.6645e-18 2.84974e-18   0.0478297    13045.6  0.0104063          0          0
         8 1.46484e-06   -0.234375  -0.484375  -0.484375  7.93894e-19 3.35787e-18 -1.47918e-18   0.0478297    13045.6  0.0104063          0          0
         9 1.46484e-06   -0.203125  -0.484375  -0.484375  -1.32067e-18 6.58207e-18   1.12e-18   0.0478297    13045.6  0.0104063          0          0
      DARK     mass         x          y          z             vx         vy         vz         eps          phi  
         0 7.95288e-06   -0.484375  -0.484375  -0.484375           0          0          0   0.0104063          0
         1 7.95288e-06   -0.453125  -0.484375  -0.484375           0          0          0   0.0104063          0
         2 7.95288e-06   -0.421875  -0.484375  -0.484375           0          0          0   0.0104063          0
         3 7.95288e-06   -0.390625  -0.484375  -0.484375           0          0          0   0.0104063          0
         4 7.95288e-06   -0.359375  -0.484375  -0.484375           0          0          0   0.0104063          0
         5 7.95288e-06   -0.328125  -0.484375  -0.484375           0          0          0   0.0104063          0
         6 7.95288e-06   -0.296875  -0.484375  -0.484375           0          0          0   0.0104063          0
         7 7.95288e-06   -0.265625  -0.484375  -0.484375           0          0          0   0.0104063          0
         8 7.95288e-06   -0.234375  -0.484375  -0.484375           0          0          0   0.0104063          0
         9 7.95288e-06   -0.203125  -0.484375  -0.484375           0          0          0   0.0104063          0
Total Mass 0.3086
COM position 0 0 0
COM velocity -7.43029e-20 -7.32042e-20 -6.91466e-20
Angular Momentum  -3.33711e-22 8.80864e-22 -3.65071e-22
velocity dispersion 1.04967e-18 1.00987e-18 1.04428e-18  1.79225e-18

Auxiliary files

With -a you can have printtipsy search for auxiliary files associated with the specified filename and print the data from those as well. -a all will do all known extensions. -a HI,HeI will do just those extensions (CSV string)

Example:

$ printtipsy -g -a HI,HeI,HeII cosmo32out_z3.00168  
  Time 0.259712 Particles in STD TIPSY file: 32768 gas, 32768 dark, 0 stars
       GAS     mass         x          y          z             vx         vy         vz         dens         temp      eps          Z        phi  
         0 1.46484e-06   -0.484375  -0.484375  -0.484375  6.66478e-18 4.95972e-18 1.33751e-18   0.0478297    12686.8  0.0104063          0          0
         1 1.46484e-06   -0.453125  -0.484375  -0.484375  -1.71271e-18 9.34982e-18 -3.43242e-19   0.0478297    12686.8  0.0104063          0          0
         2 1.46484e-06   -0.421875  -0.484375  -0.484375  -3.3276e-20 4.98073e-18 1.52779e-18   0.0478297    12686.8  0.0104063          0          0
         3 1.46484e-06   -0.390625  -0.484375  -0.484375  -1.8945e-19 8.05944e-18 1.16615e-18   0.0478297    12686.8  0.0104063          0          0
         4 1.46484e-06   -0.359375  -0.484375  -0.484375  -1.39842e-18 2.92882e-18 -4.86804e-19   0.0478297    12686.8  0.0104063          0          0
         5 1.46484e-06   -0.328125  -0.484375  -0.484375  1.9688e-19 5.84649e-18 1.21852e-18   0.0478297    12686.8  0.0104063          0          0
         6 1.46484e-06   -0.296875  -0.484375  -0.484375  -1.86612e-19 3.30566e-18 -4.91823e-20   0.0478297    12686.8  0.0104063          0          0
         7 1.46484e-06   -0.265625  -0.484375  -0.484375  -4.31296e-19 6.36777e-18 2.70345e-18   0.0478297    12686.8  0.0104063          0          0
         8 1.46484e-06   -0.234375  -0.484375  -0.484375   7.316e-19 3.21884e-18 -1.37582e-18   0.0478297    12686.8  0.0104063          0          0
         9 1.46484e-06   -0.203125  -0.484375  -0.484375  -1.22738e-18 6.22874e-18 1.04215e-18   0.0478297    12686.8  0.0104063          0          0
65536 Particles in STD Binary array file cosmo32out_z3.00168.HI
GAS  3.95063e-06 3.95063e-06 3.95063e-06 3.95063e-06 3.95063e-06 3.95063e-06 3.95063e-06 3.95063e-06 3.95063e-06 3.95063e-06 
65536 Particles in STD Binary array file cosmo32out_z3.00168.HeI
GAS  2.78021e-09 2.78021e-09 2.78021e-09 2.78021e-09 2.78021e-09 2.78021e-09 2.78021e-09 2.78021e-09 2.78021e-09 2.78021e-09 
65536 Particles in STD Binary array file cosmo32out_z3.00168.HeII
GAS  0.000279316 0.000279316 0.000279316 0.000279316 0.000279316 0.000279316 0.000279316 0.000279316 0.000279316 0.000279316
Clone this wiki locally