Skip to content

Commit

Permalink
Merge pull request #64 from lsst-ts/issue/61/template_generator_phosim
Browse files Browse the repository at this point in the history
Issue/61/template generator phosim
  • Loading branch information
jbkalmbach committed Mar 2, 2021
2 parents 3b29f3e + 333f899 commit 592531c
Show file tree
Hide file tree
Showing 24 changed files with 219,608 additions and 1 deletion.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -28,3 +28,6 @@ pytest_session.txt

# Mac metadata
.DS_Store

# Existing Phosim Donut Templates
policy/cwfs/donutTemplateData/phosimTemplates/
84 changes: 84 additions & 0 deletions bin.src/runCreatePhosimDonutTemplates.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
#!/usr/bin/env python

# This file is part of ts_wep.
#
# Developed for the LSST Telescope and Site Systems.
# This product includes software developed by the LSST Project
# (https://www.lsst.org).
# See the COPYRIGHT file at the top-level directory of this distribution
# for details of code ownership.
#
# 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 GNU General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.

import argparse

from lsst.ts.wep.CreatePhosimDonutTemplates import CreatePhosimDonutTemplates

if __name__ == "__main__":

parser = argparse.ArgumentParser(
description="Generate donut templates for AOS using Phosim."
)
parser.add_argument(
"--numOfProc",
type=int,
default=1,
help="Number of processor to run PhoSim. (default: 1)",
)
parser.add_argument(
"--detectorList",
type=str,
default="",
help="""
Specify detectors.
By default will generate templates for all detectors.
(Example Input: "R22_S00 R22_S01 R22_S02")
""",
)
parser.add_argument(
"--templateSize",
type=int,
default=240,
help="Size of each side of the template in pixels. (default: 240)",
)
parser.add_argument(
"--intraVisitId",
type=int,
default=9006002,
help="Visit ID for phosim intrafocal images. (default: 9006002)",
)
parser.add_argument(
"--extraVisitId",
type=int,
default=9006001,
help="Visit ID for phosim extrafocal images. (default: 9006001)",
)
args = parser.parse_args()

# Run tasks
phosimDonuts = CreatePhosimDonutTemplates()
phosimDonuts.createWorkDirectories()
decListPhosim, decListFlats = phosimDonuts.createDetectorLists(
detectorStr=args.detectorList
)
phosimDonuts.generateDefocalImages(decListPhosim, args.numOfProc)
phosimDonuts.repackagePhosimImages()
phosimDonuts.ingestImages()
phosimDonuts.makeFlats(decListFlats)
phosimDonuts.ingestCalibs()
phosimDonuts.runISR()
phosimDonuts.cutOutIntraExtraTemplates(
args.templateSize, args.intraVisitId, args.extraVisitId
)
phosimDonuts.cleanUpWorkDirs()
2 changes: 2 additions & 0 deletions doc/content.rst
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ This module is a high-level module to use other modules.
* **PlotUtil**: Plot utility functions used in WEP.
* **ParamReader**: Parameter reader class to read the yaml configuration files used in the calculation.
* **DonutImageCheck**: Donut image check class to judge the donut image is effective or not.
* **CreatePhosimDonutTemplates**: Create donut templates on camera detectors using Phosim. See :doc:`here <phosimDonutTemplates>` for more information on generating Phosim donut templates.

.. _lsst.ts.wep-modules_wep_bsc:

Expand Down Expand Up @@ -109,6 +110,7 @@ This module calculates the wavefront error by solving the TIE.
* **DonutTemplateFactory**: Factory for creating donut template objects used by CentroidConvolveTemplate.
* **DonutTemplateDefault**: Default donut template class.
* **DonutTemplateModel**: DonutTemplateDefault child class to make donut templates using an Instrument model.
* **DonutTemplatePhosim**: DonutTemplateDefault child class to make donut templates from templates created with Phosim.

.. _lsst.ts.wep-modules_wep_deblend:

Expand Down
32 changes: 32 additions & 0 deletions doc/phosimDonutTemplates.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
.. py:currentmodule:: lsst.ts.wep
.. _lsst.ts.wep-phosimDonutTemplates:

########################################
Creating Phosim Donut Templates
########################################

This document describes the code to generate the phosim donut templates
that are used by :py:class:`DonutTemplatePhosim`.

Running the code
================

1) Make sure your environment is set up to use ts_wep and that you have phosim
installed with the environment variable $PHOSIMPATH set to the phosim directory.
2) Use python to run `runCreatePhosimDonutTemplates.py` in the bin.src directory.
Use `--help` to see all options.
3) Templates will appear in
`ts_wep/policy/cwfs/templateDonutData/phosimTemplates`.

Input files
===========

The following input files found in `policy/cwfs/donutTemplateData` are used
to create the donut templates.

* **starExtra.inst**: Phosim instance catalog to create one extra-focal donut per CCD
of LSST camera using PhosimMapper.
* **starIntra.inst**: Phosim instance catalog to create one intra-focal donut per CCD
of LSST camera using PhosimMapper.
* **star.cmd**: Phosim command file.
2 changes: 2 additions & 0 deletions doc/uml/cwfsClass.uml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@ CentroidFindFactory ..> CentroidOtsu
CentroidFindFactory ..> CentroidConvolveTemplate
CentroidConvolveTemplate *-- CentroidRandomWalk
DonutTemplateDefault <|-- DonutTemplateModel
DonutTemplateDefault <|-- DonutTemplatePhosim
DonutTemplateFactory ..> DonutTemplateModel
DonutTemplateFactory ..> DonutTemplatePhosim
DonutTemplateModel ..> CompensableImage
DonutTemplateModel ..> Instrument
Image ..> CentroidFindFactory
Expand Down
2 changes: 2 additions & 0 deletions doc/uml/wepClass.uml
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,6 @@ WepController ..> DefocalImage
WepController ..> DonutImage
SourceSelector *-- ParamReader
SourceProcessor *-- ParamReader
CreatePhosimDonutTemplates ..> CamIsrWrapper
CreatePhosimDonutTemplates ..> CamDataCollector
@enduml
11 changes: 10 additions & 1 deletion doc/versionHistory.rst
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,22 @@
Version History
##################

.. _lsst.ts.wep-1.5.3:

-------------
1.5.3
-------------

* Add ``DonutTemplatePhosim`` class.
* Add ``CreatePhosimDonutTemplates`` class and add ``bin.src/runCreatePhosimDonutTemplates.py``

.. _lsst.ts.wep-1.5.2:

-------------
1.5.2
-------------

* Fix the ``ZernikeMaskedFit()`` when passing masked data
* Fix the ``ZernikeMaskedFit()`` when passing masked data

.. _lsst.ts.wep-1.5.1:

Expand Down
Empty file.
12 changes: 12 additions & 0 deletions policy/cwfs/donutTemplateData/star.cmd
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
backgroundmode 0
raydensity 0.0
perturbationmode 1
trackingmode 0
cleartracking
clearclouds
lascatprob 0.0
contaminationmode 0
diffractionmode 1
straylight 0
detectormode 0
centroidfile 1
Loading

0 comments on commit 592531c

Please sign in to comment.