示例#1
0
## 1.2 - properties
aux_basesize = bt.shape[0]
aux0 = drop_fields(bt.data.copy(), ['YA_V', 'aFe', 'l_ssp', 'f_ssp'])
for i_av in range(len(av_sampling)):
    aux1 = np.array(np.ones(len(bt['sspfile'])) * av_sampling[i_av], dtype=np.dtype([('AV', np.float)]))
    aux2 = merge_arrays([aux0, aux1], flatten=True)
    if i_av == av_sampling[0]:
        aux_prop = db.create_dataset(name = '/tables/properties', shape=(aux_basesize * len(av_sampling),), dtype = aux2.dtype)
    aux_prop[i_av * aux_basesize: (i_av+1) * aux_basesize] = aux2
    
# 2 - Photometry
for filterid in db_f.keys():
    for ccd in db_f.get(filterid).keys():
        
        # 2.1 - Read filtercurves
        f = readfilterset() # Init filterset object
        f.read(filter_file, path='/%s/%s' % (filterid, ccd))
        f.calc_filteravgwls()
        
        # db shape
        Nz = len(np.arange(z_from, z_to, z_step))
        Ngal = aux_basesize * len(av_sampling)
        Nl = len(f.filteravgwls)
        
        # 2.2 - Create library
        db.create_dataset(name = '/%s/%s/library' % (filterid, ccd), shape = (Nz,Ngal,Nl), dtype = np.dtype([('m_ab', np.float), ('e_ab', np.float)]) )
        db.create_dataset(name = '/%s/%s/filtercurves' % (filterid, ccd),  data = np.array(f.filterset, dtype=([('ID_filter', '|S32'), ('wl', '<f4'), ('transm', '<f4')])))
        aux = np.zeros(shape = len(f.filteravgwls), dtype = ([('ID_filter', '|S32'), ('wl_central', np.float)]))
        aux['ID_filter'] = np.unique(f.filterset['ID_filter'])
        aux['wl_central'] = f.filteravgwls
        db.create_dataset(name = '/%s/%s/filterset' % (filterid, ccd),  data = aux)
示例#2
0
import atpy

import numpy as np

from bgpe.io.readfilterset import readfilterset
from bgpe.io.hdf5util import inithdf5

if __name__ == "__main__" and len(sys.argv) > 2:

    dbfile = sys.argv[1]
    # Init file
    db = inithdf5(dbfile)

    for filter_file in sys.argv[2:]:
        aux_id = os.path.basename(filter_file).split(".")
        f = readfilterset()
        f.read(filter_file)
        for fid in np.unique(f.filterset["ID_filter"]):
            dataset = "/%s/%s/%s" % (aux_id[0], aux_id[1], fid)
            print dataset
            aux = atpy.Table(name=fid)
            aux.add_column(name="wl", data=f.filterset["wl"][f.filterset["ID_filter"] == fid])
            aux.add_column(name="transm", data=f.filterset["transm"][f.filterset["ID_filter"] == fid])
            db.create_dataset(dataset, data=aux.data)

    db.close()

else:
    print "Usage: %s filterdbfile.hdf5 FilterSet.CCD1.filter FilterSet.CCD2.filter ... FilterSet.CCD#.filter" % sys.argv[
        0
    ]