Skip to content
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

Read eBOSS fiberpos #104

Open
londumas opened this issue Mar 26, 2019 · 2 comments
Open

Read eBOSS fiberpos #104

londumas opened this issue Mar 26, 2019 · 2 comments
Assignees

Comments

@londumas
Copy link

For the eBOSS option of the mocks: see PR desihub/desisim#481 and PR desihub/specsim#100 and issue desihub/desisim#437.
We need a dummy eBOSS fiberpos, I created it via a copy of $DESIMODEL/data/focalplane/fiberpos.fits, keeping only the first two spectrographs, getting a random x and y position within a radius of 325. mm, within the two half-plates.
How @sbailey, do you want me to parse this file?
I was thinking of an option set to None by default, and if given read eBOSS file. Does that sound reasonable? Also where should I copy the fits file?

def load_fiberpos():

import fitsio
import scipy as sp

def main():

    radius = 325.
    outpath = 'eboss_fiberpos.fits'
    p = '$DESIMODEL/data/focalplane/fiberpos.fits'

    sp.random.seed(42)

    h = fitsio.FITS(p)
    print(h[1].read_header())

    ### Store
    cat = {}
    for k in h[1].get_colnames():
        cat[k] = h[1][k][:]

    w = cat['SPECTRO']<2
    for k in cat.keys():
        cat[k] = cat[k][w]

    theta = sp.pi*sp.random.rand(500)
    r = radius*sp.sqrt(sp.random.rand(500))
    x = r*sp.cos(theta)
    y = r*sp.sin(theta)
    cat['X'][cat['SPECTRO']==0] = x
    cat['Y'][cat['SPECTRO']==0] = y

    theta = (2*sp.pi-sp.pi)*sp.random.rand(500)+sp.pi
    r = radius*sp.sqrt(sp.random.rand(500))
    x = r*sp.cos(theta)
    y = r*sp.sin(theta)
    cat['X'][cat['SPECTRO']==1] = x
    cat['Y'][cat['SPECTRO']==1] = y

    print(cat['X'],cat['Y'])
    import matplotlib.pyplot as plt
    plt.errorbar(cat['X'],cat['Y'],fmt='o')
    plt.grid()
    plt.show()


    ### Save
    out = fitsio.FITS(outpath,'rw',clobber=True)
    cols = [ v for v in cat.values() ]
    names = [ k for k in cat.keys() ]
    out.write(cols,names=names)
    out.close()

    return

main()
@londumas londumas self-assigned this Mar 26, 2019
@sbailey
Copy link
Contributor

sbailey commented Mar 26, 2019

Could you provide some more context about why we need a fiberpos file for eBOSS when eBOSS doesn't have fiber positioners at fixed locations? i.e. specifically what doesn't work if this file doesn't exist? It smells like we're using the fiber positioners file as a convenience for interpolating x, y, z, platescale, etc. when maybe that should be parameterized differently.

@belaa
Copy link
Contributor

belaa commented Mar 27, 2019

@londumas desisim.simexp.simulate_spectra() has a specsim_config_file parameter - if that's set to 'eboss' maybe we can force it to generate these fiber positions on the fly, rather than having to add a separate file to desimodel?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants