Skip to content

Commit

Permalink
Merge branch 'master' into issue/299/design-note
Browse files Browse the repository at this point in the history
  • Loading branch information
drphilmarshall committed Mar 29, 2017
2 parents e54d907 + 77d0b0e commit a4a72ca
Show file tree
Hide file tree
Showing 89 changed files with 65,376 additions and 862 deletions.
8 changes: 5 additions & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,23 +1,25 @@
language: C

install:
- travis_wait 25 ./setup/travis_install.sh lsst-sims nose pandas pylint
- travis_wait 30 ./setup/travis_install.sh lsst-sims nose pandas pylint future scikit-learn
- ln -sf /home/travis/miniconda/lib/libssl.so.1.0.0 /home/travis/miniconda/lib/libssl.so.10
- ln -sf /home/travis/miniconda/lib/libcrypto.so.1.0.0 /home/travis/miniconda/lib/libcrypto.so.10
- export PATH="$HOME/miniconda/bin:$PATH"
- source eups-setups.sh
- pip install coveralls
- setup lsst_sims
- pip install om10
- eups declare -r . twinkles -t current
- setup twinkles

cache:
directories:
- $HOME/miniconda.tarball
timeout: 600

before_cache:
- du -h $HOME/miniconda.tarball
- ls -l $HOME/miniconda.tarball

services:
- mysql

Expand All @@ -27,7 +29,7 @@ before_script:

script:
- nosetests -s --with-coverage --cover-package=desc.twinkles
- pylint --py3k `find . -name \*.py -print | grep -v workflows`
- pylint -r n --py3k `find . -name \*.py -print | grep -v workflows | grep -v configScripts`

after_success:
- coveralls
56 changes: 28 additions & 28 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,62 +19,62 @@ plans and progress to date.

### Latest News

[![Build Status](https://travis-ci.org/DarkEnergyScienceCollaboration/Twinkles.svg?branch=master)](https://travis-ci.org/DarkEnergyScienceCollaboration/Twinkles) [![Coverage Status](https://coveralls.io/repos/github/DarkEnergyScienceCollaboration/Twinkles/badge.svg?branch=master)](https://coveralls.io/github/DarkEnergyScienceCollaboration/Twinkles?branch=master)

* We have a [public website](https://darkenergysciencecollaboration.github.io/Twinkles/), whose main function is to host the **["Twinkles Weeklies"](https://darkenergysciencecollaboration.github.io/Twinkles/weekly/index.html)**. These are brief summaries from our weekly meetings, with links to the progress that is reported there.
* Check out **[our most recently updated GitHub issues](https://github.com/DarkEnergyScienceCollaboration/Twinkles/issues?q=is%3Aissue+is%3Aopen+sort%3Aupdated-desc)** to see what we're working on at the moment. You can filter our [issue list](https://github.com/DarkEnergyScienceCollaboration/Twinkles) in various ways to see what we're up to more generally.
* For a quick overview of how far we've got so far, you can peruse our **[Summer 2016 Twinkles 1 Progress Report](https://github.com/DarkEnergyScienceCollaboration/Twinkles/blob/master/doc/Summary_2016Q2.md)**
* We're keeping our DM Level 2 measurements in **[databases](https://github.com/DarkEnergyScienceCollaboration/Twinkles/blob/master/doc/Database.md)**, using our homegrown emulator **[`Pserv`](https://github.com/DarkEnergyScienceCollaboration/Pserv)** while Qserv is still under development.
* Veuillez s'il vous plait consulter le Twinkles **[difference imaging sandbox](https://github.com/DarkEnergyScienceCollaboration/Twinkles/wiki/A-sandbox-for-difference-imaging)**
* Our goal for the March 2016 collaboration meeting was to produce and begin analyzing a small prototype Twinkles 1 dataset: **[Run 1](https://github.com/DarkEnergyScienceCollaboration/Twinkles/blob/master/doc/Run1.md)**
* We are a **[2015 DESC Taskforce](https://github.com/DarkEnergyScienceCollaboration/Twinkles/blob/master/doc/Taskforce2015_Twinkles.md)**, assembled in order to kick-start development ready for our first data release at DC1.
* **[Twinkles is on the sky!](http://github.com/DarkEnergyScienceCollaboration/Twinkles/blob/master/examples/notebooks/First%20Light.ipynb)** LSST DESC Hack Day, February 2015.
[![Build Status](https://travis-ci.org/LSSTDESC/Twinkles.svg?branch=master)](https://travis-ci.org/LSSTDESC/Twinkles) [![Coverage Status](https://coveralls.io/repos/github/LSSTDESC/Twinkles/badge.svg?branch=master)](https://coveralls.io/github/LSSTDESC/Twinkles?branch=master)

* We have a [public website](https://lsstdesc.github.io/Twinkles/), whose main function is to host the **["Twinkles Weeklies"](https://lsstdesc.github.io/Twinkles/weekly/index.html)**. These are brief summaries from our weekly meetings, with links to the progress that is reported there.
* Check out **[our most recently updated GitHub issues](https://github.com/LSSTDESC/Twinkles/issues?q=is%3Aissue+is%3Aopen+sort%3Aupdated-desc)** to see what we're working on at the moment. You can filter our [issue list](https://github.com/LSSTDESC/Twinkles) in various ways to see what we're up to more generally.
* For a quick overview of how far we've got so far, you can peruse our **[Summer 2016 Twinkles 1 Progress Report](https://github.com/LSSTDESC/Twinkles/blob/master/doc/Summary_2016Q2.md)**
* We're keeping our DM Level 2 measurements in **[databases](https://github.com/LSSTDESC/Twinkles/blob/master/doc/Database.md)**, using our homegrown emulator **[`Pserv`](https://github.com/LSSTDESC/Pserv)** while Qserv is still under development.
* Veuillez s'il vous plait consulter le Twinkles **[difference imaging sandbox](https://github.com/LSSTDESC/Twinkles/wiki/A-sandbox-for-difference-imaging)**
* Our goal for the March 2016 collaboration meeting was to produce and begin analyzing a small prototype Twinkles 1 dataset: **[Run 1](https://github.com/LSSTDESC/Twinkles/blob/master/doc/Run1.md)**
* We are a **[2015 DESC Taskforce](https://github.com/LSSTDESC/Twinkles/blob/master/doc/Taskforce2015_Twinkles.md)**, assembled in order to kick-start development ready for our first data release at DC1.
* **[Twinkles is on the sky!](http://github.com/LSSTDESC/Twinkles/blob/master/examples/notebooks/First%20Light.ipynb)** LSST DESC Hack Day, February 2015.
* **[Initial design for the Twinkles pipeline](https://confluence.slac.stanford.edu/display/LSSTDESC/Twinkles+flow+chart)** LSST DESC Hack Day, February 2015.


### Read More

Some of these links are quite old, but will have to do while we write
up our progress so far as a set of LSST DESC Notes.
* [Scientific and Technical Motivation](https://github.com/DarkEnergyScienceCollaboration/Twinkles/blob/master/doc/Motivation.md)
* [Survey Design](https://github.com/DarkEnergyScienceCollaboration/Twinkles/blob/master/doc/Design.md)
* [Data Generation and Analysis: Pipeline Design](https://github.com/DarkEnergyScienceCollaboration/Twinkles/blob/master/doc/Organisation.md)
* [Getting Set Up to Run Twinkles Simulations](https://github.com/DarkEnergyScienceCollaboration/Twinkles/blob/master/doc/Setup.md)
* [Scientific and Technical Motivation](https://github.com/LSSTDESC/Twinkles/blob/master/doc/Motivation.md)
* [Survey Design](https://github.com/LSSTDESC/Twinkles/blob/master/doc/Design.md)
* [Data Generation and Analysis: Pipeline Design](https://github.com/LSSTDESC/Twinkles/blob/master/doc/Organisation.md)
* [Getting Set Up to Run Twinkles Simulations](https://github.com/LSSTDESC/Twinkles/blob/master/doc/Setup.md)


### People

* Phil Marshall (SLAC,
[@drphilmarshall](https://github.com/DarkEnergyScienceCollaboration/Twinkles/issues?q=assignee%3Adrphilmarshall))
[@drphilmarshall](https://github.com/LSSTDESC/Twinkles/issues?q=assignee%3Adrphilmarshall))
* Michael Wood-Vasey (Pitt,
[@wmwv](https://github.com/DarkEnergyScienceCollaboration/Twinkles/issues?q=assignee%3Awmwv))
[@wmwv](https://github.com/LSSTDESC/Twinkles/issues?q=assignee%3Awmwv))
* Richard Dubois (SLAC,
[@richardxdubois](https://github.com/DarkEnergyScienceCollaboration/Twinkles/issues?q=assignee%3Arichardxdubois))
[@richardxdubois](https://github.com/LSSTDESC/Twinkles/issues?q=assignee%3Arichardxdubois))
* Rahul Biswas (UW,
[@rbiswas4](https://github.com/DarkEnergyScienceCollaboration/Twinkles/issues?q=assignee%3Arbiswas4))
[@rbiswas4](https://github.com/LSSTDESC/Twinkles/issues?q=assignee%3Arbiswas4))
* Jim Chiang (SLAC,
[@jchiang87](https://github.com/DarkEnergyScienceCollaboration/Twinkles/issues?q=assignee%3Ajchiang87))
[@jchiang87](https://github.com/LSSTDESC/Twinkles/issues?q=assignee%3Ajchiang87))
* Scott Daniel (UW,
[@danielsf](https://github.com/DarkEnergyScienceCollaboration/Twinkles/issues?q=assignee%3Adanielsf))
[@danielsf](https://github.com/LSSTDESC/Twinkles/issues?q=assignee%3Adanielsf))
* Seth Digel (SLAC,
[@sethdigel](https://github.com/DarkEnergyScienceCollaboration/Twinkles/issues?q=assignee%3Asethdigel))
[@sethdigel](https://github.com/LSSTDESC/Twinkles/issues?q=assignee%3Asethdigel))
* Tom Glanzman (SLAC,
[@TomGlanzman](https://github.com/DarkEnergyScienceCollaboration/Twinkles/issues?q=assignee%3ATomGlanzman))
[@TomGlanzman](https://github.com/LSSTDESC/Twinkles/issues?q=assignee%3ATomGlanzman))
* Tony Johnson (SLAC,
[@tony-johnson](https://github.com/DarkEnergyScienceCollaboration/Twinkles/issues?q=assignee%3Atony-johnson))
[@tony-johnson](https://github.com/LSSTDESC/Twinkles/issues?q=assignee%3Atony-johnson))
* Bryce Kalmbach (UW,
[@jbkalmbach](https://github.com/DarkEnergyScienceCollaboration/Twinkles/issues?q=assignee%3Ajbkalmbach))
* Heather Kelly (SLAC, [@heather999](https://github.com/DarkEnergyScienceCollaboration/Twinkles/issues?q=assignee%3Aheather999))
[@jbkalmbach](https://github.com/LSSTDESC/Twinkles/issues?q=assignee%3Ajbkalmbach))
* Heather Kelly (SLAC, [@heather999](https://github.com/LSSTDESC/Twinkles/issues?q=assignee%3Aheather999))
* Simon Krughoff (UW,
[@SimonKrughoff](https://github.com/DarkEnergyScienceCollaboration/Twinkles/issues?q=assignee%3ASimonKrughoff))
[@SimonKrughoff](https://github.com/LSSTDESC/Twinkles/issues?q=assignee%3ASimonKrughoff))
* Curtis McCully (LCOGT)
* Saba Sehrish (Fermilab)


Check out all of our [GitHub contributions](https://github.com/DarkEnergyScienceCollaboration/Twinkles/graphs/contributors)!
Check out all of our [GitHub contributions](https://github.com/LSSTDESC/Twinkles/graphs/contributors)!

### Credits etc

This is work in progress. If you would like to cite the Twinkles project in your research, please use '(LSST DESC, in prep.)' for now, and provide the [URL of this repository](https://github.com/DarkEnergyScienceCollaboration/Twinkles). We aim to release our data products along with a companion paper during the DESC DC1 era, c. 2016. If you are interested in this project, feel free to post greetings, comments or queries to the [issues](https://github.com/DarkEnergyScienceCollaboration/Twinkles/issues).
This is work in progress. If you would like to cite the Twinkles project in your research, please use '(LSST DESC, in prep.)' for now, and provide the [URL of this repository](https://github.com/LSSTDESC/Twinkles). We aim to release our data products along with a companion paper during the DESC DC1 era, c. 2016. If you are interested in this project, feel free to post greetings, comments or queries to the [issues](https://github.com/LSSTDESC/Twinkles/issues).

All content is Copyright 2015, 2016 the above authors, and distributed under the MIT License, which means you can do whatever you like with it but agree not to blame us - but we'd prefer it if you kept in touch while you did so!
1 change: 1 addition & 0 deletions bin/build_index_files.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#!/usr/bin/env python
"""
Script to generate a set of astrometry.net index files from a phosim
instance catalog.
Expand Down
151 changes: 151 additions & 0 deletions bin/generatePhosimInput.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,151 @@
#!/usr/bin/env python
"""
Script to run the generation of phoSim instance catalogs
"""
from __future__ import with_statement, absolute_import, division, print_function
import time
import os
import argparse
import pandas as pd
from sqlalchemy import create_engine
from lsst.utils import getPackageDir
from lsst.sims.catUtils.utils import ObservationMetaDataGenerator
from desc.twinkles import TwinklesSky


def phoSimInputFileName(obsHistID,
prefix='InstanceCatalogs/PhoSim_input',
suffix='.txt',
location='./'):
"""
function to return the absolute path to a filename for writing the phoSim
input corresponding to obsHistID.
Parameters
----------
prefix : string, optional
suffix : string, optional, defaults to '.txt'
location : string, optional, defaults to './'
"""

return os.path.join(location, prefix + '_{}'.format(obsHistID) + suffix)


def _sql_constraint(obsHistIDList):
"""
sql constraint to get OpSim pointing records for a list of obsHistID
Parameters
----------
obsHistIDList : list of integers, mandatory
list of obsHistIDs of interest
"""
sql_string = 'SELECT * FROM Summary WHERE ObsHistID in ('
sql_string += ', '.join(map(str, obsHistIDList))
sql_string += ')'
return sql_string


def generateSinglePointing(obs_metaData, availableConns, sntable,
fname,
sn_sed_file_dir,
db_config,
cache_dir):
"""
obs_metaData : instance of `lsst.sims.utils.ObservationMetaData`
observation metadata corresponding to an OpSim pointing
availableConns : available connections to fatboy
sntable : Table for SN on the fatboy database
fname : output file for phoSim instance Catalog
sn_sed_file_dir : directory to which the SN seds corresponding to this
phoSim metadat
db_config : the name of a file overriding the fatboy connection information
cache_dir : the directory containing the source data of astrophysical objects
"""
tstart = time.time()
obs_metaData.boundLength = 0.3
print(obs_metaData.summary)
obsHistID = obs_metaData._OpsimMetaData['obsHistID']

# all but first two are default values of optional parameters
# Kept in script to emphasize inputs
tSky = TwinklesSky(obs_metadata=obs_metaData,
availableConnections=availableConns,
brightestStar_gmag_inCat=11.0,
brightestGal_gmag_inCat=11.0,
sntable=sntable,
sn_sedfile_prefix=os.path.join(sn_sed_file_dir, 'specFile_'),
db_config=db_config,
cache_dir=cache_dir)
# fname = phoSimInputFileName(obsHistID)
# if not os.path.exists(os.path.dirname(fname)):
# os.makedirs(os.path.dirname(fname))
if not os.path.exists(sn_sed_file_dir):
os.makedirs(sn_sed_file_dir)
tSky.writePhoSimCatalog(fname)
availConns = tSky.availableConnections
tend = time.time()
print (obsHistID, tend - tstart)


if __name__ == '__main__':

parser = argparse.ArgumentParser(description='Write phoSim Instance Catalogs'
'and SN spectra to disk '
'example : '
'python generatePhosimInput.py 230\ '
'--OpSimDBDir ~/data/LSST/OpSimData/\ '
'--seddir "./"\ '
'--outfile phosim_instance_catalog_220.txt')
parser.add_argument('--opsimDB',
type=str,
help='OpSim database sqlite filename',
default='minion_1016_sqlite.db')
parser.add_argument('visit',
type=int,
help='Visit number (obsHistID)')
parser.add_argument('--OpSimDBDir',
help='absolute path to dir with the opsimBD',
type=str,
default='./')
parser.add_argument('--outfile', type=str, default=None,
help='output filename for instance catalog')
parser.add_argument('--seddir',
type=str,
default='.',
help='directory to contain SED files')
parser.add_argument('--db_config', type=str, default=None,
help='config file overriding CatSim database connection information')
parser.add_argument('--cache_dir', type=str,
default=os.path.join(getPackageDir('twinkles'), 'data'),
help='directory containing the source data for the InstanceCatalogs')
args = parser.parse_args()

# set the filename default to a sensible value using the obsHistID
if args.outfile is None:
args.outfile = phoSimInputFileName(args.visit,
prefix='phosim_input',
suffix='.txt',
location='./')
# Set up OpSim database
opSimDBPath = os.path.join(args.OpSimDBDir, args.opsimDB)
engine = create_engine('sqlite:///' + opSimDBPath)

obs_gen = ObservationMetaDataGenerator(database=opSimDBPath)
sql_query = 'SELECT * FROM Summary WHERE ObsHistID == {}'.format(args.visit)
df = pd.read_sql_query(sql_query, engine)
recs = df.to_records()
obsMetaDataResults = obs_gen.ObservationMetaDataFromPointingArray(recs)
obs_metaData = obsMetaDataResults[0]
sn_sed_file_dir = os.path.join(args.seddir, 'spectra_files')

availConns = None
print('will generate pointing for {0} and write to filename {1}'.format(
obs_metaData._OpsimMetaData['obsHistID'], args.outfile))
generateSinglePointing(obs_metaData,
availableConns=availConns,
sntable='TwinkSN_run3',
fname=args.outfile,
sn_sed_file_dir=sn_sed_file_dir,
db_config=args.db_config,
cache_dir=args.cache_dir)
Loading

0 comments on commit a4a72ca

Please sign in to comment.