| | 1 | === IPP Object Catalog Bit Masks === |
| | 2 | |
| | 3 | The IPP pipeline stores some information about object in the FLAGS value in the CMF file. These values represent "bit masks", not standard integer values. That is, individual bits within the value have meaning, rather than the value itself. The bit masks for CMF files are |
| | 4 | |
| | 5 | <code> |
| | 6 | <pre> |
| | 7 | typedef enum { |
| | 8 | PM_SOURCE_MODE_DEFAULT = 0x0000, ///< |
| | 9 | PM_SOURCE_MODE_PSFMODEL = 0x0001, ///< Source fitted with a psf model (linear or non-linear) |
| | 10 | PM_SOURCE_MODE_EXTMODEL = 0x0002, ///< Source fitted with an extended-source model |
| | 11 | PM_SOURCE_MODE_FITTED = 0x0004, ///< Source fitted with non-linear model (PSF or EXT; good or bad) |
| | 12 | PM_SOURCE_MODE_FAIL = 0x0008, ///< Fit (non-linear) failed (non-converge, off-edge, run to zero) |
| | 13 | PM_SOURCE_MODE_POOR = 0x0010, ///< Fit succeeds, but low-SN, high-Chisq, or large (for PSF -- drop?) |
| | 14 | PM_SOURCE_MODE_PAIR = 0x0020, ///< Source fitted with a double psf |
| | 15 | PM_SOURCE_MODE_PSFSTAR = 0x0040, ///< Source used to define PSF model |
| | 16 | PM_SOURCE_MODE_SATSTAR = 0x0080, ///< Source model peak is above saturation |
| | 17 | PM_SOURCE_MODE_BLEND = 0x0100, ///< Source is a blend with other sourcers |
| | 18 | PM_SOURCE_MODE_EXTERNAL = 0x0200, ///< Source based on supplied input position |
| | 19 | PM_SOURCE_MODE_BADPSF = 0x0400, ///< Failed to get good estimate of object's PSF |
| | 20 | PM_SOURCE_MODE_DEFECT = 0x0800, ///< Source is thought to be a defect |
| | 21 | PM_SOURCE_MODE_SATURATED = 0x1000, ///< Source is thought to be saturated pixels (bleed trail) |
| | 22 | PM_SOURCE_MODE_CR_LIMIT = 0x2000, ///< Source has crNsigma above limit |
| | 23 | PM_SOURCE_MODE_EXT_LIMIT = 0x4000, ///< Source has extNsigma above limit |
| | 24 | PM_SOURCE_MODE_SUBTRACTED = 0x8000, ///< XXX this flag is actually only used internally (move) |
| | 25 | } pmSourceMode; |
| | 26 | </pre> |
| | 27 | </code> |
| | 28 | |
| | 29 | These are defined in the IPP code base in "ipp/psModules/src/objects/pmSource.h" |
| | 30 | |
| | 31 | If I were in charge of the Transient Classification Server and only wanted to consider objects that were single PSF-like, I might use the following bitmasks to denote bad and good objects: |
| | 32 | |
| | 33 | <code> |
| | 34 | <pre> |
| | 35 | badbitmask = PM_SOURCE_MODE_FAIL + PM_SOURCE_MODE_POOR + PM_SOURCE_MODE_SATSTAR + PM_SOURCE_MODE_BLEND + |
| | 36 | PM_SOURCE_MODE_EXTERNAL + PM_SOURCE_MODE_BADPSF + PM_SOURCE_MODE_DEFECT + PM_SOURCE_MODE_SATURATED + |
| | 37 | PM_SOURCE_MODE_CR_LIMIT + PM_SOURCE_MODE_EXT_LIMIT |
| | 38 | |
| | 39 | goodbitmask = PM_SOURCE_MODE_PSFMODEL + PM_SOURCE_MODE_FITTED |
| | 40 | </pre> |
| | 41 | </code> |
| | 42 | |
| | 43 | === Intro to Bit Masks === |
| | 44 | |
| | 45 | [Paul Price] |
| | 46 | For an introduction to this idea, see: |
| | 47 | http://en.wikipedia.org/wiki/Bitmask |
| | 48 | |
| | 49 | A real quick example may also help. Let's say I want to encode some |
| | 50 | boolean values about food. Below I list some food characteristics, and |
| | 51 | their mask value in binary and decimal: |
| | 52 | |
| | 53 | <code><pre> |
| | 54 | DELICIOUS 0001 => 1 |
| | 55 | SPICY 0010 => 2 |
| | 56 | CHEAP 0100 => 4 |
| | 57 | MEAT 1000 => 8 |
| | 58 | </pre></code> |
| | 59 | |
| | 60 | Now, some typical dishes might be: |
| | 61 | |
| | 62 | <code><pre> |
| | 63 | Lobster MEAT => 1000 => 8 |
| | 64 | Chicken salad CHEAP | MEAT => 1100 => 12 |
| | 65 | Chicken curry DELICIOUS | SPICY | CHEAP | MEAT => 1111 => 15 |
| | 66 | Tofu curry SPICY | CHEAP => 0110 => 6 |
| | 67 | Spaghetti DELICIOUS | CHEAP => 0101 => 5 |
| | 68 | </pre></code> |
| | 69 | |
| | 70 | Here, the pipe ("|") between symbols means a bitwise OR operation on the |
| | 71 | mask values (i.e., do an OR for each bit). |
| | 72 | |
| | 73 | Now, with such a list, say I want to find something to eat tonight. I'm |
| | 74 | in the mood for something spicy, so I go down the list, looking for |
| | 75 | lines that have the SPICY bit set. This is done using the "&" (bitwise |
| | 76 | AND) operation --- look for values for which "value & SPICY" is true. |
| | 77 | In this case, it could be either chicken curry (value 15) or tofu curry |
| | 78 | (value 6). Despite the fact that the values are very different, they |
| | 79 | both have the appropriate bit set, so they both match the filter. |