Skip to content

Commit

Permalink
Use SpherePoint instead of Coord or IcrsCoord
Browse files Browse the repository at this point in the history
  • Loading branch information
r-owen committed Mar 16, 2018
1 parent a47eb89 commit 94d329e
Show file tree
Hide file tree
Showing 12 changed files with 31 additions and 35 deletions.
4 changes: 2 additions & 2 deletions bin.src/plot_jointcal_results.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,9 @@ def prep_reference_loader(center, radius):
Parameters
----------
center: afw.coord
center: lsst.afw.SpherePoint
The center of the field you're testing on.
radius: afw.geom.angle
radius: lsst.afw.geom.angle
The radius to load objects around center.
"""
refLoader = LoadAstrometryNetObjectsTask(LoadAstrometryNetObjectsConfig())
Expand Down
6 changes: 3 additions & 3 deletions include/lsst/jointcal/CcdImage.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@
#include "lsst/afw/geom/SkyWcs.h"
#include "lsst/afw/image/PhotoCalib.h"
#include "lsst/afw/image/VisitInfo.h"
#include "lsst/afw/coord/Coord.h"
#include "lsst/daf/base/PropertySet.h"
#include "lsst/afw/geom/Box.h"
#include "lsst/afw/geom/SpherePoint.h"
#include "lsst/jointcal/MeasuredStar.h"
#include "lsst/jointcal/Gtransfo.h"
#include "lsst/jointcal/Frame.h"
Expand Down Expand Up @@ -117,7 +117,7 @@ class CcdImage {
/**
* @brief Gets the boresight RA/Dec.
*/
lsst::afw::coord::IcrsCoord getBoresightRaDec() const { return _boresightRaDec; }
lsst::afw::geom::SpherePoint getBoresightRaDec() const { return _boresightRaDec; }

//!
double getHourAngle() const { return _hourAngle; }
Expand Down Expand Up @@ -166,7 +166,7 @@ class CcdImage {
CcdIdType _ccdId;
VisitIdType _visit;

lsst::afw::coord::IcrsCoord _boresightRaDec;
lsst::afw::geom::SpherePoint _boresightRaDec;
double _airMass; // airmass value.
double _mjd; // modified julian date
std::shared_ptr<afw::image::PhotoCalib> _photoCalib;
Expand Down
20 changes: 11 additions & 9 deletions python/lsst/jointcal/jointcal.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
import lsst.pipe.base as pipeBase
import lsst.afw.image as afwImage
import lsst.afw.geom as afwGeom
import lsst.afw.coord as afwCoord
import lsst.pex.exceptions as pexExceptions
import lsst.afw.table
import lsst.meas.algorithms
Expand Down Expand Up @@ -363,17 +362,20 @@ def run(self, dataRefs, profile_jointcal=False):
filters = collections.Counter(filters)

centers = [ccdImage.getBoresightRaDec() for ccdImage in associations.getCcdImageList()]
commonTangentPoint = lsst.afw.coord.averageCoord(centers)
self.log.debug("Using common tangent point: %s", commonTangentPoint.getPosition())
associations.setCommonTangentPoint(commonTangentPoint.getPosition())
commonTangentPoint = afwGeom.averageSpherePoint(centers)
self.log.debug("Using common tangent point: %s", commonTangentPoint.getPosition(afwGeom.degrees))
associations.setCommonTangentPoint(commonTangentPoint.getPosition(afwGeom.degrees))

# Use external reference catalogs handled by LSST stack mechanism
# Get the bounding box overlapping all associated images
# ==> This is probably a bad idea to do it this way <== To be improved
bbox = associations.getRaDecBBox()
center = afwCoord.IcrsCoord(bbox.getCenter(), afwGeom.degrees)
corner = afwCoord.IcrsCoord(bbox.getMax(), afwGeom.degrees)
radius = center.angularSeparation(corner).asRadians()
# with Python 3 this can be simplified to afwGeom.SpherePoint(*bbox.getCenter(), afwGeom.degrees)
bboxCenter = bbox.getCenter()
center = afwGeom.SpherePoint(bboxCenter[0], bboxCenter[1], afwGeom.degrees)
bboxMax = bbox.getMax()
corner = afwGeom.SpherePoint(bboxMax[0], bboxMax[1], afwGeom.degrees)
radius = center.separation(corner).asRadians()

# Get astrometry_net_data path
anDir = lsst.utils.getPackageDir('astrometry_net_data')
Expand Down Expand Up @@ -428,8 +430,8 @@ def _do_load_refcat_and_fit(self, associations, defaultFilter, center, radius,
The star/reference star associations to fit.
defaultFilter : str
filter to load from reference catalog.
center : lsst.afw.coord.IcrsCoord
Center of field to load from reference catalog.
center : lsst.afw.geom.SpherePoint
ICRS center of field to load from reference catalog.
radius : lsst.afw.geom.Angle
On-sky radius to load from reference catalog.
name : str
Expand Down
2 changes: 1 addition & 1 deletion python/lsst/jointcal/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ def __init__(self, match_radius=0.1*arcseconds, flux_limit=100.0,
"""
Parameters
----------
match_radius : lsst.afw.Angle
match_radius : lsst.afw.geom.Angle
match sources within this radius for RMS statistics
flux_limit : float
Signal/Noise (flux/fluxSigma) for sources to be included in the RMS cross-match.
Expand Down
3 changes: 1 addition & 2 deletions src/Associations.cc
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
#include "lsst/pex/exceptions.h"
#include "lsst/afw/geom/Box.h"
#include "lsst/afw/geom/Point.h"
#include "lsst/afw/coord/Coord.h"
#include "lsst/afw/image/Calib.h"

namespace jointcal = lsst::jointcal;
Expand Down Expand Up @@ -167,7 +166,7 @@ void Associations::collectRefStars(lsst::afw::table::SortedCatalogT<lsst::afw::t
for (size_t i = 0; i < refCat.size(); i++) {
auto const &record = refCat.get(i);

afw::coord::IcrsCoord coord = record->get(coordKey);
auto coord = record->get(coordKey);
double defaultFlux = record->get(fluxKey) / JanskyToMaggy;
double defaultFluxErr;
if (fluxErrKey.isValid()) {
Expand Down
6 changes: 3 additions & 3 deletions src/SipToGtransfo.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

#include "Eigen/Core"
#include "lsst/jointcal/SipToGtransfo.h"
#include "lsst/afw/coord/Coord.h"
#include "lsst/afw/geom/Angle.h"
#include "lsst/afw/geom/SkyWcs.h"
#include "lsst/afw/geom/SpherePoint.h"
#include "lsst/afw/image/ImageUtils.h"
#include "lsst/jointcal/Point.h"
#include "lsst/jointcal/Frame.h"
Expand Down Expand Up @@ -54,8 +54,8 @@ std::shared_ptr<afw::geom::SkyWcs> gtransfoToTanWcs(const jointcal::TanSipPix2Ra
"FITS units" yet because the SkyWcs constructors expect it in LSST
units */

afw::coord::IcrsCoord const crval(wcsTransfo.getTangentPoint().x * afwGeom::degrees,
wcsTransfo.getTangentPoint().y * afwGeom::degrees);
afw::geom::SpherePoint const crval(wcsTransfo.getTangentPoint().x * afwGeom::degrees,
wcsTransfo.getTangentPoint().y * afwGeom::degrees);

// CD matrix:
Eigen::Matrix2d cdMat;
Expand Down
10 changes: 5 additions & 5 deletions tests/jointcalTestBase.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,11 @@ def setUp_base(self, center, radius,
Parameters
----------
center : lsst.afw.IcrsCoord
center : lsst.afw.geom.SpherePoint
Center of the reference catalog.
radius : lsst.afw.Angle
radius : lsst.afw.geom.Angle
Radius from center to load reference catalog objects inside.
match_radius : lsst.afw.Angle
match_radius : lsst.afw.geom.Angle
matching radius when calculating RMS of result.
input_dir : str
Directory of input butler repository.
Expand Down Expand Up @@ -94,9 +94,9 @@ def _prep_reference_loader(self, center, radius):
Parameters
----------
center : afw.coord
center : lsst.afw.SpherePoint
The center of the field you're testing on.
radius : afw.geom.angle
radius : lsst.afw.geom.angle
The radius to load objects around center.
"""
refLoader = LoadAstrometryNetObjectsTask(LoadAstrometryNetObjectsConfig())
Expand Down
3 changes: 1 addition & 2 deletions tests/test_jointcal_cfht.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@

from astropy import units as u

import lsst.afw.coord
import lsst.afw.geom
import lsst.utils
import lsst.pex.exceptions
Expand Down Expand Up @@ -41,7 +40,7 @@ def setUp(self):
do_plot = False

# center of the cfht validation_data catalog
center = lsst.afw.coord.IcrsCoord(214.884832*lsst.afw.geom.degrees, 52.6622199*lsst.afw.geom.degrees)
center = lsst.afw.geom.SpherePoint(214.884832, 52.6622199, lsst.afw.geom.degrees)
radius = 3*lsst.afw.geom.degrees

input_dir = os.path.join(self.data_dir, 'cfht')
Expand Down
3 changes: 1 addition & 2 deletions tests/test_jointcal_cfht_minimal.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
import unittest
import os

import lsst.afw.coord
import lsst.afw.geom
import lsst.utils
import lsst.pex.exceptions
Expand Down Expand Up @@ -33,7 +32,7 @@ def setUp(self):
do_plot = False

# center of the cfht validation_data catalog
center = lsst.afw.coord.IcrsCoord(214.884832*lsst.afw.geom.degrees, 52.6622199*lsst.afw.geom.degrees)
center = lsst.afw.geom.SpherePoint(214.884832, 52.6622199, lsst.afw.geom.degrees)
radius = 3*lsst.afw.geom.degrees

input_dir = os.path.join(self.data_dir, 'cfht_minimal')
Expand Down
3 changes: 1 addition & 2 deletions tests/test_jointcal_decam.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@

from astropy import units as u

import lsst.afw.coord
import lsst.afw.geom
import lsst.utils
import lsst.pex.exceptions
Expand Down Expand Up @@ -41,7 +40,7 @@ def setUp(self):
do_plot = False

# center of the decam validation_data catalog
center = lsst.afw.coord.IcrsCoord(150.1191666*lsst.afw.geom.degrees, 2.20583333*lsst.afw.geom.degrees)
center = lsst.afw.geom.SpherePoint(150.1191666, 2.20583333, lsst.afw.geom.degrees)
radius = 3*lsst.afw.geom.degrees

input_dir = os.path.join(self.data_dir, 'decam')
Expand Down
3 changes: 1 addition & 2 deletions tests/test_jointcal_hsc.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@

from astropy import units as u

import lsst.afw.coord
import lsst.afw.geom
import lsst.utils
import lsst.pex.exceptions
Expand Down Expand Up @@ -41,7 +40,7 @@ def setUp(self):
do_plot = False

# center of the hsc validation_data catalog
center = lsst.afw.coord.IcrsCoord(320.367492*lsst.afw.geom.degrees, 0.3131554*lsst.afw.geom.degrees)
center = lsst.afw.geom.SpherePoint(320.367492, 0.3131554, lsst.afw.geom.degrees)
radius = 5*lsst.afw.geom.degrees

input_dir = os.path.join(self.data_dir, 'hsc')
Expand Down
3 changes: 1 addition & 2 deletions tests/test_jointcal_lsstSim.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@

import lsst.afw.geom
import lsst.afw.image
import lsst.afw.coord
import lsst.utils
import lsst.pex.exceptions
from lsst.meas.extensions.astrometryNet import LoadAstrometryNetObjectsTask
Expand Down Expand Up @@ -45,7 +44,7 @@ def setUp(self):
do_plot = False

# position of the Twinkles run 1 catalog
center = lsst.afw.coord.IcrsCoord(53.00914*lsst.afw.geom.degrees, -27.43895*lsst.afw.geom.degrees)
center = lsst.afw.geom.SpherePoint(53.00914, -27.43895, lsst.afw.geom.degrees)
radius = 3*lsst.afw.geom.degrees

input_dir = os.path.join(self.data_dir, 'twinkles1')
Expand Down

0 comments on commit 94d329e

Please sign in to comment.