next up previous index
Next: Interaction Sets Up: Expressions Previous: Aliasing   Index


Casting the Value of an Expression

Normally the value of a variable defined by an expressions will be a float64 (this is a numpy type). For large datasets this may use too much space. You can cast the result of any expression to a different type using the numpy astype method. For example, the alias defined by this expression will be of type float32:

lnpop = ( ln(urbansim.gridcell.population) ).astype(float32)

The following numpy types can be used as the argument to the astype method: bool8, int8, uint8, int16, uint16, int32, uint32, int64, uint64 float32, float64, complex64, complex128, and longlong.


next up previous index
Next: Interaction Sets Up: Expressions Previous: Aliasing   Index
info (at) urbansim.org