Code Monkey home page Code Monkey logo

astroinject's Introduction

AstroInject

Description

AstroInject is a Python package designed to manage the injection of astronomical data into a PostgreSQL database with proper pgsphere coordinates indexes. It provides utilities to search for files based on specific patterns, process those files into Pandas DataFrames, and then inject them into a database for further use or analysis.

Features

  • File Search: Search for files in a directory based on specific patterns.
  • Data Processing: Convert FITS tables and CSV files to Pandas DataFrames.
  • Data Injection: Insert processed DataFrames into a PostgreSQL database.
  • Indexing and Key Management: Automatically apply primary keys and indexes (including pgsphere) to database tables.
  • Configuration: Easy configuration via YAML files and command-line options.

Installation

You can install AstroInject using pip:

pip install astroinject

Usage

Command-line Interface

# Inject data into a database using a configuration file
python -m astroinject --config=config.yaml

# Print an example configuration file
python -m astroinject --getconfig

Configuration File Example

database:
  host: localhost
  database: postgres
  user: postgres
  password: postgres
  schema: astroinject
  tablename: astroinject

operations: [
  {"name": "find_pattern", "pattern": "*.fits"},
  {"name": "insert_files"},
  {"name": "map_table"}
]

API

from astroinject.inject import conn, funcs

# Establish a database connection
connection = conn.Connection({
    'host': 'localhost',
    'database': 'postgres',
    'user': 'postgres',
    'password': 'postgres'
})
connection.connect()

# Find files based on a pattern
files = funcs.find_files_with_pattern("/path/to/files", "*.fits")

# Process and inject files
funcs.inject_files_procedure(files, connection, {"_format": "fits"}, config_object)

Making insertions from the command line

astroinject -u {user} -p {password} -C {config_file}

There are some examples of config files in the config.examples/ directory.

Backup and restore

It's possible to create backups with astroinject.

astroinject -u {user} -p {password} --backup {database} {schema} {outfile}

Then to restore:

astroinject -u {user} -p {password} --restore {database} {infile}

astroinject's People

Contributors

schwarzam avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.