Sharing a view#

A view can leave the notebook in three ways: as a web page that anyone can open and explore in a browser, as a full-resolution picture, or as a saved state that opens another viewer the same way. Every live viewer on these pages is the first kind, written by the code above it.

A web page of the view#

share writes the view as a single web page: the viewer itself and the data it shows. It opens in any browser, with nothing installed and no server behind it. Readers can pan, zoom, restretch, read values and sky coordinates, draw regions and export images, just as you can.

v = pc.show("image.fits", scale="asinh", limits="99.5", cmap="magma")
v.share("field.html", title="Our field", caption="Taken 2026 March 3", credit="A. Astronomer")

The page opens as you last left the view in a viewer: the stretch, colors, regions, pan and zoom. (If no viewer has shown it yet, as in a script, it opens as the view would.) The Share button in the viewer’s toolbar does the same, with a dialog for the same choices.

What goes in the page#

A shared page always holds a preview of each image, so it opens at once anywhere. data decides where full resolution comes from:

data

Full resolution

For

"compact" (default)

compact data, in the page

one file to email or attach

"compact_files"

compact data, in a folder beside the page, read as needed

a web site (as these docs do)

"embed"

the files themselves, in the page

exact values, one file

"link"

read from the files at a URL (urls), only the part on screen

data already online

"preview"

none: the preview only

the smallest page

Compact data keeps only the images the view shows, each value to within a quarter of its noise (as fpack does), which no stretch can show. Every tool keeps working, at a fraction of the files’ size. Integer images are kept exactly.

preview sets the size of the overview the page opens with: "small", "medium" (the default) or "large", about 1, 4 or 16 megapixels for all the images together. tools=False opens the page with every tool hidden, the image alone; readers bring them back with h.

v.share("site/field.html", data="compact_files", preview="small")    # for a web server
v.share("field.html", data="link", urls="https://example.org/data/") # files read from there

With data="link", give one base URL ending in /, or one URL per file. The host must answer range requests and allow the page to read the files (CORS) if it’s served from elsewhere. Each file is checked by its size and a fingerprint, so a page never shows another file of the same name.

What readers can do with it#

Besides exploring, a reader can Save (Ctrl+S, ⌘S) a copy of the page that opens with their view, with their own title, caption and credit, and pass that on. Download saves the view as shown, a full-resolution image, or the data files. With sky coordinates, they also get SIMBAD’s What is this? and the Aladin Lite panel.

A full-resolution picture#

Export in the toolbar opens on Figure, a figure for a paper or a talk (axes, colorbar, compass; PDF or PNG). Its Full-resolution image tab (also right-click › Export full-resolution image…) renders a PNG next to the data, at full resolution: the whole image, the crop, the view or a box, turned as the view is, optionally block-averaged, with regions, text and a colorbar. It’s written next to the notebook and named in the line under the viewer, ready for a paper or a poster. Every PNG carries the color settings in its metadata, so the picture can be reproduced exactly.

Save view as shown (in the export menu, or right-click) downloads what’s on screen to your own computer instead.

pc.save_png writes the same picture from code, with no viewer on screen: one file, a folder of exposures in a loop, or a view as you left it. See Saving pictures.

Opening the same view again#

A viewer’s state is the view as you left it: the stretch, colors, regions, pan and zoom (for a table, its filters, sort, columns and plot). Pass it as state= to open another viewer the same way: the next file in a series, or the same file in a later session.

v = pc.show("night1.fits")
# ... adjust it in the viewer ...

import json
json.dump(v.state, open("look.json", "w"))                   # keep it

pc.show("night2.fits", state=json.load(open("look.json")))   # the same look on another night

For mosaics, Save mosaic writes a .pcmosaic file of its files, layout and level matching, which pc.show opens again.

Where files go#

Exports, shared pages written from the toolbar and saved mosaics are written on the server, next to the notebook by default. out_dir sends them elsewhere:

pc.show("image.fits", out_dir="figures")

Region files, color settings and Save view as shown download to your own computer instead.