new Aladin(aladinDiv, requestedOptions)
Creates an instance of the Aladin interactive sky atlas.
Parameters:
Name | Type | Description |
---|---|---|
aladinDiv |
string | HTMLElement | The ID of the HTML element or the HTML element itself where the Aladin sky atlas will be rendered. |
requestedOptions |
AladinOptions | Options to customize the behavior and appearance of the Aladin atlas. |
Throws:
-
Throws an error if aladinDiv is not provided or is invalid.
- Type
- Error
Example
// Usage example:
import { A } from 'aladin-lite';
let aladin = A.Aladin('#aladin-lite-div', { option1: 'value1', option2: 'value2' });
Members
removeLayer
- Deprecated:
- Old method name, use
Aladin.prototype.removeOverlay
instead.
- Old method name, use
- Source:
removeLayers
- Deprecated:
- Old method name, use
Aladin.prototype.removeOverlays
instead.
- Old method name, use
- Source:
setImageSurvey
Change the base layer of the view
It internally calls
Aladin.setBaseImageLayer
with the url/HiPS
/Image
given
Methods
addColormap(label, colors)
Add a custom colormap from a list of colors
Parameters:
Name | Type | Description |
---|---|---|
label |
string | The label of the colormap |
colors |
Array.<string> | A list string colors |
Example
aladin.addColormap('mycmap', ["lightblue", "red", "violet", "#ff00aaff"])
addNewImageLayer(surveyopt)
Add a new HiPS layer to the view on top of the others
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
survey |
string | HiPS | Image |
<optional> |
"P/DSS2/color" | Can be:
|
addStatusBarMessage(options)
Append a message to the status bar with a specific duration
Parameters:
Name | Type | Description | |||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
options |
Object | The message to display
Properties
|
Example
aladin.addStatusBarMessage({
duration: 10000,
type: 'info',
message: 'Aladin Lite v3.3 is out. New features available:<ul><li>New Button, Box objects</li><li>Polygonal, circular selection</li></ul>'
})
angularDist(x1, y1, x2, y2, frameopt) → {number}
Get the angular distance in degrees between two locations
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
x1 |
number | The x-coordinate of the first pixel coordinates. | |
y1 |
number | The y-coordinate of the first pixel coordinates. | |
x2 |
number | The x-coordinate of the second pixel coordinates. | |
y2 |
number | The y-coordinate of the second pixel coordinates. | |
frame |
CooFrame |
<optional> |
The frame in which we want to retrieve the coordinates. If not given, the frame chosen is the one from the view |
Throws:
-
Throws an error if an issue occurs during the transformation.
- Type
- Error
Returns:
- The angular distance between the two pixel coordinates in degrees
- Type
- number
contains(urlOrHiPSOrFITS)
Check whether a survey is currently in the view
Parameters:
Name | Type | Description |
---|---|---|
urlOrHiPSOrFITS |
string | HiPS | Image | Can be: |
createImageSurvey(id, nameopt, url, cooFrameopt, maxOrderopt, optionsopt) → {HiPS}
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
id |
string | Mandatory unique identifier for the survey. | |
name |
string |
<optional> |
A convinient name for the survey, optional |
url |
string | FileList | HiPSLocalFiles | Can be:
FileList pointing to the opened webkit directory is also accepted.
|
|
cooFrame |
string |
<optional> |
Values accepted: 'equatorial', 'icrs', 'icrsd', 'j2000', 'gal', 'galactic' |
maxOrder |
number |
<optional> |
The maximum HEALPix order of the HiPS, i.e the HEALPix order of the most refined tile images of the HiPS. |
options |
HiPSOptions |
<optional> |
Options describing the survey |
Returns:
A HiPS image object.
- Type
- HiPS
displayFITS(url, optionsopt, successCallbackopt, errorCallbackopt, layeropt)
Display a FITS image in the Aladin Lite.
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
url |
string | The URL of the FITS image. | ||
options |
ImageOptions |
<optional> |
Options to customize the display | |
successCallback |
function |
<optional> |
<center the view on the FITS file> | The callback function to be executed on a successful display. The callback gives the ra, dec, and fov of the image; By default, it centers the view on the FITS file loaded. |
errorCallback |
function |
<optional> |
The callback function to be executed if an error occurs during display. | |
layer |
string |
<optional> |
"base" | The name of the layer. If not specified, it will be replace the base layer. |
Example
aladin.displayFITS(
'https://fits.gsfc.nasa.gov/samples/FOCx38i0101t_c0f.fits', // url of the fits file
{
minCut: 5000,
maxCut: 17000,
colormap: 'viridis'
},
(ra, dec, fov, image) => {
// ra, dec and fov are centered around the fits image
image.setColormap("magma", {stretch: "asinh"});
aladin.gotoRaDec(ra, dec);
aladin.setFoV(fov);
},
);
displayJPG(url, optionsopt, successCallbackopt, errorCallbackopt, layeropt)
Display a JPEG image in the Aladin Lite view.
Parameters:
Name | Type | Attributes | Default | Description | |||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
url |
string | The URL of the JPEG image. | |||||||||||||||||||||||||||
options |
Object |
<optional> |
Options to customize the display. Can include the following properties:
Properties
|
||||||||||||||||||||||||||
successCallback |
function |
<optional> |
The callback function to be executed on a successful display. The callback gives the ra, dec, and fov of the image; | ||||||||||||||||||||||||||
errorCallback |
function |
<optional> |
The callback function to be executed if an error occurs during display. | ||||||||||||||||||||||||||
layer |
string |
<optional> |
"overlay" | The name of the layer. If not specified, it will add a new overlay layer on top of the base. |
Example
aladin.displayJPG(
// the JPG to transform to HiPS
'https://noirlab.edu/public/media/archives/images/large/noirlab1912a.jpg',
{
transparency: 0.6,
label: 'NOIRLab image'
},
(ra, dec, fov) => {
// your code here
})
);
getBaseImageLayer() → {HiPS|Image}
Get the base image layer object
Returns:
- Returns the image layer corresponding to the base layer
getFoVCorners(nbStepsopt, frameopt) → {Array.<Array.<number>>}
Gets a set of points along the current Field of View (FoV) corners.
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
nbSteps |
number |
<optional> |
1 | The number of points to return along each side (the total number of points returned is 4 * nbSteps). |
frame |
CooFrame |
<optional> |
The frame in which the coo will be given. Default to the view frame. |
Throws:
-
Throws an error if an issue occurs during the transformation.
- Type
- Error
Returns:
- A set of positions along the current FoV with the following format: [[ra1, dec1], [ra2, dec2], ..., [ra_n, dec_n]].
The positions will be given in degrees
- Type
- Array.<Array.<number>>
getFov() → {Array.<number>}
Gets the current Field of View (FoV) size in degrees as a 2-element array.
Returns:
- A 2-element array representing the current FoV size in degrees. The first element is the FoV width,
and the second element is the FoV height.
- Type
- Array.<number>
getFrame() → {string}
Returns the current coordinate system: possible values are 'J2000', 'J2000d', and 'Galactic' .
Returns:
The current coordinate system: possible values are 'J2000', 'J2000d', and 'Galactic' .
- Type
- string
Example
const aladin = A.aladin('#aladin-lite-div', {cooFrame: 'galactic'});
let cooFrame = aladin.getFrame();
assert(cooFrame, 'galactic')
getListOfColormaps()
Add a custom colormap from a list of colors
Returns:
- The list of all the colormap labels
getOverlayImageLayer(layeropt) → {HiPS|Image}
Get an image layer from a layer name
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
layer |
string |
<optional> |
"overlay" | The name of the layer |
Returns:
- The requested image layer.
getOverlays() → {Array.<MOC>|Array.<Catalog>|Array.<ProgressiveCat>|Array.<GraphicOverlay>}
Get list of overlays layers
Returns:
- Type
- Array.<MOC> | Array.<Catalog> | Array.<ProgressiveCat> | Array.<GraphicOverlay>
getParentDiv() → {HTMLElement}
Returns the HTML div element
Returns:
- The aladin lite div HTML element
- Type
- HTMLElement
getRaDec() → {Array.<number>}
Gets the current [Right Ascension, Declination] position of the center of the Aladin view.
This method returns the celestial coordinates of the center of the Aladin view in the International
Celestial Reference System (ICRS) or J2000 equatorial coordinates.
Returns:
- An array representing the [Right Ascension, Declination] coordinates in degrees.
The first element is the Right Ascension (RA), and the second element is the Declination (Dec).
- Type
- Array.<number>
getSize() → {Array.<number>}
Returns the size in pixels for the Aladin view
Returns:
- A 2-element array representing the current Aladin view size in pixels. The first element is the width,
and the second element is the height.
- Type
- Array.<number>
getStackLayers() → {Array.<HiPS>|Array.<Image>}
Get list of layers
Returns:
getViewArrayBuffer(withLogo) → {Promise.<ArrayBuffer>}
Return the current view as a png ArrayBuffer
Parameters:
Name | Type | Description |
---|---|---|
withLogo |
boolean | Display or not the Aladin Lite logo |
Returns:
The image as a png ArrayBuffer
- Type
- Promise.<ArrayBuffer>
getViewCenter2NorthPoleAngle() → {number}
Get the view center to north pole angle in degrees. This is equivalent to getting the 3rd Euler angle
Returns:
- Angle between the position center and the north pole
- Type
- number
getViewData(dataType, imgTypeopt, withLogoopt) → {Promise.<any>}
Return the current view as a png Blob
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
dataType |
string | The type of data to return. Can be 'url', 'arraybuffer' or 'blob' | ||
imgType |
string |
<optional> |
'image/png' | The type of image to return. Can be 'image/png', 'image/jpeg' or 'image/webp' |
withLogo |
boolean |
<optional> |
true | Display or not the Aladin Lite logo |
Returns:
- Type
- Promise.<any>
getViewDataURL(optionsopt) → {Promise.<string>}
Return the current view as a png data URL (base64-formatted string)
Parameters:
Name | Type | Attributes | Description | |||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
options |
Object |
<optional> |
Object with attributs, options are:
Properties
|
Returns:
The image as a png data URL
- Type
- Promise.<string>
getViewWCS() → {Object}
Return the current view WCS as a key-value dictionary
Can be useful in coordination with getViewDataURL
Returns:
- A JS object describing the WCS of the view.
- Type
- Object
gotoObject(targetName, callbackOptionsopt)
Moves the Aladin instance to the specified astronomical object.
Parameters:
Name | Type | Attributes | Description | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
targetName |
string | The name or identifier of the astronomical object to move to. | |||||||||||||
callbackOptions |
Object |
<optional> |
Optional callback options.
Properties
|
Example
// Move to the astronomical object named 'M42' with callbacks
const aladinInstance = A.aladin('#aladin-lite-div');
aladinInstance.gotoObject('M42', {
success: () => {
console.log('Successfully moved to M42.');
},
error: (err) => {
console.error('Error moving to M42:', err);
}
});
gotoPosition(lon, lat, frameopt)
Moves the Aladin instance to the specified position.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
lon |
number | longitude in degrees | |
lat |
number | latitude in degrees | |
frame |
string |
<optional> |
The name of the coordinate frame. Possible values: 'j2000d', 'j2000', 'gal', 'icrs'. The given string is case insensitive. |
Example
// Move to position
const aladin = A.aladin('#aladin-lite-div');
aladin.gotoPosition(20, 10, "galactic");
gotoRaDec(ra, dec)
Moves the Aladin instance to the specified position given in ICRS frame
Parameters:
Name | Type | Description |
---|---|---|
ra |
number | Right-ascension in degrees |
dec |
number | Declination in degrees |
Example
const aladin = A.aladin('#aladin-lite-div');
aladin.gotoRaDec(20, 10);
newImageSurvey(id, optionsopt, successopt, erroropt) → {HiPS}
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
id |
string | Can be:
|
|
options |
HiPSOptions |
<optional> |
Options for rendering the image |
success |
function |
<optional> |
A success callback |
error |
function |
<optional> |
A success callback |
- Deprecated:
- Create a new layer from an url or CDS ID.
Please use
A.hiPS
instead for creating a new survey image
- Create a new layer from an url or CDS ID.
Please use
- Source:
Returns:
A FITS image object.
- Type
- HiPS
on(what, myFunction)
Listen aladin for specific events
Parameters:
Name | Type | Description |
---|---|---|
what |
ListenerCallback | e.g. objectHovered, select, zoomChanged, positionChanged |
myFunction |
function | a callback function.
Note:
|
Example
// define function triggered when a source is hovered
aladin.on('objectHovered', function(object, xyMouseCoords) {
if (object) {
msg = 'You hovered object ' + object.data.name + ' located at ' + object.ra + ', ' + object.dec + '; mouse coords - x: '
+ xyMouseCoords.x + ', y: ' + xyMouseCoords.y;
}
else {
msg = 'No object hovered';
}
$('#infoDiv').html(msg);
});
aladin.on('objectHoveredStop', function(object, xyMouseCoords) {
if (object) {
msg = 'You stopped hove object ' + object.data.name + ' located at ' + object.ra + ', ' + object.dec + '; mouse coords - x: '
+ xyMouseCoords.x + ', y: ' + xyMouseCoords.y;
}
$('#infoDiv').html(msg);
});
// define function triggered when an object is clicked
var objClicked;
aladin.on('objectClicked', function(object, xyMouseCoords) {
if (object) {
objClicked = object;
object.select();
msg = 'You clicked object ' + object.data.name + ' located at ' + object.ra + ', ' + object.dec + '; mouse coords - x: '
+ xyMouseCoords.x + ', y: ' + xyMouseCoords.y;
}
else {
objClicked.deselect();
msg = 'You clicked in void';
}
$('#infoDiv').html(msg);
});
aladin.on("objectsSelected", (objs) => {
console.log("objs", objs)
})
aladin.on("positionChanged", ({ra, dec}) => {
console.log("positionChanged", ra, dec)
})
aladin.on("layerChanged", (layer, layerName, state) => {
console.log("layerChanged", layer, layerName, state)
})
pix2world(x, y, frameopt) → {Array.<number>}
Transform pixel coordinates to world coordinates.
The origin (0,0) of pixel coordinates is at the top-left corner of the Aladin Lite view.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
x |
number | The x-coordinate in pixel coordinates. | |
y |
number | The y-coordinate in pixel coordinates. | |
frame |
CooFrame |
<optional> |
The frame in which we want to retrieve the coordinates. If not given, the frame chosen is the one from the view |
Throws:
-
Throws an error if an issue occurs during the transformation.
- Type
- Error
Returns:
- An array representing the [Right Ascension, Declination] coordinates in degrees in the `frame`.
If not specified, returns the coo in the frame of the current view.
- Type
- Array.<number>
remove(item)
Remove an image layer/overlay from the instance
Parameters:
Name | Type | Description |
---|---|---|
item |
string | Overlay | the overlay object or image layer name to remove |
removeHiPSFromFavorites(urlOrHiPSOrFITS)
Remove a HiPS/FITS image from the list of favorites.
Parameters:
Name | Type | Description |
---|---|---|
urlOrHiPSOrFITS |
string | HiPS | Image | Can be: |
Throws:
A warning when the asset is currently present in the view
removeImageLayer(layer)
Remove a specific layer
Parameters:
Name | Type | Description |
---|---|---|
layer |
string | The name of the layer to remove or the HiPS/Image object |
removeOverlay(overlay)
Remove an overlay by its layer name
Parameters:
Name | Type | Description |
---|---|---|
overlay |
string | Overlay | The name of the overlay to remove or the overlay object itself |
removeOverlays()
Remove all the overlays (MOC, Overlay, ProgressiveCat, Catalog) from the view
select(modeopt, callbackopt)
Enters selection mode
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
mode |
string |
<optional> |
'rect' | The mode of selection, can be either, 'rect', 'poly', or 'circle' |
callback |
function |
<optional> |
A function called once the selection has been done
The callback accepts one parameter depending of the mode used: - If mode='circle' that parameter is of type CircleSelection - If mode='rect' that parameter is of type RectSelection - If mode='poly' that parameter is of type PolygonSelection |
Example
// Creates and add a MOC from the user polygonal selection
aladin.select('poly', p => {
try {
let ra = []
let dec = []
for (const v of p.vertices) {
let [lon, lat] = aladin.pix2world(v.x, v.y);
ra.push(lon)
dec.push(lat)
}
let moc = A.MOCFromPolygon(
{ra, dec},
{name: 'poly', lineWidth: 3.0, color: 'pink'},
);
aladin.addMOC(moc)
} catch(_) {
alert('Selection covers a region out of the projection definition domain.');
}
})
selectObjects(objectsnullable)
Select specific objects in the view
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
objects |
Array.<Source, Footprint, Circle, Ellipse, Polyline, Vector> |
<nullable> |
If null is passed then nothing will be selected and sources already selected will be deselected |
setBaseImageLayer(urlOrHiPSOrFITS)
Change the base layer of the view
Parameters:
Name | Type | Description |
---|---|---|
urlOrHiPSOrFITS |
string | HiPS | Image | Can be: |
setCooGrid(options)
Sets the coordinate grid options for the Aladin Lite view.
This method allows you to customize the appearance of the coordinate grid in the Aladin Lite view.
Parameters:
Name | Type | Description | ||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
options |
Object | Options to customize the coordinate grid.
Properties
|
Example
// Set the coordinate grid color to red
aladin.setCooGrid({ color: 'red' });
// Enable the coordinate grid
aladin.setCooGrid({ enabled: true });
setFoV(FoV)
Sets the field of view (FoV) of the Aladin instance to the specified angle in degrees.
Parameters:
Name | Type | Description |
---|---|---|
FoV |
number | The angle of the field of view in degrees. |
Example
let aladin = A.aladin('#aladin-lite-div');
aladin.setFoV(60);
setFoVRange(minFoV, maxFoV)
Restrict the FoV range between a min and a max value
Parameters:
Name | Type | Description |
---|---|---|
minFoV |
number | in degrees when zoom in at max. If undefined, the zooming in is not limited |
maxFoV |
number | in degrees when zoom out at max. If undefined, the zooming out is not limited |
Example
let aladin = A.aladin('#aladin-lite-div');
aladin.setFoVRange(30, 60);
setFrame(frame)
Sets the coordinate frame of the Aladin instance to the specified frame.
Parameters:
Name | Type | Description |
---|---|---|
frame |
string | The name of the coordinate frame. Possible values: 'j2000d', 'j2000', 'gal', 'icrs'. The given string is case insensitive. |
Example
// Set the coordinate frame to 'J2000'
const aladin = A.aladin('#aladin-lite-div');
aladin.setFrame('J2000');
setImageLayer(urlOrHiPSOrFITS)
Change the base layer of the view
It internally calls
Aladin.setBaseImageLayer
with the url/HiPS
/Image
given
Parameters:
Name | Type | Description |
---|---|---|
urlOrHiPSOrFITS |
string | HiPS | Image | Can be: |
setOverlayImageLayer(urlOrHiPSOrFITS, layeropt)
Add a new HiPS/FITS image layer in the view
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
urlOrHiPSOrFITS |
string | HiPS | Image | Can be: | ||
layer |
string |
<optional> |
"overlay" | A layer name. By default 'overlay' is chosen and it is destined to be plot on top the 'base' layer. If the layer is already present in the view, it will be replaced by the new HiPS/FITS image given here. |
setProjection(projection)
Sets the projection of the Aladin instance to the specified type.
Parameters:
Name | Type | Description |
---|---|---|
projection |
string | The type of projection to set. Possible values
"TAN" (Gnomonic projection) "STG" (Stereographic projection) "SIN" (Orthographic projection) "ZEA" (Zenital equal-area projection) "MER" (Mercator projection) "AIT" (Hammer-Aitoff projection) "MOL" (Mollweide projection) |
Example
// Set the projection to 'orthographic'
let aladin = A.aladin('#aladin-lite-div');
aladin.setProjection('SIN');
setViewCenter2NorthPoleAngle(rotation)
Set the view center rotation in degrees
Parameters:
Name | Type | Description |
---|---|---|
rotation |
number | The center rotation in degrees. Positive angles rotates the view in the counter clockwise order (or towards the east) |
world2pix(lon, lat, frameopt) → {Array.<number>}
Transform world coordinates to pixel coordinates in the view.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
lon |
number | Londitude coordinate in degrees. | |
lat |
number | Latitude coordinate in degrees. | |
frame |
CooFrame |
<optional> |
If not specified, the frame used is ICRS |
Throws:
-
Throws an error if an issue occurs during the transformation.
- Type
- Error
Returns:
- An array representing the [x, y] coordinates in pixel coordinates in the view.
- Type
- Array.<number>
(static) MOC#serialize(formatopt)
Serialize a MOC into different format
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
format |
string |
<optional> |
'json' | The output format. Only json is currently supported but 'fits' could be added. |
(static) createImageFITS(url, optionsopt, successopt, erroropt) → {Image}
Creates a FITS image object
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
url |
string | The url of the fits. | |
options |
ImageOptions |
<optional> |
Options for rendering the image |
success |
function |
<optional> |
A success callback |
error |
function |
<optional> |
A success callback |
Returns:
A FITS image object.
- Type
- Image
(static) createImageFITS(url, optionsopt, successopt, erroropt) → {Image}
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
url |
string | The url of the fits. | |
options |
ImageOptions |
<optional> |
Options for rendering the image |
success |
function |
<optional> |
A success callback |
error |
function |
<optional> |
A success callback |
Returns:
A FITS image object.
- Type
- Image
(static) createImageSurvey(id, nameopt, url, cooFrameopt, maxOrderopt, optionsopt) → {HiPS}
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
id |
string | Mandatory unique identifier for the survey. | |
name |
string |
<optional> |
A convinient name for the survey, optional |
url |
string | FileList | HiPSLocalFiles | Can be:
FileList pointing to the opened webkit directory is also accepted.
|
|
cooFrame |
string |
<optional> |
Values accepted: 'equatorial', 'icrs', 'icrsd', 'j2000', 'gal', 'galactic' |
maxOrder |
number |
<optional> |
The maximum HEALPix order of the HiPS, i.e the HEALPix order of the most refined tile images of the HiPS. |
options |
HiPSOptions |
<optional> |
Options describing the survey |
Returns:
A HiPS image object.
- Type
- HiPS