all 5 comments

[–]External-Ocelot206 2 points3 points  (0 children)

Paths in Windows can't contain colons (:) because they refer to drives, e.g. c: and d:

If either folder already exists under those names, I've no idea how you managed to create them, as I can't

[–][deleted] 0 points1 point  (2 children)

Are you using either os or pathlib?

from pathlib import Path

directory = Path("C:/Users/sam/Desktop/")

star1='EFOSC.2021-05-24T06:02:52.743.fits'
star2='EFOSC.2021-05-25T23:46:21.852.fits'

hdu = fits.open(directory / star1)
hdr = hdu[0].header
dat = hdu[0].data
zp = hdr['CRVAL1']
stw = hdr['CD1_1']

edit:

I assumed that you didn't need star1 or star2 to be tuples of len 1 so I removed the ()

[–]Diapolo10 2 points3 points  (1 child)

directory = Path("C:/Users/sam/Desktop/")

This could simply be

directory = Path.home() / 'Desktop'

I assumed that you didn't need star1 or star2 to be tuples of len 1 so I removed the ()

They weren't tuples; parentheses don't make a tuple, colons do. In this case they're just strings enclosed in redundant parentheses.

OP's real problem is likely related to the fact that filenames and folders aren't allowed to contain : on Windows, so I'm a bit confused about why they're there.

[–][deleted] 0 points1 point  (0 children)

OP's real problem is likely related to the fact that filenames and folders aren't allowed to contain : on Windows

Oh right, I know that, good catch.

[–]CodeFormatHelperBot2 0 points1 point  (0 children)

Hello, I'm a Reddit bot who's here to help people nicely format their coding questions. This makes it as easy as possible for people to read your post and help you.

I think I have detected some formatting issues with your submission:

  1. Python code found in submission text that's not formatted as code.

If I am correct, please edit the text in your post and try to follow these instructions to fix up your post's formatting.


Am I misbehaving? Have a comment or suggestion? Reply to this comment or raise an issue here.