0

when I open a *.fits file in OIFitsExplorer, I obtain a structure as in the figure.

enter image description here

How can I get data only from GRAVITY_SC_P1 in oifits python3 module?

I access the data as follows:

target = "Zeta_Ori"

for infile in sys.argv[1:]:

    obj = oifits.open(infile)
    obj.info()

    outfile = os.path.basename(infile).replace("fits", "dat")
    fout = open("dat_vis/" + outfile, "w")

    for vis2 in obj.vis2:       

        if vis2.target.target == target:
            fout.write("# %s\n" % (vis2))
            fout.write("# %s\n" % (vis2.target))

            t1 = astropy.time.Time(vis2.timeobs, scale='utc', format='datetime')
            t2 = t1.tdb

            for i in range(len(vis2.wavelength.eff_wave)):
                if vis2.vis2data[i] != "--":
                    fout.write("%22.8f    %32.16e %32.16e    %32.16e %32.16e    %32.16e %32.16e %8s\n" % (t2.jd, vis2.ucoord, vis2.vcoord, vis2.wavelength.eff_wave[i], vis2.wavelength.eff_band[i], vis2.vis2data[i], vis2.vis2err[i], str(vis2.station[0])[:2]+str(vis2.station[1])[:2]))


    fout.close()

However, the data are from all four "subdirectories" (INSNAME), not only from a chosen one. How to select data with a given INSNAME? Thank you

3
  • I don't know Python enough but I am sure it's an easy restriction to implement. Either your sys.argv[1:] is too wide and you can limit it just through the input command line, or you can compare the "infile" variable before going deeper into it (can you display it to know how much file are looped into?). Anyway, I think you will not meet a lot of OIFITS experts here. You could maybe e-mail the author of OIFITS.PY directly : github.com/pboley/oifits
    – b126
    Commented Mar 8, 2024 at 12:55
  • Or try to replace the first line target = "Zeta_Ori" with target="GRAVITY_SC_P1"
    – b126
    Commented Mar 8, 2024 at 13:02
  • sys.argv[1:] is just for several *.fits file. target="GRAVITY_SC_P1" does not work. Thank you, I will contact the author.
    – Elena Greg
    Commented Mar 8, 2024 at 14:10

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.