Skip to content

Commit

Permalink
Merge pull request #15 from gwastro/sample-rate-workaround
Browse files Browse the repository at this point in the history
Implemented a workaround to assert the correct sample-rate is correct.
  • Loading branch information
MarlinSchaefer authored Dec 10, 2021
2 parents fea6513 + 70420c4 commit e7dfbc3
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion generate_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -407,12 +407,21 @@ def get(self, start, end, generate_duration=3600):
segstart = start + done_duration
segend = min(end, segstart + generate_duration)
logging.debug(f'Generation segment: {(segstart, segend)} of duration {segend - segstart}')

#Workaround for sample-rate issues
pad = 0
duration = segend - segstart + 256
while 1 / (1 / (duration + pad)) != (duration + pad):
pad += 1
tmp = colored_noise(psd,
segstart,
segend,
segend+pad,
seed=self.seed[i],
sample_rate=self.sample_rate,
low_frequency_cutoff=self.low_frequency_cutoff)
tmp = tmp[:len(tmp)-int(pad * tmp.sample_rate)]
#End of workaround for sample-rate issue

logging.debug(f'Succsessfully generated time domain noise')
if noise is None:
logging.debug('Setting noise to tmp')
Expand Down

0 comments on commit e7dfbc3

Please sign in to comment.