Skip to content

Commit ba4f464

Browse files
committed
Add real and imag properties for operands
1 parent 687750e commit ba4f464

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

dedalus/core/field.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -326,6 +326,20 @@ def valid_modes(self):
326326
# Return copy to avoid mangling cached result from coeff_layout
327327
return valid_modes.copy()
328328

329+
@property
330+
def real(self):
331+
if self.is_real:
332+
return self
333+
else:
334+
return (self + np.conj(self)) / 2
335+
336+
@property
337+
def imag(self):
338+
if self.is_real:
339+
return 0
340+
else:
341+
return (self - np.conj(self)) / 2j
342+
329343

330344
class Current(Operand):
331345

0 commit comments

Comments
 (0)