gully / ynot

Astronomical échellogram digital twins with pixel-perfect machine learning: rehabilitating archival data and pathfinding for EPRV
https://ynot.readthedocs.io
MIT License
4 stars 0 forks source link

Add list of night sky lines for enhanced wavelength calibration #2

Closed gully closed 3 years ago

gully commented 3 years ago

Each known night sky line can inform the wavelength calibration process. We need to implement the reading-in and filtering of these sky lines. Most orders will only have a few, which is fine. The weakest sky lines can be safely ignored, assuming a GP in wavelength with identify them.

gully commented 3 years ago

Ok, this works as of 1b2298e I implemented sky line sparsity as an initialization option dense_sky=False, which toggles between a sky model of ~1400 sub-pixel sky lines, and a sparse sky of a few to tens of labeled sky lines. I added a sky continuum function to compensate for the loss of sky emission that was filled in generously with the dense sky model; for now sky continuum is a fourth order polynomial (implemented as Chebyshev polynomials) in wavelength.

When running a full training run on 14000 epochs, an undesirable phenomenon occurs. The sky traces---which have ~1400 parameters---have the most flexibility to deal with the sharp decrease in flux on the red side of the detector, so they bloat in width at the expense of underfitting the sky-trace entirely. Here are a few strategies that would fix this overzealous fitting, and I think we can do all of them:

A few other issues:

gully commented 3 years ago

Here's a Tensorboard screenshot illustrating the bloating over-fitting phenomenon described above.

tensorboard_demo

gully commented 3 years ago

Making sky continuum a function of x had little impact on GPU training performance, but did seem to use about 20% less memory. I'd say let's keep it in wavelength, since that is closer to physical reality and more interpretable. Instead I simply place a torch.no_grad() context manager before we make the Chebyshev Polynomial array. Essentially what this says is that the minüte changes to wavelength calibration will have negligible effect on the smooth polynomial function, so don't even bother using memory to track those changes in the backprop.

gully commented 3 years ago

Sampling in log space dramatically improves the speed of training since it can access a much higher dynamic range in a fixed amount of time.

gully commented 3 years ago

The spectral traces now bloat to over-fill the entire slit length in order to fit the sky lines, even after masking the dark right-edge region, which also makes sense from a loss function perspective. I think the solution to this and other problems is to use a better sky model (new issue #7) combined with a GP for imperfections in that sky model (issue #3). The basic functionality is in place, so let's close this task.