@@ -34,7 +34,7 @@ EXP requires one of the following two sequences of 4 unit types:
34342. Mass, Length, Velocity, gravitational constant (G)
3535
3636
37- Each is defined by a _tuple_ which takes the form::
37+ Each unit is a `` tuple `` which takes the form::
3838
3939 ('unit type', 'unit name', <float value>)
4040
@@ -46,7 +46,7 @@ The type and name strings are checked against the allowed values as follows:
4646 'M' for 'mass'; 'Time', 't', 'T' for 'time', 'vel',
4747 'Vel', 'Velocity', 'v', 'V' for 'velocity'; and 'Grav', 'grav',
4848 'grav_constant', 'Grav_constant', 'gravitational_constant',
49- 'Graviational_constant ' for 'G'.
49+ 'Gravitational_constant ' for 'G'.
5050
5151- The ``unit name `` is one of the usual unit names for each of the
5252 ``unit type ``. The allowed list is a subset of the standard
@@ -91,7 +91,7 @@ gravitational constant and length units provided by the user.
9191The Units interface
9292-------------------
9393
94- The `pyEXP ` user interface includes two member functions for explicity
94+ The `pyEXP ` user interface includes two member functions for explicitly
9595setting and removing units as part of the `Coef ` class. For setting
9696units, we have:
9797
@@ -101,12 +101,13 @@ units, we have:
101101 setUnits(list )
102102 removeUnits(type )
103103 getAllowedUnitTypes()
104+ getAllowedTypeAliases(type )
104105 getAllowedUnitName(type )
105106
106107 where ``type `` and ``unit `` are strings and ``value `` is a float. The
107- list is a list of tuples of ``(name, unit, value) ``. The last two
108- members return the list of unit types and their aliaes and the allowed
109- unit names for each unit type, respectively.
108+ list is a list of tuples of ``(name, unit, value) ``. The last three
109+ members return the list of unit types, the recognized aliases for each
110+ type, and the allowed unit names for each unit type, respectively.
110111
111112For an example, suppose you are making a set of coefficients for a
112113simulation with default Gadget units. Say your coefficients instance
@@ -118,9 +119,24 @@ is called ``coefs``. The following command will register the unit set:
118119 (' velocity' , ' km/s' , 1.0 ), (' G' , ' mixed' , 43007.1 ) ])
119120
120121 These units will be in the HDF5 that you create using
121- ``coefs.WriteH5Coefs('filename') ``. A quick note: 'mixed' is an
122- allowed alias when dealing with gravitational constants that have
123- physical units.
122+ ``coefs.WriteH5Coeds('filename') ``. You can query, for example, the
123+ allowed 'mass' units with the call
124+ ``coefs.getAllowedUnitNames('mass') `` which returns:
125+
126+ .. code-block :: python
127+
128+ [' gram' , ' earth_mass' , ' solar_mass' , ' kilograms' , ' kg' , ' g' , ' Mearth' , ' Msun' , ' None' , ' none' ]
129+
130+ A quick note: 'mixed' is an allowed alias when dealing with
131+ gravitational constants that have physical units. You can see all
132+ unit types with ``getAllowedUnitTypes() ``; this returns ``['mass',
133+ 'length', 'time', 'velocity', 'G'] ``. You can see the recognized
134+ aliases for each type using ``getAllowedTypeAliases(type) ``. For
135+ example, the recognized aliases for 'G' are:
136+
137+ .. code-block :: python
138+
139+ [' G' , ' Grav' , ' Grav_constant' , ' Gravitational_constant' , ' grav' , ' grav_constant' , ' gravitational_constant' ]
124140
125141 The C++ UI echos the functions above and adds functions to retrieve
126142units
@@ -137,10 +153,12 @@ units
137153 std::vector<std::tuple<std::string, std::string, float>> getUnits();
138154 // Get a list of unit types and their aliases
139155 std::vector<std::string> getAllowedTypes();
156+ // Get a list aliases for each type
157+ std::vector<std::string> getAllowedTypeAliaes(const std::string& type);
140158 // Get a list of unit name and their aliases for a given unit type
141159 std::vector<std::string> getAllowedUnits(const std::string& type)
142160
143- and to interact with HDF files that will only of interest to
161+ and to interact with HDF files that will only be of interest to
144162developers creating new coefficient classes.
145163
146164
@@ -160,7 +178,7 @@ information) for each snapshot time in the coefficient set.
160178
161179The units information is stored in the root group as dataset named
162180"Units". The dataset is a sequence or list of 4 tuples. Each tuple
163- had three fields: two fixed length strings of sixteen (16) characters
181+ has three fields: two fixed length strings of sixteen (16) characters
164182and a float value.
165183
166184For an EXP run, the units specification appears as dataset in the root
@@ -219,7 +237,7 @@ following code:
219237 import h5py
220238 import numpy as np
221239
222- # Define the compound datatype with fixed-length UTF-8 strings and a float32
240+ # Define the compound datatype with fixed-length ASCII strings and a float32
223241 dt = np.dtype([
224242 (' name' , ' S16' ), # Fixed-length ASCII string of 16 bytes
225243 (' unit' , ' S16' ), # Fixed-length ASCII string of 16 bytes
0 commit comments