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

major refactor of select_mock_targets #264

Merged
merged 120 commits into from
Feb 27, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
120 commits
Select commit Hold shift + click to select a range
4af179b
start refactor
moustakas Oct 10, 2017
c1941d7
fixed spectra conflict
moustakas Dec 21, 2017
a8c81ac
deprecate realtargets optional input
moustakas Dec 21, 2017
5fc924e
use initialize function in targets_truth
moustakas Dec 21, 2017
b3305c6
use read_catalog
moustakas Dec 21, 2017
71d241a
compute MW_TRANSMISSION for all mock targets
moustakas Dec 21, 2017
b7e24c3
assume uniform depth model
moustakas Dec 22, 2017
49a4023
add units to targets, truth tables
moustakas Dec 22, 2017
f9398c6
starting including fluctuations
moustakas Dec 22, 2017
fc9ff1f
remove obsolete shapes_and_fluxes function
moustakas Dec 22, 2017
b2a52ef
minor tweaks to QA.density_fluctuations
moustakas Dec 22, 2017
5c2a674
chunk into smaller healpixels
moustakas Dec 22, 2017
e97605e
first version of iterative code working
moustakas Dec 22, 2017
03f5ff7
move obsolete BrickInfo to new brickinfo.py
moustakas Dec 22, 2017
54e4bb4
remove obsolete fileid_filename
moustakas Dec 22, 2017
a9fff5a
remove obsolete get_spectra_onebrick
moustakas Dec 22, 2017
3ae7aaa
major cleanup/reorganization of mock.build
moustakas Dec 22, 2017
05a02d2
properly assign brickid and objid
moustakas Dec 23, 2017
e3d623f
add overwrite option to select_mock_targets
moustakas Dec 23, 2017
8892520
fix skies
moustakas Dec 23, 2017
cbc1b95
scatter photo in own function
moustakas Dec 23, 2017
b0ae5ea
more logging
moustakas Dec 23, 2017
f369af3
cleanup
moustakas Dec 23, 2017
d03de84
deal with (numerous) faint stars [ci skip]
moustakas Dec 24, 2017
dfeec8e
skip deprecated unit tests
moustakas Dec 24, 2017
4b8d0ae
use simqso for qso templates
moustakas Dec 30, 2017
93134aa
use healpix for brickid
moustakas Dec 30, 2017
e183670
make the html output directory
moustakas Dec 31, 2017
f173d67
include contaminants in goal QSO density
moustakas Dec 31, 2017
c75d400
start iospectra module
moustakas Dec 31, 2017
0e7dc5c
move initialize_no_spectra to its own method
moustakas Dec 31, 2017
614f933
use iospectra methods in targets_truth
moustakas Jan 1, 2018
ae41e2e
rename iospectra mockmaker
moustakas Jan 1, 2018
5170e77
QSOs and SKY working
moustakas Jan 1, 2018
96aaa8c
add LRGs and vdisp sampling
moustakas Jan 1, 2018
335e53f
add GMM
moustakas Jan 1, 2018
6b9608e
fix bug in depth computation
moustakas Jan 1, 2018
b4d3c73
more in mockmaker
moustakas Jan 1, 2018
d1f08c1
add WDs
moustakas Jan 2, 2018
e9f62e9
consolidate some of the mockmaker classes
moustakas Jan 2, 2018
ab832c9
add nearby stars
moustakas Jan 2, 2018
452b2c4
Lya skewers done
moustakas Jan 2, 2018
a408905
support new galaxia mocks
moustakas Jan 2, 2018
a958b64
select boss standards
moustakas Jan 2, 2018
f8c47c4
start adding contaminants
moustakas Jan 2, 2018
91ca7dc
populate targets, truth in mockmaker
moustakas Jan 2, 2018
81f20a5
major speedup of faintstar targets
moustakas Jan 3, 2018
db7200e
less verbose [ci skip]
moustakas Jan 3, 2018
0774b6f
move the nominal depth to mockmaker
moustakas Jan 3, 2018
b3c38cb
a bit more cleanup
moustakas Jan 3, 2018
60f4be9
read both file prefixes in faintstar mocks
moustakas Jan 11, 2018
51fcc5d
read GaussianField reader
moustakas Jan 14, 2018
147bcc1
start documentation and exampls notebook
moustakas Jan 14, 2018
431a947
more documentation
moustakas Jan 15, 2018
2b7ecee
done with mockmaker documentation
moustakas Jan 16, 2018
1d20587
finish examples notebook
moustakas Jan 18, 2018
afac043
Merge branch 'master' into fix-densities
moustakas Jan 19, 2018
f74c770
start adding fluctuations model
moustakas Jan 19, 2018
685a547
works...i think
moustakas Jan 20, 2018
400efc4
start moving (obsolete) quicksurvey code to dedicated module
moustakas Jan 20, 2018
5a5f679
more cleanup
moustakas Jan 20, 2018
781773e
remove mock/spectra and mock/selection
moustakas Jan 23, 2018
804dfe4
remove mock/QA, mock/brickinfo, mock/sample
moustakas Jan 23, 2018
89c5338
cleanup mock.io
moustakas Jan 23, 2018
e42ea28
merged new QA code
moustakas Jan 23, 2018
8649036
update api.rst
moustakas Jan 23, 2018
4a58e54
remove obsconditions (see #253)
moustakas Jan 23, 2018
934feb0
restore sample.py
moustakas Jan 23, 2018
219a353
only load targets_truth_no_spectra when needed
moustakas Jan 23, 2018
56a78b6
update changes.rst [ci skip]
moustakas Jan 23, 2018
6ed61d4
Merge branch 'fix-densities' of https://github.com/desihub/desitarget…
moustakas Jan 23, 2018
4e01611
fix mxxl directory typo
moustakas Feb 7, 2018
1fd1316
capture nside_galaxia undefined error
moustakas Feb 7, 2018
9ea7da0
require nside input
moustakas Feb 7, 2018
d016f3d
make NSIDE a required input
moustakas Feb 7, 2018
ca69bd5
more error messages
moustakas Feb 8, 2018
2df229f
add uniformsky class reader
moustakas Feb 11, 2018
a287386
update input.yaml configuration file
moustakas Feb 11, 2018
80477f3
add QA sky method to SelectTargets
moustakas Feb 11, 2018
001a324
use updated LRG mocks (#263)
moustakas Feb 12, 2018
f1885a6
resolve conflicts
moustakas Feb 23, 2018
f704403
use partial pixel weights and encode_targetid for mockid
moustakas Feb 23, 2018
8b75f25
sandbox notebook for testing
moustakas Feb 23, 2018
829d283
read the HDF5 file in read-only mode
moustakas Feb 23, 2018
7ee690a
incorporate #278 logging changes
moustakas Feb 23, 2018
bac4673
start fluctuations refactor
moustakas Feb 24, 2018
7493cb4
add mock_density method to ReadGaussianField class
moustakas Feb 24, 2018
b46a5be
downsampling QSOs almost there
moustakas Feb 24, 2018
d529afc
iterate until we reach the desired target density
moustakas Feb 24, 2018
e73dff8
a little cleanup
moustakas Feb 24, 2018
39cc62e
resolved conflicts
moustakas Feb 24, 2018
9421f9a
documentation
moustakas Feb 24, 2018
dfbeb35
QSOs are working
moustakas Feb 24, 2018
a2f5fc2
speed up BGS mock read method
moustakas Feb 25, 2018
0164b86
do not iterate if density is not provided
moustakas Feb 25, 2018
c7ca273
clean up normfilter
moustakas Feb 25, 2018
49f5a57
bgs, qso, and lrg in ok shape
moustakas Feb 25, 2018
c68ced6
ELGs
moustakas Feb 25, 2018
2c11af6
skies are done; density_factor must be <=1
moustakas Feb 25, 2018
8f7edc6
mws_nearby is done
moustakas Feb 25, 2018
db4ea76
WDs and mws_main done
moustakas Feb 26, 2018
ca39410
take the mock sky density as-is (see #280)
moustakas Feb 26, 2018
6aa4120
documentation cleanup
moustakas Feb 26, 2018
c0accd0
update qso photometry *after* Lya forest has been applied
moustakas Feb 26, 2018
79408f0
clean up documentation in build.py
moustakas Feb 26, 2018
5329bd3
more useful maxiter warning message
moustakas Feb 26, 2018
d2468dc
attenuate fluxes for Galactic extinction
moustakas Feb 27, 2018
6b1c8ba
correct for extinction before selecting targets
moustakas Feb 27, 2018
7554dac
start updating notebook
moustakas Feb 27, 2018
f304214
Merge branch 'master' into fix-densities
moustakas Feb 27, 2018
e1338f8
remove obsolete twopercent-sprint-qa notebook
moustakas Feb 27, 2018
6209d5a
remove obsolete mock-density-qa notebook
moustakas Feb 27, 2018
ebd2a55
a bit more cleanup
moustakas Feb 27, 2018
049f8dd
workaround hdf5 bug on NERSC /project
Feb 27, 2018
009c6ce
Merge branch 'fix-densities' of https://github.com/desihub/desitarget…
Feb 27, 2018
b176dd3
fix bug when selecting faintstar contaminants
moustakas Feb 27, 2018
f147b05
update connecting-spectra-to-mocks notebook
moustakas Feb 27, 2018
f4a620e
update changes.rst
moustakas Feb 27, 2018
0ecc32a
a few masks moved location
Feb 27, 2018
1c7c852
update travis dep versions and cpu time units
Feb 27, 2018
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
8 changes: 4 additions & 4 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,10 @@ env:
- ASTROPY_VERSION=1.2.1
- SPHINX_VERSION=1.5
- DESIUTIL_VERSION=1.9.9
- DESISPEC_VERSION=0.11.0
- DESISIM_VERSION=master
- DESIMODEL_VERSION=0.7.0
- DESIMODEL_DATA=branches/test-0.7.0
- DESISPEC_VERSION=0.18.0
- DESISIM_VERSION=0.25.1
- DESIMODEL_VERSION=0.9.2
- DESIMODEL_DATA=branches/test-0.9
- SPECLITE_VERSION=0.5
- MAIN_CMD='python setup.py'
# Additional conda channels to use.
Expand Down
7 changes: 3 additions & 4 deletions bin/mpi_select_mock_targets
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ parser.add_argument('--nside', help='Divide the DESI footprint into this healpix
parser.add_argument('--tiles', help='Path to file with tiles to cover', type=str)
parser.add_argument('--npix', help='Number of healpix per process', type=int, default=1)
parser.add_argument('--healpixels', help='Integer list of healpix pixels (corresponding to nside) to process.', type=int, nargs='*', default=None)
parser.add_argument('--realtargets', '-r', help='Path to real target catalog', type=str)
parser.add_argument('-v','--verbose', action='store_true', help='Enable verbose output.')
parser.add_argument('--no-check-env', action='store_true', help="Don't check NERSC environment variables")
parser.add_argument('--sort-pixels', action='store_true', help="Sort pixels by galactic latitude")
Expand Down Expand Up @@ -162,9 +161,9 @@ if len(rankpix) > 0:
log.info(' nproc {}'.format(args.nproc))
log.info(' verbose {}'.format(args.verbose))
log.info(' healpixels {}'.format(rankpix[i:i+n]))
targets_truth(params, args.output_dir, seed=rankseeds[i], nside=args.nside,
nproc=args.nproc, verbose=args.verbose,
healpixels=rankpix[i:i+n])
targets_truth(params, output_dir=args.output_dir, seed=rankseeds[i],
nside=args.nside, nproc=args.nproc, verbose=args.verbose,
healpixels=rankpix[i:i+n])

runtime = (time.time()-t0) / 60
log.info('Pixels {} took {:.1f} minutes'.format(rankpix[i:i+n], runtime))
Expand Down
48 changes: 23 additions & 25 deletions bin/select_mock_targets
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import yaml
import healpy as hp
from astropy.table import Table

from desitarget.mock.build import targets_truth, targets_truth_no_spectra
from desitarget.mock.build import targets_truth
from desiutil.log import get_logger, DEBUG
import desimodel
import desitarget.mock.io as mockio
Expand All @@ -25,14 +25,14 @@ parser.add_argument('-c', '--config', default='input.yaml')
parser.add_argument('-O', '--output_dir', help='Path to write the outputs', type=str, default='./')
parser.add_argument('-s', '--seed', help='Seed for random number generation', type=int, default=None)
parser.add_argument('-n', '--nproc', type=int, help='number of concurrent processes to use [{}]'.format(nproc), default=nproc)
parser.add_argument('--nside', help='Divide the DESI footprint into this healpix resolution', type=int, default=64)
parser.add_argument('--nside', help='Divide the DESI footprint into this healpix resolution', type=int, default=None)
parser.add_argument('--tiles', help='Path to file with tiles to cover', type=str)
parser.add_argument('--healpixels', help='Integer list of healpix pixels (corresponding to nside) to process.', type=int, nargs='*', default=None)
parser.add_argument('--realtargets', '-r', help='Path to real target catalog', type=str)
parser.add_argument('--join', action='store_true', help='Join the target and truth files in output_dir.')
parser.add_argument('--qa', action='store_true', help='Generate QA plots from the joined target and truth files in output_dir.')
parser.add_argument('-v','--verbose', action='store_true', help='Enable verbose output.')
parser.add_argument('--no-spectra', action='store_true')
parser.add_argument('--no-spectra', action='store_true', help='Do not generate spectra.')
parser.add_argument('--overwrite', action='store_true', help='Overwrite existing files.')

args = parser.parse_args()

Expand All @@ -43,6 +43,10 @@ else:

log.info('Starting select_mock_targets at {}'.format(time.asctime()))

if args.nside is None:
log.warning('NSIDE is a required input.')
raise ValueError

# Divide the DESI footprint into healpix pixels.
if args.nside < 2:
log.fatal('NSIDE = {} must be >=2'.format(args.nside))
Expand All @@ -51,7 +55,6 @@ if args.nside < 2:
if args.tiles and args.healpixels:
log.error('use --tiles or --healpixels but not both')
sys.exit(1)


if args.tiles is not None:
if args.tiles.endswith('.ecsv'):
Expand All @@ -64,23 +67,18 @@ if args.tiles is not None:
else:
healpixels = np.array(args.healpixels)

keep = list()
for i, pixnum in enumerate(healpixels):
truthfile = mockio.findfile('truth', args.nside, pixnum, basedir=args.output_dir)
if not os.path.exists(truthfile):
keep.append(i)

log.info('{}/{} pixels remaining to do'.format(len(keep), len(healpixels)))
healpixels = healpixels[keep]

# Optionally read the "real" target catalog.
if args.realtargets is not None:
from astropy.io import fits
log.info('Loading real targets from {}'.format(args.realtargets))
realtargets = fits.getdata(args.realtargets, 1)
if args.overwrite:
log.info('Processing {} pixel(s).'.format(len(healpixels)))
else:
realtargets = None

keep = list()
for i, pixnum in enumerate(healpixels):
truthfile = mockio.findfile('truth', args.nside, pixnum, basedir=args.output_dir)
if not os.path.exists(truthfile):
keep.append(i)

log.info('{}/{} pixels remaining to do'.format(len(keep), len(healpixels)))
healpixels = healpixels[keep]

if args.join:
from desitarget.mock.build import join_targets_truth
join_targets_truth(args.output_dir, nside=args.nside, healpixels=healpixels, verbose=args.verbose)
Expand All @@ -103,13 +101,13 @@ with open(args.config, 'r') as pfile:

log.info('Calling targets_truth at {}'.format(time.asctime()))
if args.no_spectra:
targets_truth_no_spectra(params, output_dir=args.output_dir,seed=args.seed,
from desitarget.mock.build import targets_truth_no_spectra
targets_truth_no_spectra(params, output_dir=args.output_dir, seed=args.seed,
verbose=args.verbose, nproc=args.nproc, nside=args.nside,
healpixels=healpixels)
else:
targets_truth(params, args.output_dir, realtargets=realtargets, seed=args.seed,
verbose=args.verbose, nproc=args.nproc, nside=args.nside,
healpixels=healpixels)
targets_truth(params, output_dir=args.output_dir, seed=args.seed, nside=args.nside,
verbose=args.verbose, nproc=args.nproc, healpixels=healpixels)


log.info('All done at {}'.format(time.asctime()))
Expand Down
8 changes: 1 addition & 7 deletions doc/api.rst
Original file line number Diff line number Diff line change
Expand Up @@ -38,21 +38,15 @@ desitarget API
.. automodule:: desitarget.mock.io
:members:

.. automodule:: desitarget.mock.QA
.. automodule:: desitarget.mock.mockmaker
:members:

.. automodule:: desitarget.mock.sample
:members:

.. automodule:: desitarget.mock.selection
:members:

.. automodule:: desitarget.mock.sfdmap
:members:

.. automodule:: desitarget.mock.spectra
:members:

.. automodule:: desitarget.mtl
:members:

Expand Down
2 changes: 2 additions & 0 deletions doc/changes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,11 @@ desitarget Change Log
0.18.2 (unreleased)
-------------------

* Major refactor of select_mock_targets code infrastructure[`PR #264`_].
* Remove extraneous imports from __init__.py, fix read the docs build
[`PR #282`_].

.. _`PR #264`: https://github.com/desihub/desitarget/pull/264
.. _`PR #282`: https://github.com/desihub/desitarget/pull/282

0.18.1 (2018-02-23)
Expand Down
131 changes: 45 additions & 86 deletions doc/mock_example/input.yaml
Original file line number Diff line number Diff line change
@@ -1,104 +1,63 @@
#mock target configuration file

# mock target configuration file
dust_dir: /project/projectdirs/desi/software/edison/dust/v0_1/maps

decals_brick_info: /project/projectdirs/desi/target/catalogs/brick-info-dr3.v0.0.1.fits

density_fluctuations: True

subset:
ra_dec_cut: True
min_ra: 200
max_ra: 210
min_dec: -8
max_dec: 8
sources:
SKY: {
target_name: SKY,
truth_name: SKY,
root_mock_dir: /project/projectdirs/desi/mocks/GaussianRandomField/v0.0.1/2048,
mock_name: random,
format: gaussianfield,
density: 1400.0,
selection: ndens
}
STD_FSTAR: {
target_name: STD_FSTAR,
truth_name: STD_FSTAR,
mag_bright: 16.0,
grcolor : 0.32,
rzcolor : 0.13,
colortol : 0.16,
mag_faint: 19.0,
root_mock_dir: /project/projectdirs/desi/mocks/mws/galaxia/alpha/v0.0.2/bricks,
format: galaxia,
selection: mag
BGS: {
target_name: BGS,
mockfile: /project/projectdirs/desi/mocks/bgs/MXXL/desi_footprint/v0.0.4/BGS.hdf5,
format: durham_mxxl_hdf5,
magcut: 20.2,
}
ELG: {
target_name: ELG,
truth_name: ELG,
root_mock_dir: /project/projectdirs/desi/mocks/GaussianRandomField/v0.0.4,
mockfile: /project/projectdirs/desi/mocks/GaussianRandomField/v0.0.7_2LPT/ELG.fits,
format: gaussianfield,
selection: ndens
density: 2155,
}
LRG: {
target_name: LRG,
truth_name: LRG,
root_mock_dir: /project/projectdirs/desi/mocks/GaussianRandomField/v0.0.4,
mockfile: /project/projectdirs/desi/mocks/GaussianRandomField/v0.0.7_2LPT/LRG.fits,
format: gaussianfield,
selection: ndens
density: 480,
}
QSO: {
target_name: QSO,
truth_name: QSO,
min_z : 0.0,
max_z : 2.1,
root_mock_dir: /project/projectdirs/desi/mocks/GaussianRandomField/v0.0.4,
format: gaussianfield,
selection : ndens,
}
BADQSO: {
target_name: QSO,
truth_name: STD_FSTAR,
root_mock_dir: /project/projectdirs/desi/mocks/mws/galaxia/alpha/v0.0.2/bricks,
format: galaxia,
global_density: True,
selection: ndens
target_name: QSO,
mockfile: /project/projectdirs/desi/mocks/GaussianRandomField/v0.0.7_2LPT/QSO.fits,
format: gaussianfield,
density: 120,
}
LYA: {
target_name: QSO,
truth_name: QSO,
root_mock_dir: /project/projectdirs/desi/mocks/lya_forest/v0.0.2,
format: lya,
selection : ndens
}
BGS: {
target_name: BGS,
truth_name: BGS,
mag_bright: 15.0,
mag_faintest: 20.0,
mag_priority_split: 19.5,
root_mock_dir: /project/projectdirs/desi/mocks/bgs/MXXL/desi_footprint/v0.0.3,
format: durham_mxxl_hdf5,
selection: mag
target_name: LYA,
mockfile: /project/projectdirs/desi/mocks/lya_forest/v2.0.2/master.fits,
format: CoLoRe,
nside_lya: 16,
density: 50,
}
MWS_MAIN: {
target_name: MWS_MAIN,
truth_name: MWS_MAIN,
mag_bright: 15.0,
mag_faint_filler: 19.0,
mag_faintest: 20.0,
# root_mock_dir: /project/projectdirs/desi/users/forero/galaxia_small,
root_mock_dir: /project/projectdirs/desi/mocks/mws/galaxia/alpha/v0.0.2/bricks,
format: galaxia,
selection: mag
target_name: MWS_MAIN,
mockfile: /project/projectdirs/desi/mocks/mws/galaxia/alpha/v0.0.5/healpix,
nside_galaxia: 8,
format: galaxia,
}
MWS_NEARBY: {
target_name: MWS_NEARBY,
mockfile: /project/projectdirs/desi/mocks/mws/100pc/v0.0.3/mock_100pc.fits,
format: mws_100pc,
}
WD: {
target_name: WD,
mockfile: /project/projectdirs/desi/mocks/mws/wd/v0.0.2/mock_wd.fits,
format: mws_wd,
}
FAINTSTAR: {
target_name: FAINTSTAR,
mockfile: /project/projectdirs/desi/mocks/mws/galaxia/alpha/0.0.5_superfaint/healpix,
nside_galaxia: 8,
format: galaxia,
magcut: 23.5,
}
MWS_WD: {
target_name: MWS_WD,
truth_name: MWS_WD,
mag_bright: 15.0,
mag_faint: 20.0,
root_mock_dir: /project/projectdirs/desi/mocks/mws/wd100pc/v0.0.1,
format: wd100pc,
selection: mag
SKY: {
target_name: SKY,
mockfile: /project/projectdirs/desi/mocks/uniformsky/0.1/uniformsky-2048-0.1.fits,
format: uniformsky,
density: 1400,
}
Loading