Пример #1
0
def get_corr_map_photon(coo1, coo2, skypos, skyrange, sec, bound, bandwidth):
  imsz = imagetools.deg2pix(skypos, skyrange, 0.0001)
  count = np.zeros(imsz)
  print(imsz)
  co_rel = np.array([[0,0]])
  len1 = coo1.shape[0]
  len2 = coo2.shape[0]
  print(len1,len2)
  wcs = imagetools.define_wcs(skypos,skyrange,width=False,height=False,verbose=0,pixsz=0.0001)

  if len2<=80 or len1<=80:
    return count, np.array([0.0, 0.0])
  if len2>len1:
    for i in range(len2):
      #print(i)
      tmp_co = np.roll(coo2, i, axis=0)[0:len1,:]-coo1
      tmp_co = tmp_co[np.absolute(tmp_co[:,0])<=bound,:]
      tmp_co = tmp_co[np.absolute(tmp_co[:,1])<=bound,:]
      co_rel = np.concatenate((co_rel, tmp_co), axis = 0)

  else:
    for i in range(len1):
      #print(i)
      tmp_co = coo2-np.roll(coo1, i, axis=0)[0:len2,:]
      tmp_co = tmp_co[np.absolute(tmp_co[:,0])<=bound,:]
      tmp_co = tmp_co[np.absolute(tmp_co[:,1])<=bound,:]
      co_rel = np.concatenate((co_rel, tmp_co), axis = 0)

  print co_rel.shape
  if co_rel.shape[0]>1000:
    centroid = ck.find_centroid(co_rel[1:], bandwidth, 11, bound)
  else:
    return count, np.array([0.0, 0.0])

  return count, centroid
Пример #2
0
def get_corr_map_fast(coo1, coo2, skypos, skyrange, sec, bound, bandwidth):
  imsz = imagetools.deg2pix(skypos, skyrange, 0.0001)
  count = np.zeros(imsz)
  print(imsz)
  co_rel = np.array([[0,0]])
  len1 = coo1.shape[0]
  len2 = coo2.shape[0]
  print(len1,len2)
  wcs = imagetools.define_wcs(skypos,skyrange,width=False,height=False,verbose=0,pixsz=0.0001)
  #with open('../data/try2_%d.csv'%sec, 'wb') as csvfile:
    #writer = csv.writer(csvfile)
  if len2>len1:
    for i in range(len1):
      #print(i)
      tmp_co = coo2-coo1[i,:]
      tmp_co = tmp_co[np.absolute(tmp_co[:,0])<=bound,:]
      tmp_co = tmp_co[np.absolute(tmp_co[:,1])<=bound,:]
      co_rel = np.concatenate((co_rel, tmp_co), axis = 0)
  else:
    for i in range(len2):
      #print(i)
      tmp_co = coo2[i,:]-coo1
      tmp_co = tmp_co[np.absolute(tmp_co[:,0])<=bound,:]
      tmp_co = tmp_co[np.absolute(tmp_co[:,1])<=bound,:]
      co_rel = np.concatenate((co_rel, tmp_co), axis = 0)
  print co_rel.shape
  if co_rel.shape[0]>50:
    centroid = ck.find_centroid(co_rel[1:], bandwidth, 11, bound)
  else:
    return count, np.array([0.0, 0.0])

  return count, centroid
def get_corr_map(coo1, coo2, skypos, skyrange, sec, bound, bandwidth):
    imsz = imagetools.deg2pix(skypos, skyrange, 0.0001)
    count = np.zeros(imsz)
    print(imsz)
    co_rel = np.array([[0, 0]])
    len1 = coo1.shape[0]
    len2 = coo2.shape[0]
    print(len1, len2)
    wcs = imagetools.define_wcs(skypos,
                                skyrange,
                                width=False,
                                height=False,
                                verbose=0,
                                pixsz=0.0001)
    #with open('../data/try2_%d.csv'%sec, 'wb') as csvfile:
    #writer = csv.writer(csvfile)
    if len2 > len1:
        for i in range(len2):
            print(i)
            tmp_co = np.roll(coo2, i, axis=0)[0:len1, :] - coo1
            tmp_co = tmp_co[np.absolute(tmp_co[:, 0]) <= bound, :]
            tmp_co = tmp_co[np.absolute(tmp_co[:, 1]) <= bound, :]
            co_rel = np.concatenate((co_rel, tmp_co), axis=0)
            '''
      if (i+1)%200 == 0:
        writer.writerows(co_rel[1:])
        foc = wcs.sip_pix2foc(wcs.wcs_world2pix(co_rel[1:],1),1)
        H,xedges,yedges=np.histogram2d(foc[:,1]-0.5, foc[:,0]-0.5,\
                                   bins=imsz, range=([ [0,imsz[0]],[0,imsz[1]] ]))
        count += H
        co_rel = np.array([[0, 0]])
      '''
    else:
        for i in range(len1):
            print(i)
            tmp_co = coo2 - np.roll(coo1, i, axis=0)[0:len2, :]
            tmp_co = tmp_co[np.absolute(tmp_co[:, 0]) <= bound, :]
            tmp_co = tmp_co[np.absolute(tmp_co[:, 1]) <= bound, :]
            co_rel = np.concatenate((co_rel, tmp_co), axis=0)
            '''
      if (i+1)%200 == 0:
        writer.writerows(co_rel[1:])
        foc = wcs.sip_pix2foc(wcs.wcs_world2pix(co_rel[1:],1),1)
        H,xedges,yedges=np.histogram2d(foc[:,1]-0.5, foc[:,0]-0.5,\
                                   bins=imsz, range=([ [0,imsz[0]],[0,imsz[1]] ]))
        count += H
        co_rel = np.array([[0, 0]])
      '''
    '''
  if co_rel.shape[0]>1:
    #writer.writerows(co_rel[1:])
    foc = wcs.sip_pix2foc(wcs.wcs_world2pix(co_rel[1:],1),1)
    H,xedges,yedges=np.histogram2d(foc[:,1]-0.5, foc[:,0]-0.5,\
                               bins=imsz, range=([ [0,imsz[0]],[0,imsz[1]] ]))
    count += H
  #csvfile.close()
  '''
    centroid = ck.find_centroid(co_rel[1:], bandwidth, 11, bound)

    return count, centroid
Пример #4
0
def get_corr_map(coo1, coo2, skypos, skyrange, sec, bound, bandwidth):
  imsz = imagetools.deg2pix(skypos, skyrange, 0.0001)
  count = np.zeros(imsz)
  print(imsz)
  co_rel = np.array([[0,0]])
  len1 = coo1.shape[0]
  len2 = coo2.shape[0]
  print(len1,len2)
  wcs = imagetools.define_wcs(skypos,skyrange,width=False,height=False,verbose=0,pixsz=0.0001)
  #with open('../data/try2_%d.csv'%sec, 'wb') as csvfile:
    #writer = csv.writer(csvfile)
  if len2>len1:
    for i in range(len2):
      #print(i)
      tmp_co = np.roll(coo2, i, axis=0)[0:len1,:]-coo1
      tmp_co = tmp_co[np.absolute(tmp_co[:,0])<=bound,:]
      tmp_co = tmp_co[np.absolute(tmp_co[:,1])<=bound,:]
      co_rel = np.concatenate((co_rel, tmp_co), axis = 0)
      '''
      if (i+1)%200 == 0:
        writer.writerows(co_rel[1:])
        foc = wcs.sip_pix2foc(wcs.wcs_world2pix(co_rel[1:],1),1)
        H,xedges,yedges=np.histogram2d(foc[:,1]-0.5, foc[:,0]-0.5,\
                                   bins=imsz, range=([ [0,imsz[0]],[0,imsz[1]] ]))
        count += H
        co_rel = np.array([[0, 0]])
      '''
  else:
    for i in range(len1):
      #print(i)
      tmp_co = coo2-np.roll(coo1, i, axis=0)[0:len2,:]
      tmp_co = tmp_co[np.absolute(tmp_co[:,0])<=bound,:]
      tmp_co = tmp_co[np.absolute(tmp_co[:,1])<=bound,:]
      co_rel = np.concatenate((co_rel, tmp_co), axis = 0)
      '''
      if (i+1)%200 == 0:
        writer.writerows(co_rel[1:])
        foc = wcs.sip_pix2foc(wcs.wcs_world2pix(co_rel[1:],1),1)
        H,xedges,yedges=np.histogram2d(foc[:,1]-0.5, foc[:,0]-0.5,\
                                   bins=imsz, range=([ [0,imsz[0]],[0,imsz[1]] ]))
        count += H
        co_rel = np.array([[0, 0]])
      '''
  '''
  if co_rel.shape[0]>1:
    #writer.writerows(co_rel[1:])
    foc = wcs.sip_pix2foc(wcs.wcs_world2pix(co_rel[1:],1),1)
    H,xedges,yedges=np.histogram2d(foc[:,1]-0.5, foc[:,0]-0.5,\
                               bins=imsz, range=([ [0,imsz[0]],[0,imsz[1]] ]))
    count += H
  #csvfile.close()
  '''
  print co_rel.shape
  if co_rel.shape[0]>50:
    centroid = ck.find_centroid(co_rel[1:], bandwidth, 11, bound)
  else:
    return count, np.array([0.0, 0.0])

  return count, centroid
Пример #5
0
def get_corr_map(coo1, coo2, skypos, skyrange, sec, bound, bandwidth):
    imsz = imagetools.deg2pix(skypos, skyrange, 0.0001)
    count = np.zeros(imsz)
    print(imsz)
    co_rel = np.array([[0, 0]])
    len1 = coo1.shape[0]
    len2 = coo2.shape[0]
    print(len1, len2)
    wcs = imagetools.define_wcs(skypos,
                                skyrange,
                                width=False,
                                height=False,
                                verbose=0,
                                pixsz=0.0001)
    #with open('../data/try2_%d.csv'%sec, 'wb') as csvfile:
    #writer = csv.writer(csvfile)
    if len2 > len1:
        for i in range(len1):
            #print(i)
            tmp_co = coo2 - coo1[i, :]
            tmp_co = tmp_co[np.absolute(tmp_co[:, 0]) <= bound, :]
            tmp_co = tmp_co[np.absolute(tmp_co[:, 1]) <= bound, :]
            co_rel = np.concatenate((co_rel, tmp_co), axis=0)
    else:
        for i in range(len2):
            #print(i)
            tmp_co = coo2[i, :] - coo1
            tmp_co = tmp_co[np.absolute(tmp_co[:, 0]) <= bound, :]
            tmp_co = tmp_co[np.absolute(tmp_co[:, 1]) <= bound, :]
            co_rel = np.concatenate((co_rel, tmp_co), axis=0)

    print co_rel.shape
    plt.hist2d(co_rel[:, 0], co_rel[:, 1], bins=100)
    #plt.hist2d(co_rel[:,0], co_rel[:,1], bins=200, range=[[-0.06,-0.03],[-0.08,-0.04]])
    plt.show()
    centroid = ck.find_centroid(co_rel[1:], bandwidth, 11, bound)
    print centroid
    #plt.hist2d(co_rel[:,0], co_rel[:,1], bins=200)
    '''
  plt.hist(co_rel[:,0],100)
  plt.show()
  plt.hist(co_rel[:,1],100)
  plt.show()
  '''
    '''
Пример #6
0
def get_corr_map_photon(coo1, coo2, skypos, skyrange, sec, bound, bandwidth):
    imsz = imagetools.deg2pix(skypos, skyrange, 0.0001)
    count = np.zeros(imsz)
    print(imsz)
    co_rel = np.array([[0, 0]])
    len1 = coo1.shape[0]
    len2 = coo2.shape[0]
    print(len1, len2)
    wcs = imagetools.define_wcs(skypos,
                                skyrange,
                                width=False,
                                height=False,
                                verbose=0,
                                pixsz=0.0001)

    if len2 <= 80 or len1 <= 80:
        return count, np.array([0.0, 0.0])
    if len2 > len1:
        for i in range(len2):
            #print(i)
            tmp_co = np.roll(coo2, i, axis=0)[0:len1, :] - coo1
            tmp_co = tmp_co[np.absolute(tmp_co[:, 0]) <= bound, :]
            tmp_co = tmp_co[np.absolute(tmp_co[:, 1]) <= bound, :]
            co_rel = np.concatenate((co_rel, tmp_co), axis=0)

    else:
        for i in range(len1):
            #print(i)
            tmp_co = coo2 - np.roll(coo1, i, axis=0)[0:len2, :]
            tmp_co = tmp_co[np.absolute(tmp_co[:, 0]) <= bound, :]
            tmp_co = tmp_co[np.absolute(tmp_co[:, 1]) <= bound, :]
            co_rel = np.concatenate((co_rel, tmp_co), axis=0)

    print co_rel.shape
    if co_rel.shape[0] > 1000:
        centroid = ck.find_centroid(co_rel[1:], bandwidth, 11, bound)
    else:
        return count, np.array([0.0, 0.0])

    return count, centroid
Пример #7
0
def get_corr_map_fast(coo1, coo2, skypos, skyrange, sec, bound, bandwidth):
    imsz = imagetools.deg2pix(skypos, skyrange, 0.0001)
    count = np.zeros(imsz)
    print(imsz)
    co_rel = np.array([[0, 0]])
    len1 = coo1.shape[0]
    len2 = coo2.shape[0]
    print(len1, len2)
    wcs = imagetools.define_wcs(skypos,
                                skyrange,
                                width=False,
                                height=False,
                                verbose=0,
                                pixsz=0.0001)
    #with open('../data/try2_%d.csv'%sec, 'wb') as csvfile:
    #writer = csv.writer(csvfile)
    if len2 > len1:
        for i in range(len1):
            #print(i)
            tmp_co = coo2 - coo1[i, :]
            tmp_co = tmp_co[np.absolute(tmp_co[:, 0]) <= bound, :]
            tmp_co = tmp_co[np.absolute(tmp_co[:, 1]) <= bound, :]
            co_rel = np.concatenate((co_rel, tmp_co), axis=0)
    else:
        for i in range(len2):
            #print(i)
            tmp_co = coo2[i, :] - coo1
            tmp_co = tmp_co[np.absolute(tmp_co[:, 0]) <= bound, :]
            tmp_co = tmp_co[np.absolute(tmp_co[:, 1]) <= bound, :]
            co_rel = np.concatenate((co_rel, tmp_co), axis=0)
    print co_rel.shape
    if co_rel.shape[0] > 50:
        centroid = ck.find_centroid(co_rel[1:], bandwidth, 11, bound)
    else:
        return count, np.array([0.0, 0.0])

    return count, centroid