Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Specify the query for the 'DESI-EDR' dataset? #253

Open
Cyanglll opened this issue Sep 27, 2024 · 1 comment
Open

Specify the query for the 'DESI-EDR' dataset? #253

Cyanglll opened this issue Sep 27, 2024 · 1 comment

Comments

@Cyanglll
Copy link

`from sparcl.client import SparclClient
import pandas as pd
import matplotlib.pyplot as plt
import os

client = SparclClient()
print(client.all_datasets)
help(client.find)

stars = pd.read_csv("Z:\Blue straggler\ra_dec_match.csv", header=None, names=["ra", "dec"])

fits_folder = "Z:\Blue straggler\DESI\FITS"
png_folder = "Z:\Blue straggler\DESI\PNG"
os.makedirs(fits_folder, exist_ok=True)
os.makedirs(png_folder, exist_ok=True)

for index, row in stars.iterrows():
ra = row['ra']
dec = row['dec']

constraints = {'ra': [ra, ra], 'dec': [dec, dec], 'data_release': ['DESI-EDR']}
found = client.find(constraints=constraints, outfields=['sparcl_id'], limit=None)

if found.records:
    for record in found.records:
        results = client.retrieve(uuid_list=[record.sparcl_id], include=['flux', 'wavelength'])

        flux = results.records[0].flux
        wavelength = results.records[0].wavelength
        plt.figure()
        plt.plot(wavelength, flux)
        plt.xlabel('Wavelength (Angstrom)')
        plt.ylabel('Flux')
        plt.title(f'Spectrum for RA: {ra}, Dec: {dec}')
        plt.savefig(os.path.join(png_folder, f"{ra}_{dec}.png"))
        plt.close()
else:
    print(f"No spectra found for RA: {ra}, Dec: {dec}")

`

Excuse me, where should I specify to query the 'DESI-ADR' dataset?
Can you provide a tutorial on cross referencing DESI spectra based on "ra dec",please?

@rnikutta
Copy link
Member

Hi @Cyanglll thanks for reaching out. You can do cross-matches based on RA and Dec using Data Lab xmatch service. Either online: https://datalab.noirlab.edu/xmatch.php or using Python (e.g. on our NB server). An example notebook is: https://github.com/astro-datalab/notebooks-latest/blob/master/04_HowTos/CrossmatchTables/How_to_crossmatch_tables.ipynb

The table that has DESI-EDR positions is sparcl.main: https://datalab.noirlab.edu/query.php?name=sparcl.main

Please note also that we have a helpdesk where you can find previous questions and answers, and also submit new questions: https://datalab.noirlab.edu/help/

Please don't hesitate to contact us again if you require more help.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants