Skip to main content

Librería para análisis de imágenes polarimétricas y detección de parejas de estrellas

Project description

🌟 StellarPolAnalyzer

Empareja, fotometriza y astrometriza imágenes polarimétricas de campo estelar en un solo flujo.


📚 Descripción

StellarPolAnalyzer es una librería Python que automatiza todo el pipeline polarimétrico en imágenes astronómicas:

  1. Detección de estrellas con DAOStarFinder.
  2. Emparejado de componentes ordinaria/extraordinaria (beam splitter).
  3. Fotometría de apertura en 4 ángulos de polarización.
  4. Cálculo de parámetros de polarización: Q, U, P, θ y errores.
  5. Alineación de imágenes (phase cross-correlation).
  6. Generación de imagen sintética y solución WCS con Astrometry.Net.
  7. Cruce SIMBAD para identificar objetos celestes.
  8. Visualización clara de pares, aperturas y resultados.
  9. Reporte rápido vía funciones modulares o pipeline completo.

Ideal para tus proyectos de TFM, exoplanetas, discos circumestelares o estudios de polarización galáctica.


🚀 Instalación

pip install StellarPolAnalyzer

Requiere Python ≥3.7 y dependencias: numpy, astropy, photutils, scikit-learn, scikit-image, scipy, astroquery, matplotlib.


📁 Estructura del paquete

StellarPolAnalyzer/
├─ alignment.py        # Alineación FITS y guardado
├─ detection.py        # Detección de fuentes y process_image
├─ pairing.py          # Cálculo de distancias/ángulos y emparejado
├─ photometry.py       # Aperture photometry y polarimetría
├─ astrometry.py       # Imagen sintética, Astrometry.Net y SIMBAD
├─ visualization.py    # Funciones de dibujo y resumen
├─ pipeline.py         # compute_full_polarimetry + run_complete_pipeline
├─ utils.py            # Utilidades (exportar pares)
└─ __init__.py         # API pública

🛠️ Uso detallado

1️⃣ Detección y emparejado básico

from StellarPolAnalyzer.detection import process_image
from StellarPolAnalyzer.visualization import draw_pairs

# 1. Procesar una imagen FITS (p.ej. 0°)
img_path = 'data/field_0.fits'
data, sources, cands, pairs, d_mode, a_mode = process_image(
    img_path,
    fwhm=3.0,
    threshold_multiplier=5.0,
    tol_distance=1.44,
    tol_angle=1.20,
    max_distance=75
)

# 2. Visualizar resultados
draw_pairs(
    image_data=data,
    sources=sources,
    pairs=pairs,
    num_stars=len(sources),
    mode_distance=d_mode,
    mode_angle=a_mode,
    tol_distance=1.44,
    tol_angle=1.20
)

🔎 Salida: gráfico con puntos rojos (estrella), líneas lime (parejas), círculos azules/rojos y resumen.


2️⃣ Pipeline completo de polarimetría + astrometría

from StellarPolAnalyzer.pipeline import run_complete_polarimetric_pipeline
import astropy.units as u

# Definir paths y ángulos
ref = 'data/field_0.fits'
others = ['data/field_22.fits', 'data/field_45.fits', 'data/field_67.fits']
angles = [0.0, 22.5, 45.0, 67.5]

# Ejecutar flujo completo
final_paths, polar_results, wcs, enriched = \
    run_complete_polarimetric_pipeline(
        ref_path=ref,
        other_paths=others,
        pol_angles=angles,
        fwhm=3.0,
        threshold_multiplier=5.0,
        tol_distance=1.44,
        tol_angle=1.20,
        max_distance=75,
        phot_aperture_radius=5,
        r_in=7,
        r_out=10,
        SNR_threshold=5,
        astrometry_api_key='TU_API_KEY',
        simbad_radius=0.01*u.deg,
        synthetic_name='synthetic_field.fits'
    )

# Mostrar resultados básicos
print('°° Imágenes procesadas:')
for p in final_paths:
    print(' -', p)

print('\n⭐ Polarimetría por par:')
for entry in enriched:
    print(f"Par {entry['pair_index']:02d} -> P={entry['P']:.2f}%  θ={entry['theta']:.1f}°  SIMBAD={entry['simbad_id']}")

🌐 Salida:

  • FITS alineados
  • Lista de dicts con {pair_index, q, u, P, θ, error, ra, dec, simbad_id}

3️⃣ Métodos individuales

Función Descripción
detect_stars(image_data, fwhm, thr) Detecta fuentes en image_data.
process_image(path, ...) Detección + emparejado en 1 imagen.
compute_distance_angle(p1, p2) Distancia y ángulo minimal entre 2 puntos.
find_candidate_pairs(sources, max_dist) Todas las parejas en rango max_dist.
filter_pairs_by_mode(pairs, tol_d, t_a) Filtra por distancia/ángulo modal.
compute_polarimetry_for_pairs(...) Fotometría + Q/U/P/θ en 4 ángulos.
align_images(ref, img) Alinear img a ref via phase_cross_correlation.
save_fits_with_same_headers(...) Guarda FITS conservando metadatos original.
annotate_with_astrometry_net(...) Imagen sintética + WCS + SIMBAD.
draw_pairs(...) Visualiza pares y resumen.
compute_full_polarimetry(...) Pipeline polarimetría (4 imágenes).
run_complete_polarimetric_pipeline(...) Pipeline completo + astrometría.

📄 Licencia

Librería MIT License – uso libre, modifica y contribuye. 👐


🤝 Contribuciones

¡Pull requests, issues y estrellas son bienvenidas! 🛠️


¡Lleva tu análisis polarimétrico un paso más allá!

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

stellarpolanalyzer-0.1.12.tar.gz (15.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

stellarpolanalyzer-0.1.12-py3-none-any.whl (16.1 kB view details)

Uploaded Python 3

File details

Details for the file stellarpolanalyzer-0.1.12.tar.gz.

File metadata

  • Download URL: stellarpolanalyzer-0.1.12.tar.gz
  • Upload date:
  • Size: 15.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.11.5

File hashes

Hashes for stellarpolanalyzer-0.1.12.tar.gz
Algorithm Hash digest
SHA256 50ef06fa4f58dcaaa19ccddd5d7fc942a3d0f53ca7ef0d0f6cd39ccef248490c
MD5 e5ab7415802b78101652b444a7c4b763
BLAKE2b-256 9d5521a16f4f4581a7a3efbe6adc4bbe3b49e191bb2db89293331bacc73a5596

See more details on using hashes here.

File details

Details for the file stellarpolanalyzer-0.1.12-py3-none-any.whl.

File metadata

File hashes

Hashes for stellarpolanalyzer-0.1.12-py3-none-any.whl
Algorithm Hash digest
SHA256 0d5fedee25778df79739d21630c81fcb29cb1e3e71e45a106844cf7f33b24ec5
MD5 49a57bbb749bb28f15e68bb3c674c67e
BLAKE2b-256 1ef35f7ea46972d5d93238c67c551ac3dc04501f0511dea397d8c688a66ae858

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page