def make_table(self, VoTable, name_t, hdu_list=[], fits_ref='', links=[]): ta = vo.Table(VoTable, name=name_t) if links: for link in links: ta.links.append(self.make_link(link[0], link[1], link[2])) if hdu_list: ta.fields.append( vo.Field(votable, name='key', datatype='char', arraysize=str(self._key_len))) ta.fields.append( vo.Field(votable, name='value_float', datatype='double')) ta.fields.append( vo.Field(votable, name='value_str', datatype='char', arraysize=str(self._val_len))) #str(vlen)+'*') ta.fields.append( vo.Field(votable, name='comments', datatype='char', arraysize=str(self._com_len))) #str(clen)+'*') ta.para_array = hdu_list ta.format = self._format ta.set_href(fits_ref) return ta
def _votable_maker(self): if self._hdu_list: self.clean() self.hdu_unpack() # print("1->{}".format(self.href)) if not self.href: self._href = self.href_setter() # print("2->{}".format(self.href)) votable = vo.VOTableFile(version='1.2') resource = vo.Resource() resource.description = self.fits_pre votable.resources.append(resource) table = vo.Table(votable) field0 = vo.Field(votable, name='key', datatype='char', arraysize=str(self._key_len)) field1 = vo.Field(votable, name='value_float', datatype='double') field2 = vo.Field(votable, name='value_str', datatype='char', arraysize=str(self._val_len)) #str(vlen)+'*') field3 = vo.Field(votable, name='comments', datatype='char', arraysize=str(self._com_len)) #str(clen)+'*') table.fields.append(field0) table.fields.append(field1) table.fields.append(field2) table.fields.append(field3) table.para_array = self._hdu_list table.format = self._format # print(self.href) table.set_href(self.href) resource.tables.append(table) votable.to_xml(self.xml_pre + self.fits_pre + self.xml_end + '.xml')
fitsList = glob.glob('./TWHYA_BAND7/*.fits') fits0 = fitsList[0] fits_nm = fits0.rsplit('/', 1)[-1] fits_pre = fits_nm.rsplit('.', 1)[-2] print(fits_pre) hdu = fits.open(fits0)[0] votable = vo.VOTableFile(version='1.2') resource = vo.Resource() votable.resources.append(resource) table = vo.Table(votable) resource.tables.append(table) table.description = fits_pre # h0 = hdu[0] hdu_dict = dict(hdu.header) for k in set(hdu_dict.keys()): if not k: continue if k == 'HISTORY': continue else: v = hdu_dict[k] v_type = type(hdu_dict[k]).__name__ # print(type(v_type))