Skip to content

Commit

Permalink
rescale nb of random dla
Browse files Browse the repository at this point in the history
  • Loading branch information
armengau committed Dec 4, 2024
1 parent 038252e commit 97f7d47
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
5 changes: 3 additions & 2 deletions py/desisim/dla.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

c_cgs = const.c.to('cm/s').value

def insert_dlas(wave, zem, rstate=None, seed=None, fNHI=None, debug=False, **kwargs):
def insert_dlas(wave, zem, rstate=None, seed=None, fNHI=None, ndla_rescaling=1.0, **kwargs):
""" Insert zero, one or more DLAs into a given spectrum towards a source
with a given redshift
Args:
Expand All @@ -26,6 +26,7 @@ def insert_dlas(wave, zem, rstate=None, seed=None, fNHI=None, debug=False, **kwa
rstate (numpy.random.rstate, optional): for random numberes
seed (int, optional):
fNHI (spline): f_NHI object
ndla_rescaling (float): the average number of DLAs drawn from a Poison law is rescaled by this number
**kwargs: Passed to init_fNHI()
Returns:
Expand Down Expand Up @@ -59,7 +60,7 @@ def insert_dlas(wave, zem, rstate=None, seed=None, fNHI=None, debug=False, **kwa
fzdla = interpolate.interp1d(cum_lz/tot_lz, zlya[gdz],
bounds_error=False,fill_value=np.min(zlya[gdz]))#
# n DLA
nDLA = rstate.poisson(tot_lz, 1)
nDLA = rstate.poisson(tot_lz * ndla_rescaling, 1)

# Generate DLAs
dlas = []
Expand Down
6 changes: 5 additions & 1 deletion py/desisim/scripts/quickquasars.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,9 @@ def parse(options=None):
parser.add_argument('--dla',type=str,required=False, help="Add DLA to simulated spectra either randonmly\
(--dla random) or from transmision file (--dla file)")

parser.add_argument('--ndla-rescaling', type=float, default=1, help='When setting --dla random, the average\
number of DLA drawn from a Poison law is rescaled by this number')

parser.add_argument('--balprob',type=float,required=False, help="To add BAL features with the specified probability\
(e.g --balprob 0.5). Expect a number between 0 and 1 ")

Expand Down Expand Up @@ -571,7 +574,8 @@ def simulate_one_healpix(ifilename,args,model,obsconditions,decam_and_wise_filte
transmission_dla = dla_spec(trans_wave,dlas)

elif args.dla=='random':
dlas, transmission_dla = insert_dlas(trans_wave, metadata['Z'][ii], rstate=random_state_just_for_dlas)
dlas, transmission_dla = insert_dlas(trans_wave, metadata['Z'][ii],
rstate=random_state_just_for_dlas, ndla_rescaling=args.ndla_rescaling)
for idla in dlas:
idla['dlaid']+=idd*1000 #Added to have unique DLA ids. Same format as DLAs from file.

Expand Down

0 comments on commit 97f7d47

Please sign in to comment.