Skip to content

Commit

Permalink
🚧 Start implementing add_hips function on python and js side
Browse files Browse the repository at this point in the history
  • Loading branch information
Xen0Xys committed Apr 25, 2024
1 parent 981833f commit 6652312
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 3 deletions.
11 changes: 8 additions & 3 deletions js/widget.js
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,11 @@ function render({ model, el }) {
aladin.addOverlay(overlay);
overlay.addFootprints(A.footprintsFromSTCS(msg["stc_string"]));
break;
case "add_hips":
const id = msg["url"] + " | " + JSON.stringify(msg["options"]);
const hips = A.imageHiPS(id, msg["url"], msg["options"]);
aladin.addNewImageLayer(hips);
break;
case "change_colormap":
aladin.getBaseImageLayer().setColormap(msg["colormap"]);
break;
Expand All @@ -235,16 +240,16 @@ function render({ model, el }) {
let table_bytes = model.get("_table");
let decoder = new TextDecoder("utf-8");
let blob = new Blob([decoder.decode(table_bytes)]);
let url = URL.createObjectURL(blob);
let tableUrl = URL.createObjectURL(blob);
A.catalogFromURL(
url,
tableUrl,
Object.assign(msg.options, { onClick: "showTable" }),
(catalog) => {
aladin.addCatalog(catalog);
},
false,
);
URL.revokeObjectURL(url);
URL.revokeObjectURL(tableUrl);
break;
}
});
Expand Down
20 changes: 20 additions & 0 deletions src/ipyaladin/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -265,6 +265,26 @@ def add_moc_from_dict(self, moc_dict, moc_options=None):
moc_options = {}
self.add_moc(moc_dict, **moc_options)

def add_hips(self, url, **options):
"""Add a HiPS survey to the Aladin Lite widget.
Parameters
----------
url : str
Can be an `url` that refers to a HiPS. Or it
can be a "CDS ID" pointing towards a HiPS
options : dict
Options describing the survey
"""
self.send(
{
"event_name": "add_hips",
"url": url,
"options": options,
}
)

def add_table(self, table, **table_options):
"""Load a table into the widget.
Expand Down

0 comments on commit 6652312

Please sign in to comment.