Jump to content

NLCbanner2024.jpg.2478be509670e60c2d6efd04834b8b47.jpg

What is my (latest) python screw-up?


Demonperformer

Recommended Posts

As is so often the case, I am not sure this is the cprrect forum, but as it is about a computer program to access astro-info, I guess this might be the right one.

I am trying to use a program called Astropy to extract the data from a fits table.
Going through https://docs.astropy.org/en/stable/io/unified.html#table-io it appears that the showtable instruction is going to be the simplest way (at least initially).
The image shows the instructions given on the webpage for accessing their 'example' file that comes with the installation and my attempts to follow them.
A check on explorer has confirmed the presence of the file table.fits (about 8.6k in length).
After the initial "py", I typed in the instruction line given. The result is "invalid syntax".
I next tried typing in "from astropy.table import Table" first. I got this from further up the page which it required before doing other read/write operations. I then repeated the original instruction and again got an "invalid sytax" error.
So I then tried accessing the "full documentation and available options" and now I get a "'showtable' is not defined".
This last one suggests to me that if I can get the program to recognise (define?) 'showtable' I may actually get somewhere, but I cannot find an instruction for doing this. It all gives me the gut-feeling that I have committed some MSM (mega-stupid mistake) that might well be blindingly obvious to anyone who has even the most tangential knowledge of how python works (which I obviously don't).

So, what's my (latest) python screw-up?

Answers on the back of a £20 note ...

Thanks.

showtable problem.png

Link to comment
Share on other sites

Thanks for the response.

My initial response upon reading it was "I knew I'd been incredibly stupid - exactly like that". But when I tried it, I'm still getting the syntax error.

Just taken a v quick look at fitsio - may well be easier as it seems to be specifically dedicated to what I want to achieve. Will take a more in-depth look in a while.

Thanks

Image4.png

Link to comment
Share on other sites

7 minutes ago, Demonperformer said:

Thanks, Martin.

No longer a syntax error, just not recognized ...

Thanks.

Image5.png

You need to do one of the following:

1) Change to the directory containing showtable and run the command from there

2) Update your windows path variable (search environment variables to find the right panel) to include the showtable location

3) Fully specify the path containing showtable from the command line i.e. c:\astropy\showtable astropyy/.....   (assumes showtable is in the astropy directory off the c drive)

  • Like 1
Link to comment
Share on other sites

I use astropy but I've not used showtable. I just had a look for it on my Mac (using 'which showtable') and found it the bin directory of my miniconda distribution. I'm not sure if this is from astropy or something else, I have so much stuff on my system...

I'm not a windows user so don't know how you search for commands (maybe 'which' works for you too), but in any case it looks like it either isn't available because it hasn't been downloaded with astropy, or it isn't on your path. 

  • Like 1
Link to comment
Share on other sites

No expert but first you need to change directory to the folder were the files are on your PC/laptop. For example if the files are located on your PC/laptop in a folder on the C drive named Astropy, then in a folder called Fits you navigate to the correct folder first in command prompt with the command

CD C:\Astropy\Fits

This will change the path to show you are now in the Astropy\Fits folder.

Typing in py on the command line on its own puts you into the python editor command line where you can type in ptyhon commands directly (i.e. print(“Hello”) which will print hello on the command line as >>>Hello. This is not what you need here. 

  • Like 1
Link to comment
Share on other sites

3 minutes ago, Knighty2112 said:

No expert but first you need to change directory to the folder were the files are on your PC/laptop. For example if the files are located on your PC/laptop in a folder on the C drive named Astropy, then in a folder called Fits you navigate to the correct folder first in command prompt with the command

CD C:\Astropy\Fits

This will change the path to show you are now in the Astropy\Fits folder.

Typing in py on the command line on its own puts you into the python editor command line where you can type in ptyhon commands directly (i.e. print(“Hello”) which will print hello on the command line as >>>Hello. This is not what you need here. 

Thanks. Think I'm starting to see the light at the end of the tunnel ... or maybe it's just the train ...

  • Like 1
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue. By using this site, you agree to our Terms of Use.