Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add dwave out to quickquasars #533

Merged
merged 5 commits into from
May 5, 2020
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 17 additions & 11 deletions py/desisim/scripts/quickquasars.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,17 +75,19 @@ def parse(options=None):

parser.add_argument('--downsampling', type=float, default=None,help="fractional random down-sampling (value between 0 and 1)")

parser.add_argument('--zmin', type=float, default=0,help="Min redshift")
parser.add_argument('--zmin', type=float, default=0, help="Min redshift")

parser.add_argument('--zmax', type=float, default=10,help="Max redshift")
parser.add_argument('--zmax', type=float, default=10, help="Max redshift")

parser.add_argument('--wmin', type=float, default=3500,help="Min wavelength (obs. frame)")
parser.add_argument('--wmin', type=float, default=3500, help="Min wavelength (obs. frame)")

parser.add_argument('--wmax', type=float, default=10000,help="Max wavelength (obs. frame)")
parser.add_argument('--wmax', type=float, default=10000, help="Max wavelength (obs. frame)")

parser.add_argument('--dwave', type=float, default=0.2,help="Internal wavelength step (don't change this)")
parser.add_argument('--dwave', type=float, default=0.2, help="Internal wavelength step (don't change this)")

parser.add_argument('--zbest', action = "store_true",help="add a zbest file per spectrum either with the truth\
parser.add_argument('--dwave_out', type=float, default=0.8, help="Output wavelength step")

parser.add_argument('--zbest', action = "store_true", help="add a zbest file per spectrum either with the truth\
redshift or adding some error (optionally use it with --sigma_kms_fog and/or --gamma_kms_zfit)")

parser.add_argument('--sigma_kms_fog',type=float,default=150, help="Adds a gaussian error to the quasar \
Expand All @@ -102,7 +104,7 @@ def parse(options=None):

parser.add_argument('--mags', action = "store_true", help="DEPRECATED; use --bbflux")

parser.add_argument('--bbflux', action = "store_true", help="compute and write the QSO broad-band fluxes in the fibermap")
parser.add_argument('--bbflux', action = "store_true", help="compute and write the QSO broad-band fluxes in the fibermap ")
parser.add_argument('--add-LYB', action='store_true', help = "Add LYB absorption from transmision file")

parser.add_argument('--metals', type=str, default=None, required=False, help = "list of metals to get the\
Expand Down Expand Up @@ -299,6 +301,11 @@ def simulate_one_healpix(ifilename,args,model,obsconditions,decam_and_wise_filte
log.info("Creating dir {}".format(pixdir))
os.makedirs(pixdir)

if not eboss is None:
dwave_out=1. #to keep the same value used for DR16
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@alxogm - I'm worried that eBOSS users might think that dwave_out will also affect them, and here we hide its effect. We could rename the adgument to dwave_DESI, or at least edit the help string to make it clear it only affects DESI. May be add also a print warning here if you were trying to run with eBOSS and also trying to change the value of dwave_out?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually, the eBOSS version should really just ignore dwave_out, since the SDSS spectrograph doesn't have constant pixels in wavelength, but logarithmic.

I'd suggest to set dwave_out=None when running with eBOSS flag.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @andreufont, right!

dwave_out=None was my first option, but I changed to 1 because I was not considering the there is an eBOSS branch that is not yet merged, so I didn't see what you mention about eBOSS not having constant pixels. So I've set it back to dwave_out=None, and changed the argument name also, to avoid confusion...

else:
dwave_out=args.dwave_out

log.info("Read skewers in {}, random seed = {}".format(ifilename,seed))

# Read transmission from files. It might include DLA information, and it
Expand All @@ -323,7 +330,6 @@ def simulate_one_healpix(ifilename,args,model,obsconditions,decam_and_wise_filte
if args.downsampling or args.desi_footprint:
raise ValueError("eboss option can not be run with "
+"desi_footprint or downsampling")

# Get the redshift distribution from SDSS
selection = sdss_subsample_redshift(metadata["RA"],metadata["DEC"],metadata['Z'],eboss['redshift'])
log.info("Select QSOs in BOSS+eBOSS redshift distribution {} -> {}".format(metadata['Z'].size,selection.sum()))
Expand Down Expand Up @@ -685,9 +691,9 @@ def simulate_one_healpix(ifilename,args,model,obsconditions,decam_and_wise_filte
log.info("Dust extinction added")
log.info('exposure time adjusted to {}'.format(obsconditions['EXPTIME']))

sim_spectra(qso_wave,qso_flux, args.program, obsconditions=obsconditions,spectra_filename=ofilename,
sourcetype="qso", skyerr=args.skyerr,ra=metadata["RA"],dec=metadata["DEC"],targetid=targetid,
meta=specmeta,seed=seed,fibermap_columns=fibermap_columns,use_poisson=False) # use Poisson = False to get reproducible results.
sim_spectra(qso_wave,qso_flux, args.program, obsconditions=obsconditions, spectra_filename=ofilename,
sourcetype="qso", skyerr=args.skyerr, ra=metadata["RA"], dec=metadata["DEC"], targetid=targetid,
meta=specmeta, seed=seed, fibermap_columns=fibermap_columns, use_poisson=False, dwave_out=dwave_out) # use Poisson = False to get reproducible results.

### Keep input redshift
Z_spec = metadata['Z'].copy()
Expand Down
5 changes: 3 additions & 2 deletions py/desisim/scripts/quickspectra.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@
from desispec.resolution import Resolution

def sim_spectra(wave, flux, program, spectra_filename, obsconditions=None,
sourcetype=None, targetid=None, redshift=None, expid=0, seed=0, skyerr=0.0, ra=None, dec=None, meta=None, fibermap_columns=None, fullsim=False,use_poisson=True):
sourcetype=None, targetid=None, redshift=None, expid=0, seed=0, skyerr=0.0, ra=None,
dec=None, meta=None, fibermap_columns=None, fullsim=False, use_poisson=True, dwave_out=None):
"""
Simulate spectra from an input set of wavelength and flux and writes a FITS file in the Spectra format that can
be used as input to the redshift fitter.
Expand Down Expand Up @@ -176,7 +177,7 @@ def sim_spectra(wave, flux, program, spectra_filename, obsconditions=None,

sim = desisim.simexp.simulate_spectra(wave, flux, fibermap=frame_fibermap,
obsconditions=obsconditions, redshift=redshift, seed=seed,
psfconvolve=True)
psfconvolve=True, dwave_out=dwave_out)

random_state = np.random.RandomState(seed)
sim.generate_random_noise(random_state,use_poisson=use_poisson)
Expand Down