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.14.tar.gz (15.6 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.14-py3-none-any.whl (16.2 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: stellarpolanalyzer-0.1.14.tar.gz
  • Upload date:
  • Size: 15.6 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.14.tar.gz
Algorithm Hash digest
SHA256 1e3ccaea7b3ddd34584022a75a07d1654af32f00d4fdb4182b71c0269f2ea583
MD5 3b3e89dd30a5e3b8b9d9fc52d778a68c
BLAKE2b-256 5dcc5b6a90d5c00074d4296cfae5bf252c4546504a50b0324e60dc72a88cfa50

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for stellarpolanalyzer-0.1.14-py3-none-any.whl
Algorithm Hash digest
SHA256 3bcd6b59b45c4b16d30a707821a7f59219009c2cbd7a0f0db423bb159d92d32f
MD5 ad9f72e7670e3f3795ae3b515e11b4a7
BLAKE2b-256 652e30c06f65fb74d812787c1229dad6e67259efd1d03badf61ca0a435bf0320

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