-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #18 from lsst/tickets/DM-6349
Passed some tests with twinkles data. Merging before I rewrite the Readme to use the PhoSim Globus data. Current version is in sync with PhoSim 3.4.2.
- Loading branch information
Showing
216 changed files
with
6,462 additions
and
8,286 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
Description | ||
=========== | ||
|
||
This obs_lsstSim package provides an interface to the phosim output for the LSST Data Management software. | ||
|
||
Updating camera description | ||
--------------------------- | ||
|
||
The camera description FITS files are built from the phosim lsst data text files. To update the camera description to match a new version of phosim, you will need two files from `phosim_release/data/lsst`, and the gain and saturation data from the header of the phosim generated files for the entire focalplane. | ||
|
||
1. Checkout the latest version of phosim: | ||
* `git clone https://bitbucket.org/phosim/phosim_release.git` | ||
2. Copy these files from your phosim checkout into this repo's `description/` directory: | ||
* `description/lsst/focalplanelayout.txt` | ||
* `description/lsst/segmentation.txt` | ||
3. Generate the gain/saturation file (with obs_lsstSim setup via eups): | ||
1. Build phosim (see [Using Phosim](https://bitbucket.org/phosim/phosim_release/wiki/Using%20PhoSim) for build instructions). You likely will need to create an SEDs directory (even if its empty): | ||
`mkdir data/SEDs` | ||
2. Run phosim to generate a simple no-background simulation (give this several hours to complete): | ||
`./phosim $OBS_LSSTSIM_DIR/description/nostars_allchips -c examples/nobackground` | ||
3. Extract the gain and saturation values from the headers produced by the above commands: | ||
`extractPhosimGainSaturation.py -v output/` | ||
3. Update the phosim verison in this repo's `description/phosim_version.txt` to match the version associated with the above files. | ||
4. Commit your above changes and push. | ||
|
||
The files you have updated above will be converted into the camera description files when this product is built by scons. You can check that this completes successfully by setting up this product and running "scons" at the root level. | ||
|
||
Note that this process does not build the wavefront sensor files. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,13 @@ | ||
# -*- python -*- | ||
import lsst.sconsUtils | ||
from lsst.sconsUtils import scripts | ||
scripts.BasicSConstruct("obs_lsstSim") | ||
scripts.BasicSConstruct("obs_lsstSim", | ||
defaultTargets=scripts.DEFAULT_TARGETS + ("description",), | ||
sconscriptOrder=["python", "description", "tests"] | ||
) | ||
env = lsst.sconsUtils.env | ||
# Don't need to rebuild the camera descriptions if this code changes, so just Requires(), not Depends(). | ||
env.Requires(lsst.sconsUtils.targets['description'], lsst.sconsUtils.targets['version']) | ||
env.Requires(lsst.sconsUtils.targets['description'], lsst.sconsUtils.targets['python']) | ||
# Do need to rerun tests anytime the camera descriptions change. | ||
env.Depends(lsst.sconsUtils.targets['tests'], lsst.sconsUtils.targets['description']) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
#!/usr/bin/env python2 | ||
# | ||
# LSST Data Management System | ||
# Copyright 2014 LSST Corporation. | ||
# | ||
# This product includes software developed by the | ||
# LSST Project (http://www.lsst.org/). | ||
# | ||
# This program is free software: you can redistribute it and/or modify | ||
# it under the terms of the GNU General Public License as published by | ||
# the Free Software Foundation, either version 3 of the License, or | ||
# (at your option) any later version. | ||
# | ||
# This program is distributed in the hope that it will be useful, | ||
# but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
# GNU General Public License for more details. | ||
# | ||
# You should have received a copy of the LSST License Statement and | ||
# the GNU General Public License along with this program. If not, | ||
# see <http://www.lsstcorp.org/LegalNotices/>. | ||
# | ||
""" | ||
Extract gain and saturation values from phosim headers to make a gainFile for | ||
makeLsstCameraRepository.py. | ||
You first have to run phosim to generate images for each amp. These can be the | ||
simplest no-background, no-source images, so long as they have a real gain and | ||
saturation threshold. | ||
""" | ||
from __future__ import absolute_import, division, print_function | ||
|
||
import os | ||
import glob | ||
|
||
from astropy.io import fits | ||
|
||
|
||
def read_files(path, verbose=False): | ||
"""Return a dictionary of amp name: (gain, saturation) for all amp files in path.""" | ||
amps = {} | ||
files = glob.glob(os.path.join(path, 'lsst_*_R??_S??_C??*.fits.gz')) | ||
for file in files: | ||
if verbose: | ||
print(file) | ||
header = fits.getheader(file) | ||
ampid = '_'.join((header['CCDID'], header['AMPID'])) | ||
amps[ampid] = header['GAIN'], int(header['SATURATE']) | ||
return amps | ||
|
||
|
||
def write_gain_file(amps, filename): | ||
"""Write a gainFile for use by makeLsstCameraRepository.py.""" | ||
with open(filename, 'w') as outfile: | ||
for amp in sorted(amps): | ||
line = '{} {} {}\n'.format(amp, amps[amp][0], amps[amp][1]) | ||
outfile.write(line) | ||
|
||
|
||
def main(): | ||
import argparse | ||
parser = argparse.ArgumentParser(description=__doc__) | ||
parser.add_argument("phosim_output_path", | ||
help="Path to phosim output directory containing amp files.") | ||
parser.add_argument("--verbose", "-v", action="store_true", help="Show file processing prgress.") | ||
args = parser.parse_args() | ||
|
||
amps = read_files(args.phosim_output_path, verbose=args.verbose) | ||
filename = os.path.join(os.environ['OBS_LSSTSIM_DIR'], 'description', 'gain_saturation.txt') | ||
write_gain_file(amps, filename) | ||
print("Wrote: ", filename) | ||
|
||
|
||
if __name__ == "__main__": | ||
main() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.