Skip to content

Commit

Permalink
Add scales argument to fill_random
Browse files Browse the repository at this point in the history
  • Loading branch information
kburns committed Apr 1, 2024
1 parent f86f309 commit b0b4363
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion dedalus/core/field.py
Original file line number Diff line number Diff line change
Expand Up @@ -844,7 +844,7 @@ def broadcast_ghosts(self, output_nonconst_dims):
comm_sub.Bcast(data, root=0)
return data

def fill_random(self, layout=None, seed=None, chunk_size=2**20, distribution='standard_normal', **kw):
def fill_random(self, layout=None, scales=None, seed=None, chunk_size=2**20, distribution='standard_normal', **kw):
"""
Fill field with random data. If a seed is specified, the global data is
reproducibly generated for any process mesh.
Expand All @@ -853,6 +853,8 @@ def fill_random(self, layout=None, seed=None, chunk_size=2**20, distribution='st
----------
layout : Layout object, 'c', or 'g', optional
Layout for setting field data. Default: current layout.
scales : number or tuple of numbers, optional
Scales for setting field data. Default: current scales.
seed : int, optional
RNG seed. Default: None.
chunk_size : int, optional
Expand All @@ -864,6 +866,12 @@ def fill_random(self, layout=None, seed=None, chunk_size=2**20, distribution='st
**kw : dict
Other keywords passed to the distribution method.
"""
init_layout = self.layout
# Set scales if requested
if scales is not None:
self.preset_scales(scales)
if layout is None:
self.preset_layout(init_layout)
# Set layout if requested
if layout is not None:
self.preset_layout(layout)
Expand Down

0 comments on commit b0b4363

Please sign in to comment.