Пример #1
0
def initialize_hessio(filename, file_closed):
    if file_closed:
        file_closed = util_functions.load_hessio(filename)
        print(file_closed)
        util_functions.nextevent_hessio()
    else:
        pass

    #ld.telescope_id = h.get_telescope_ids().tolist() #--> this function only can be used if the according python wrapper hase been added to pyhessio.c and hessio.py

    ld.telescope_id = h.get_teldata_list().tolist()
    ld.telescope_num = h.get_num_telescope()

    return file_closed
def initialize_hessio(filename,file_closed):
    if file_closed:
        file_closed = util_functions.load_hessio(filename)
        print(file_closed)
        util_functions.nextevent_hessio()
    else:
        pass
    
    #ld.telescope_id = h.get_telescope_ids().tolist() #--> this function only can be used if the according python wrapper hase been added to pyhessio.c and hessio.py
    
    ld.telescope_id = h.get_teldata_list().tolist()
    ld.telescope_num = h.get_num_telescope()

    return file_closed
def initialize_telescope(filename, file_closed = True):
    ld.clear_lists_telescope()
    ld.clear_lists_camera()

    if 'simtel.gz' in filename:
        if file_closed:
            file_closed = load_hessio(filename)
            nextevent_hessio()
        else:
            pass

        #ld.telescope_id = h.get_telescope_ids().tolist() #--> this function only can be used if the according python wrapper hase been added to pyhessio.c and hessio.py
        ld.telescope_id = h.get_teldata_list().tolist()
        ld.telescope_num = h.get_num_telescope()

    elif 'fits' in filename:
        if file_closed:
            hdulist = load_fits(filename)
            file_closed = hdulist
        else:
            pass
        teles = hdulist[1].data
        ld.telescope_id = teles["TelID"].tolist()
        ld.telescope_posX = teles["TelX"].tolist()
        ld.telescope_posY = teles["TelY"].tolist()
        ld.telescope_posZ = teles["TelZ"].tolist()
        ld.telescope_num = len(ld.telescope_id)

    for tel in ld.telescope_id:
        initialize_camera(tel,filename,file_closed)
        initialize_optics(tel,filename,file_closed)

    if 'simtel.gz' in filename:   
        close_hessio()
    elif 'fits' in filename:
        close_fits(hdulist)
def initialize_telescope(filename, file_closed=True):
    ld.clear_lists_telescope()
    ld.clear_lists_camera()

    if 'simtel.gz' in filename:
        if file_closed:
            file_closed = load_hessio(filename)
            nextevent_hessio()
        else:
            pass

        #ld.telescope_id = h.get_telescope_ids().tolist() #--> this function only can be used if the according python wrapper hase been added to pyhessio.c and hessio.py
        ld.telescope_id = h.get_teldata_list().tolist()
        ld.telescope_num = h.get_num_telescope()

    elif 'fits' in filename:
        if file_closed:
            hdulist = load_fits(filename)
            file_closed = hdulist
        else:
            pass
        teles = hdulist[1].data
        ld.telescope_id = teles["TelID"].tolist()
        ld.telescope_posX = teles["TelX"].tolist()
        ld.telescope_posY = teles["TelY"].tolist()
        ld.telescope_posZ = teles["TelZ"].tolist()
        ld.telescope_num = len(ld.telescope_id)

    for tel in ld.telescope_id:
        initialize_camera(tel, filename, file_closed)
        initialize_optics(tel, filename, file_closed)

    if 'simtel.gz' in filename:
        close_hessio()
    elif 'fits' in filename:
        close_fits(hdulist)
Пример #5
0
from astropy.table import Table
from astropy import units as u
from ctapipe import io

# TODO: use io.fits instead and make the table be variable length
# TODO: make this a tool (ctapipe-eventio2tels)

if __name__ == '__main__':

    filename = sys.argv.pop(1)

    h.file_open(filename)
    event = h.move_to_next_event()
    next(event)

    for telid in range(1, h.get_num_telescope()):
        try:
            px, py = h.get_pixel_position(telid)
            camtab = Table(names=['PIX_POS_X', 'PIX_POS_Y'],
                           data=[px * u.m, py * u.m])
            camtab.meta['N_PIX'] = h.get_num_pixels(telid)
            camtab.meta['N_SAMPS'] = h.get_num_samples(telid)
            camtab.meta['N_TIMES'] = h.get_pixel_timing_num_times_types(telid)
            camtab.meta['MIR_AREA'] = h.get_mirror_area(telid)
            geom = io.guess_camera_geometry(px * u.m, py * u.m)
            camtab.meta['TELCLASS'] = geom.cam_id
            camtab.meta['PIXTYPE'] = geom.pix_type

            filename = "cam_{:03d}.fits".format(telid)
            camtab.write(filename)
            print("WROTE ", filename)