Commit 9dfc819c authored by LUSTIG Peter's avatar LUSTIG Peter

begin of combining...

parent c6e1de3c
from astropy.table import Table from astropy.table import Table, vstack
from astropy.io.fits import PrimaryHDU, BinTableHDU, HDUList, open from astropy.io.fits import PrimaryHDU, BinTableHDU, HDUList, open
from pathlib import Path from pathlib import Path
import astropy.units as u import astropy.units as u
import numpy as np
import os import os
import sys import sys
print(os.getcwd()) print(os.getcwd())
...@@ -13,6 +14,25 @@ print(fnames) ...@@ -13,6 +14,25 @@ print(fnames)
hdul = [PrimaryHDU()] hdul = [PrimaryHDU()]
n = 0 n = 0
def CombineMeasurements(sourceslist, fakesourceslist):
fake_sources = Table()
sources = Table()
for _fake, _detected in zip(sourceslist, fakesourceslist):
n_fake = len(fake_sources)
n_detected = len(sources)
if _detected is not None:
_detected['ID'] = _detected['ID'] + n_detected
_detected['fake_sources'] = _detected['fake_sources'] + n_fake
sources = vstack([sources, _detected])
_fake['ID'] = _fake['ID'] + n_fake
_fake['find_peak'] = _fake['find_peak'] + n_detected
fake_sources = vstack([fake_sources, _fake])
return sources, fake_sources
for i, ifile in enumerate(fnames): for i, ifile in enumerate(fnames):
_file = open(ifile) _file = open(ifile)
_flux = u.Quantity(_file[0].header['influx']) _flux = u.Quantity(_file[0].header['influx'])
...@@ -28,6 +48,13 @@ for i, ifile in enumerate(fnames): ...@@ -28,6 +48,13 @@ for i, ifile in enumerate(fnames):
hdul.append(BinTableHDU(data=_ft, name='FAKE_SOURCES{}'.format(i))) hdul.append(BinTableHDU(data=_ft, name='FAKE_SOURCES{}'.format(i)))
n += 1 n += 1
hdul[0].header['flux{}'.format(i)] = '{}'.format(_flux) hdul[0].header['flux{}'.format(i)] = '{}'.format(_flux)
'''
idxsort = np.argsort(flux.to_value(u.mJy))
self.flux = flux[idxsort]
self.sources = [sources[i] for i in idxsort]
self.fake_sources = [fake_sources[i] for i in idxsort]
'''
hdul[0].header['nfluxes'] = n hdul[0].header['nfluxes'] = n
hdul = HDUList(hdul) hdul = HDUList(hdul)
hdul.writeto(outname, overwrite=True) hdul.writeto(outname, overwrite=True)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment