You treat it like any other job. The people who are writing these kinds of papers are actual career scientists.
You start with a literature review and textbook search. read 5-10 different undergraduate astronomy and physics text books, then undertake a current literature review. Do searches in science journals that you might get free from your local library, or the library associated with your alma mater if you have connections there still.
That gets you the basic knowledge needed.
Next is the hard part, using current state of knowledge, finding current data sets, finding your own algorithms for "scratching your own itch"
Writing the script/programming is the last step - the least skilled step.
Imagine you are John Carmack writing Doom for the first time. He had to know the math, look for "at the time state of the art" university dissertations regarding 3d rendering and occlusion, etc and combine that with his own knowledge about coding, assembly language, and put all that together to make Doom run on the hardware he had access to at the time.
It's exactly the same for any field. Be humble, learn the basics, get caught up on current research, read deeply, read other people's disserations and ideas, then using what you have, and combine it with other people's ideas, and then you start the programming part (or you can hire people to code it for you, nothing wrong with that). and that's how it works.
We all stand on the shoulders of giants who come before us.