Skip to content

A Python package for processing .fits file metadata, homogenize it and standardize it. This package also provides support for MOC use, and Astropy regions treatment.

License

Notifications You must be signed in to change notification settings

Redemption007/MetaFITS

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

MetaFITS

A Python package for processing .fits file metadata, homogenize it and standardize it. This package also provides support for MOC use, and Astropy regions treatment.


Table of Contents


Installation

Prerequisites

  • Python 3.7 or higher: Ensure you have a compatible Python version installed.
  • pip: Python package installer.

Installing from Source

  1. Clone the Repository

    git clone https://github.com/Redemption007/MetaFITS.git
    cd MetaFits
  2. Install Dependencies

    Install the required packages listed in requirements.txt:

    pip install -r requirements.txt
  3. Install the Package

    Install the package locally using setup.py:

    pip install .

    For development purposes, you may want to install it in editable mode:

    pip install -e .

Usage

Examples of usages are shown in the FITFile test file and in the MetaTable test file.

Processing FITS Files

Create a FITSFile instance:

from MetaFITS import FITSFile
file = FITSFile(path='./tests/fitscollection/5GHz_n_f.fits')

Modify the FITSFile header property with

file.updateHeader({'keyword1': 'value1',
                   'keyword2': 'value2'})

Synchronize the file header with the instance property with

file.updateFitsMetaData()

Homogenizing FITS Files

Homogenize dates of FITSFile header property with

file.homogenizeDates()

Homogenize coordinates of FITSFile header property with

file.homogenizeCoordinates()

Homogenize coordinates system of FITSFile header property with

file.homogenizeCoordSystem()

Standardize deprecated keywords of FITSFile header property with

file.standardize()

Do these four operations in one go with

file.homogenize()

Loading Metadata

Creating a MetaTable instance:

# properties you want to store into the Table
# they must be foundable in a fits Header
prop = {'NAXIS1': int,
        'CRVAL1': float,
        'CUNIT1': str}

metatable = MetaTable(path='./tests/fitscollection/', properties=prop)

You may want to homogenize all FITSFiles in this directory before building the table. You can do it with

metatable.homogenize()

Building the table from the files (or rebuilding it from scratch):

metatable.build()

Plotting MOCs

Two functions exist to plot metadatas inside a MetaTable object.

Plotting independant MOCs

You can plot a different MOC for every file listed in the MetaTable object (it will show several figures) and save them.

metatable.plotSingle(depth=4, savePath='./tests/figures/singles/')

Or you can plot a MOC for one given file listed in the MetaTable object (it will show 1 figure) and save them.

metatable.plotSingle(index=0, depth=4)

Plotting the MetaTable MOC

You can also plot one single MOC for the entire MetaTable object (it will show 1 figure) and save the figure.

metatable.plotTable(depth=9, savePath='./tests/figures/table/')

Searching in FITS Files

You can search for the presence of objects or regions in FITSFile and MetaTable objects.

Search an Object

For an object, it gives:

from astropy.coordinates import SkyCoord
# Create the object we will search for
obj = SkyCoord(84.71504322970168, -69.13528638778595, unit='deg', frame='icrs')

# Return bool
file.contains(obj)
metatable.containsObject(obj)

Search a SkyRegion

For a SkyRegion, it gives:

from region import PolygonSkyRegion
# Create the object we will search for
region = PolygonSkyRegion(
   vertices=SkyCoord([[151.11090180555556, 2.0246038888884446],
                      [149.11090180555556, 2.5246038888884446],
                      [151.11090180555556, 3.]],
   unit=u.deg,
   frame='icrs'))

# Returns bool
FITSFile.regionContainsObject(region, obj)
# Returns SkyRegion
metatable.createRegionIntersection(region)
# Returns SkyRegion
metatable.createRegionUnion(region)

Contributing

Contributions are welcome! If you have suggestions, bug reports, or patches, please open an issue or submit a pull request on the GitHub repository.

Steps to Contribute

  1. Fork the Repository

    Click the "Fork" button on the top right of the repository page.

  2. Clone Your Fork

    git clone https://github.com/Redemption007/MetaFITS.git
    cd MetaFITS
  3. Create a New Branch

    git checkout -b feature/your-feature-name
  4. Make Changes

    Implement your changes or additions.

  5. Commit and Push

    git add .
    git commit -m "Description of your changes"
    git push origin feature/your-feature-name
  6. Submit a Pull Request

    Go to your forked repository on GitHub and click "New pull request".


Licence

This project is licensed under the GNU License - see the LICENSE file for details.

MetaFITS is a programm allowing one to extract FITS metadata and standardize it. It also allows to use MOCs on files or directory, and to play with Astropy Regions.

Copyright (C) 2024 Baptiste MORIN

This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program. If not, see https://www.gnu.org/licenses/.

MetaFITS Copyright (C) 2024 Baptiste MORIN

This program comes with ABSOLUTELY NO WARRANTY; for details type show w. This is free software, and you are welcome to redistribute it under certain conditions; type show c for details.


Acknowledgments

  • Astropy: For providing core astronomical utilities.
  • Astroquery: For facilitating queries to astronomical databases.
  • MOCpy: For handling Multi-Order Coverage maps.
  • Matplotlib: For plotting and visualization.

Disclaimer: This package is provided as-is without any guarantees. Use it at your own risk.

About

A Python package for processing .fits file metadata, homogenize it and standardize it. This package also provides support for MOC use, and Astropy regions treatment.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published