Beispiel #1
0
def get_2Dimage(detectid_obj, detects, fibers, width=100, height=50):

    fiber_table = Table(
        detects.hdfile.root.Fibers.read_where("detectid == detectid_obj"))

    fsort = fiber_table.argsort(keys="weight", reverse=True)

    fiber_table = fiber_table[fsort]

    weight_total = np.sum(fiber_table["weight"])

    # open blank image to store summed image and 4 brightest fibers
    im_sum = np.zeros((height, width))

    for fiber_i in fiber_table:
        wave_obj = fiber_i["wavein"]
        multiframe_obj = fiber_i["multiframe"]
        expnum_obj = fiber_i["expnum"]
        fibnum_obj = fiber_i["fibnum"]
        weight = fiber_i["weight"] / weight_total
        fiber_id_obj = fiber_i["fiber_id"]

        im_fib = fibers.get_fib_image2D(
            wave_obj=wave_obj,
            fibnum_obj=fibnum_obj,
            multiframe_obj=multiframe_obj,
            expnum_obj=expnum_obj,
            width=width,
            height=height,
        )

        im_sum += weight * im_fib

    return im_sum
Beispiel #2
0
def get_2Dimage_array(detectid_obj, detects, fibers, width=100, height=50):

    fiber_table = Table(
        detects.hdfile.root.Fibers.read_where("detectid == detectid_obj"))

    fsort = fiber_table.argsort(keys="weight", reverse=True)

    fiber_table = fiber_table[fsort]

    weight_total = np.sum(fiber_table["weight"])

    im_arr = np.zeros((4, height, width))

    for i, fiber_i in enumerate(fiber_table[0:4]):
        wave_obj = fiber_i["wavein"]
        multiframe_obj = fiber_i["multiframe"]
        expnum_obj = fiber_i["expnum"]
        fibnum_obj = fiber_i["fibnum"]
        weight = fiber_i["weight"] / weight_total
        im_fib = fibers.get_fib_image2D(
            wave_obj=wave_obj,
            fibnum_obj=fibnum_obj,
            multiframe_obj=multiframe_obj,
            expnum_obj=expnum_obj,
            width=width,
            height=height,
        )
        im_arr[i] = im_fib

    return im_arr, fiber_table
Beispiel #3
0
def get_part_function(molecule, interp=False, order=2):
    # if fit=True the function will return
    # a function fitted to the values
    CATURL = SPECIES_PAGE_URL+'e{0}.cat'.format(molecule.split(' ')[0])
    catpage = requests.get(CATURL)
    catpage.close()
    cathtml = bs4.BeautifulSoup(catpage.content, "lxml")
    parttable = [i for i in cathtml.find_all('tr') if i.get_text()[1:3] == 'Q(']
    parttable = [[j.get_text() for j in i.find_all('td')] for i in parttable]
    # extract partition function value and Temperature
    T, value = np.array(parttable).T
    try:
        # convert values into floats
        value = value.astype('float')
    except(ValueError):
        # if its a value error, it could be
        # that the table consists of two values
        # like "2521.8958 (2141.5366, 380.3592)"
        # e.g. for D2CO (as of 2016-11-14)
        value = [str(i).split(" ")[0] for i in value]
        value = np.array(value, dtype='float')
    # convert temperature to floats
    T = np.array([float(i[3:-1]) for i in T])

    return_table = Table()
    return_table['temp'] = T
    return_table['part_value'] = value
    return_table = return_table[return_table.argsort(keys='temp')]
    return_table.meta['species'] = molecule.split(' ')[1]
    return_table.meta['source'] = CATURL
    return_table.meta['source_html'] = cathtml

    # now if we want to fit a function to the values
    if interp:
        from scipy.interpolate import InterpolatedUnivariateSpline
        qrot = InterpolatedUnivariateSpline(return_table['temp'], return_table['part_value'], k=order)
        return return_table, qrot
    return return_table