Coverage for metadetect / procflags.py: 97%
32 statements
« prev ^ index » next coverage.py v7.13.1, created at 2026-01-07 01:53 -0800
« prev ^ index » next coverage.py v7.13.1, created at 2026-01-07 01:53 -0800
1import copy
3import ngmix.flags
4from ngmix.flags import NO_ATTEMPT # noqa
6# these flags start at 19 always
7# this allows us to combine them with the flags in ngmix
8SHEAR_RANGE_ERROR = 2**19
9EDGE_HIT = 2**20
10PSF_FAILURE = 2**21
11OBJ_FAILURE = 2**22
12NOMOMENTS_FAILURE = 2**23
13BAD_BBOX = 2**24
14ZERO_WEIGHTS = 2**25
15NO_DATA = 2**26
16MISSING_BAND = 2**27
17INCONSISTENT_BANDS = 2**28
18CENTROID_FAILURE = 2**29
19DEBLEND_FAILURE = 2**30
20# DO NOT use 2**31 or higher
22NAME_MAP = copy.deepcopy(ngmix.flags.NAME_MAP)
23NAME_MAP[SHEAR_RANGE_ERROR] = "shear is out of range (abs(g) > 1 or abs(g_1,2) > 1)"
24NAME_MAP[EDGE_HIT] = "bbox hit edge"
25NAME_MAP[PSF_FAILURE] = "PSF fit failed"
26NAME_MAP[OBJ_FAILURE] = "object fit failed"
27NAME_MAP[NOMOMENTS_FAILURE] = "no moments"
28NAME_MAP[BAD_BBOX] = "problem making bounding box"
29NAME_MAP[ZERO_WEIGHTS] = "weights all zero"
30NAME_MAP[NO_DATA] = "no data"
31NAME_MAP[MISSING_BAND] = "missing data in one or more bands"
32NAME_MAP[INCONSISTENT_BANDS] = (
33 "# of bands for PSF vs shear vs flux is not correct or "
34 "there was a stamp coadding issue"
35)
36NAME_MAP[CENTROID_FAILURE] = "finding the centroid failed"
37NAME_MAP[DEBLEND_FAILURE] = "The deblending failed"
39for k, v in list(NAME_MAP.items()):
40 NAME_MAP[v] = k
43def get_procflags_str(val):
44 """Get a descriptive string given a flag value.
46 Parameters
47 ----------
48 val : int
49 The flag value.
51 Returns
52 -------
53 flagstr : str
54 A string of descriptions for each bit separated by `|`.
55 """
56 return ngmix.flags.get_flags_str(val, name_map=NAME_MAP)