#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Mon Feb 16 12:43:46 2026

@author: fedora
"""

from astropy import units as un
from astropy.coordinates import SkyCoord

from astroquery.gaia import Gaia

Gaia.ROW_LIMIT = -1
Gaia.MAIN_GAIA_TABLE = "gaiadr3.gaia_source"

path_out = '/home/STEP/catalogs/'
name = 'F5'

ra_0 = 259.28690349834005
dec_0 = 67.953160897
d_ra = 5.5
d_dec = 3
mag_min = 5
max_max = 20

width =  d_ra * un.deg
height =  d_dec * un.deg

coord_0 = SkyCoord(ra_0 * un.deg, dec_0 * un.deg, frame='icrs')

r = Gaia.query_object_async(coordinate=coord_0, width=width, height=height,
                       columns = ['source_id',
                                  'ra',
                                  'dec',
                                  'phot_g_mean_mag',
                                  ])

GAIA = r.to_pandas()
GAIA = GAIA[['ra','dec','phot_g_mean_mag','source_id']]
GAIA.to_csv(path_out + name + '.list',
            encoding='ascii', index_label='g_inx', sep=' ', header=None)