#The sample of 5105 spectra of M-type stars with stellar labels are stored as fits file 'M_sample_5105_spectra.fits'
#If you read by python astropy.io.fits
#example
import astropy.io.fits as pyfits
import numpy as np

hdu=astropy.io.fits.open('./M_sample_5105_spectra.fits')
flux_array=hdu[0].data
labels=hdu[1].data

nlen=flux_array.shape[1]
c0=hdu[0].header['COEFF0']
c1=hdu[0].header['COEFF1']
wavelength=np.logspace(c0,c0+c1*(nlen-1),nlen)

teff_array = labels.TEFF 
logg_array = labels.LOGG
MH_array  = labels.M_H

flux_target0 = flux_array[0]  #the first star spectrum
teff_target0 = teff_array[0] # the teff of the first star
logg_target0 = logg_array[0] #the log g of the first star
MH_target0 = MH_array[0]  # the [M/H] of the first star

#Other Keywords are obtained in the same way
#Keywords: Gaia_source_id, LAMOST_specid,LAMOST_FILE,designation,ra,dec,SPT_1D,RV_1D,TEFF,LOGG,M_H,Parameter_catalog
#Teff (K) = Teff_ASPCAP - 87, Teff_Ding22 + 39, Teff_LASPM + 9 for M dwarf stars
#Teff (K) = Teff_ ASPCAP - 156, Teff_Qiu23 - 169  for M giant stars
#log g (dex) = logg_ASPCAP + 0.05, logg_Ding22 - 0.10, logg_LASPM - 0.24  for M dwarf stars 
#log g (dex) = logg_ ASPCAP - 0.16, logg_Qiu23 - 0.20' for M giant stars
#M_H (dex) = M_H_ASPCAP + 0.02, M_H_Ding22 + 0.23, M_H_LASPM + 0.38' for M dwarf stars
#M_H (dex) = M_H_ ASPCAP + 0.17, M_H_Qiu23 + 0.17 for M giant stars

    

