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

New Features and Improvements to AstroImages #30

Merged
merged 181 commits into from
Jun 15, 2022
Merged

Conversation

sefffal
Copy link
Member

@sefffal sefffal commented Apr 7, 2022

History: #29

Status: T-2 weeks until ready to review & merge

This PR is an overhaul of AstroImages to address the following issues:

It implements a new AstroImage struct based on DimensionalData.jl that:

  • Keeps track of mappings from array indices to parent indices during slicing (necessary for WCS.jl support)
  • Stores FITS headers
  • Stores a WCSTransform object to map pixel coordinates to physical coordinates and back. Object is generated lazily from FITS headers when needed.
  • Thanks to DimensionalData, can apply reductions with named dimensions e.g. sum(img, dims=X).
  • Broadcasting, transformations, etc

It implements a new imview function for rendering arrays to static images that supports:

  • optional non-linear scales
  • arbitrary colormaps
  • clipping functions
  • contrast & brightness adjustments
  • safe handling of NaN, missing, +/- Inf pixels & empty arrays

It also implements plot recipes that:

  • use image series instead of heatmaps and reuses imview
  • render images with pixel-perfect locations matching DS9 in GR and PyPlot
  • display custom colorbars that account for non-linear colorscales, etc.
  • display WCS world coordinates ticks and arbitrarily warped grid lines
  • set the axis and colorbar titles according to WCS and FITS headers
  • displays any unseen dimensions as a title (e.g. when slicing cubes)
  • visualize polarization data

Still TODO:

  • update tests (Edit: started)
  • Reproject integration
  • recenter function for adjusting image origin
  • Better interface for RGB composites
  • Finish docs
  • FileIO registration

Known issues:

  • WCS gridlines & ticks broken on images that wrap around past 0
  • ImageFiltering
  • views currently copy headers instead of sharing them. Needs support from upstream DimensionalData

Gallery

imview(img; clims=percent(99), cmap=:seaborn_rocket_gradient)

implot(img, contrast=2, stretch=asinhstretch)

More:

@rafaqz
Copy link

rafaqz commented Jun 1, 2022

Absolutely. We're discussing ways to implement a package like that over at: lorenzoh/Invariants.jl#2

@sefffal
Copy link
Member Author

sefffal commented Jun 2, 2022

The docs aren't ready yet & there are still some rough edges but I think this is about ready to merge.

The last major outstanding thing is FileIO.jl registration.
I currently have

    # TODO: This should be registered correctly with FileIO
    del_format(format"FITS")
    add_format(format"FITS",
        # See https://www.loc.gov/preservation/digital/formats/fdd/fdd000317.shtml#sign
        [0x53,0x49,0x4d,0x50,0x4c,0x45,0x20,0x20,0x3d,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x54],
        [".fit", ".fits", ".fts", ".FIT", ".FITS", ".FTS", ".fit",],
        [:FITSIO => UUID("525bcba6-941b-5504-bd06-fd0dc1a4d2eb")],
        [:AstroImages => UUID("fe3fc30c-9b16-11e9-1c73-17dabf39f4ad")]
    )

in AstroImages.__init__() which is obviously a hack.

When running load("img.fits") FileIO goes down the list, so AstroImages will be used if installed and otherwise fallback to FITSIO.

Does anyone know the procedure to request that change in the FileIO registry? Do I need to run this the (other) FITSIO maintainers?

Edit: it would be nice for this to work with .fits.gz but I wasn't able to make that work. I'm not sure FileIO can differentiate .fits.gz from .gz.

@sefffal sefffal changed the title [draft] New Features and Improvements to AstroImages New Features and Improvements to AstroImages Jun 3, 2022
@sefffal
Copy link
Member Author

sefffal commented Jun 12, 2022

Even with the FileIO registration question outstanding, I think this is ready for a review and merge.
After merge, I can keep adding tests and continue progress on the docs.

Copy link
Member

@giordano giordano left a comment

Choose a reason for hiding this comment

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

I went through this very quickly. Amazing work, looking forward to future developments!

docs/examples/basics/displaying.jl Outdated Show resolved Hide resolved
docs/examples/basics/loading.jl Outdated Show resolved Hide resolved
docs/examples/config.json Outdated Show resolved Hide resolved
docs/src/basics.md Outdated Show resolved Hide resolved
src/precompile.jl Outdated Show resolved Hide resolved
@sefffal
Copy link
Member Author

sefffal commented Jun 15, 2022

Thanks @giordano and everyone else for your help and guidance along the way! Will merge now and prep to tag a new release.

@sefffal sefffal merged commit c6dc1a7 into JuliaAstro:master Jun 15, 2022
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.

4 participants