DPF operators to reduce numerical precision

Does anybody know if DPF has operators to round, chop, or reduced to specified amount of significant figures?
The use case would be to minimize the size of data on disk if using these approximate numbers is good enough
Answers
-
@Paul Profizi @Rafa Canton any ideas?
0 -
Hi @Mike.Thompson, @Ayush Kumar,
There are two answers to this question:
- Do you want to change the type of number DPF operators work with, for example 32 bits instead of 64? I think you can do this by creating a custom type Field with int32. See https://dpf.docs.pyansys.com/version/stable/api/ansys/dpf/core/custom_type_field/CustomTypeField.html#ansys.dpf.core.custom_type_field.CustomTypeField. I would have to look further into how well this is supported by other operators though.
- Do you want to serialize data to a file using a specific precision? Then it depends on the serialization operator, for example exports to hdf5 propose such an option https://dpf.docs.pyansys.com/version/stable/examples/05-file-IO/00-hdf5_double_float_comparison.html. I took a quick look and most of them do not currently propose to define this.
Do not hesitate to detail the workflow you have in mind so we can provide further assistance.
0 -
@Paul Profizi , I don’t mean double vs single precision, and this does not intrinsically tie into writing files, although it could be used with that.
The request is for operators to do any of the following:
1. Round the numbers to specific decimal place
2. Chop the numbers at specific decimal place. This simply removes the number is past that decimal place and does not round up or down.
3. Change the number to a specified significant digit amount. So 456.78 at 2 significant figures becomes 460.0These operators should operate on a field or fields container.
0 -
@Mike.Thompson these are mathematical operators we currently lack but could be easy to implement. @Ayush Kumar This should be brought up as feature requests. Here we can list "round", "ceil", "floor", and "truncate", but I also see we lack "modulo" or an operator to easily switch from double to int or from int to double.
1 -
@Paul Profizi agreed!
0