spacetelescope / ullyses

Code to create products for the ULLYSES program
https://ullyses.stsci.edu/
BSD 3-Clause "New" or "Revised" License
2 stars 6 forks source link

Setting a specified transition wavelength in coadd.abut() #3

Open nkerman opened 3 years ago

nkerman commented 3 years ago

Idea:

Users would benefit from being able to choose the point at which two abutted spectra transition from the lower-λ (A) to longer-λ spectrum (B)

Problem:

At present, the transition wavelength is always decided by the function, find_transition_wavelength, which chooses the center of the overlap.

This is less than ideal, as often you would get a better abutted spectrum by using A for the vast majority of the overlap.

Potential Fix:

This does not have to be automatic within the wrapper (that would be great, but there's a lot of variables and data-dependent decisions). Instead, the user should be able to do this piecewise, i.e.

imports...
initialize SegmentList, make WL array, coadd (or use convenience function to do these steps)
abut1 = abut(blue, middle, transition_wl=1400)
abut2 = abut(abut1, red, transition_wl=2000)

Where the abut function checks for a user-specified transition wavelength, before using find_transition_wavelength, i.e.

def abut(product_short, product_long,    transition_wvln = None):
    # check for user trans_wvln:
    if transition_wvln:
        # check it's in the right region:
        if (user_trans_wvln>product_long.min) & user_trans_wvln<product_short.max):
            transition_wvln =  user_trans_wvln
        else: # user specified a wvln outside of the overlap
            print(‘invalid wvln specified’)
            exit
    else: # user didn't try to specify a transition wvln
        transition_wvln = get_transition_wvln()

@jotaylor (who helped draft this idea) @stscirij

nkerman commented 3 years ago

I implemented a really quick version of this that seems to work! Happy to talk and see if it's compatible, and just add it in if you want.

One strange thing I've noticed is that when there's a specified transition wavelength, there's usually-but-not-always the same sampling rate discontinuity at the transition seen when the transition is automatically chosen. I can't seem to figure out why it isn't ALWAYS there, but it seems to be some multiple of the sample rates combined.

Please see the fig.

Screen Shot 2021-04-15 at 17 15 42