cds-astro / aladin-lite

An astronomical HiPS visualizer in the browser
https://aladin.cds.unistra.fr/AladinLite/
GNU General Public License v3.0
98 stars 40 forks source link

Visualize proper motion #91

Open imbasimba opened 1 year ago

imbasimba commented 1 year ago

I would like to see proper motion support in Aladin Lite 3. This was implemented by the ESASky team in our Aladin Lite 2 fork, but I fear that it is not a simple integration now that Aladin Lite 3 is heavily using Rust and WASM.

See the video of how this feature is used in ESASky: https://www.youtube.com/watch?v=HtszrCCx7Dw&t=503s

Description of what I would like to see in Aladin Lite 3:

  1. Example of a source: A.source(186.549225, 12.945969, {name: 'M 86', size: 6.03, otype: 'Galaxy in group of galaxies', arrowRa: '186.449225', arrowDec: '12.845969', arrowFlipped: false, arrowColor: '#0000ff' });
  2. With a list of sources like that in a catalog, I would like to display an arrow from object source to arrowRa, arrowDec
  3. Have an option to flip the direction of the arrow
  4. Have the option to subtract the average proper motion of a catalog of sources. Imagine looking at a cluster of stars moving in essentially the same direction, all arrows would be very similar. Using the 'subtract the average proper motion' option would allow users to see the relative motion of the stars within the cluster.
  5. Have the option to subtract the median proper motion of a catalog of sources
  6. Allow setting the color of the arrows
  7. Dealing with the fact that proper motions are usually very small, i.e. the arrows would be tiny unless the user really zooms in a lot. To be able to provide the user with useful information, I want an alternate display mode when the arrows would be too small to be helpful. This alternate display mode would only show the direction of the proper motion, not the actual proper motion. In the ESASky fork, the direction is shown by dotted lines instead of arrows. This dotted line is always the same size, regardless of zoom level, which means it is always visible. All dotted lines in the same catalogs have the same length, as this is just indicating the direction. In the ESASky fork, this normalized vector is calculated outside aladin.js, but it probably makes more sense to fully integrate this in Aladin Lite 3.
  8. Have the option to change the lengths of the dotted lines

The bulk of the implementation within the Aladin Lite 2 system, can be found in the below file, row 18085 - 18259 https://sky.esa.int/esasky/esasky_cl_5_0_2_2023_03_27T13_10_11Z/aladinESDC.js

bmatthieu3 commented 2 months ago

The api to do that is the following:

const pmCat = A.catalogFromURL('./data/proper_motion.xml', {
  onClick: 'showTable',
  name: 'mean pm over HPX cells around LMC from GaiaDR2',
  hoverColor: 'yellow',
  selectionColor: 'white',
  // Footprint associated to sources
  shape: (s) => {
    // discard drawing a vector for big pm
    let totalPmSquared = s.data.pmra*s.data.pmra + s.data.pmdec*s.data.pmdec;
    if (totalPmSquared > 6) {
      return;
    }

    let color = rainbowColorMap((totalPmSquared - 2.5) / 2)

    // Compute the mean of pm over the catalog sources
    if (!pmraMean || !pmdecMean) {
      pmraMean = 0, pmdecMean = 0;
      for (var s of pmCat.getSources()) {
        pmraMean += +s.data.pmra;
        pmdecMean += +s.data.pmdec;
      }

      const numSources = pmCat.getSources().length;

      pmraMean /= numSources
      pmdecMean /= numSources
    }

    let dra = +s.data.pmra - pmraMean;
    let ddec = +s.data.pmdec - pmdecMean;

    return A.vector(
      s.ra,
      s.dec,
      s.ra + dra,
      s.dec + ddec,
      {lineWidth: 3, color}
    )
  }
});
aladin.addCatalog(pmCat);

image

There is a shape method you can pass that is executed for each source and for which you can associate a footprint (circle, ellipsis, arrowed vector). I will not close that issue because it still need to be polished in terms of API and performance. We would like to also be able to associate an Image or a HTMLCanvasElement to a source.