Reading FITS files from subdirectories

I am trying to implement the following python code in rust. It involves creating a list of files ending with S1D.fits, and extracting information from the FITS file.

import glob
from pathlib import Path

list_of_files= Path().cwd().glob("**/**/*S1D_A.fits") #create the list of files ending with S1D_A.fits in the current directory and subdirectories
for file_name in list_of_files:
    data=fits.getdata(file_name)  #read fits file and get data  
    flux=data.flux    #extract a values under column "flux"
    header=fits.getheader(file_name)   #read header of the fits file
    mjd=header['MJD-OBS']  #get value corresponding to MJD-OBS

I tried fitsio and fits-rs crates. But I could not do it. Does anybody know how to code for this?

Especially for python, proper formatting is important.

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.