Skip to content

Commit

Permalink
Repliates #510 changes on this branch. Runs with quicksurvey_example …
Browse files Browse the repository at this point in the history
…given quicksurvey_example #20 changes.
  • Loading branch information
michaelJwilson committed Dec 28, 2019
1 parent 65df22e commit 116f1dc
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 17 deletions.
18 changes: 5 additions & 13 deletions py/desisim/quickcat.py
Original file line number Diff line number Diff line change
Expand Up @@ -175,14 +175,10 @@ def get_redshift_efficiency(simtype, targets, truth, targets_in_tile, obsconditi
a_small_flux=1e-40
true_gflux[true_gflux<a_small_flux]=a_small_flux
true_rflux[true_rflux<a_small_flux]=a_small_flux




if (obsconditions is None) or ('OIIFLUX' not in truth.dtype.names):
raise Exception('Missing obsconditions and flux information to estimate redshift efficiency')



if (simtype == 'ELG'):
# Read the model OII flux threshold (FDR fig 7.12 modified to fit redmonster efficiency on OAK)
# filename = resource_filename('desisim', 'data/quickcat_elg_oii_flux_threshold.txt')
Expand All @@ -195,28 +191,24 @@ def get_redshift_efficiency(simtype, targets, truth, targets_in_tile, obsconditi
oii_flux_limit = np.interp(truth['TRUEZ'],fdr_z,modified_fdr_oii_flux_threshold)
oii_flux_limit[oii_flux_limit<1e-20]=1e-20

# efficiency is modeled as a function of flux_OII/f_OII_threshold(z) and an arbitrary sigma_fudge

# efficiency is modeled as a function of flux_OII/f_OII_threshold(z) and an arbitrary sigma_fudge
snr_in_lines = params["ELG"]["EFFICIENCY"]["SNR_LINES_SCALE"]*7*truth['OIIFLUX']/oii_flux_limit
snr_in_continuum = params["ELG"]["EFFICIENCY"]["SNR_CONTINUUM_SCALE"]*true_rflux
snr_tot = np.sqrt(snr_in_lines**2+snr_in_continuum**2)
sigma_fudge = params["ELG"]["EFFICIENCY"]["SIGMA_FUDGE"]
nsigma = 3.
simulated_eff = eff_model(snr_tot,nsigma,sigma_fudge)

elif(simtype == 'LRG'):


r_mag = 22.5 - 2.5*np.log10(true_rflux)
elif(simtype == 'LRG'):
r_mag = 22.5 - 2.5*np.log10(true_rflux)

sigmoid_cutoff = params["LRG"]["EFFICIENCY"]["SIGMOID_CUTOFF"]
sigmoid_fudge = params["LRG"]["EFFICIENCY"]["SIGMOID_FUDGE"]
simulated_eff = 1./(1.+np.exp((r_mag-sigmoid_cutoff)/sigmoid_fudge))
simulated_eff = 1./(1.+np.exp((r_mag-sigmoid_cutoff)/sigmoid_fudge))

log.info("{} eff = sigmoid with cutoff = {:4.3f} fudge = {:4.3f}".format(simtype,sigmoid_cutoff,sigmoid_fudge))

elif(simtype == 'QSO'):

zsplit = params['QSO_ZSPLIT']
r_mag = 22.5 - 2.5*np.log10(true_rflux)
simulated_eff = np.ones(r_mag.shape)
Expand Down
9 changes: 5 additions & 4 deletions py/desisim/quicksurvey.py
Original file line number Diff line number Diff line change
Expand Up @@ -254,15 +254,16 @@ def simulate_epoch(self, epoch, truth, targets, obscon, perfect=False, zcat=None
print("{} Launching fiberassign".format(asctime()))
f = open('fiberassign.log','a')

call = [self.fiberassign, '--mtl', os.path.join(self.tmp_output_path, 'mtl.fits'), '--stdstar', self.stdfile, '--sky', self.skyfile,\
# Assume stds within mtl. {'--stdstar', self.stdfile} otherwise.
call = [self.fiberassign, '--mtl', os.path.join(self.tmp_output_path, 'mtl.fits'), '--sky', self.skyfile,\
'--surveytiles', self.surveyfile, '--footprint', self.footprint, '--outdir', os.path.join(self.tmp_output_path, 'fiberassign'), '--overwrite']

if self.status is not None:
call.append('--status')
call.append(self.status)

## Doesn't catch no overwrite return on fiberassign.
p = subprocess.call(call, stdout=f)
## Doesn't catch no overwrite return on fiberassign.
p = subprocess.call(call, stdout=f)

print("{} Finished fiberassign".format(asctime()))
f.close()
Expand Down Expand Up @@ -297,7 +298,7 @@ def simulate_epoch(self, epoch, truth, targets, obscon, perfect=False, zcat=None
obsconditions['TILEID'] = self.exposures['TILEID']
obsconditions['AIRMASS'] = self.exposures['AIRMASS']
obsconditions['SEEING'] = self.exposures['SEEING']
obsconditions['LINTRANS'] = self.exposures['TRANSP']
obsconditions['TRANSP'] = self.exposures['TRANSP']
obsconditions['MOONFRAC'] = self.exposures['MOONFRAC']
obsconditions['MOONALT'] = self.exposures['MOONALT']

Expand Down

0 comments on commit 116f1dc

Please sign in to comment.