multiple pulses in same file
This commit is contained in:
parent
7e6bdcb475
commit
2ef005ca70
21
signalgen.py
21
signalgen.py
|
@ -28,6 +28,7 @@ LOG_MIN_DM = 2.5
|
||||||
LOG_MAX_DM = 3.5
|
LOG_MAX_DM = 3.5
|
||||||
LOG_MIN_WIDTH = 0
|
LOG_MIN_WIDTH = 0
|
||||||
LOG_MAX_WIDTH = 3 #in ms
|
LOG_MAX_WIDTH = 3 #in ms
|
||||||
|
MAX_BURSTS = 4
|
||||||
rng = np.random.default_rng()
|
rng = np.random.default_rng()
|
||||||
|
|
||||||
#This function from https://josephwkania.github.io/will/examples/inject_pulse.html#Show-how-we-can-inject-a-pulse-into-a-GREENBURST-filterbank.
|
#This function from https://josephwkania.github.io/will/examples/inject_pulse.html#Show-how-we-can-inject-a-pulse-into-a-GREENBURST-filterbank.
|
||||||
|
@ -130,6 +131,10 @@ def addBurst(values):
|
||||||
|
|
||||||
logger.info(f"{basename} loaded. Sampling pulse {values.nsamp} times.")
|
logger.info(f"{basename} loaded. Sampling pulse {values.nsamp} times.")
|
||||||
|
|
||||||
|
pulseNum = rng.integers(1, high=MAX_BURSTS, endpoint=True)
|
||||||
|
starts = np.arange(samples//4, 3*(samples//4), num=pulseNum, dtype=int)
|
||||||
|
while pulseNum > 0:
|
||||||
|
start = starts[pulseNum]
|
||||||
#create pulse
|
#create pulse
|
||||||
|
|
||||||
#check if this is part of a rng run
|
#check if this is part of a rng run
|
||||||
|
@ -158,15 +163,21 @@ def addBurst(values):
|
||||||
)
|
)
|
||||||
pulse = pulseObj.sample_pulse(nsamp=values.nsamp) #30000 by default
|
pulse = pulseObj.sample_pulse(nsamp=values.nsamp) #30000 by default
|
||||||
|
|
||||||
logger.info("Injecting pulse")
|
logger.info("Injecting pulse and saving file.")
|
||||||
#inject pulse
|
#inject pulse
|
||||||
injectedSpectra = inject.inject_constant_into_file(
|
inject.inject_constant_into_file(
|
||||||
yr_input = filterbankObj,
|
yr_input = filterbankObj,
|
||||||
pulse = pulse,
|
pulse = pulse,
|
||||||
start = samples // 3
|
start = start,
|
||||||
|
out_fil = path.join("./", f"{basename}_injected.fil")
|
||||||
)
|
)
|
||||||
|
#reload into object
|
||||||
|
filterbankObj = Your(path.join("./", f"{basename}_injected.fil"))
|
||||||
|
pulseNum -= 1
|
||||||
|
os.remove(path.join("./", f"{basename}_trunc.fil")) #delete truncated file to save 2GB of disk space
|
||||||
|
logger.info(f"Truncated file removed.")
|
||||||
|
|
||||||
#now generate new filterbank file
|
""" #now generate new filterbank file
|
||||||
newName = f"{basename}_injected.fil"
|
newName = f"{basename}_injected.fil"
|
||||||
sigprocObj = make_sigproc_object(
|
sigprocObj = make_sigproc_object(
|
||||||
rawdatafile=newName, #d
|
rawdatafile=newName, #d
|
||||||
|
@ -194,7 +205,7 @@ def addBurst(values):
|
||||||
sigprocObj.append_spectra(injectedSpectra, newName)
|
sigprocObj.append_spectra(injectedSpectra, newName)
|
||||||
logger.info(f"{newName} successfully written.")
|
logger.info(f"{newName} successfully written.")
|
||||||
os.remove(path.join("./", f"{basename}_trunc.fil")) #delete truncated file to save 2GB of disk space
|
os.remove(path.join("./", f"{basename}_trunc.fil")) #delete truncated file to save 2GB of disk space
|
||||||
logger.info(f"Truncated file removed.")
|
logger.info(f"Truncated file removed.") """
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue