Skip to content

Firefly-2121: Fix Various Table Recognizer and Related UCD Issues - #2066

Merged
aventura121 merged 1 commit into
devfrom
FIREFLY-2121-ucd-fixes
Nov 24, 2026
Merged

aventura121 merged 1 commit into
devfrom
FIREFLY-2121-ucd-fixes

Conversation

@aventura121

@aventura121 aventura121 commented Nov 13, 2026 •

Copy link
Copy Markdown
Contributor

Firefly-2121 "Analyze and add test for VoCoreUtils.js and VoTableRecognizer.js"

This pull request addresses issues stemming from the recognizer hardcoding ra/dec, and the app not handling coordinates properly in several edge cases.

Description

# What's tested before after
1 RA/Dec table that also has other position-like columns correct same
2 Galactic columns, tagged no markers right place
3 Galactic names (glon/glat), no tags wrong place right place
4 Drift speeds next to a galactic position wrong place right place
5 Galactic table over 50,000 rows wrong place right place
6 SIMBAD search from a galactic row galactic numbers sent as RA/Dec converted to RA/Dec first
7 Save a galactic table as a region file galactic numbers labeled J2000 not offered
8 Galactic table as a TAP upload galactic columns pre-filled as RA/Dec not pre-filled

Where the branch does less than dev (7, 8), dev's result was wrong, so the branch leaves it out.

Dev mixes up the grids in four ways:

  1. It only looks for RA/Dec tags (UCDs), so galactic columns go unnoticed unless their names look like a position (step 2).
  2. Untagged columns with position-like names, such as glon/glat, are read as RA/Dec (step 3).
  3. Drift-speed columns are taken as the position, because their tag contains pos.eq.ra (step 4).
  4. Even when it knows a table is galactic, several features use the numbers as RA/Dec anyway (steps 5–8).

The branch follows the tags:

  • It takes the position columns and their grid from the tags. Without tags, it reads the grid from the column names: glon/glat mean galactic; elon/elat mean ecliptic; ra/dec and any other lon/lat, such as obj_lon, mean RA/Dec, as on dev.
  • Features that use a row's position, such as the coverage map and the SIMBAD search, convert it to RA/Dec first.
  • Features that pass the columns on as they are, the region file and the TAP upload, only use RA/Dec columns.
  • The one name it doesn't read as RA/Dec is sglon/sglat, supergalactic, a different grid (VoTableRecognizer.js:723). Without tags those columns aren't used; dev read them as RA/Dec.

How to test

Run each step on both builds and compare:

Load the table (every step):

  1. Open the build's URL. Use a fresh page for every step, so earlier tables don't carry over.
  2. Click the Tables (TAP) tab.
  3. In the box next to Select TAP Service, pick the step's service: HEASARC or IRSA.
  4. At the top right, next to View:, click Edit ADQL.
  5. Paste the step's query into the ADQL Query box.
  6. Click Search at the bottom left. The table appears at the bottom of the page.

The Coverage tab at the top left shows HiPS display failed on both builds: a CDS outage, not this branch.

Show it on the sky (steps 1–5):

  1. Click the Survey Maps (HiPS) tab.
  2. Click 2MASS color J (1.23um), H (1.66um), K (2.16um), then Load at the bottom left. The sky image appears at the top left, with the table's markers on it.
  3. Just above the image, click Equ / Spherical and pick Aitoff.
  4. Move the mouse over the image. Four magnifiers appear at its top left; click the third.
  5. Click ⤡, the last icon in the row just above HiPS / MOC.

The whole sky now fills the window as an oval. The bright band is the Milky Way; each red box is a group of nearby rows, labeled with how many. < Close at the top left goes back.

Which build is right? Steps 2–8 also give an RA/Dec version of the query: the same rows, with their position as ra/dec. Both builds read RA/Dec correctly, so it shows where the sources really are. Run it on the after build, the same way.

RA/Dec tables are safe

RA/Dec tables behave as on dev: the new code only runs for a table with no RA/Dec tags. The exceptions, all deliberate:

  • Columns tagged as something other than the position are no longer taken as it: offsets, errors, drift speeds, Sun-centered positions and orbits (VoTableRecognizer.js:625). A column found by its name is also skipped when its tag's first word names a different quantity (isPositionPair at VoTableRecognizer.js:698). Dev placed those rows by numbers that aren't positions. Step 4 shows one.
  • Empty position cells give no position, instead of RA 0, Dec 0 (TableAnalysis.js:446). Centering an image on the row (ActiveRowToImageWatcher.js:180) already gave none on dev for a null cell; now an empty-text cell gives none too.
  • A negative RA now lands in the right place on the coverage map of a table under 50,000 rows, which the browser builds from positions the server sends (SearchServerCommands.java:151, :177). An RA from 0 to 360 passes through unchanged.
  • A latitude beyond ±90, such as a -999 placeholder, is skipped when the browser builds the coverage map (HpxIndexCntlr.js:673). On dev, one such row makes the map build throw, and every later row is lost.
  • Untagged ra/dec next to one tagged galactic or ecliptic pair: the tagged pair is now the position (VoTableRecognizer.js:354-355); dev took ra/dec by name. The markers land in the same place when the table's two positions agree, because the tagged position is converted to RA/Dec. The region file and the TAP upload still use ra/dec (TableAnalysis.js:50).
flowchart TD
    A["getCenterColumns()<br/>VoTableRecognizer.js:503"] --> B{"CENTER_COLUMN set?<br/>:505"}
    B -- yes --> B1["use it"]
    B -- no --> C{"How many RA/Dec-tagged pairs? *<br/>:343-349"}
    C -- "exactly 1" --> C1["use it<br/>:344"]
    C -- "2 or more" --> C2["UType, then ObsCore name tie-break †<br/>:393, :412"]
    C -- "0" --> D{"NEW: exactly 1 galactic<br/>or ecliptic pair?<br/>:354-355"}
    D -- yes --> D1["use it"]
    D -- no --> E["UType, ObsCore names,<br/>then the name guess<br/>:393, :412, :431"]
    classDef new fill:#d4f4dd,stroke:#2e7d32,color:#000
    classDef changed fill:#fff3cd,stroke:#b8860b,color:#000
    class D,D1 new
    class C,E changed
Loading

Green is new, yellow is changed, and plain boxes give the same result as dev for an RA/Dec table.

* "RA/Dec-tagged" now leaves out columns tagged as an offset, an error or a drift speed (VoTableRecognizer.js:167-168, isCoordColumn at :670, the list of such tags at :625). A pair with meta.main on only one column is now paired from its tags (:195-202); where dev found such a pair by its column names, the branch returns the same pair.

† The tie-break now reads the grid from the tags (:400, :423); for RA/Dec tags that is J2000, as before.

1. RA/Dec tables don't change

A table with RA/Dec columns looks the same on both builds, even when it also has RA/Dec of 1900 and 1950, galactic and drift-speed columns.

Service: HEASARC

Query:

SELECT * FROM bsc5p WHERE vmag < 1.5

Do: load the table, then show it on the sky.

  • Both builds: the same 22 stars in the same places.
Step 1: before | after

Code: VoTableRecognizer.js:343-344: one RA/Dec-tagged pair, used before any new code runs.

Validation

2. Galactic columns, tagged

A table whose position columns are tagged galactic now gets markers on the sky, where its RA/Dec version puts them; dev draws none.

Service: HEASARC

Query:

SELECT name, lii, bii FROM ascagps

RA/Dec version:

SELECT name, ra, dec FROM ascagps

Do: load the table, then show it on the sky.

  • Before: no markers.
  • After: markers along the Milky Way, as in the RA/Dec version. One source, AX J170047-4139, lands in a different box: the archive's own galactic and RA/Dec numbers for it are 31° apart.
Step 2: before | after

Code: VoTableRecognizer.js:354-355, :370. 74 of the 163 longitudes are negative; the server now sends them as 0 to 360 (SearchServerCommands.java:151, :177), tested by SearchServerCommandsTest.

3. Galactic names, no tags

Untagged columns named glon/glat are now read as galactic; dev reads them as RA/Dec and draws them on empty sky.

Service: HEASARC

Query (renamed columns lose their tags):

SELECT name, lii AS glon, bii AS glat FROM ascagps

RA/Dec version:

SELECT name, ra, dec FROM ascagps

Do: load the table, then show it on the sky.

  • Before: the markers sit on empty sky, far from the Milky Way.
  • After: the same picture as step 2's after build: along the Milky Way.
Step 3: before | after

Code: VoTableRecognizer.js:467, :718-723.

4. Drift speeds aren't positions

Columns tagged as a drift speed (pos.pm;pos.eq.ra) are no longer taken as the position of a table without RA/Dec columns; dev piles 19 of the 22 stars into one spot.

Service: HEASARC

Query:

SELECT name, pmra, pmdec, glon, glat, vmag FROM bsc5p WHERE vmag < 1.5

RA/Dec version:

SELECT name, ra, dec, vmag FROM bsc5p WHERE vmag < 1.5

Do: load the table, then show it on the sky.

  • Before: 19 of the 22 stars bunch up in one patch of empty sky; the 3 fastest drifters land further out.
  • After: each star in its place, the same picture as step 1 and the RA/Dec version.
Step 4: before | after

Code: VoTableRecognizer.js:167-168, isCoordColumn at :670.

5. Galactic table over 50,000 rows

A galactic table over 50,000 rows now gets its markers in the right place; dev's server places them by the galactic numbers read as RA/Dec, far from the Milky Way.

Service: IRSA

Query (68,222 rows):

SELECT glon, glat FROM fp_psc WHERE CONTAINS(POINT('ICRS', ra, dec), CIRCLE('ICRS', 266.7, -28.5, 0.35))=1

RA/Dec version:

SELECT ra, dec FROM fp_psc WHERE CONTAINS(POINT('ICRS', ra, dec), CIRCLE('ICRS', 266.7, -28.5, 0.35))=1

Do: load the table, but before you click Search, change Row Limit (next to it) from 50000 to 200000. Then show it on the sky.

  • Before: all 68,222 rows on empty sky, far from the Milky Way.
  • After: all 68,222 rows on the bright center of the Milky Way, as in the RA/Dec version.
Step 5: before | after

Code: HpxIndexCntlr.js:261.

6. Search SIMBAD from the row

From a galactic row, SIMBAD now searches at the star; dev searches 43° away.

Service: HEASARC

Query (one row, the star Mizar):

SELECT name, alt_name, glon, glat, vmag FROM bsc5p WHERE name = 'HR 5054'

RA/Dec version:

SELECT name, alt_name, ra, dec, vmag FROM bsc5p WHERE name = 'HR 5054'

Do:

  1. Load the table.
  2. In the toolbar at the table's top right, click the first icon (the microscope), then Go to and Search Simbad at row with 5" radius.
  3. SIMBAD opens in a new browser tab. Read Coord= in its address. The page itself shows an error during the CDS outage; only the address matters.
  • Before: Coord=113.11+61.58, Mizar's galactic numbers read as RA/Dec.
  • After: Coord=200.98141370159107+54.92448073783569.
  • RA/Dec version: Coord=200.9812+54.9253, 3″ from the after build's (the table rounds glon/glat to 0.01°).

Code: TableAnalysis.js:449; DefaultSearchActions.js:297, :322.

7. Save as a region file

UPDATE: region files now support galactic and ecliptic tables, saved under a GALACTIC or ECLIPTIC label instead of J2000.

A galactic table is no longer offered as a region file; dev offers it and writes the galactic numbers under a J2000 label.

Service: HEASARC

Query (the same as step 6):

SELECT name, alt_name, glon, glat, vmag FROM bsc5p WHERE name = 'HR 5054'

RA/Dec version:

SELECT name, alt_name, ra, dec, vmag FROM bsc5p WHERE name = 'HR 5054'

Do:

  1. Load the table.
  2. In the toolbar at the table's top right, click the floppy-disk icon. The Save table dialog opens.
  3. Open the File format list and look for Region (.reg). If it's there, pick it, click Save, and open the saved file.
  • Before: Region (.reg) is offered; the file reads J2000; color=blue, then point 113.11 61.58 # 10 point=circle.
  • After: Region (.reg) isn't offered.
  • RA/Dec version: Region (.reg) is offered; the file reads J2000; color=blue, then point 200.9812 54.9253 # 10 point=circle.

Code: TableSave.jsx:120.

8. Use the table as a TAP upload

A galactic table used as a TAP upload no longer gets its position columns pre-filled; dev pre-fills glon, glat, which the search then reads as RA/Dec.

Service: HEASARC

Query (the same as step 6):

SELECT name, alt_name, glon, glat, vmag FROM bsc5p WHERE name = 'HR 5054'

RA/Dec version:

SELECT name, alt_name, ra, dec, vmag FROM bsc5p WHERE name = 'HR 5054'

Do:

  1. Load the table.
  2. In the toolbar at the table's top right, click the first icon (the microscope), then Use table as an upload to TAP search.
  3. At the top right, next to View:, click UI assisted.
  4. Under Spatial, read the Position Columns line that ends (from the uploaded table).
  • Before: Position Columns: glon, glat (from the uploaded table)
  • After: Position Columns: Unspecified Column(s) (from the uploaded table)
  • RA/Dec version: Position Columns: ra, dec (from the uploaded table)

Code: UploadTableSelector.jsx:375, :381; UploadTableChooser.js:200; SpatialSearch.jsx:156; DefaultSearchActions.js:231.

Other changed files

  • TableAnalysis.js: findTableEqCenterColumns (:50) is the RA/Dec-only lookup that steps 7 and 8 use; makeWorldPtUsingCenterColumns returns J2000 (:81). Helpers: toNum (Point.js:248) and convertToJ2000 (VisUtil.js:151).
  • ActiveRowToImageWatcher.js:180: centering an image on the highlighted row uses the same J2000 row position.
  • ttFeatureWatchers.js:223, :229: Prepare Download sends only RA/Dec position columns and converts the cutout center to J2000.
  • ServDescProducts.js:129: service-descriptor cutouts convert the row position to J2000.
  • ObsCoreUtil.java:63: the server returns null ra/dec instead of throwing when a row has no RA/Dec position.
  • WisePlotRequests.js:61: WISE time-series images read only RA/Dec columns; WISE tables use RA/Dec, so nothing changes.
  • VOAnalyzer-test.js also tests the recognizer behind steps 1–4: "by UCD, coordinate system", "columns described as something else are not the position", and the name-guess test.each cases.
  • VoCoreUtils-test.js is new: it tests isUCDWith and findCsysFromUCD, as the ticket asked. VoCoreUtils.js is unchanged.

@aventura121 aventura121 added this to the 2027.1 milestone Nov 13, 2026
@aventura121 aventura121 self-assigned this Nov 13, 2026
@aventura121
aventura121 force-pushed the FIREFLY-2121-ucd-fixes branch from a4d878b to aa89100 Compare November 13, 2026 19:25
@aventura121
aventura121 marked this pull request as ready for review November 13, 2026 19:52
@lrebull

lrebull commented Nov 17, 2026

Copy link
Copy Markdown
Contributor

I think I heard that HEASARC got hacked? In any case, the very first test fails for me, maybe because HEASARC isn't fully functional? :
Cause:
Unable to create job: Error: java.lang.NullPointerException

@lrebull

lrebull commented Nov 17, 2026

Copy link
Copy Markdown
Contributor

test 5 works for me, as it's talking to our TAP server.

@lrebull

lrebull commented Nov 17, 2026

Copy link
Copy Markdown
Contributor

OK, now HEASARC is working for me, so everything is working great until I got to number 7. The first time I saved the region file, I got not only the region file save as an option, but it worked properly and saved it with the ra/dec in the file! I tried to reproduce it while recording and not only did I get the region file save as an option, but it saved an empty region file. I initially thought maybe it was because I had just done the "go to simbad" test so maybe it had already calculated ra/dec and so was just using those numbers? but that's not it. Movie attached where you can see me try to work this out. More from me in a bit.

video1972256944.mp4

@lrebull

lrebull commented Nov 17, 2026

Copy link
Copy Markdown
Contributor

everything else i tried, worked.

@robyww robyww left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This all looks very good. I appreciate all the analysis, clean up, test, and identification of bugs (and fixes). VoTableRecognizer.js in particular looks much more solid.

I would like you to do a little more before you are done.

  • VOAnalyzer-test.js is in the wrong place. I think it was left there after a refactor a couple of years ago. Can you move it to the voAnalyzer/__tests__ dir?
  • Add a todo to fetchPartialTableHealpixIndex(), around line 269, that we should update the HealpixIndex search processor to handle a coordinate system parameter. I am not sure we will ever do this work but I would like to have a marker of where to begin.
  • update the region save code to output the correct coordinate system so the region download does not need to be disabled (see detail in the comment).

Comment on lines +61 to +62
// ra and dec are null when the table has no equatorial position columns.
// Arrays.asList accepts the nulls; List.of throws on them.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

interesting, i don't think I knew that.

//TODO determine when best to use full index and when to use partial. Is there any other factor beyond total rows
// the partial index is computed on the server, which reads the position columns as J2000 ra/dec.
// a galactic or ecliptic table must use the full index, which is built in the browser and converts to J2000.
if (csys !== CoordinateSys.EQ_J2000) return false;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This fixes the bug but maybe not the bigger problem. It would be possible to get a very large, non-j2000 table that the client cannot handle without Partial Index.

Fortunately I thinks those type of table are rare.

The code if fine but I am just highlighting the issue.

*/
export class VoTableRecognizer {
constructor(tableModel, posCoord = 'eq') {
constructor(tableModel, posCoord) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should the posCoord param just be taken out? It does no appear to be used and it appears that defaulting it just created a bug.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's used by findTableEqCenterColumns() to prefer ra/dec.

Comment on lines +718 to +724
function findCsysFromColumnName(lonColName, lonWord) {
if (lonWord === 'ra') return CoordinateSys.EQ_J2000;
const prefix = lonColName.toLowerCase().split(lonWord)[0].replace(/[-_]/g, '');
if (prefix === 'g' || prefix === 'gal') return CoordinateSys.GALACTIC;
if (prefix === 'e' || prefix === 'ecl') return CoordinateSys.ECL_J2000;
if (prefix === 'sg') return undefined;
return CoordinateSys.EQ_J2000;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

findCsysFromColumnName() is a nice addition to the guessing logic.

const prefix = lonColName.toLowerCase().split(lonWord)[0].replace(/[-_]/g, '');
if (prefix === 'g' || prefix === 'gal') return CoordinateSys.GALACTIC;
if (prefix === 'e' || prefix === 'ecl') return CoordinateSys.ECL_J2000;
if (prefix === 'sg') return undefined;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why returned undefined here? and not CoordinateSys.SUPERGALACTIC

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated to return it

Comment thread src/firefly/js/tables/HpxIndexCntlr.js Outdated
// skip the row: for an EQ_J2000 table getIpixForWp would throw and the full index would lose every later row;
// for any other frame convertCelestial would turn the bad latitude into a wrong but valid J2000 position
if (!tableWp || Math.abs(tableWp.y) > 90) return;
const wp= convertCelestial(tableWp);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i think this could be convertToJ2000() to be more consistent with your other changes.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also updated

Comment thread src/firefly/js/tables/ui/TableSave.jsx Outdated
const table = getTblById(tbl_id);
//should we send table.title along with center columns to write into the region file?
const cenCols = findTableCenterColumns(table, true);
const cenCols = findTableEqCenterColumns(table, true);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think this is the best way to fix this issue. Region files support other coordinate systems. In the region case I think you should send the coordinate system string. You can assign to the request the same way 'center_col' is assigned on line 260.

Then change the small file RegionTableWriter.java (around line 20) to write other coordinate systems out.

DS9 regions can support

Coordinate Systems
For each region, it is important to specify the coordinate system used to interpret the region, i.e., to set the context in whichsposition and size values are interpreted. For this purpose, the following keywords are recognized:
 
PHYSICAL                # pixel coords of original file using LTM/LTV
IMAGE                   # pixel coords of current file
FK4, B1950              # sky coordinate systems
FK5, J2000              # sky coordinate systems
GALACTIC                # sky coordinate systems
ECLIPTIC                # sky coordinate systems
ICRS                    # currently same as J2000
LINEAR                  # linear wcs as defined in file
AMPLIFIER               # mosaic coords of original file using ATM/ATV
DETECTOR                # mosaic coords of original file using DTM/DTV

so J2000,B1950,GALACTIC,ECLIPTIC could be passed in the request.

This is a fairly small change that I think you could go ahead and do in this PR instead of us making another ticket.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated

@aventura121

aventura121 commented Nov 18, 2026 •

Copy link
Copy Markdown
Contributor Author

OK, now HEASARC is working for me, so everything is working great until I got to number 7. The first time I saved the region file, I got not only the region file save as an option, but it worked properly and saved it with the ra/dec in the file! I tried to reproduce it while recording and not only did I get the region file save as an option, but it saved an empty region file. I initially thought maybe it was because I had just done the "go to simbad" test so maybe it had already calculated ra/dec and so was just using those numbers? but that's not it. Movie attached where you can see me try to work this out. More from me in a bit.

video1972256944.mp4

hi @lrebull, thanks for sharing. apologies, the description could have been clearer about which save it refers to. step 7 is for the floppy disk icon in the *table panel. (in that case, the branch's build, it shouldn't offer the region file). i think the behavior you're seeing for the image's save icon may be zoom dependent, and it does the conversion too.

p.s. if you see Trey's comment, we'll change it to offer the region file.

@aventura121

Copy link
Copy Markdown
Contributor Author

This all looks very good. I appreciate all the analysis, clean up, test, and identification of bugs (and fixes). VoTableRecognizer.js in particular looks much more solid.

I would like you to do a little more before you are done.

  • VOAnalyzer-test.js is in the wrong place. I think it was left there after a refactor a couple of years ago. Can you move it to the voAnalyzer/__tests__ dir?
  • Add a todo to fetchPartialTableHealpixIndex(), around line 269, that we should update the HealpixIndex search processor to handle a coordinate system parameter. I am not sure we will ever do this work but I would like to have a marker of where to begin.
  • update the region save code to output the correct coordinate system so the region download does not need to be disabled (see detail in the comment).

Sounds good:

  • Added the todo,
  • Moved the test module,
  • And the region file now supports the coord system.

@aventura121
aventura121 requested a review from robyww November 24, 2026 16:34

@robyww robyww left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changes look good.

@aventura121
aventura121 force-pushed the FIREFLY-2121-ucd-fixes branch from 10f35d0 to 086d296 Compare November 24, 2026 19:06
@aventura121
aventura121 merged commit 703c14e into dev Nov 24, 2026
2 checks passed
@aventura121
aventura121 deleted the FIREFLY-2121-ucd-fixes branch November 24, 2026 19:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants