Skip to content

Commit

Permalink
updated treatment of positions files
Browse files Browse the repository at this point in the history
  • Loading branch information
Michael Mommert committed Apr 18, 2017
1 parent 10cb0bd commit 16b2e36
Show file tree
Hide file tree
Showing 3 changed files with 58 additions and 16 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ dump/
# stuff we don't want to track
setup/mytelescopes.py
doc/_build/
ppident_asteroids*
ppident_variablestars*

### Python ###
## Byte-compiled / optimized / DLL files
Expand Down
5 changes: 5 additions & 0 deletions pp_calibrate.py
Original file line number Diff line number Diff line change
Expand Up @@ -377,6 +377,11 @@ def calibrate(filenames, minstars, manfilter, manualcatalog,
exptime_keyword=obsparam['exptime'],
time_keyword='MIDTIMJD'), \
'(sources, columns) read from', filename)
else:
cat.read_ldac(ldac_filename, filename, maxflag=maxflag,
object_keyword=obsparam['object'],
exptime_keyword=obsparam['exptime'],
time_keyword='MIDTIMJD')

catalogs.append(cat)

Expand Down
67 changes: 51 additions & 16 deletions pp_distill.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,14 +66,36 @@ def manual_positions(posfile, catalogs, display=True):
option)"""

if display:
print('# target positions as a function of time manually provided... ', end=' ')
print('# target positions as a function of time manually provided... ',
end=' ')
sys.stdout.flush()
logging.info('target positions as a function of time manually provided')

positions = numpy.genfromtxt(posfile, dtype=[('filename', 'S50'),
('ra', float),
('dec', float),
('MJD', float)])
# handle wildcard symbol
if posfile == 'all_objects':

objects = []
for filename in os.listdir('.'):
if 'positions_' in filename and '.dat' in filename:
objects.append(manual_positions(filename, catalogs,
display=False))

if display:
print(old_div(len(objects),len(catalogs)), 'object(s) found')

return (list(numpy.hstack(objects)))

try:
positions = numpy.genfromtxt(posfile, dtype=[('filename', 'S50'),
('ra', float),
('dec', float),
('MJD', float),
('name', 'S30')])
except:
positions = numpy.genfromtxt(posfile, dtype=[('filename', 'S50'),
('ra', float),
('dec', float),
('MJD', float)])

try:
assert len(positions) == len(catalogs)
Expand All @@ -86,12 +108,19 @@ def manual_positions(posfile, catalogs, display=True):

objects = []
for cat_idx, cat in enumerate(catalogs):
objects.append({'ident' : 'manual_target',
'obsdate.jd' : cat.obstime,
'cat_idx' : cat_idx,
'ra.deg' : positions[cat_idx]['ra'],
'dec.deg' : positions[cat_idx]['dec']})

try:
objects.append({'ident' : positions[cat_idx]['name'].decode('utf-8'),
'obsdate.jd' : cat.obstime,
'cat_idx' : cat_idx,
'ra.deg' : positions[cat_idx]['ra'],
'dec.deg' : positions[cat_idx]['dec']})
except:
objects.append({'ident' : 'manual_target',
'obsdate.jd' : cat.obstime,
'cat_idx' : cat_idx,
'ra.deg' : positions[cat_idx]['ra'],
'dec.deg' : positions[cat_idx]['dec']})

if display:
print(old_div(len(objects),len(catalogs)), 'object(s) found')

Expand Down Expand Up @@ -368,7 +397,7 @@ def distill(catalogs, man_targetname, offset, fixed_targets_file, posfile,
### check for positions file
if posfile is not None:
objects += manual_positions(posfile, catalogs, display=display)

### select a sufficiently bright star as control star
objects += pick_controlstar(catalogs, display=display)

Expand Down Expand Up @@ -399,9 +428,9 @@ def distill(catalogs, man_targetname, offset, fixed_targets_file, posfile,
# 'potential target(s) per frame identified:', \
# ", ".join(set([obj['ident'] for obj in objects]))

logging.info('%d potential targets per frame identified: %s' %
(int(old_div(len(objects),len(catalogs))),
", ".join(set([obj['ident'] for obj in objects]))))
# logging.info('%d potential targets per frame identified: %s' %
# (int(old_div(len(objects),len(catalogs))),
# ", ".join(set([obj['ident'] for obj in objects]))))


##### extract source data for identified targets
Expand All @@ -423,12 +452,18 @@ def distill(catalogs, man_targetname, offset, fixed_targets_file, posfile,
continue
if (obj['ra.deg'] > max_ra or obj['ra.deg'] < min_ra or
obj['dec.deg'] > max_dec or obj['dec.deg'] < min_dec):
if display:
print('\"%s\" not in image %s' % (obj['ident'],
cat.catalogname))
logging.info('\"%s\" not in image %s' % (obj['ident'],
cat.catalogname))

continue
objects_thiscat.append(obj)

if len(objects_thiscat) == 0:
continue

# create a new catalog
target_cat = catalog('targetlist:_'+cat.catalogname)

Expand Down

0 comments on commit 16b2e36

Please sign in to comment.