Processing HDF to FITS Image: Python Pipeline Mode

Processing HDF to FITS Image: Python Pipeline Mode

IJCSN International Journal of Computer Science and Network, Volume 3, Issue 4, August 2014 ISSN (Online) : 2277-5420 www.IJCSN.org Impact Factor: 0.274 234 Processing HDF to FITS Image: Python Pipeline Mode 1 Alexander Akoto-Danso, 2 Felix Tetteh Madjitey, 3 Emmanuel Proven-Adziri , 4 Theophilus Ansah-Narh, 5 Marcellin Atemkeng 1, 2, 3 Ghana Space Science and Technology Institute (GSSTI), Ghana Atomic Energy Commission (GAEC). 4, 5 RATT, Rhodes University, South Africa. Abstract - Research scientists and students especially those in data is stored in different formats such as HDF and other astronomy normally use image data in Flexible Image Transport formats and we need to convert the data into FITS form System (FITS) format for their simulations. Simulation tools before using for simulations. like Meqtrees, Oskar, Map simulator and Swarp all run using FITS file. Sometimes, the image data is stored in different FITS is also used to store both image and non-image data, formats such as Hierarchical Data Format (HDF) and other formats. We need to convert the data into FITS form before such as spectra, photon lists, data cubes and multi-table using for simulations. The paper therefore presents a python databases. It is one of the commonest file format used in program on how to extract data from HDF into FITS file. The astronomy. Detailed explanations on how to use FITS file h5py helps us to extract the image data from HDF, numpy then are [7, 8 and 9]. converts the data into an array and pyfits helps us to write the extracted data in FITS format. The h5py, numpy and pyfits are 2. Program Structure imported into python for the conversion to take place. The developed code and output are presented in Appendices A and B respectively. Figure 1 is a flow chart describing clearly how HDF is converted into FITS file. The h5py, numpy and pyfits are Keywords - Hierarchical Data Format (HDF ), Flexible python modules or packages that must be installed to be Image Transport System (FITS) , Python, h5py, numpy, pyfits. able to import them into the python platform for conversion. 1. Introduction Appendix A shows the python script developed to convert Hierarchical Data Format (HDF) was formally developed HDF to FITS file. at the National Center for Supercomputing Applications with its former version being HDF4 and now changed to 3. Results and Discussions HDF5. It is designed to store any large amount of scientific data in an organized form. The current version, Appendices B – 1 to B – 4 show the outputs of the FITS HDF5 simplifies the file structure into two major types of file created. Appendix B – 1 shows the running process objects: during the conversion by going through the flowchart in • Datasets :- these are multidimensional arrays of a Fig. 1. Appendix B – 2 shows the output of the headers homogenous type. when no update is made and appendix B – 3 is the • Groups :- these are structures in a form of updated output of the headers using World Coordinate containers that hold the datasets and other System (WCS) [10] which can always be updated to suit groups. the required image data. Detailed explanations on how to use HDF format are [1 and 2]. Appendix B – 4 is the image data in array form extracted into FITS file. The FITS file created consists of more Most simulation tools such as MeqTrees [3], OSKAR [4], header and data units, normally referred to as HDUs. The MIT Array Performance Simulator (MAPS) [5] and HDU consists of the header which describes the data SWarp [6] all run using FITS file. Sometimes, the image contained in it, followed by the data itself. IJCSN International Journal of Computer Science and Network, Volume 3, Issue 4, August 2014 ISSN (Online) : 2277-5420 www.IJCSN.org Impact Factor: 0.274 235 HDF image First Stage Numpy array convertor Second Stage FITS image Convert to numpy Write array into Start python array .hdf> FITS HDF image Update FITS header <xx.hdf> Extract DATA No Is header fixed Yes Stop python Fig. 1: Procedure for Converting HDF to FITS 4. Conclusion and Future Work The National Center for Supercomputing Applications (NCSA) HDF group and others are currently working In this paper, we provided how to convert HDF to FITS together to convert all HDF objects to FITS and vice versa, using python module pyfits. Clearly, the paper showed the making it possible to access FITS files with HDF software basic operations with FITS file such as reading, modifying and vice versa [11] but until then this paper should easily and writing an image data. help in converting HDF to FITS. The FITS file created in this paper is the Primary HDU Appendix A and therefore, a continuation of this study is to develop a #!/usr/bin/env python Multi – Extension FITS (MEF) file in BINTABLE format. """ This would be very important particularly in the hdf2fits.py application of Hierarchical , Equal Area and Iso-Latitude ========= Pixelisation (HEALPIX) for spherical designs such as sky Converts HDF to FITS format maps. """ __version__ = "1.0" import h5py IJCSN International Journal of Computer Science and Network, Volume 3, Issue 4, August 2014 ISSN (Online) : 2277-5420 www.IJCSN.org Impact Factor: 0.274 236 import pyfits in_header['BSCALE'] import numpy as np except KeyError: from pyfits import getdata, getheader print "\t No BSCALE Found, adding entry for this" print " ------------------------------------------------------" in_header.update('BSCALE',1.0,'PhysValue = BZERO print "\n >> Please enter HDF5 file name to convert + BSCALE * ArrayValue') (including extension):" print " ------------------------------------------------------" try: filename=raw_input() #Input .hdf5 file in_header['CRVAL1'] print " >> Opening file and reading data" except KeyError: print " ------------------------------------------------------" print "\t No CRVAL1 Found, adding entry for this" hdf_data =h5py.File(filename,'r') in_header.update('CRVAL1',11.88798983,'WCS Ref print " >> Extracting data from HDF file" value (RA in decimal degrees)') print " ------------------------------------------------------" try: extract_data = hdf_data.values()[:] in_header['CRVAL2'] print " >> Converting HDF data into arrays" except KeyError: print " ------------------------------------------------------" print "\t No 'EPOCH' Found, adding entry for this" a_ray = np.array(extract_data) in_header.update('EPOCH',1999.55329832624,'Epoch ############################################### in Julain Year at start of observation') ################ try: print " >> Converting HDF data into FITS" in_header['CRPIX1'] print " ------------------------------------------------------" except KeyError: hdu = pyfits.PrimaryHDU(a_ray) print "\t No 'CRPIX1' Found, adding entry for this" hdu.writeto('newhd2fits.fits') in_header.update('CRPIX1',256.5,'WCS Coordinate ############################################### reference pixel') ############### try: print " ------------------------------------------------------" in_header['CRPIX2'] print "\n >> Please checking & fixing headers:" except KeyError: print " ------------------------------------------------------" print "\t No 'CRPIX2' Found, adding entry for this" filename1='newhd2fits.fits' #Input .fits file in_header.update('CRPIX2',356.5,'WCS Coordinate reference pixel') print " >> Opening FITS file and reading header" try: print " ------------------------------------------------------" in_header['CD1_1'] except KeyError: hdulist = pyfits.open(filename1) print "\t No 'CD1_1' Found, adding entry for this" in_header=hdulist[0].header in_header.update('CD1_1',- in_header.update('BITPIX', -64) 0.000277777783923599,'WCS Coordinate scale matrix') print " >> BITPIX Fixed\n >> Now checking for all try: required fits header keywords" in_header['CD1_2'] print " ------------------------------------------------------" except KeyError: print "\t No 'CD1_2' Found, adding entry for this" try: in_header.update('CD1_2',1.78947724260645E-08, in_header['COMMENT'] 'WCS Coordinate scale matrix') except KeyError: try: print "\t No COMMENT Found, adding entry for this" in_header['CD2_1'] in_header.update('COMMENT', 'Standard WCS except KeyError: reduction:') print "\t No CD2_1 Found, adding fake entry for this" try: in_header.update('CD2_1',1.78947724260645E- in_header['BZERO'] 08,'WCS Coordinate scale matrix') except KeyError: try: print "\t No BZERO Found, adding entry for this" in_header['CD2_2'] in_header.update('BZERO',0.0,'PhysValue = BZERO + except KeyError: BSCALE * ArrayValue') print "\t No CD2_2 Found, adding fake entry for this" try: IJCSN International Journal of Computer Science and Network, Volume 3, Issue 4, August 2014 ISSN (Online) : 2277-5420 www.IJCSN.org Impact Factor: 0.274 237 print "\t No CNPIX1 Found, adding fake entry for this" in_header.update('CD2_2',0.000277777783923599,'WCS in_header.update('CNPIX1','0','New CNPIX1') Coordinate scale matrix') try: try: in_header['MJD-OBS'] in_header['CD3_1'] except KeyError: except KeyError: print "\t No MJD-OBS Found, adding fake entry for print "\t No 'CD3_1' Found, adding entry for this" this" in_header.update('CD3_1',1.78947724260645E-08, in_header.update('MJD- 'WCS Coordinate scale matrix') OBS',51381.3422136574,'modified Julian date at start of try: observation') in_header['CD3_2'] try: except KeyError: in_header['CRPIX3'] print "\t No 'CD3_2' Found, adding entry for this" except KeyError: in_header.update('CD3_2',1.78947724260645E-08, print "\t No CRPIX3 Found, adding fake entry for this" 'WCS Coordinate scale matrix') in_header.update('CRPIX3',1.0) try: ############################### in_header['CTYPE1']

View Full Text

Details

  • File Type
    pdf
  • Upload Time
    -
  • Content Languages
    English
  • Upload User
    Anonymous/Not logged-in
  • File Pages
    8 Page
  • File Size
    -

Download

Channel Download Status
Express Download Enable

Copyright

We respect the copyrights and intellectual property rights of all users. All uploaded documents are either original works of the uploader or authorized works of the rightful owners.

  • Not to be reproduced or distributed without explicit permission.
  • Not used for commercial purposes outside of approved use cases.
  • Not used to infringe on the rights of the original creators.
  • If you believe any content infringes your copyright, please contact us immediately.

Support

For help with questions, suggestions, or problems, please contact us