示例#1
0
def Regrid_PS(PS1, Corners):
    dim1, dim2 = Corners.shape[1:]
    dim1 -= 1
    dim2 -= 1
    global px, py
    px, py = np.where(PS1)
    global squares
    squares = np.array(Make_squares(Corners))
    square_num = np.arange(0, len(squares))

    points = np.zeros((len(px), 2))
    points[:, 0] = px
    points[:, 1] = py

    global pspixels
    pspixels = Footprint_square(Corners, points)

    global psimage
    psimage = PS1.copy()

    pool = MultiPool()
    values = list(pool.map(Pix_sum, square_num))
    pool.close()

    PS_scene = np.array(values)
    PS_scene = np.nansum(PS_scene, axis=0)
    PS_scene = PS_scene.astype('float')
    PS_scene = PS_scene.reshape(dim1, dim2)
    return PS_scene
示例#2
0
print('Running the ML analysis - this may take a while')
optres = scipy.optimize.basinhopping(f_mlnlike,
                                     start,
                                     niter=n_basinhopping,
                                     T=T,
                                     interval=3,
                                     minimizer_kwargs=minimizer_kwargs,
                                     take_step=my_take_step,
                                     callback=my_print_fun)
print('[', end='')
print(', '.join(map(lambda _: '{:.5g}'.format(_), optres.x)), end='')
print('] ', end='')
print('{}'.format(optres.fun))

if pool:
    pool.close()

# -- Step 5. Output results
print('-- Likelihood maximization of variable ' + ly + ' --')
print(', '.join(map(lambda x: '{:.3g}'.format(x), optres.x)))

fit_result = optres.x

m_scale, n_scale = xGASS_auxiliary.get_slope_intercept(fit_result[0],
                                                       fit_result[1])
m_shape, n_shape = xGASS_auxiliary.get_slope_intercept(fit_result[2],
                                                       fit_result[3])
m_zero, n_zero = xGASS_auxiliary.get_slope_intercept(fit_result[4],
                                                     fit_result[5])

xx = np.linspace(max(min(df['v0']), sel_lgMstar[0]),