Skip to content

FIREFLY-1694,1105,1784: Improve unit recognition of SpectrumDM #1798

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 12 commits into
base: dev
Choose a base branch
from

Conversation

jaladh-singhal
Copy link
Member

@jaladh-singhal jaladh-singhal commented Jun 13, 2025

Fixes FIREFLY-1694, FIREFLY-1105, FIREFLY-1784

Following task-list is derived from the text and comments in above tickets (+ conversations about this work in meetings):

  • Make firefly recognize flux units in erg/s/cm^2 and convert to equivalent units: W/m^2/Hz <-> Jy <-> erg/s/cm^2/Hz. erg/s/cm^2/A can't be converted to flux density in frequency space so added one more wavelength space unit W/m^2/um.
  • Show units in options dialog even when firefly can't recognize them: instead of dropdown of convertible units, this will be a readonly field with a tip text.
  • Make firefly recognize alias of same unit: Angstrom = angstrom = A, erg/s/cm^2/Angstrom = erg/s/cm2/Angstrom = erg/s/cm**2/Angstrom = erg.s**-1.cm**-2.Angstrom**-1, etc.
  • Make firefly display the recognized units on chart axes in shorter latex syntax i.e., if it's recognized by firefly, it will match the dropdown label + other label addition that firefly makes like redshift correction
  • Make firefly recognize units prefixed with a scalar factor, also convert them so it will be a new entry in dropdown
  • Fix bug in axis label doesn't update with correct units when spectrum is single trace
  • Change disabled input fields to just simple text
  • Add lamda, F_lambda symbols that appear in chart to dialog too indicate they map to column name
  • Add unit tests
  • wording changes in spectra file upload

Testing

https://fireflydev.ipac.caltech.edu/firefly-1694-1105/firefly/

Upload test files (attached in the 1694 ticket), first on irsaviewer ops and then on this build. Open chart dialogs for each file and notice how they differ between irsaviewer and this build. Change unit dropdowns (and redshift correction ones), it should update the column field with correct formula and chart axes label with correct label (once you hit apply)

@jaladh-singhal jaladh-singhal self-assigned this Jun 13, 2025
@jaladh-singhal jaladh-singhal added the Charts Anything related to charts label Jun 13, 2025
@jaladh-singhal jaladh-singhal force-pushed the FIREFLY-1694,1105-spec-units branch from 53710a4 to 0c06b30 Compare June 13, 2025 21:00
@jaladh-singhal jaladh-singhal force-pushed the FIREFLY-1694,1105-spec-units branch from dbe375a to afa6a60 Compare June 17, 2025 10:58
@jaladh-singhal
Copy link
Member Author

For tracking everything at one place:

Comments from @loitly on Jun 17, 2025:

However, since I’ve already taken a quick look and likely won’t do a full review—here are my thoughts:

  • The improvements to the conversion logic make it more robust—nice work!

  • I like the added documentation. But, one thing I didn’t see (or may have missed) is a top-level explanation of how the main data structures relate to each other, e.g., UnitMetadata, UnitXref, and Measurement.

  • A unit test for this file would also be helpful. Something like sprintf-test.js that shows the expected input and output for each function. (not all, just the important ones)

I haven’t looked at it in detail. These are just my initial impressions, so take them with a grain of salt.

@jaladh-singhal jaladh-singhal marked this pull request as ready for review June 18, 2025 10:54
@jaladh-singhal jaladh-singhal added enhancement multi-ticket This PR implements multiple Jira tickets labels Jun 18, 2025
@jaladh-singhal jaladh-singhal added this to the 2025.4 milestone Jun 18, 2025
@lrebull
Copy link
Contributor

lrebull commented Jun 18, 2025

minor word changes, not directly related to this issue so i made a new ticket: https://jira.ipac.caltech.edu/browse/FIREFLY-1784 Jaladh, i added you as a watcher since trey is out and i don't know if this is an easy fix or not.

This looks really nice! i have also asked vandana to take a look.

@vandesai1
Copy link

vandesai1 commented Jun 18, 2025

Testing at https://fireflydev.ipac.caltech.edu/firefly-1694-1105/firefly/

Test 1. Open a Euclid combspec file as delivered.

a. The 1D spectrum extensions are correctly plotted as spectra.

b. In the chart options, "Trace Style" is now at the top, and no longer in the Trace options. That's kinda strange.

c. The conversion between erg/s/cm^2/Angstrom and W/m^2/micron looks correct.

Test 2. I uploaded a file that I modified (modified_euclid_spectrum.vot). The flux has units of 1e-16erg.s**-1.cm**-2.Angstrom**-1

a. This was recognized as a spectrum and plotted correctly.

b. The unit conversion looks correct, even with the factor out front! Nice!

Test 3: I uploaded another modified file (mod2_euclid_spectrum.vot), in which I replaced all instances of "Angstrom" to "Ang".

a. Firefly still recognized this as a spectrum. good.

b. The units were displayed in the chart area, but there weren't any conversion options. On ops, the units were not shown. good.

Test 4. I uploaded mod3.vot, which has units of 1e-16erg.s**-1.cm^-2.Angstrom**-1

Firefly did NOT understand this.

Test 5. I uploaded mod4.vot, which has units of 1e-16erg.s**-1.cm-2.Angstrom**-1

Firefly did NOT understand this.

Test 5. I uploaded mod5.vot, which has units of 1e-16erg/s/cm2/A

Worked fine!

Test 6. I uploaded mod6.vot, which has units of 1e-16erg/s/cm**2/A

Worked fine!

Test 7. I uploaded mod7.vot, which has units of 1e-16erg/s/cm^2/A

Worked fine!

@jaladh-singhal
Copy link
Member Author

jaladh-singhal commented Jun 18, 2025

@vandesai1 thanks for the detailed testing. It seems to me you’re mostly happy with your test results except the bolded ones:

In the chart options, “Trace Style” is now at the top, and no longer in the Trace options. That’s kinda strange.

  1. It was never inside in Trace options in ops too (not sure why but that's the case for scatter chart type too: go to "overplot new trace"). And about moving it to top, I did it because we have section separators for each X and Y axis now so if I kept it below, it would seem it's part of Y axis section but it's not.
ops this PR build
image image

I also feel it should be inside Trace options collapsible, I can move it there unless we had an historical reason to keep it outside?


Test 4. I uploaded mod3.vot, which has units of 1e-16erg.s**-1.cm^-2.Angstrom**-1
Test 5. I uploaded mod4.vot, which has units of 1e-16erg.s**-1.cm-2.Angstrom**-1
Firefly did NOT understand this.

  1. Yes firefly can't recognize mixed notations of powers (u**2, u^2, u2) and in this VO dot product representation (VOUnits Grammar on page 42) it strictly expects ** for powers. Do you want Firefly to recognize your test units containing mixed notations?

@jaladh-singhal jaladh-singhal changed the title FIREFLY-1694,1105: Improve unit recognition of SpectrumDM FIREFLY-1694,1105,1784: Improve unit recognition of SpectrumDM Jun 18, 2025
@lrebull
Copy link
Contributor

lrebull commented Jun 18, 2025

I can see your code changes (oooh i'm getting more confident in understanding how to use github!)
"Some table appears to be a spectrum" sounds very strange too.
How about "Some tables appear to be spectra."
(the other change looks good!)

@jaladh-singhal
Copy link
Member Author

I can see your code changes (oooh i'm getting more confident in understanding how to use github!)

Yay!

"Some table appears to be a spectrum" sounds very strange too.
How about "Some tables appear to be spectra."

Done!

@jaladh-singhal jaladh-singhal force-pushed the FIREFLY-1694,1105-spec-units branch from f4d738a to 0953145 Compare June 18, 2025 18:58
@vandesai1
Copy link

  1. Yes firefly can't recognize mixed notations of powers (u**2, u^2, u2) and in this VO dot product representation (VOUnits Grammar on page 42) it strictly expects ** for powers. Do you want Firefly to recognize your test units containing mixed notations?

Nah, I think it's ok like this.

I need to eat something and then look at #1.

@vandesai1
Copy link

  1. It was never inside in Trace options in ops too (not sure why but that's the case for scatter chart type too: go to "overplot new trace"). And about moving it to top, I did it because we have section separators for each X and Y axis now so if I kept it below, it would seem it's part of Y axis section but it's not.

I agree that it's strange that the trace style has appeared in the Y axis section. I can't remember why that was there. Maybe we shouldn't change it without a ccb, since it wasn't part of any of these tickets?

Copy link
Contributor

@loitly loitly left a comment

Choose a reason for hiding this comment

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

Code looks good. About the Trace Style, I think it was mainly to keep frequently changed settings outside the collapsible panel. Whatever we decide, I think we should do the same for the Scatter plot options panel too.

Comment on lines +11 to +14
// TODO: write tests for all exported functions?
test('getUnitConvExpr', () => {

});
Copy link
Contributor

Choose a reason for hiding this comment

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

What I’m looking for here is documentation that demonstrates how this module is intended to be used and what results to expect(documenting behavior).
Some usage examples would help so I don’t have to read through the code. Simple examples are great, but a few trickier ones would be even better.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Charts Anything related to charts enhancement multi-ticket This PR implements multiple Jira tickets
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants