How to subtract specific rows of 2 separate files with different increments

前端 未结 1 1576
孤街浪徒
孤街浪徒 2021-01-25 17:34

https://i.stack.imgur.com/oYoYz.png https://i.stack.imgur.com/AdmuM.png

The first column in the images linked above is the wavelength, while the second is the flux. I ne

相关标签:
1条回答
  • 2021-01-25 17:56

    Please consider the following example

    import numpy
    a = numpy.array([51, -2, -16, 38, 27])
    b = numpy.array([-16, 51, 38])
    print([numpy.where(b[x] == a)[0][0] for x in range(len(b))])
    # [2, 0, 3]
    

    The indices corresponding to the values of b in a are returned. This only works if all values of b are contained into a. For your example, that is the case, b being the first column of your second picture and a the first column of your first picture. Having the indices, you can then easily subtract flux values at the same wavelength.

    0 讨论(0)
提交回复
热议问题