Skip to content

Commit

Permalink
Save useful TNOmag file. Fix bug introduced yesterday.
Browse files Browse the repository at this point in the history
  • Loading branch information
Mikea1985 committed Aug 13, 2018
1 parent 1c3507f commit b8dd2e4
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 5 deletions.
9 changes: 5 additions & 4 deletions maphot/maphot.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,13 @@
import best
from maphot_functions import (getArguments, getObservations, coordRateAngle,
getSExCatalog, predicted2catalog,
saveTNOMag, saveStarMag,
saveTNOMag, saveStarMag, saveTNOMag2,
getDataHeader, addPhotToCatalog, PS1_vs_SEx,
PS1_to_CFHT, CFHT_to_PS1, inspectStars,
chooseCentroid, removeTSF,
extractGoodStarCatalogue)
from __version__ import __version__
from pix2world import pix2world
from pix2world import pix2MPC

__author__ = ('Mike Alexandersen (@mikea1985, github: mikea1985, '
'[email protected])')
Expand Down Expand Up @@ -332,6 +332,8 @@
TNOCoords = WCS.all_pix2world(xUse, yUse, 1)
#Save TNO magnitudes neatly.
timeNow = datetime.now().strftime('%Y-%m-%d/%H:%M:%S')
saveTNOMag2(inputFile, coordsfile, MJDm, TNOCoords, xUse, yUse,
FILTER, fwhm, finalTNOphotPS1, timeNow, __version__, extno=extno)
saveTNOMag(inputFile, coordsfile, MJD, MJDm, TNOCoords, xUse, yUse,
MAGZERO, FILTER, fwhm, bestap, TNOPhot,
magCalibration, dmagCalibration, finalTNOphotCFHT, zptGood,
Expand All @@ -350,8 +352,7 @@
inputName, outfile=outfile, repfact=repfact, remove=remove)

#Run function to save photometry in MPC format
pix2world(WCS, EXPTIME, MJD, finalTNOphotPS1[0], xUse, yUse, FILTER,
extno)
pix2MPC(WCS, EXPTIME, MJD, finalTNOphotPS1[0], xUse, yUse, FILTER, extno)

print('Done with ' + inputFile + '!')
outfile.close()
Expand Down
32 changes: 31 additions & 1 deletion maphot/maphot_functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -425,7 +425,7 @@ def saveTNOMag(image_fn, mpc_fn, headerMJD, obsMJD, SExTNOCoord, x_tno, y_tno,
'ZptGood\tRunTime\t' +
'GoodMag_PS1\tdGoodMag_PS1\t' +
'bgXMin\tbgXMax\tbgYMin\tbgYMax\t' +
'gphot_version\n')
'maphot_version\n')
TNOFile.write('{}\t{}\t'.format(image_fn, mpc_fn) +
'{}\t{}\t'.format(headerMJD, obsMJD) +
'{}\t{}\t'.format(SExTNOCoord[0], SExTNOCoord[1]) +
Expand All @@ -441,6 +441,36 @@ def saveTNOMag(image_fn, mpc_fn, headerMJD, obsMJD, SExTNOCoord, x_tno, y_tno,
return


def saveTNOMag2(image_fn, mpc_fn, obsMJD, SExTNOCoord, x_tno, y_tno,
obsFILTER, FWHM, finalTNOphotPS1, timeNow, version,
extno=None):
'''Save the TNO magnitude and other information.'''
if extno is None:
print('Warning: Treating this as a single extension file.')
TNOFileName = 'TNOmags.txt'
else:
TNOFileName = 'TNOmags{0:02.0f}.txt'.format(extno)
TNOFile = open(TNOFileName, 'a+')
TNOFile.write('#Filename\tObject\tMJDm\t' +
'RA(deg)\tDec(deg)\t' +
'x_pix\ty_pix\t' +
'Filter\tFWHM\t' +
'GoodMag_PS1\tdGoodMag_PS1\t' +
'RunTime\t' +
'maphot_version\n')
TNOFile.write(image_fn.replace('.fits','') + '\t' +
mpc_fn.replace('.mpc', '').replace('../MPC/', '') + '\t' +
'{}\t'.format(obsMJD) +
'{}\t{}\t'.format(SExTNOCoord[0], SExTNOCoord[1]) +
'{}\t{}\t'.format(x_tno, y_tno) +
'{}\t{}\t'.format(obsFILTER, FWHM) +
'{}\t{}\t'.format(finalTNOphotPS1[0], finalTNOphotPS1[1]) +
'{}\t'.format(timeNow) +
'{}\n'.format(version))
TNOFile.close()
return


def saveStarMag(image_fn, finalCat, timeNow, version, headerMJD, extno=None):
'''Save the star magnitudes and other information.'''
if extno is None:
Expand Down

0 comments on commit b8dd2e4

Please sign in to comment.