@@ -22,6 +22,8 @@ class Observation(object):
22
22
Weight map, same shape as image
23
23
bmask: ndarray, optional
24
24
A bitmask array
25
+ ormask: ndarray, optional
26
+ A bitmask array
25
27
noise: ndarray, optional
26
28
A noise field to associate with this observation
27
29
jacobian: Jacobian, optional
@@ -38,6 +40,7 @@ def __init__(self,
38
40
image ,
39
41
weight = None ,
40
42
bmask = None ,
43
+ ormask = None ,
41
44
noise = None ,
42
45
jacobian = None ,
43
46
gmix = None ,
@@ -62,6 +65,7 @@ def __init__(self,
62
65
63
66
# optional, if None nothing is set
64
67
self .set_bmask (bmask )
68
+ self .set_ormask (ormask )
65
69
self .set_noise (noise )
66
70
self .set_gmix (gmix )
67
71
self .set_psf (psf )
@@ -131,6 +135,23 @@ def bmask(self, bmask):
131
135
"""
132
136
self .set_bmask (bmask )
133
137
138
+ @property
139
+ def ormask (self ):
140
+ """
141
+ getter for ormask
142
+
143
+ currently this simply returns a reference
144
+ """
145
+ return self ._ormask
146
+
147
+ @ormask .setter
148
+ def ormask (self , ormask ):
149
+ """
150
+ set the ormask
151
+ """
152
+ self .set_ormask (ormask )
153
+
154
+
134
155
@property
135
156
def noise (self ):
136
157
"""
@@ -300,6 +321,39 @@ def has_bmask(self):
300
321
else :
301
322
return False
302
323
324
+ def set_ormask (self , ormask ):
325
+ """
326
+ Set the bitmask
327
+
328
+ parameters
329
+ ----------
330
+ ormask: ndarray (or None)
331
+ """
332
+ if ormask is None :
333
+ if self .has_ormask ():
334
+ del self ._ormask
335
+ else :
336
+
337
+ image = self .image
338
+
339
+ # force contiguous C, but we don't know what dtype to expect
340
+ ormask = numpy .ascontiguousarray (ormask )
341
+ assert len (ormask .shape )== 2 ,"ormask must be 2d"
342
+
343
+ assert (ormask .shape == image .shape ),\
344
+ "image and ormask must be same shape"
345
+
346
+ self ._ormask = ormask
347
+
348
+ def has_ormask (self ):
349
+ """
350
+ returns True if a bitmask is set
351
+ """
352
+ if hasattr (self ,'_ormask' ):
353
+ return True
354
+ else :
355
+ return False
356
+
303
357
def set_noise (self , noise ):
304
358
"""
305
359
Set a noise image
@@ -514,6 +568,11 @@ def copy(self):
514
568
else :
515
569
bmask = None
516
570
571
+ if self .has_ormask ():
572
+ ormask = self .ormask .copy ()
573
+ else :
574
+ ormask = None
575
+
517
576
if self .has_noise ():
518
577
noise = self .noise .copy ()
519
578
else :
@@ -536,6 +595,7 @@ def copy(self):
536
595
self .image .copy (),
537
596
weight = self .weight .copy (),
538
597
bmask = bmask ,
598
+ ormask = ormask ,
539
599
noise = noise ,
540
600
gmix = gmix ,
541
601
jacobian = self .jacobian , # makes a copy
0 commit comments