Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Link pretty image from FITS file #538

Merged
merged 3 commits into from
Jul 29, 2018
Merged

Conversation

wtgee
Copy link
Member

@wtgee wtgee commented Jul 11, 2018

The CR2 files are linked as part of the download process. This links those generated directly from FITS files (e.g. SBIG, FLI).

Replacing parts of #511.

@wtgee wtgee requested review from a team July 11, 2018 02:21
@codecov
Copy link

codecov bot commented Jul 11, 2018

Codecov Report

Merging #538 into develop will decrease coverage by 0.2%.
The diff coverage is n/a.

Impacted file tree graph

@@             Coverage Diff             @@
##           develop     #538      +/-   ##
===========================================
- Coverage    70.55%   70.35%   -0.21%     
===========================================
  Files           64       64              
  Lines         5475     5484       +9     
  Branches       761      762       +1     
===========================================
- Hits          3863     3858       -5     
- Misses        1405     1417      +12     
- Partials       207      209       +2
Impacted Files Coverage Δ
pocs/utils/images/__init__.py 77.21% <ø> (+0.14%) ⬆️
pocs/dome/astrohaven.py 71.05% <0%> (-1.76%) ⬇️
pocs/serial_handlers/protocol_arduinosimulator.py 75.38% <0%> (-1.54%) ⬇️
pocs/focuser/focuser.py 75.4% <0%> (-1.26%) ⬇️
pocs/camera/camera.py 89.72% <0%> (-0.88%) ⬇️
pocs/dome/protocol_astrohaven_simulator.py 79.74% <0%> (-0.85%) ⬇️
pocs/core.py 77.16% <0%> (ø) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 2b3ec28...1ceef2a. Read the comment docs.

pretty_path = _make_pretty_from_fits(fname, **kwargs)

# Symlink latest.jpg to the image; first remove the symlink if it already exists.
latest_path = '{}/images/latest.jpg'.format(os.getenv('PANDIR'))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What do you think about moving the linking for CR2 files from the cr2_to_jpg.sh script into this file?
Then we don't have two different approaches. And we don't have the primary==False check in just the CR2 case, and not the FITS case?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would almost prefer to go the other way and bury the details of the linking inside _make_pretty_from_fits, which is almost what I did in the first place.

For the CR2 we use the convert shell command. We could split this out of the existing bash script but then would just be calling another bash script. Not a huge deal either way.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can't see it making sense to complicate the two conversion to jpeg routines and bash scripts with linking to latest. It seems wrong to me.

So, let me be more definite and say that we should put the linking code into this routine, and share it between FITS and CR2.

@wtgee
Copy link
Member Author

wtgee commented Jul 17, 2018

Changed it so there is a common linking. Note that this now saves over the original JPG so it is a reduced size and has a timestamp, which means that the timelapse that are created will be the same thing. Not necessarily a bad thing but FYI.

@jamessynge
Copy link
Contributor

jamessynge commented Jul 21, 2018 via email

@wtgee
Copy link
Member Author

wtgee commented Jul 21, 2018

I'm not sure I understand the problem with overwriting that you're mentioning. Could you clarify?

The JPG is extracted directly from the CR2 (it's an embedded thumbnail, i.e. not a conversion we perform). Originally we were keeping that copy alongside the FITS file but also resizing the JPG and adding the caption to the bottom and saving that as a different file. So for the CR2 it was not actually doing a symlink to the original file but instead generating a new JPG. The timelapse movies have been generated from the original JPGs, which means they are not resized and don't have a caption.

So with the above change we no longer have two JPGs but instead resize and caption the original and then do a symlink. As such the timelapse will start to appear with a caption (which will have an unreadable time since it's 3 fps) and will be slightly different size. Not a big deal either way and probably for the better to have only one JPG anyway.

@wtgee
Copy link
Member Author

wtgee commented Jul 22, 2018

Note also that on PAN008 here in Sydney running a Raspberry Pi B 3 (not the +) it was taking too long for me to run the convert process (inside $POCS/scripts/cr2_to_jpg.sh) that resizes and captions. As such I am skipping that entirely and just writing the one jpeg alongside the fits and linking it to the latest in the images folder.

I do miss the time stamp as it's handy to know when the image changed. Luckily (:confused: ?) my tracking isn't very good right now so it's easy to tell when the image updated.

@@ -88,9 +88,25 @@ def make_pretty_image(fname, timeout=15, **kwargs): # pragma: no cover
warn("File doesn't exist, can't make pretty: {}".format(fname))

if fname.endswith('.cr2'):
return _make_pretty_from_cr2(fname, timeout=timeout, **kwargs)
pretty_path = _make_pretty_from_cr2(fname, timeout=timeout, **kwargs)
elif fname.endswith('.fits'):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you want to include an else clause to handle the case of an unsupported extension?

pretty_path = _make_pretty_from_fits(fname, **kwargs)

# Symlink latest.jpg to the image; first remove the symlink if it already exists.
if os.path.exists(pretty_path):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps add: and fname.endswith('.jpg')

Copy link
Contributor

@jamessynge jamessynge left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suggested a couple of changes, but I'll leave it to you to decide whether to make them. They can come later if appropriate.

@wtgee wtgee merged commit b689fc1 into panoptes:develop Jul 29, 2018
@wtgee wtgee deleted the link-pretty-from-fits branch July 29, 2018 02:28
@jamessynge
Copy link
Contributor

jamessynge commented Aug 26, 2018

I've updated to this version of software. I find that the pretty image is no longer being produced.
What testing/coverage of this portion of the code do we have?

@wtgee
Copy link
Member Author

wtgee commented Aug 26, 2018

Is it not produced at all or just not linking? Any errors?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants