Skip to content

Commit

Permalink
fix pixel res filtering
Browse files Browse the repository at this point in the history
  • Loading branch information
bmatthieu3 committed May 19, 2024
1 parent 00f7005 commit 6ab5aba
Show file tree
Hide file tree
Showing 5 changed files with 41 additions and 33 deletions.
22 changes: 8 additions & 14 deletions examples/al-cat-proper-motion.html
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,14 @@
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;
Expand All @@ -46,27 +53,14 @@
pmdecMean /= numSources
}

console.log("mean", pmraMean, pmdecMean)

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

// 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)

return A.vector(
s.ra,
s.dec,
s.ra + dra,
s.dec + ddec,
null,
{lineWidth: 3, color}
)
}
Expand Down
3 changes: 3 additions & 0 deletions examples/al-catalog-hips-shape.html
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@
fov: 1,
showContextMenu: true,
showZoomControl: true,
showSettingsControl: true,
showSimbadPointerControl: true,
samp: true,
});
// define custom draw function

Expand Down
5 changes: 2 additions & 3 deletions src/js/A.js
Original file line number Diff line number Diff line change
Expand Up @@ -298,15 +298,14 @@ A.ellipse = function (ra, dec, radiusRaDeg, radiusDecDeg, rotationDeg, options)
* @param {number} dec1 - Declination (Dec) coordinate of the center in degrees.
* @param {number} ra2 - Right Ascension (RA) coordinate of the center in degrees.
* @param {number} dec2 - Declination (Dec) coordinate of the center in degrees.
* @param {CooFrame} [frame] - Frame in which the coordinates are given. If none, the frame used is icrs/j2000.
* @param {ShapeOptions} options - Options for configuring the vector.
*
* @returns {Line}
*/
A.vector = function (ra1, dec1, ra2, dec2, frame, options) {
A.vector = function (ra1, dec1, ra2, dec2, options) {
options['arrow'] = true;

return A.line(ra1, dec1, ra2, dec2, frame, options);
return A.line(ra1, dec1, ra2, dec2, options);
}

/**
Expand Down
41 changes: 25 additions & 16 deletions src/js/gui/Box/HiPSBrowserBox.js
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ export class HiPSBrowserBox extends Box {
self.filterBox._show({
position: {
nextTo: filterBtn,
direction: "right",
direction: "bottom",
aladin,
},
});
Expand All @@ -194,6 +194,8 @@ export class HiPSBrowserBox extends Box {
},
});

let filterNumberElt = document.createElement("div");

super(
{
close: true,
Expand All @@ -208,7 +210,7 @@ export class HiPSBrowserBox extends Box {
classList: ['aladin-HiPS-browser-box'],
content: Layout.vertical([
Layout.horizontal(["Search:", searchDropdown, infoCurrentHiPSBtn]),
Layout.horizontal(["Filter:", Layout.horizontal([filterEnabler, filterBtn])]),
Layout.horizontal(["Filter:", Layout.horizontal([filterEnabler, filterBtn, filterNumberElt])]),
]),
...options,
},
Expand All @@ -220,6 +222,7 @@ export class HiPSBrowserBox extends Box {
self._filterHiPSList(params);
},
})
this.filterNumberElt = filterNumberElt;
this.filterBox._hide();

this.searchDropdown = searchDropdown;
Expand All @@ -231,24 +234,30 @@ export class HiPSBrowserBox extends Box {
self = this;

this.filterCallback = (HiPS, params) => {
if (!HiPS.obs_regime || (
params.regime &&
HiPS.obs_regime &&
params.regime.toLowerCase() !==
HiPS.obs_regime.toLowerCase()
)) {
return false;
}
if (params.regime) {
if (!HiPS.obs_regime)
return false;

if (Array.isArray(params.spatial) && HiPS.ID && !(params.spatial.includes(HiPS.ID))) {
return false;
if (params.regime.toLowerCase() !== HiPS.obs_regime.toLowerCase()) {
return false;
}
}

if (!HiPS.hips_tile_width || !HiPS.hips_order)
return false;
if (params.spatial) {
if (!HiPS.ID)
return false;

if (Array.isArray(params.spatial) && !(params.spatial.includes(HiPS.ID))) {
return false;
}
}

if (params.resolution) {
let pixelHEALPixOrder = Math.log2(HiPS.hips_tile_width) + HiPS.hips_order;
if (!HiPS.hips_tile_width || !HiPS.hips_order) {
return false;
}

let pixelHEALPixOrder = Math.log2(HiPS.hips_tile_width) + (+HiPS.hips_order);
let resPixel = Math.sqrt(Math.PI / (3*Math.pow(4, pixelHEALPixOrder)));

if (resPixel > params.resolution)
Expand Down Expand Up @@ -284,7 +293,6 @@ export class HiPSBrowserBox extends Box {

// This method is executed only if the filter is enabled
_filterHiPSList(params) {
console.log("update dropdown")
let self = this;
let HiPSIDs = [];

Expand All @@ -302,6 +310,7 @@ export class HiPSBrowserBox extends Box {
}

self.searchDropdown.update({ options: HiPSIDs });
self.filterNumberElt.innerHTML = HiPSIDs.length + "/" + Object.keys(HiPSBrowserBox.HiPSList).length;
}

_hide() {
Expand Down
3 changes: 3 additions & 0 deletions src/js/gui/Box/HiPSFilterBox.js
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,9 @@ export class HiPSFilterBox extends Box {
enable(enable) {
this.on = enable;

if (this.on)
this._requestMOCServer();

this._triggerFilteringCallback();
}
}

0 comments on commit 6ab5aba

Please sign in to comment.