def initialize_optics(filename, tel_id,file_closed = True):
    if file_closed:
        ld.clear_lists_optics()
        ld.clear_lists_telescope()
    else:
        pass

    if 'simtel.gz' in filename:
        OD.initialize_hessio(filename,tel_id,file_closed)
    elif 'fits' in filename:
        OD.initialize_fits(filename,tel_id,file_closed)
def initialize_optics(filename, tel_id, file_closed=True):
    if file_closed:
        ld.clear_lists_optics()
        ld.clear_lists_telescope()
    else:
        pass

    if 'simtel.gz' in filename:
        OD.initialize_hessio(filename, tel_id, file_closed)
    elif 'fits' in filename:
        OD.initialize_fits(filename, tel_id, file_closed)
def initialize_telescope(filename, file_closed = True):
    ld.clear_lists_telescope()
    ld.clear_lists_camera()
    ld.clear_lists_optics()

    if 'simtel.gz' in filename:
        file_closed = TD.initialize_hessio(filename,file_closed)
        for tel in ld.telescope_id:
            CD.initialize_hessio(filename,tel,file_closed)
            OD.initialize_hessio(filename,tel,file_closed)
        util_functions.close_hessio()

    elif 'fits' in filename:
        file_closed = TD.initialize_fits(filename,file_closed)
        for tel in ld.telescope_id:
            CD.initialize_fits(filename,tel,file_closed)
            OD.initialize_fits(filename,tel,file_closed)
        util_functions.close_fits(file_closed)
def initialize_telescope(filename, file_closed=True):
    ld.clear_lists_telescope()
    ld.clear_lists_camera()
    ld.clear_lists_optics()

    if 'simtel.gz' in filename:
        file_closed = TD.initialize_hessio(filename, file_closed)
        for tel in ld.telescope_id:
            CD.initialize_hessio(filename, tel, file_closed)
            OD.initialize_hessio(filename, tel, file_closed)
        util_functions.close_hessio()

    elif 'fits' in filename:
        file_closed = TD.initialize_fits(filename, file_closed)
        for tel in ld.telescope_id:
            CD.initialize_fits(filename, tel, file_closed)
            OD.initialize_fits(filename, tel, file_closed)
        util_functions.close_fits(file_closed)
 def initialize(cls,filename,tel_id,item):
     """
     Load all the information about the optics of a given telescope with
     ID `tel_id` from an open file with name `filename`.
     
     Parameters
     ----------
     filename: string
         name of the file
     tel_id: int
         ID of the telescope whose optics information should be loaded
     item: of various type depending on the file extension
         return value of the opening/loading process of the file
     """
     (mir_class,mir_area,mir_number,prim_mirpar,prim_refrad,prim_diameter,
      prim_hole_diam,sec_mirpar,sec_refrad,sec_diameter,sec_hole_diam,
      mir_reflection,opt_foclen,foc_surfparam,foc_surf_refrad,
      tel_trans) = OD.initialize(filename,tel_id,item)
     opt = cls(mir_class,mir_area,mir_number,prim_mirpar,prim_refrad,
            prim_diameter,prim_hole_diam,sec_mirpar,sec_refrad,sec_diameter,
            sec_hole_diam,mir_reflection,opt_foclen,foc_surfparam,
            foc_surf_refrad,tel_trans)
     return opt