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

DM-20163: Use PixelAreaBoundedField in fgcmcal calibration outputs #9

Merged
merged 4 commits into from
Jan 10, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion fgcm/_version.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from __future__ import division, absolute_import, print_function

__version__ = '2.3.2'
__version__ = '2.4.0'

__version_info__ = __version__.split('.')
1 change: 1 addition & 0 deletions fgcm/fgcmConfig.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@ class FgcmConfig(object):
nCore = ConfigField(int, default=1)
randomSeed = ConfigField(int, required=False)
logger = ConfigField(None, required=False)
outputFgcmcalZpts = ConfigField(bool, default=False)

brightObsGrayMax = ConfigField(float, default=0.15)
minStarPerCCD = ConfigField(int, default=5)
Expand Down
4 changes: 2 additions & 2 deletions fgcm/fgcmLUT.py
Original file line number Diff line number Diff line change
Expand Up @@ -936,7 +936,7 @@ def computeI0(self, lnPwv, o3, lnTau, alpha, secZenith, pmb, indices):
dSecZenith = secZenith - (self.secZenith[0] + indices[5] * self.secZenithDelta)

indicesSecZenithPlus = np.array(indices[:-1])
indicesSecZenithPlus[5] += 1
indicesSecZenithPlus[5] = np.clip(indicesSecZenithPlus[5] + 1, 0, self.secZenith.size - 1)
indicesPwvPlus = np.array(indices[:-1])
indicesPwvPlus[1] = np.clip(indicesPwvPlus[1] + 1, 0, self.lnPwv.size-1)

Expand Down Expand Up @@ -981,7 +981,7 @@ def computeI1(self, lnPwv, o3, lnTau, alpha, secZenith, pmb, indices):
dSecZenith = secZenith - (self.secZenith[0] + indices[5] * self.secZenithDelta)

indicesSecZenithPlus = np.array(indices[:-1])
indicesSecZenithPlus[5] += 1
indicesSecZenithPlus[5] = np.clip(indicesSecZenithPlus[5] + 1, 0, self.secZenith.size - 1)
indicesPwvPlus = np.array(indices[:-1])
indicesPwvPlus[1] = np.clip(indicesPwvPlus[1] + 1, 0, self.lnPwv.size-1)

Expand Down
8 changes: 4 additions & 4 deletions fgcm/fgcmSigmaRef.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,10 +77,10 @@ def computeSigmaRef(self):
offsetRef = np.zeros(self.fgcmStars.nBands)
sigmaRef = np.zeros(self.fgcmStars.nBands)

if goodRefStars.size < 100:
# Arbitrarily do 100 as the cutoff between small and large number...
if goodRefStars.size < 50:
# Arbitrarily do 50 as the cutoff between small and large number...

self.fgcmLog.info('Found %d refstars (< 100), so computing "small-number" statistics:' % (goodRefStars.size))
self.fgcmLog.info('Found %d refstars (< 50), so computing "small-number" statistics:' % (goodRefStars.size))

for bandIndex, band in enumerate(self.fgcmStars.bands):
# Filter on previous bad refstars
Expand All @@ -103,7 +103,7 @@ def computeSigmaRef(self):

else:
# Large numbers
self.fgcmLog.debug('More than 100 reference stars, so computing "large-number" statistics.')
self.fgcmLog.debug('More than 50 reference stars, so computing "large-number" statistics.')

# and we do 4 runs: full, blue 25%, middle 50%, red 25%

Expand Down
22 changes: 20 additions & 2 deletions fgcm/fgcmStars.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,8 @@ def __init__(self,fgcmConfig):

self.seeingSubExposure = fgcmConfig.seeingSubExposure

self.secZenithRange = 1. / np.cos(np.radians(fgcmConfig.zenithRange))

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Feel free to ignore, but I've always preferred np.deg2rad() over np.radians since then in the input units are clear.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll make this change in the next version of fgcm. I don't know why I'm using radians here, since I do usually use deg2rad.


self.starsLoaded = False

def loadStarsFromFits(self,fgcmPars,computeNobs=True):
Expand Down Expand Up @@ -426,10 +428,18 @@ def loadStars(self, fgcmPars,
self.fgcmLog.debug('Applying sigma0Phot = %.4f to mag errs' %
(self.sigma0Phot))

obsMagADU = snmm.getArray(self.obsMagADUHandle)
obsMagADUErr = snmm.getArray(self.obsMagADUErrHandle)

obsFlag = snmm.getArray(self.obsFlagHandle)
bad, = np.where(obsMagADUErr <= 0.0)

bad, = np.where(~np.isfinite(obsMagADU))
obsFlag[bad] |= obsFlagDict['BAD_MAG']
if bad.size > 0:
self.fgcmLog.info('Flagging %d observations with bad magnitudes.' %
(bad.size))

bad, = np.where((np.nan_to_num(obsMagADUErr) <= 0.0) | ~np.isfinite(obsMagADUErr))
obsFlag[bad] |= obsFlagDict['BAD_ERROR']
if (bad.size > 0):
self.fgcmLog.info('Flagging %d observations with bad errors.' %
Expand Down Expand Up @@ -661,7 +671,15 @@ def loadStars(self, fgcmPars,

bad,=np.where(obsFlag != 0)
tempSecZenith[bad] = 1.0 # filler here, but these stars aren't used
snmm.getArray(self.obsSecZenithHandle)[:] = tempSecZenith
obsSecZenith = snmm.getArray(self.obsSecZenithHandle)
obsSecZenith[:] = tempSecZenith

# Check the airmass range
if ((np.min(obsSecZenith) < self.secZenithRange[0]) |
(np.max(obsSecZenith) > self.secZenithRange[1])):
raise ValueError("Input stars have a secZenith that is out of range of LUT."
"Observed range is %.2f to %.2f, and LUT goes from %.2f to %.2f" % (np.min(obsSecZenith), np.max(obsSecZenith), self.secZenithRange[0], self.secZenithRange[1]))

if not self.quietMode:
self.fgcmLog.info('Computed secZenith in %.1f seconds.' %
(time.time() - startTime))
Expand Down
2 changes: 1 addition & 1 deletion fgcm/fgcmSuperStarFlat.py
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ def computeSuperStarFlats(self, doPlots=True, doNotUseSubCCD=False, onlyObsErr=F
# And for signaling here, we're going to set to a large value
superStarOffset[~gd] = 100.0

# And the central parameter should be in flux or mag space depending
# And the central parameter should be in flux space
self.fgcmPars.parSuperStarFlat[:, :, :, 0] = 10.**(superStarOffset / (-2.5))

else:
Expand Down
9 changes: 5 additions & 4 deletions fgcm/fgcmUtilities.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,11 @@ def _pickle_method(m):
'BAD_QUANTITY': 2**6}

# Dictionary of observation flags
obsFlagDict = {'NO_EXPOSURE':2**0,
'BAD_ERROR':2**1,
'SUPERSTAR_OUTLIER':2**2,
'NO_ZEROPOINT': 2**4}
obsFlagDict = {'NO_EXPOSURE': 2**0,
'BAD_ERROR': 2**1,
'SUPERSTAR_OUTLIER': 2**2,
'NO_ZEROPOINT': 2**4,
'BAD_MAG': 2**5}

# Dictionary of exposure flags
expFlagDict = {'TOO_FEW_STARS':2**0,
Expand Down