Skip to content

Commit 777a63b

Browse files
authored
random time of day for random_dates
Made a better random timestamp sampler that incorporates time of day as well.
1 parent e6bce87 commit 777a63b

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

openquake/hme/utils/utils.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -739,10 +739,10 @@ def sample_rups(
739739
return sampled_rups
740740

741741

742-
def random_dates(start, end, n, rand_seed=1, replace=False):
743-
dates = pd.date_range(start, end).to_series()
744-
return dates.sample(n, replace=replace, random_state=rand_seed)
745-
742+
def random_dates(start, end, n, rand_seed=1):
743+
rng = np.random.default_rng(seed)
744+
rand_ns = rng.integers(lo, hi + 1, size=n, dtype=np.int64)
745+
return pd.to_datetime(rand_ns).round('S')
746746

747747
def trim_inputs(input_data, cfg):
748748
mag_bins = get_mag_bins_from_cfg(cfg)

0 commit comments

Comments
 (0)