def from_file(cls,filename='fake_data',tel_id=1,attribute='closed'): """ Load all the information about the camera of a given telescope with ID `tel_id` from an open file with name `filename`. Parameters ---------- filename: string name of the file, if no file name is given, faked data is produced 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 """ ext = uf.get_file_type(filename) if attribute == 'closed': load = getattr(uf,"load_%s" % ext) item = load(filename) else: item = attribute function = getattr(CD,"from_file_%s" % ext) (cam_class,cam_fov,pix_id,pix_posX,pix_posY,pix_posZ,pix_area,pix_type, pix_neighbors,fadc_pulsshape) = function(filename,tel_id,item) cam = cls(cam_class,cam_fov,pix_id,pix_posX,pix_posY,pix_posZ,pix_area, pix_type,pix_neighbors,fadc_pulsshape) if attribute == 'closed': close = getattr(uf,"close_%s" % ext) close(item) return cam
def read_file(cls,filename='fake_data',tel_id=1,attribute='closed'): """ 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, if no file name is given, faked data is produced tel_id: int ID of the telescope whose optics information should be loaded attribute: if file is closed, the attribute 'close' is given, else the astropy table with the whole data read from the file is given """ ext = uf.get_file_type(filename) if attribute == 'closed': load = getattr(uf,"load_%s" % ext) instr_table = load(filename) else: instr_table = attribute (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.get_data(instr_table,tel_id) 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,instr_table
def read_file(cls,filename='fake_data',attribute='closed'): """ Load all the information about the telescope and its components (= parameters of the inherited classes) from an open file with name `filename`. Parameters ---------- filename: string name of the file, if no file name is given, faked data is produced attribute: if file is closed, the attribute 'close' is given, else the astropy table with the whole data read from the file is given """ ext = uf.get_file_type(filename) if attribute == 'closed': load = getattr(uf,"load_%s" % ext) instr_table = load(filename) else: instr_table = attribute tel_id, tel_num,tel_posX,tel_posY,tel_posZ = TD.get_data(instr_table) tel = cls(tel_num,tel_id,tel_posX,tel_posY,tel_posZ) opt = [] cam = [] for i in range(len(tel_id)): opt.append(Optics.read_file(filename,tel_id[i],instr_table)[0]) cam.append(Camera.read_file(filename,tel_id[i],instr_table)[0]) return tel,opt,cam,instr_table
def read_file(cls,filename='fake_data',tel_id=1,attribute='closed'): """ Load all the information about the camera of a given telescope with ID `tel_id` from an open file with name `filename`. Parameters ---------- filename: string name of the file, if no file name is given, faked data is produced tel_id: int ID of the telescope whose optics information should be loaded attribute: if file is closed, the attribute 'close' is given, else the astropy table with the whole data read from the file is given """ ext = uf.get_file_type(filename) if attribute == 'closed': load = getattr(uf,"load_%s" % ext) instr_table = load(filename) else: instr_table = attribute (cam_class,cam_fov,pix_id,pix_posX,pix_posY,pix_area,pix_type, pix_neighbors,fadc_pulsshape) = CD.get_data(instr_table,tel_id) cam = cls(cam_class,cam_fov,pix_id,pix_posX,pix_posY,pix_area, pix_type,pix_neighbors,fadc_pulsshape) return cam,instr_table
def read_file(cls, filename='fake_data', tel_id=1, attribute='closed'): """ 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, if no file name is given, faked data is produced tel_id: int ID of the telescope whose optics information should be loaded attribute: if file is closed, the attribute 'close' is given, else the astropy table with the whole data read from the file is given """ ext = uf.get_file_type(filename) if attribute == 'closed': load = getattr(uf, "load_%s" % ext) instr_table = load(filename) else: instr_table = attribute (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.get_data(instr_table, tel_id) 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, instr_table
def read_file(cls, filename='fake_data', attribute='closed'): """ Load all the information about the telescope and its components (= parameters of the inherited classes) from an open file with name `filename`. Parameters ---------- filename: string name of the file, if no file name is given, faked data is produced attribute: if file is closed, the attribute 'close' is given, else the astropy table with the whole data read from the file is given """ ext = uf.get_file_type(filename) if attribute == 'closed': load = getattr(uf, "load_%s" % ext) instr_table = load(filename) else: instr_table = attribute tel_id, tel_num, tel_posX, tel_posY, tel_posZ = TD.get_data( instr_table) tel = cls(tel_num, tel_id, tel_posX, tel_posY, tel_posZ) opt = [] cam = [] for i in range(len(tel_id)): opt.append(Optics.read_file(filename, tel_id[i], instr_table)[0]) cam.append(Camera.read_file(filename, tel_id[i], instr_table)[0]) return tel, opt, cam, instr_table
def read_file(cls, filename='fake_data', tel_id=1, attribute='closed'): """ Load all the information about the camera of a given telescope with ID `tel_id` from an open file with name `filename`. Parameters ---------- filename: string name of the file, if no file name is given, faked data is produced tel_id: int ID of the telescope whose optics information should be loaded attribute: if file is closed, the attribute 'close' is given, else the astropy table with the whole data read from the file is given """ ext = uf.get_file_type(filename) if attribute == 'closed': load = getattr(uf, "load_%s" % ext) instr_table = load(filename) else: instr_table = attribute (cam_class, cam_fov, pix_id, pix_posX, pix_posY, pix_area, pix_type, pix_neighbors, fadc_pulsshape) = CD.get_data(instr_table, tel_id) cam = cls(cam_class, cam_fov, pix_id, pix_posX, pix_posY, pix_area, pix_type, pix_neighbors, fadc_pulsshape) return cam, instr_table
def initialize(filename,item): """ calls the specific initialize function depending on the file extension of the given file. The file must already be open/have been loaded. The return value of the opening/loading process must be given as an argument (item). Parameters ---------- filename: string name of the file item: of various type depending on the file extension return value of the opening/loading process of the file """ ext = get_file_type(filename) function = getattr(Initialize,"_initialize_%s" % ext) return function(filename,item)
def from_file(cls,filename='fake_data',attribute='closed'): """ Load all the information about the telescope and its components (= parameters of the inherited classes) from an open file with name `filename`. Parameters ---------- filename: string name of the file, if no file name is given, faked data is produced item: of various type depending on the file extension return value of the opening/loading process of the file """ print(filename) ext = uf.get_file_type(filename) if attribute == 'closed': load = getattr(uf,"load_%s" % ext) item = load(filename) else: item = attribute function = getattr(TD,"from_file_%s" % ext) tel_id, tel_num,tel_posX,tel_posY,tel_posZ = function(filename, item) tel = cls(tel_num,tel_id,tel_posX,tel_posY,tel_posZ) opt = [] cam = [] for i in range(len(tel_id)): opt.append(Optics.from_file(filename,tel_id[i],item)) cam.append(Camera.from_file(filename,tel_id[i],item)) if attribute == 'closed': close = getattr(uf,"close_%s" % ext) close(item) return tel,opt,cam
def from_file(cls,filename='fake_data',tel_id=1,attribute='closed'): """ 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, if no file name is given, faked data is produced 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 """ ext = uf.get_file_type(filename) if attribute == 'closed': load = getattr(uf,"load_%s" % ext) item = load(filename) else: item = attribute function = getattr(OD,"from_file_%s" % ext) (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) = function(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) if attribute == 'closed': close = getattr(uf,"close_%s" % ext) close(item) return opt