问题
so basically what I need to do is write a program which will look in a directory and load all the files of a specific file type into a program called "Astrometrica". I then want the code to basically automate what I would do in the program. I'm working on my science fair project which I'm entering into the astronomy category.
--.fits = flexible image transport system. My images are stored in this file type.
--I'm looking at images of space and certain stars.
What I usually do in Astrometrica is load all of the .fits images in a certain folder into Astrometrica. I usually end up loading less than 30 images.
Next I change what is known as a configuration in Astrometrica. To change the configuration you have to select the configuration file from the file explorer. Astrometrica provides a dropdown window to select your file. I think this could be achieved through if statements, ie: I would check if the filename had a specific string of characters and if it did I would select the configuration to match that file.
I continue by pressing a button which checks my images against a star catalog. This basically means that I just try to figure out which stars are which. This should be fairly easy as I just need to call the program's function to do this.
The next step is to press another button which aligns all of the images in a certain way.
Finally, you press another button which combines all of the images and saves it as one.
tldr: there are a lot of careful steps that this program will need to automate.
I don't think that this will be very challenging, as I've already created a program which does something very similar to this. Below is what I have written so far,
import os
import subprocess
target_directory = 'C:/read_directory/' # change this as required make sure to leave a / at the end.
target_write_directory = 'C:/write_directory/' # also change this as needed and leave a / at the end.
def automateProcess(): #Execute the astrometrica commands.
targetFiles = [x for x in os.listdir(target_directory)if x.lower().endswith('.fits')]
for filename in targetFiles:
subprocess.call([r'C:/Astrometrica.exe', os.path.abspath(filename), '-load','-', '-savefits', os.path.abspath(target_write_directory + filename[:-3]), '-exit'])
automateProcess()
root.mainloop()
Ok so I'm not completely sure how to execute the commands in Astrometrica. As I have it right now, the for loop (which isn't even functional) will try to do something for each file rather than load all of the files and then do something.
The program is clearly not fully functional. I can provide more information or a screen recording if you can't seem to understand the steps.
The main issue I'm having is figuring out how to tell the program to do all of these specific procedures.
All help is appreciated :)
Thank you for reading!
来源:https://stackoverflow.com/questions/59385450/how-do-i-automate-the-usage-of-a-program-in-python